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 ...
随机推荐
- QEMU-KVM中的多线程压缩迁移技术
导读 目前的迁移技术,都是通过向QEMUFILE中直接写入裸内存数据来达到传送虚拟机的目的端,这种情况下,发送的数据量大,从而会导致更高的迁移时间(total time)和黑宕时间(downtime) ...
- hiho一下 第九十六周 数论五·欧拉函数
题目1 : 数论五·欧拉函数 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 小Hi和小Ho有时候会用密码写信来互相联系,他们用了一个很大的数当做密钥.小Hi和小Ho约定 ...
- systemd在各个linux发行版的普及
后面我要说下自己的意见: 原则如果阻碍了进步,那还算个屁,不客气地说,UNIX 原则已经过时了. 移植性问题:我除了 Mac 外不用任何 BSD 系统,当然 Mac 上一般只做开发不做运维(但就算如此 ...
- 2.11 2D平面最近点对问题[closest pair problem]
[本文链接] http://www.cnblogs.com/hellogiser/p/closest-pair-problem.html [题目] 给定平面上N个点的坐标,找出距离最近的两个点之间的距 ...
- Java for LeetCode 073 Set Matrix Zeroes
Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. 解题思路: ...
- Hibernate常见问题
问题1,hql条件查询报错 执行Query session.createQuery(hql) 报错误直接跳到finally 解决方案 加入 <prop key="hibernate.q ...
- Android之自定义控件深入
本文主要讲述两个知识点:popwindow的使用和通过继承View实现一个自定义控件,实现点击,手动按钮的效果. popwindow的使用 //定义 popupWindow popWin = new ...
- zabbix 监控客户端数据库 zabbix客户端
[root@zabbix客户端 zabbix]# grep -v "^$" etc/zabbix_agentd.conf|grep -v "^#" LogFil ...
- C++基础内容复习
下列语句定义了5个变量: int count; double sales_price,sum; std::string title; Sales_item bookItem; 每个定义都是以类型说明符 ...
- java 学习之路
一.基础篇 1.1 JVM 1.1.1. Java内存模型,Java内存管理,Java堆和栈,垃圾回收 http://www.jcp.org/en/jsr/detail?id=133 http://i ...