RectAnimation用于在DrawingVisual画进度条
使用Visual来画图,可以使用其派生类,UIElement、Viewport3DVisual用于呈现3D内容,其他可以用来画图的为DrawingVisual,使用DrawingVisual可以使用编程的方式来实现复杂的图形实现,当使用DrawingVisual,必须使用FrameworkElement作为宿主容器,用来提供DrawingVisual所缺乏的布局和事件支持。下面实现了使用DrawingVisual来实现进度条,主要使用RectAnimation来实现。DrawRoundedRectangle(Brush brush, Pen pen, Rect rectangle, AnimationClock rectangleAnimations, double radiusX, AnimationClock radiusXAnimations, double radiusY, AnimationClock radiusYAnimations)方法的使用RectAnimation对象的AnimationClock对 Rec进行动画处理。
RectAnimation myRectAnimation;
public override System.Windows.Media.Visual drawShape()
{
DrawingVisual drawingWordsVisual = new DrawingVisual();
DrawingContext drawingContext = drawingWordsVisual.RenderOpen();
try
{
Rect rect2 = new Rect(currentLayout.StartPoint.X,
currentLayout.StartPoint.Y, VisusalSize.Width, );
Rect rect3 = new Rect(currentLayout.StartPoint.X,
currentLayout.StartPoint.Y, VisusalSize.Width, );
Rect rect1 = new Rect(currentLayout.StartPoint.X, currentLayout.StartPoint.Y, , );
//Rect rect4 = new Rect(currentLayout.StartPoint.X, currentLayout.StartPoint.Y, VisusalSize.Width*0.5, 0);
myRectAnimation = new RectAnimation();
myRectAnimation.Duration = TimeSpan.FromSeconds();
myRectAnimation.FillBehavior = FillBehavior.HoldEnd;
myRectAnimation.From = rect1;
//myRectAnimation.By = rect4;
myRectAnimation.To = rect3;
_showFilePanelClock = myRectAnimation.CreateClock();
_showFilePanelClock.Controller.Pause();
GradientStop gs1 = new GradientStop(Color.FromRgb(, ,
), );
GradientStop gs2 = new GradientStop(Color.FromRgb(, ,
), );
GradientStopCollection gsc = new GradientStopCollection();
gsc.Add(gs1);
gsc.Add(gs2);
Brush colorbrush = new LinearGradientBrush(gsc,
new Point(, ), new Point(, 0.8));
Brush solidBrush = new SolidColorBrush(Color.FromRgb(,
, ));
drawingContext.DrawRectangle(solidBrush, new Pen(), rect2);
drawingContext.DrawRoundedRectangle(colorbrush, new Pen(),
rect1, _showFilePanelClock, , null, , null);
}
catch (Exception ex)
{
new SaveExceptionInfo().SaveLogAsTXTInfoex(ex.Message);
}
finally
{
drawingContext.Close();
}
return drawingWordsVisual;
}
使用下面的方法来控制进度条的进度,根据要显示的百分比,使用ClockController.Seek来控制进度条的进度。
public void FilesavedSize_saveSizeChanged(object sender, SendFileEventArgs args)
{
double percent = double.Parse(args.SavedSize.ToString())
/ double.Parse(args.FileSize.ToString());
TimeSpan timeSpan = TimeSpan.FromMilliseconds(percent * );
_showFilePanelClock.Controller.Seek(timeSpan,
TimeSeekOrigin.BeginTime);
_showFilePanelClock.Controller.Pause();
}
RectAnimation用于在DrawingVisual画进度条的更多相关文章
- html5 canvas画进度条
这个ie8的兼容是个问题,ie8 的innerHTML有问题啊,添加两个附件吧 <!DOCTYPE html> <html> <head> <meta cha ...
- CProgressCtrl进度条
CProgressCtrl进度条 使用方法总结 标签: CProgressCtrlmfc 2016-03-03 09:19 762人阅读 评论(0) 收藏 举报 分类: MFC(11) 版权声明: ...
- android 自定义进度条颜色
android 自定义进度条颜色 先看图 基于产品经理各种自定义需求,经过查阅了解,下面是自己对Android自定义进度条的学习过程! 这个没法了只能看源码了,还好下载了源码, sources\b ...
- QStandardItemModel简单好用,QTableView带进度条
类QabstractItemModel,QabstractListModel,QAbstractTableModel不保存数据,用户需要从这些类派生出子类,并在子类中定义某种数据结构来保存数据.与此不 ...
- android113 自定义进度条
MainActivity: package com.itheima.monitor; import android.os.Bundle; import android.app.Activity; im ...
- Android ProgressBar 反向进度条/进度条从右到左走
近期的项目,有个需求须要使用条状图显示比例,而且右对齐,见下图: 我想到了使用进度条,这样不就不须要在代码动态绘制条状了,省了非常多活. 那么进度条如何从右向左显示呢? 方案一: 将ProgressB ...
- Android自定义一款带进度条的精美按键
Android中自定义View并没有什么可怕的,拿到一个需要自定义的View,首先要做的就是把它肢解,然后思考每一步是怎样实现的,按分析的步骤一步一步的编码实现,最后你就会发现达到了你想要的效果.本文 ...
- [Delphi]带进度条的ListView
带进度条的ListView unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, C ...
- 自己定义进度条PictureProgressBar——从开发到开源公布全过程
自己定义进度条PictureProgressBar--从开发到开源公布全过程 出处: 炎之铠邮箱:yanzhikai_yjk@qq.com 本文原创.转载请注明本出处! 本项目JCenter地址:ht ...
随机推荐
- FineUI第六天---表单控件
表单控件 所有表单控件都有的属性有: ShowLabel:是否显示标签(默认值:true). ShowEmptyLabel:是否显示空白的标签(默认值:false). Label:标签文本(默认值:& ...
- 总结使用Unity 3D优化游戏运行性能的经验
原地址:http://www.gameres.com/msg_221889.html 作者:Amir Fasshihi 流畅的游戏玩法来自流畅的帧率,而我们即将推出的动作平台游戏<Shadow ...
- [UOJ#131][BZOJ4199][NOI2015]品酒大会 后缀数组 + 并查集
[UOJ#131][BZOJ4199][NOI2015]品酒大会 试题描述 一年一度的“幻影阁夏日品酒大会”隆重开幕了.大会包含品尝和趣味挑战两个环节,分别向优胜者颁发“首席品酒家”和“首席猎手”两个 ...
- nginx学习(一):基本安装
转载自http://summervast.blog.51cto.com/690507/385511 注意:可能因版本不同,个别指令不起作用,需要注意版本灵活安装,我在安装时也遇到过此问题 开始学习ng ...
- Step
php+MySQL html+css JQuery Mobile JavaScript weiPHP Sina Cloud 微信公众订阅号平台开发
- Textview下划线注册用户跳转实现
在xml中: <TextView android:id="@+id/textView_regtext" android:layout_width="wrap_con ...
- PHP 的__call()
PHP5 的对象新增了一个专用方法 __call(),这个方法用来监视一个对象中的其它方法.如果你试着调用一个对象中不存在或被权限控制中的方法,__call 方法将会被自动调用. 例七:__call ...
- 【OpenStack】OpenStack系列6之Sheepdog环境搭建
准备 repo配置 yum clean all yum makecache yum install -y make automake autoconf gcc nss-devel wget git g ...
- 15.含有指针成员的类的拷贝[ClassCopyConstructorWithPointerMember]
[题目] 下面是一个数组类的声明与实现.请分析这个类有什么问题,并针对存在的问题提出几种解决方案. C++ Code 123456789101112131415161718192021222324 ...
- C++调用Object-C界面
在C++代码中想调用显示一个IOS界面,使用NSNotificationCenter 1.在界面中注册消息 [[NSNotificationCenter defaultCenter] addObse ...