namespace Microsoft.Windows.Forms.Animate { /// /// 线性动画 /// public sealed class UILinearAnimation : Animation { /// /// 默认动画执行时间 /// public const int DEFAULT_ANIMATION_SPAN = 200; private float m_From; /// /// 获取或设置起点 /// public float From { get { return this.m_From; } set { this.m_From = value; } } private float m_To; /// /// 获取或设置终点 /// public float To { get { return this.m_To; } set { this.m_To = value; } } private float m_Current; /// /// 获取动画当前帧 /// public override float Current { get { if (this.m_From >= this.m_To) { this.Stop(); return this.m_Current = this.m_To; } double percentage = this.Percentage; return this.m_Current = (percentage == STOPPED ? this.m_To : (float)(this.m_From + (this.m_To - this.m_From) * percentage)); } } /// /// 构造函数 /// public UILinearAnimation() { base.Span = DEFAULT_ANIMATION_SPAN; } /// /// 继续动画 /// /// 终点 public void Continue(float to) { this.m_From = this.m_Current; this.m_To = to; this.Start(); } /// /// 重新开始动画 /// public void Next() { base.Start(); } /// /// 停止动画 /// public new void Stop() { base.Stop(); } /// /// 释放资源 /// /// 释放托管资源为 true,否则为 false protected override void Dispose(bool disposing) { } } }