示例#1
0
 /// <summary>
 /// 滑条缓变动画
 /// </summary>
 /// <param name="sliname">指定控件</param>
 /// <param name="from">起始值</param>
 /// <param name="to">目标值</param>
 /// <param name="time">持续时间(ms)</param>
 public static void FloatSlider(Slider sliname, double from, double to, int time)
 {
     lock (sliname)
     {
         EasingFunctionBase easeFunction = new PowerEase()
         {
             EasingMode = EasingMode.EaseOut,
             Power      = 5
         };
         DoubleAnimation slianimation = new DoubleAnimation()
         {
             From           = from,
             To             = to,
             EasingFunction = easeFunction,                   //缓动函数
             Duration       = TimeSpan.FromMilliseconds(time) //动画播放时间
         };
         EventHandler handler = null;
         slianimation.Completed += handler = (s, e) =>
         {
             sliname.Value           = to;
             slianimation.Completed -= handler;
             slianimation            = null;
         };
         sliname.BeginAnimation(Slider.ValueProperty, slianimation);
     }
 }
示例#2
0
        private void Image_MouseEnter(object sender, MouseEventArgs e)
        {
            if (SliderExpanded)
            {
                return;
            }
            SliderExpanded = true;
            DoubleAnimation da = new DoubleAnimation();

            da.From = Slider.ActualWidth;
            da.To   = 150;
            double?   x = da.To - da.From;
            Thickness t = new Thickness(0, 0, (int)x, 0);

            ThicknessAnimation ta = new ThicknessAnimation();

            ta.From     = Slider.Margin;
            ta.To       = t;
            ta.Duration = TimeSpan.FromSeconds(AnimationDuration);
            da.Duration = TimeSpan.FromSeconds(AnimationDuration);
            Slider.BeginAnimation(WidthProperty, da);
            sw.Start();
            Task.Factory.StartNew(() => ExpandSlider());
            //     ExpandSlider();
            //Slider.BeginAnimation(MarginProperty, ta);
        }
示例#3
0
        private void FoldSlider()
        {
            sw.Reset();
            sw.Stop();
            SliderExpanded = false;
            DoubleAnimation da = new DoubleAnimation();

            da.From     = Slider.ActualWidth;
            da.To       = 0;
            da.Duration = TimeSpan.FromSeconds(AnimationDuration);
            Slider.BeginAnimation(WidthProperty, da);
        }
示例#4
0
 /// <summary>
 /// 滑条缓变动画
 /// </summary>
 /// <param name="sliname">指定控件</param>
 /// <param name="to">目标值</param>
 /// <param name="time">持续时间(ms)</param>
 public static void FloatSlider(Slider sliname, double to, int time)
 {
     lock (sliname)
     {
         EasingFunctionBase easeFunction = new PowerEase()
         {
             EasingMode = EasingMode.EaseOut,
             Power      = 5
         };
         DoubleAnimation slianimation = new DoubleAnimation()
         {
             To             = to,
             EasingFunction = easeFunction,                   //缓动函数
             Duration       = TimeSpan.FromMilliseconds(time) //动画播放时间
         };
         sliname.BeginAnimation(Slider.ValueProperty, slianimation);
     }
 }