WPF 位置转化和动画
位置转化
private void DrawScale()
{
double majorTickUnitValue = this.ScaleSweepLenth / this.MajorDivisionsCount;
double minorTickUnitValue = this.ScaleSweepLenth / this.MinorDivisionsCount;
double correctionOffset = this.rootGrid.Width / ; Double minvalue = MinValue; ; //画主刻度
for (int i = ; i < this.MajorDivisionsCount; i++)
{
Rectangle majorTickRect = new Rectangle();
majorTickRect.Height = this.MajorTickSize.Height;
majorTickRect.Width = this.MajorTickSize.Width;
majorTickRect.Fill = new SolidColorBrush(this.MajorTickColor); TransformGroup majorTickTransformGroup = new TransformGroup();
TranslateTransform majorTickTranslateTransform = new TranslateTransform(); majorTickTranslateTransform.X = i * majorTickUnitValue - correctionOffset;
majorTickTranslateTransform.Y = this.MajorMinorDivisionOffset; majorTickTransformGroup.Children.Add(majorTickTranslateTransform);
majorTickRect.RenderTransform = majorTickTransformGroup; this.rootGrid.Children.Add(majorTickRect);
} }
动画
private void MovePointerUsingAnimate(double oldValue, double newValue)
{
if (null != this.pointer)
{
double distanceOldAndNew = Math.Abs(newValue - oldValue);
DoubleAnimation doubleAnimation = new DoubleAnimation();
double animDuration = 0.0f;
Storyboard movingPointerStoryboard = new Storyboard();
TransformGroup transformGroup = new TransformGroup();
TranslateTransform transform = new TranslateTransform(); doubleAnimation.From = oldValue;
doubleAnimation.To = newValue;
animDuration = distanceOldAndNew * animatingSpeedFactor;
doubleAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(animDuration)); movingPointerStoryboard.Completed +=new EventHandler(MovingPointerStoryboardStoryboard_Completed);
movingPointerStoryboard.Children.Add(doubleAnimation);
Storyboard.SetTarget(doubleAnimation, this.pointer); transformGroup.Children.Add(transform);
this.pointer.RenderTransform = transformGroup; Storyboard.SetTargetProperty(doubleAnimation,
new PropertyPath("(Path.RenderTransform).(TransformGroup.Children)[0].(TranslateTransform.X)")); if (Math.Abs(oldValue - newValue) > )
{
movingPointerStoryboard.Begin();
} }
}
WPF 位置转化和动画的更多相关文章
- WPF 3D 平移模型+动画(桥梁检测系统)
原文:WPF 3D 平移模型+动画(桥梁检测系统) 关于WPF 3D,网上有很多旋转的例子,但是关于平移的例子并不是太多.本文并非WPF 3D扫盲篇,因此需要对WPF 3D有一定了解,至少知道View ...
- WPF加载等待动画
原文:WPF加载等待动画 原文地址:https://www.codeproject.com/Articles/57984/WPF-Loading-Wait-Adorner 界面遮罩 <UserC ...
- 【WPF】两则动画效果
原文:[WPF]两则动画效果 引言 利用WPF的动画可以轻而易举的实现各种各样的特效,如擦除,滑动进入等,先看两个效果图 第一个效果 这个动画其实利用了OpacityMask和LinearGradie ...
- WPF 加载等待动画
原文:WPF 加载等待动画 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/qq_29844879/article/details/80216587 ...
- WPF实现射线效果动画
原文:WPF实现射线效果动画 最近的一个项目中有个需求是:从一个点向其它多个点发出射线,要求这些射线同时发出,同时到达. 我就想到了用WPF的动画来实现.WPF中有Line类用于绘制直线,但这个类中好 ...
- WPF特效-鱼游动动画3
原文:WPF特效-鱼游动动画3 WPF不支持骨骼,故使用3DMax导出了序列模型文件(.mtl;.obj). 方法1: 使用Blend 2013打开所有obj文件,拖动排列一下即可在usercontr ...
- WPF特效-鱼游动动画
原文:WPF特效-鱼游动动画 实现思路: 通过VisualBrush Binding方式获取鱼局部图像,在Viewport3D中创建ModelVisual3D块并把获取到的局部 ...
- WPF特效-鱼游动动画2
原文:WPF特效-鱼游动动画2 纯代码撸动画实践2: 原图:(png格式) ...
- WPF 精修篇 路径动画
原文:WPF 精修篇 路径动画 路径动画 是让一个对象围绕指定Path 的运动路径 进行移动的动画 举栗子 路径动画 使用 Blend 来设置 是十分简单的 首先用工具 笔 点出一条线 新建一个圆形 ...
随机推荐
- SQL获取刚插入的记录的自动增长列ID的值
假设表结构如下: CREATE TABLE TestTable ( id int identity, CreatedDate datetime ) SQL2005获得新增行的自动增长列的语句如下: i ...
- Sql server 大全
一.基础 .说明:删除数据库drop database dbname3.说明:备份sql server--- 创建 备份数据的 deviceUSE masterEXEC sp_addumpdevice ...
- Commons-logging + Log4j
一.Commons-logging能帮我们做什么? 1.提供一个统一的日志接口,简单了操作,同时避免项目与某个日志实现系统紧密耦合 2.自动选择适当的日志实现系统 a.classpath下查找comm ...
- 第七篇、微信小程序-video组件
主要属性: 效果图: ml: <View>1.播放网络视频</View> <view > <video style="width: 100%;hei ...
- Unity连接本地数据库sqlite
首先要创建一个sqlite的数据库,记住文件地址,拷贝到Assets目录下,创建的数据库文件后缀为.sqlite.具体创建方法百度sqlite 然后百度Mono.Data.Sqlite,这是一个dll ...
- CSS笔记---文字两边对齐
<style> .box{ width: 1000px; height: 500px; background-color: #aa0000; margin:0 auto; } .teste ...
- 使用Script元素发送JSONP请求
// 根据指定URL发送一个JSONP请求 //然后把解析得到的相应数据传递给回调函数 //在URL中添加一个名为jsonp的查询参数,用于指定该请求的回调函数的名称 function getJSON ...
- From MSI to WiX, Part 8 - Major Upgrade, by Alex Shevchuk
Following content is reprinted from here, please go to the original website for more information. Au ...
- 2014-10 u-boot 顶层config.mk分析
/** ****************************************************************************** * @author Maox ...
- putty 实现不用输入用户名密码直接登陆
多谢谢Eric的教程 ,下面是我的简化版,原版为Eric所写 远程登陆Linux服务器有两大著名软件,一个是商业软件securecrt,一个是开源软件putty. 两者的安全性能都很高,发展了多年,值 ...