使用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画进度条的更多相关文章

  1. html5 canvas画进度条

    这个ie8的兼容是个问题,ie8 的innerHTML有问题啊,添加两个附件吧 <!DOCTYPE html> <html> <head> <meta cha ...

  2. CProgressCtrl进度条

    CProgressCtrl进度条 使用方法总结 标签: CProgressCtrlmfc 2016-03-03 09:19 762人阅读 评论(0) 收藏 举报  分类: MFC(11)  版权声明: ...

  3. android 自定义进度条颜色

    android 自定义进度条颜色 先看图 基于产品经理各种自定义需求,经过查阅了解,下面是自己对Android自定义进度条的学习过程!   这个没法了只能看源码了,还好下载了源码, sources\b ...

  4. QStandardItemModel简单好用,QTableView带进度条

    类QabstractItemModel,QabstractListModel,QAbstractTableModel不保存数据,用户需要从这些类派生出子类,并在子类中定义某种数据结构来保存数据.与此不 ...

  5. android113 自定义进度条

    MainActivity: package com.itheima.monitor; import android.os.Bundle; import android.app.Activity; im ...

  6. Android ProgressBar 反向进度条/进度条从右到左走

    近期的项目,有个需求须要使用条状图显示比例,而且右对齐,见下图: 我想到了使用进度条,这样不就不须要在代码动态绘制条状了,省了非常多活. 那么进度条如何从右向左显示呢? 方案一: 将ProgressB ...

  7. Android自定义一款带进度条的精美按键

    Android中自定义View并没有什么可怕的,拿到一个需要自定义的View,首先要做的就是把它肢解,然后思考每一步是怎样实现的,按分析的步骤一步一步的编码实现,最后你就会发现达到了你想要的效果.本文 ...

  8. [Delphi]带进度条的ListView

    带进度条的ListView unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, C ...

  9. 自己定义进度条PictureProgressBar——从开发到开源公布全过程

    自己定义进度条PictureProgressBar--从开发到开源公布全过程 出处: 炎之铠邮箱:yanzhikai_yjk@qq.com 本文原创.转载请注明本出处! 本项目JCenter地址:ht ...

随机推荐

  1. HDU 2955 Robberies 背包概率DP

    A - Robberies Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submi ...

  2. (转)女生应该找一个玩ACM的男生

    1.强烈的事业心 将来,他也一定会有自己热爱的事业.而且,男人最性感的时刻之一,就是他专心致志做事的时候.所以,找一个机会在他全神贯注玩ACM的时候,从侧面好好观察他,你就会发现我说的话没错. 2.永 ...

  3. linux /etc/rc.d/目录的详解

    rc.d的内容如下: init.d/ :各种服务器和程序的二进制文件存放目录. rcx.d/: 各个启动级别的执行程序连接目录.里头的东西都是指向init.d/的一些软连接.具体的后边叙述. 还有三个 ...

  4. win7安装ubuntu后,进入不了win7

    方法一:进去ubuntu系统后,终端下输入如下命令:sudo update-grub,输入命令后,会提示寻找win7,ubuntu系统.并自动建立引导详情链接:http://zhidao.baidu. ...

  5. php中global与$GLOBALS的用法及区别

    php中global 与 $GLOBALS[""] 差别 原本觉得global和$GLOBALS除了写法不一样觉得,其他都一样,可是在实际利用中发现2者的差别还是很大的! 先看下面 ...

  6. MQTT——安装、测试

    MQTT学习笔记——MQTT协议体验 Mosquitto安装和使用         http://blog.csdn.net/xukai871105/article/details/39252653 ...

  7. iOS CALayer动画中使用的3个tree

    在网上经常看到关于layer的tree的描述,不太理解,今天找到了官方文档,原文在Core Animation Programming Guide 中. Layer Trees Reflect Dif ...

  8. CodeForces - 424B (贪心算法)

    Megacity Time Limit: 2000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Sta ...

  9. [Android Memory] android 警告:Exported activity does not require permission

    在一个应用程序中添加了多个antivity后,在manifest.xml文件中会除了主Activity外,其它的Activity属性中都会有个警告: Exported activity does no ...

  10. 运输装备(codevs 1669)

    1669 运输装备  时间限制: 1 s  空间限制: 256000 KB  题目等级 : 钻石 Diamond 题解       题目描述 Description 德国放松对英国的进攻后,把矛头指向 ...