Example #1
0
        public void NewWIdowsSlidFront(Window panal, double centerlocation, double duration)
        {
            DoubleAnimation slider = new DoubleAnimation();
            slider.To = centerlocation;

            slider.DecelerationRatio = .7;
            slider.From = -panal.Width - 100;
            slider.Duration = new Duration(TimeSpan.FromMilliseconds(duration));
            panal.BeginAnimation(Window.LeftProperty, slider);
        }
Example #2
0
        /// <summary>
        /// 隐藏窗口
        /// </summary>
        /// <param name="window">要隐藏的窗口</param>
        public void HideWindow(Window window)
        {
            ObjectAnimationUsingKeyFrames visAni = new ObjectAnimationUsingKeyFrames();
            visAni.KeyFrames.Add(new DiscreteObjectKeyFrame(Visibility.Hidden, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.3))));
            window.BeginAnimation(Window.VisibilityProperty, visAni);

            DoubleAnimationUsingKeyFrames alphaAni = new DoubleAnimationUsingKeyFrames();
            CubicEase ef = new CubicEase();
            alphaAni.KeyFrames.Add(new EasingDoubleKeyFrame(1, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)), ef));
            alphaAni.KeyFrames.Add(new EasingDoubleKeyFrame(0, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.3)), ef));
            window.BeginAnimation(Window.OpacityProperty, alphaAni);
        }
        /// <summary>
        /// Animates the window's height
        /// </summary>
        /// <param name="window">The window to animate</param>
        /// <param name="height">The height to animate the window to</param>
        /// <param name="duration">The duration for the animation</param>
        /// <param name="callback">An optional callback to be executed when the animation finishes</param>
        private void animateWindowHeight(Window window, double height, double duration, Action callback = null)
        {
            window.BeginInit();
            window.Dispatcher.BeginInvoke((Action)(() =>
            {
                DoubleAnimation windowAnimation = new DoubleAnimation();
                windowAnimation.Duration = new Duration(TimeSpan.FromSeconds(duration));
                windowAnimation.From = window.Height;
                windowAnimation.To = height;
                windowAnimation.FillBehavior = FillBehavior.HoldEnd;

                //If a callback is passed, execute it using a lambda expression
                if (callback != null)
                {
                    windowAnimation.Completed += (s, e) => callback();
                }
                window.BeginAnimation(Window.HeightProperty, windowAnimation);
            }), null);
            window.EndInit();
        }
Example #4
0
 public void WIdowsSlidBack(Window panal, double duration)
 {
     DoubleAnimation slider = new DoubleAnimation();
     slider.To = -panal.Width - 100;
     slider.From = panal.Left;
     slider.AccelerationRatio = .4;
     slider.Duration = new Duration(TimeSpan.FromMilliseconds(duration));
     panal.BeginAnimation(Window.LeftProperty, slider);
 }
Example #5
0
 public static void Animate(Window _this, float _time, float from, float to, DependencyProperty property , bool isClosing)
 {
     DoubleAnimation da = new DoubleAnimation(from, to, new Duration(TimeSpan.FromSeconds(_time)));
     da.Completed += (s, e) =>
     {
        
        _this.Close();
     };
     _this.BeginAnimation(property, da);
   
 }
Example #6
0
        public static void Animate(Window _this, float _time, float from, float to, DependencyProperty property)
        {
            DoubleAnimation da = new DoubleAnimation(from, to, new Duration(TimeSpan.FromSeconds(_time)));
            _this.BeginAnimation(property, da);
            //da.Completed += (s, e) =>
            //{

            //};
        }