Inheritance: EasingFunctionBase
Exemplo n.º 1
0
        public static EasingFunctionBase GetEasingFunction()
        {
            EasingFunctionBase result = null;
            switch (random.Next(5))
            {
                case 0:
                    result = new BackEase() { EasingMode = EasingMode.EaseInOut, Amplitude = 0.8 };
                    break;
                case 1:
                    result = new BounceEase() { EasingMode = EasingMode.EaseOut, Bounces = 3, Bounciness = 8 };
                    break;
                case 2:
                    result = new CircleEase() { EasingMode = EasingMode.EaseInOut };
                    break;
                case 3:
                    result = new CubicEase() { EasingMode = EasingMode.EaseIn };
                    break;
                case 4:
                    result = new ElasticEase() { EasingMode = EasingMode.EaseOut, Oscillations = 3, Springiness = 4 };
                    break;
                case 5:
                    result = new SineEase() { EasingMode = EasingMode.EaseInOut };
                    break;
                default:
                    result = new BackEase() { EasingMode = EasingMode.EaseInOut, Amplitude = 0.8 };
                    break;
            }

            return result;
        }
        public SelfExpandableControl()
        {
            SetResourceReference(StyleProperty, "SelfExpandableControlStyle");
            _currentXoffSet = 0;
            _currentYoffSet = 0;
            TransformGroupHelper.CreateTransformGroup(this);

            EasingFunction = new CubicEase { EasingMode = EasingMode.EaseOut };
               Events.UpdateOriginalSizeEvent+=EventsUpdateOriginalSizeEvent;
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        private static void DoAnimation(ColumnDefinition column, double oldValue, double newValue)
        {
            Duration duration = new Duration(TimeSpan.FromMilliseconds(600));
            CubicEase ease = new CubicEase { EasingMode = EasingMode.EaseOut };

            DoubleAnimation animation = new DoubleAnimation();
            animation.EasingFunction = ease;
            animation.Duration = duration;
            _healthStoryBoard.Children.Add(animation);
            animation.From = oldValue;
            animation.To = newValue;
            Storyboard.SetTarget(animation, column);
            Storyboard.SetTargetProperty(animation, new PropertyPath("(ColumnDefinition.MaxWidth)"));
        }
Exemplo n.º 5
0
        private void animateMove(UIElement uiElement)
        {
            Duration duration = new Duration(TimeSpan.FromMilliseconds(2000));

            DoubleAnimation myDoubleAnimation1 = new DoubleAnimation();
            DoubleAnimation myDoubleAnimation2 = new DoubleAnimation();
            CubicEase easingFunction = new CubicEase {EasingMode = EasingMode.EaseInOut};
            myDoubleAnimation1.EasingFunction = easingFunction;
            myDoubleAnimation2.EasingFunction = easingFunction;

            myDoubleAnimation1.Duration = duration;
            myDoubleAnimation2.Duration = duration;

            Storyboard storyboard = new Storyboard();
            storyboard.Completed += removeStoryboard;
            storyboard.Duration = duration;

            storyboard.Children.Add(myDoubleAnimation1);
            storyboard.Children.Add(myDoubleAnimation2);

            Storyboard.SetTarget(myDoubleAnimation1, uiElement);
            Storyboard.SetTarget(myDoubleAnimation2, uiElement);

            Storyboard.SetTargetProperty(myDoubleAnimation1, new PropertyPath("(Canvas.Left)"));
            Storyboard.SetTargetProperty(myDoubleAnimation2, new PropertyPath("(Canvas.Top)"));

            double top = (double)uiElement.GetValue(Canvas.TopProperty);
            double left = (double)uiElement.GetValue(Canvas.LeftProperty);

            if (left.Equals(WIDTH_OF_MEDIA_GALLERY_IMAGE * 2))
            {
                left = 0;
                top += WIDTH_OF_MEDIA_GALLERY_IMAGE;
            }
            else
            {
                left += WIDTH_OF_MEDIA_GALLERY_IMAGE;
            }

            myDoubleAnimation1.To = left;
            myDoubleAnimation2.To = top;

            string animationName = "animation_" + uiElement.GetValue(Image.NameProperty);
            mediaGalleryCanvas.Resources.Add(animationName, storyboard);
            animationDictionary.Add(storyboard, animationName);

            storyboard.Begin();
        }
Exemplo n.º 6
0
        public PivotContentControl()
        {
            ThicknessAnimation slideInAnimation = new ThicknessAnimation();
            slideInAnimation.From = new Thickness(200, 0, 0, 0);
            slideInAnimation.To = new Thickness(0, 0, 0, 0);
            slideInAnimation.Duration = new Duration(TimeSpan.FromSeconds(0.3));
            Storyboard.SetTargetProperty(slideInAnimation, new PropertyPath(FrameworkElement.MarginProperty));
            Storyboard.SetTarget(slideInAnimation, this);

            CubicEase easing = new CubicEase();
            easing.EasingMode = EasingMode.EaseOut;
            slideInAnimation.EasingFunction = easing;

            fadeInSB = new Storyboard();
            fadeInSB.Children.Add(slideInAnimation);
        }
Exemplo n.º 7
0
        private IEasingFunction ObterFuncaoDaAnimacao()
        {
            EasingFunctionBase funcaoDaAnimacao = null;
            
            switch (FuncaoDaAnimacao.SelectedValue.ToString())
            {
                case "BackEase":
                    funcaoDaAnimacao =  new BackEase();
                    break;
                case "BounceEase":
                    funcaoDaAnimacao = new BounceEase();
                    break;
                case "CircleEase":
                    funcaoDaAnimacao = new CircleEase();
                    break;
                case "CubicEase":
                    funcaoDaAnimacao = new CubicEase();
                    break;
                case "ElasticEase":
                    funcaoDaAnimacao = new ElasticEase();
                    break;
                case "ExponentialEase":
                    funcaoDaAnimacao = new ExponentialEase();
                    break;
                case "PowerEase":
                    funcaoDaAnimacao = new PowerEase();
                    break;
                case "QuadraticEase":
                    funcaoDaAnimacao = new QuadraticEase();
                    break;
                case "QuarticEase":
                    funcaoDaAnimacao = new QuarticEase();
                    break;
                case "QuinticEase":
                    funcaoDaAnimacao = new QuinticEase();
                    break;
                case "SineEase":
                    funcaoDaAnimacao = new SineEase();
                    break;
            }

            funcaoDaAnimacao.EasingMode = ObterModoDaAnimacao();
            return funcaoDaAnimacao;
        }
Exemplo n.º 8
0
        /// <summary>
        /// Ctor
        /// </summary>
        public PivotHeaderPanel()
        {
            // Define the storyboards
            DoubleAnimation addFadeInAnim = new DoubleAnimation(0.0, 1.0, new Duration(TimeSpan.FromMilliseconds(ADD_FADE_IN_DURATION)));
            Storyboard.SetTargetProperty(addFadeInAnim, new PropertyPath(UIElement.OpacityProperty));
            addFadeInSB = new Storyboard();
            addFadeInSB.Children.Add(addFadeInAnim);

            DoubleAnimation updateFadeInAnim = new DoubleAnimation(0.0, 1.0, new Duration(TimeSpan.FromMilliseconds(UPDATE_FADE_IN_DURATION)));
            Storyboard.SetTargetProperty(updateFadeInAnim, new PropertyPath(UIElement.OpacityProperty));
            updateFadeInSB = new Storyboard();
            updateFadeInSB.Children.Add(updateFadeInAnim);

            updateFadeInSB.Completed += new EventHandler(OnAnimationCompleted);

            headerCollection = new List<UIElement>();

            easingFn = new CubicEase();
            easingFn.EasingMode = EasingMode.EaseOut;
        }
        private void CreateAnimation()
        {
            CubicEase compositeTransformEasy = new CubicEase() { EasingMode = EasingMode.EaseOut };

            DoubleAnimation opacityAnimationIn = new DoubleAnimation() { Duration = TimeSpan.FromMilliseconds(400), From = 0, To = 1 };
            DoubleAnimation opacityAnimationOut = new DoubleAnimation() { Duration = TimeSpan.FromMilliseconds(150), From = 1, To = 0 };

            DoubleAnimation opacityAnimationViewChange = new DoubleAnimation() { Duration = TimeSpan.FromMilliseconds(170), From = 1, To = 0, AutoReverse = true };

            DoubleAnimationUsingKeyFrames compositeTransformIn = new DoubleAnimationUsingKeyFrames();

            compositeTransformIn.KeyFrames.Add(new EasingDoubleKeyFrame { KeyTime = TimeSpan.Zero, Value = -30 });
            compositeTransformIn.KeyFrames.Add(new EasingDoubleKeyFrame { KeyTime = TimeSpan.FromMilliseconds(700), Value = 0, EasingFunction = compositeTransformEasy });

            DoubleAnimationUsingKeyFrames compositeTransformOut = new DoubleAnimationUsingKeyFrames();

            compositeTransformOut.KeyFrames.Add(new EasingDoubleKeyFrame { KeyTime = TimeSpan.Zero, Value = 0 });
            compositeTransformOut.KeyFrames.Add(new EasingDoubleKeyFrame { KeyTime = TimeSpan.FromMilliseconds(150), Value = -30, EasingFunction = compositeTransformEasy });

            Storyboard.SetTargetProperty(opacityAnimationIn, new PropertyPath("Opacity"));
            Storyboard.SetTarget(opacityAnimationIn, this.MainContentGrid);

            Storyboard.SetTargetProperty(compositeTransformIn, new PropertyPath("(UIElement.RenderTransform).(CompositeTransform.TranslateX)"));
            Storyboard.SetTarget(compositeTransformIn, this.MainContentGrid);

            _StoryboardIn = new Storyboard();
            _StoryboardIn.Children.Add(opacityAnimationIn);
            _StoryboardIn.Children.Add(compositeTransformIn);

            Storyboard.SetTargetProperty(opacityAnimationOut, new PropertyPath("Opacity"));
            Storyboard.SetTarget(opacityAnimationOut, this.MainContentGrid);

            Storyboard.SetTargetProperty(compositeTransformOut, new PropertyPath("(UIElement.RenderTransform).(CompositeTransform.TranslateX)"));
            Storyboard.SetTarget(compositeTransformOut, this.MainContentGrid);

            _StoryboardOut = new Storyboard();

            _StoryboardOut.Completed += (o, t) =>
            {
                MainContentGrid.RenderTransform = startPosition;
                _StoryboardIn.Begin();
            };

            _StoryboardOut.Children.Add(opacityAnimationOut);
            _StoryboardOut.Children.Add(compositeTransformOut);

            Storyboard.SetTargetProperty(opacityAnimationViewChange, new PropertyPath("Opacity"));
            Storyboard.SetTarget(opacityAnimationViewChange, this.MainContentGrid);

            _StoryboardViewChange = new Storyboard();

            _StoryboardViewChange.Children.Add(opacityAnimationViewChange);
        }
        private DoubleAnimation CreateWaitAnimation(DependencyObject obj, DependencyProperty prop, double value, double from, double duration, EasingMode easingMode = EasingMode.EaseOut)
        {
            CubicEase easingFunction = new CubicEase() { EasingMode = easingMode };
            DoubleAnimation animation = new DoubleAnimation()
            {
                Duration = new Duration(TimeSpan.FromMilliseconds(duration)),
                From = from,
                To = value,
                FillBehavior = FillBehavior.HoldEnd,
                EasingFunction = easingFunction
            };

            Storyboard.SetTarget(animation, obj);
            Storyboard.SetTargetProperty(animation, new PropertyPath(prop));

            return animation;
        }
Exemplo n.º 11
0
 public void Start()
 {
     if (ended)
     {
         ended = false;
         nonFinalCanvas.Visibility = Visibility.Visible;
         finalCanvas.Visibility = Visibility.Collapsed;
         EasingFunctionBase easing = new CubicEase();
         effect = new RotateEffect(-90, 90, 6, EasingMode.EaseOut, easing);
         effect.Completed += effect_Completed;
         q = new Queue<FrameworkElement>();
         if (Toss)
         {
             effect.Start(finalCanvas);
             q.Enqueue(nonFinalCanvas);
             q.Enqueue(finalCanvas);
         }
         else
         {
             effect.Start(nonFinalCanvas);
             q.Enqueue(finalCanvas);
             q.Enqueue(nonFinalCanvas);
         }
     }
 }
Exemplo n.º 12
0
        private void AnimateTabPageOpen()
        {
            var animation = new DoubleAnimation();
            animation.From = 0;
            animation.To = 1;
            animation.Duration = new Duration(TimeSpan.FromMilliseconds(TAB_PAGE_OPEN_ANIMATION_TIME));

            var ease = new CubicEase();
            ease.EasingMode = EasingMode.EaseIn;

            animation.EasingFunction = ease;
            CurrentPage_CONTENT.BeginAnimation(OpacityProperty, animation);
        }
Exemplo n.º 13
0
        private void SettingsButton_Click(object sender, RoutedEventArgs e)
        {
            ThicknessAnimation animation = new ThicknessAnimation(new Thickness(0, 0, 0, 0), new Duration(TimeSpan.FromMilliseconds(500)));
            CubicEase ce = new CubicEase();
            ce.EasingMode = EasingMode.EaseInOut;

            if (currentSettingsState == 0)
            {
                animation.To = new Thickness(0, 0, 0, 0);
                currentSettingsState = 1;
                settingsButton.Content = new String(closeMenu, 1);
            }
            else
            {
                animation.To = new Thickness(0, 0, 0, 350);
                currentSettingsState = 0;
                settingsButton.Content = new String(openMenu, 1);
            }

            // Animate settings
            animation.EasingFunction = ce;
            settingsPanel.BeginAnimation(Rectangle.MarginProperty, animation);
        }
Exemplo n.º 14
0
        private void Animate(List<Rect> fromRects, List<Rect> toRects)
        {
            TargetRects = toRects;
            AnimationStoryboard.Stop();
            AnimationStoryboard.Children.Clear();

            var duration = new Duration(TimeSpan.FromMilliseconds(300));
            var easingFunction = new CubicEase();
            easingFunction.EasingMode = EasingMode.EaseInOut;

            var targetOpacity = (AnimationState == AnimationStates.Hiding) ? 0.0 : 0.6;
            DoubleAnimation backdropOpacityAnimation = new DoubleAnimation(BackdropCanvas.Opacity, targetOpacity, duration);
            backdropOpacityAnimation.EasingFunction = easingFunction;
            AnimationStoryboard.Children.Add(backdropOpacityAnimation);
            Storyboard.SetTarget(backdropOpacityAnimation, BackdropCanvas);
            Storyboard.SetTargetProperty(backdropOpacityAnimation, new PropertyPath(OpacityProperty));

            var thumbs = ThumbnailCanvas.Children;
            var count = thumbs.Count;
            for (var i=0; i< count; i++)
            {
                var thumb = (ThumbnailBorder)thumbs[i];
                thumb.HideDecorations();
                thumb.Layout();
                var animation = new RectAnimation(fromRects[i], toRects[i], duration);
                animation.EasingFunction = easingFunction;
                Storyboard.SetTarget(animation, thumb);
                Storyboard.SetTargetProperty(animation, new PropertyPath(ThumbnailBorder.RectProperty));
                //Timeline.SetDesiredFrameRate(animation, 120);
                AnimationStoryboard.Children.Add(animation);

                if (thumb.Thumb.Minimized)
                {
                    var toOpacity = 1;
                    var fromOpacity = 0;
                    if (AnimationState == AnimationStates.Hiding)
                    {
                        toOpacity = 0;
                        fromOpacity = 1;
                    }

                    var opacityAnimation = new DoubleAnimation(fromOpacity, toOpacity, duration);
                    opacityAnimation.EasingFunction = easingFunction;
                    Storyboard.SetTarget(opacityAnimation, thumb);
                    Storyboard.SetTargetProperty(opacityAnimation, new PropertyPath(OpacityProperty));
                    AnimationStoryboard.Children.Add(opacityAnimation);
                }
            }
            AnimationStoryboard.Begin();
        }
Exemplo n.º 15
0
        public DoubleAnimation CreateAnimation(DependencyObject obj, DependencyProperty prop, double value, double milliseconds, EasingMode easing = EasingMode.EaseOut)
        {
            CubicEase ease = new CubicEase() { EasingMode = easing };
            DoubleAnimation animation = new DoubleAnimation
            {
                Duration = new Duration(TimeSpan.FromMilliseconds(milliseconds)),
                From = Convert.ToDouble(obj.GetValue(prop)),
                To = Convert.ToDouble(value),
                FillBehavior = FillBehavior.HoldEnd,
                EasingFunction = ease
            };
            Storyboard.SetTarget(animation, obj);
            Storyboard.SetTargetProperty(animation, new PropertyPath(prop));

            return animation;
        }
Exemplo n.º 16
0
        private void ScaleCanvas(double relativeScale, Point center, bool animate = false)
        {
            var scale = _zoomableCanvas.Scale;

            if (scale <= 0)
            {
                return;
            }
            relativeScale = relativeScale.Clamp(
                MinScaleRelativeToMinSize * _originalScale / scale,
                Math.Max(MaxScaleRelativeToMaxSize, MaxScaleRelativeToMaxSize * _originalScale) / scale);

            var targetScale = scale * relativeScale;

            if (targetScale != scale)
            {

                var position = (Vector)center;
                var targetOffset = (Point)((Vector)(ZoomableCanvasOffset + position) * relativeScale - position);
                targetOffset = GetValideOffset(targetOffset);
                if (animate)
                {
                    if (relativeScale < 1)
                        relativeScale = 1 / relativeScale;
                    var duration = TimeSpan.FromMilliseconds(relativeScale * ScaleAnimationRelativeDuration);
                    var easing = new CubicEase();
                    _zoomableCanvas.BeginAnimation(ZoomableCanvas.ScaleProperty, new DoubleAnimation(targetScale, duration) { EasingFunction = easing }, HandoffBehavior.Compose);
                    _zoomableCanvas.BeginAnimation(ZoomableCanvas.OffsetProperty, new PointAnimation(targetOffset, duration) { EasingFunction = easing }, HandoffBehavior.Compose);
                }
                else
                {
                    _zoomableCanvas.Scale = targetScale;
                    ZoomableCanvasOffset = targetOffset;
                }
            }
        }
Exemplo n.º 17
0
        private void ShowRSS()
        {
            // 애니메이션 설정
            Storyboard fadeAnimation = new Storyboard();
            CubicEase colorEassing = new CubicEase();
            TimeSpan durationColor = TimeSpan.FromMilliseconds(300);

            // 글자 애니메이션 설정
            RSSView.TextTitle.TextEffects = null;
            for (int i = 0; i < RSSView.TextTitle.Text.Length; ++i)
            {
                // 글자 효과 설정
                SetTextEffect(RSSView.TextTitle, i);

                // 애니메이션 생성
                ColorAnimation color = new ColorAnimation
                {
                    From = Colors.Transparent,
                    To = Colors.White,
                    Duration = durationColor,
                    EasingFunction = colorEassing
                };

                // 애니메이션 시간 설정
                SetBeginTime(color, i);

                // 애니메이션 대상 설정
                Storyboard.SetTarget(color, RSSView.TextTitle);
                Storyboard.SetTargetProperty(color, new PropertyPath(string.Format("TextEffects[{0}].Foreground.Color", i)));

                // 스토리보드에 애니메이션 추가
                fadeAnimation.Children.Add(color);
            }

            // 애니메이션 실행
            fadeAnimation.Begin();
        }
Exemplo n.º 18
0
        private void AnimateTabOpening_Width()
        {
            root.Opacity = 1;

            var animation = new DoubleAnimation();
            animation.From = START_WIDTH;
            animation.To = MaxWidth;
            animation.Duration = new Duration(TimeSpan.FromMilliseconds(TAB_OPENING_WIDTH_ANIMATION_TIME));
            animation.Completed += Opening_WIDTH_Completed;

            var ease = new CubicEase();
            ease.EasingMode = EasingMode.EaseIn;

            animation.EasingFunction = ease;
            root.BeginAnimation(MaxWidthProperty, animation);
        }
Exemplo n.º 19
0
        private void AnimateTabOpening_Opacity()
        {
            var animation = new DoubleAnimation();
            animation.From = 0;
            animation.To = 1;
            animation.Duration = new Duration(TimeSpan.FromMilliseconds(TAB_OPENING_OPACITY_ANIMATION_TIME));
            animation.Completed += Animation_Completed;

            var ease = new CubicEase();
            ease.EasingMode = EasingMode.EaseIn;

            animation.EasingFunction = ease;
            root.BeginAnimation(OpacityProperty, animation);
        }
Exemplo n.º 20
0
        private void AnimateTabClosing()
        {
            spaceWidth = root.ActualWidth;
            Width = spaceWidth;

            var animation = new DoubleAnimation();
            animation.Completed += TabClosingAnimation_Completed;
            animation.From = 1;
            animation.To = 0;
            animation.Duration = new Duration(TimeSpan.FromMilliseconds(TAB_CLOSING_ANIMATION_TIME));

            var ease = new CubicEase();
            ease.EasingMode = EasingMode.EaseOut;

            animation.EasingFunction = ease;
            root.BeginAnimation(OpacityProperty, animation);
        }
Exemplo n.º 21
0
        private void AnimateSpaceClosing()
        {
            MinWidth = 0;

            var animation = new DoubleAnimation();
            animation.Completed += SpaceClosingAnimation_Completed;
            animation.From = spaceWidth;
            animation.To = 0;
            animation.Duration = new Duration(TimeSpan.FromMilliseconds(SPACE_CLOSING_ANIMATION_TIME));

            var ease = new CubicEase();
            ease.EasingMode = EasingMode.EaseOut;

            animation.EasingFunction = ease;
            BeginAnimation(WidthProperty, animation);
        }
Exemplo n.º 22
0
        private static void OnTimerTick(RadCartesianChart chart)
        {
            CameraInfo cameraInfo = GetOrCreateCameraInfo(chart);

            double durationInSeconds = 1.5;
            Point targetOffset = new Point(100, -75);

            TimeSpan timeSpan = DateTime.Now - cameraInfo.initialAnimationDateTime;
            if (durationInSeconds < timeSpan.TotalSeconds)
            {
                cameraInfo.initialAnimationTimer.Stop();
                cameraInfo.initialAnimationTimer = null;
                return;
            }

            double progress = timeSpan.TotalSeconds / durationInSeconds;

            EasingFunctionBase ease = new BackEase { EasingMode = EasingMode.EaseIn };
            double easedProgress = ease.Ease(progress);
            double hOffset = easedProgress * targetOffset.X;

            ease = new CubicEase { EasingMode = EasingMode.EaseInOut };
            easedProgress = ease.Ease(progress);
            double vOffset = easedProgress * targetOffset.Y;

            MoveCamera(chart, new Point(hOffset, vOffset));
        }
Exemplo n.º 23
0
        private void ScaleCanvas(double relativeScale, Point center, bool animate = false)
        {
            var scale = _zoomableCanvas.Scale;

            if (scale <= 0) return;

            // minimum size = 80% of size where the whole image is visible
            // maximum size = Max(120% of full resolution of the image, 120% of original scale)

            MaxScaleRelativeToMaxSize = 1.2;
            relativeScale = relativeScale.Clamp(
                MinScaleRelativeToMinSize * _originalScale / scale,
                Math.Max(MaxScaleRelativeToMaxSize, MaxScaleRelativeToMaxSize * _originalScale) / scale);

            var targetScale = scale * relativeScale;

            var newLevel = Source.GetLevel(targetScale);
            var level = _spatialSource.CurrentLevel;
            if (newLevel != level)
            {
                // If it's zooming in, throttle
                if (newLevel > level)
                    ThrottleChangeLevel(newLevel);
                else
                    _spatialSource.CurrentLevel = newLevel;
            }

            if (targetScale != scale)
            {
                var position = (Vector)center;
                var targetOffset = (Point)((Vector)(_zoomableCanvas.Offset + position) * relativeScale - position);

                if (animate)
                {
                    if (relativeScale < 1)
                        relativeScale = 1 / relativeScale;
                    var duration = TimeSpan.FromMilliseconds(relativeScale * ScaleAnimationRelativeDuration);
                    var easing = new CubicEase();
                    _zoomableCanvas.BeginAnimation(ZoomableCanvas.ScaleProperty, new DoubleAnimation(targetScale, duration) { EasingFunction = easing }, HandoffBehavior.Compose);
                    _zoomableCanvas.BeginAnimation(ZoomableCanvas.OffsetProperty, new PointAnimation(targetOffset, duration) { EasingFunction = easing }, HandoffBehavior.Compose);
                }
                else
                {
                    _zoomableCanvas.Scale = targetScale;
                    _zoomableCanvas.Offset = targetOffset;
                }
            }
        }
Exemplo n.º 24
0
        public static PlotElementAnimation CreateAnimation(AnimationTransform transform, AnimationOrigin origin, Easing easing, bool indexDelay)
        {
            var sb = new Storyboard();
              var duration = new Duration(TimeSpan.FromSeconds(0.5));

              var style = new Style();
              style.TargetType = typeof(PlotElement);
              style.Setters.Add(new Setter(PlotElement.OpacityProperty, 0.0));

              if (transform == AnimationTransform.Scale)
            style.Setters.Add(new Setter(PlotElement.RenderTransformProperty, new ScaleTransform() { ScaleX = 0, ScaleY = 0 }));
              else if (transform == AnimationTransform.Rotation)
            style.Setters.Add(new Setter(PlotElement.RenderTransformProperty, new RotateTransform() { Angle = 180 }));

              var point = new Point(0.5, 0.5);
              switch (origin)
              {
            case AnimationOrigin.Bottom:
              point = new Point(0.5, 2);
              break;
            case AnimationOrigin.Top:
              point = new Point(0.5, -2);
              break;
            case AnimationOrigin.Left:
              point = new Point(-2, 0.5);
              break;
            case AnimationOrigin.Right:
              point = new Point(2, 0.5);
              break;
            case AnimationOrigin.TopLeft:
              point = new Point(2, -2);
              break;
            case AnimationOrigin.TopRight:
              point = new Point(-2, -2);
              break;
            case AnimationOrigin.BottomLeft:
              point = new Point(2, 2);
              break;
            case AnimationOrigin.BottomRight:
              point = new Point(-2, 2);
              break;
            default:
              break;
              }

              style.Setters.Add(new Setter(PlotElement.RenderTransformOriginProperty, point));

              var da = new DoubleAnimation() { From = 0, To = 1, Duration = duration };
              Storyboard.SetTargetProperty(da, new PropertyPath("Opacity"));
              sb.Children.Add(da);

              if (transform == AnimationTransform.Scale)
              {
            var da2 = new DoubleAnimation() { From = 0, To = 1, Duration = duration };
            Storyboard.SetTargetProperty(da2, new PropertyPath("(RenderTransform).ScaleX"));

            var da3 = new DoubleAnimation() { From = 0, To = 1, Duration = duration };
            Storyboard.SetTargetProperty(da3, new PropertyPath("(RenderTransform).ScaleY"));

            sb.Children.Add(da2);
            sb.Children.Add(da3);
              }
              else if (transform == AnimationTransform.Rotation)
              {
            var da2 = new DoubleAnimation() { To = 0, Duration = duration };
            Storyboard.SetTargetProperty(da2, new PropertyPath("(RenderTransform).Angle"));
            sb.Children.Add(da2);
              }

              if (indexDelay)
              {
            foreach (var anim in sb.Children)
              PlotElementAnimation.SetIndexDelay(anim, 0.5);
              }

            #if CLR40
              if (easing != Easing.None)
              {
            IEasingFunction ef = null;

            switch (easing)
            {
              case Easing.BackEase:
            ef = new BackEase(); break;
              case Easing.BounceEase:
            ef = new BounceEase(); break;
              case Easing.CircleEase:
            ef = new CircleEase(); break;
              case Easing.CubicEase:
            ef = new CubicEase(); break;
              case Easing.ElasticEase:
            ef = new ElasticEase(); break;
              case Easing.ExponentialEase:
            ef = new ExponentialEase(); break;
              case Easing.PowerEase:
            ef = new PowerEase(); break;
              case Easing.QuadraticEase:
            ef = new QuadraticEase(); break;
              case Easing.QuarticEase:
            ef = new QuarticEase(); break;
              case Easing.QuinticEase:
            ef = new QuinticEase(); break;
              case Easing.SineEase:
            ef = new SineEase(); break;

              default:
            break;
            }

            foreach (DoubleAnimation anim in sb.Children)
              anim.EasingFunction = ef;
              }
            #endif

              return new PlotElementAnimation() { Storyboard = sb, SymbolStyle = style };
        }
Exemplo n.º 25
0
        /// <summary>
        /// Ctor
        /// </summary>
        public PivotHeaderPanel()
        {
            // Define the storyboards
            var addFadeInAnim = new DoubleAnimation(0.0, 1.0, new Duration(TimeSpan.FromMilliseconds(ADD_FADE_IN_DURATION)));
            Storyboard.SetTargetProperty(addFadeInAnim, new PropertyPath(OpacityProperty));
            _addFadeInSb = new Storyboard();
            _addFadeInSb.Children.Add(addFadeInAnim);

            var updateFadeInAnim = new DoubleAnimation(0.0, 1.0, new Duration(TimeSpan.FromMilliseconds(UPDATE_FADE_IN_DURATION)));
            Storyboard.SetTargetProperty(updateFadeInAnim, new PropertyPath(OpacityProperty));
            _updateFadeInSb = new Storyboard();
            _updateFadeInSb.Children.Add(updateFadeInAnim);

            _updateFadeInSb.Completed += OnAnimationCompleted;

            _easingFn = new CubicEase
            {
                EasingMode = EasingMode.EaseOut
            };

            // Initialize the header collection
            _headerCollection = new List<UIElement>();
        }
Exemplo n.º 26
0
        private void ExpandAnimation(bool Value)
        {
            if (!Resizing)
            {
                Resizing = true;
                double X; double Y; double Width; double Height;

                if (Value)
                {
                    X = ExpandMargin;
                    Y = ExpandMargin;
                    Width = ParentDock.ActualWidth - ExpandMargin * 2;
                    Height = ParentDock.ActualHeight - ExpandMargin * 2;
                    ParentDock.GridTopMenu.Visibility = Visibility.Visible;
                }
                else
                {
                    X = OriginalX;
                    Y = OriginalY;
                    Width = OriginalWidth;
                    Height = OriginalHeight;
                }

                Storyboard ExpandAnimation = new Storyboard();
                DoubleAnimation AnimationX = new DoubleAnimation();
                DoubleAnimation AnimationY = new DoubleAnimation();
                DoubleAnimation AnimationWidth = new DoubleAnimation();
                DoubleAnimation AnimationHeight = new DoubleAnimation();
                DoubleAnimation AnimationOpacity = new DoubleAnimation();
                CubicEase AnimationEasing = new CubicEase();
                TimeSpan AnimationDuration = TimeSpan.FromMilliseconds(500);

                AnimationX.From = Canvas.GetLeft(this);
                AnimationX.To = X;
                AnimationX.Duration = AnimationDuration;
                AnimationX.EasingFunction = AnimationEasing;

                AnimationY.From = Canvas.GetTop(this);
                AnimationY.To = Y;
                AnimationY.Duration = AnimationDuration;
                AnimationY.EasingFunction = AnimationEasing;

                AnimationWidth.From = ActualWidth;
                AnimationWidth.To = Width;
                AnimationWidth.Duration = AnimationDuration;
                AnimationWidth.EasingFunction = AnimationEasing;

                AnimationHeight.From = ActualHeight;
                AnimationHeight.To = Height;
                AnimationHeight.Duration = AnimationDuration;
                AnimationHeight.EasingFunction = AnimationEasing;

                AnimationOpacity.From = ParentDock.GridTopMenu.Opacity;
                AnimationOpacity.To = Value ? 1 : 0;
                AnimationOpacity.Duration = AnimationDuration;
                AnimationOpacity.EasingFunction = AnimationEasing;

                ExpandAnimation.Children.Add(AnimationX);
                ExpandAnimation.Children.Add(AnimationY);
                ExpandAnimation.Children.Add(AnimationWidth);
                ExpandAnimation.Children.Add(AnimationHeight);
                ExpandAnimation.Children.Add(AnimationOpacity);

                Storyboard.SetTargetProperty(AnimationX, new PropertyPath(Canvas.LeftProperty));
                Storyboard.SetTargetProperty(AnimationY, new PropertyPath(Canvas.TopProperty));
                Storyboard.SetTargetProperty(AnimationWidth, new PropertyPath(WidthProperty));
                Storyboard.SetTargetProperty(AnimationHeight, new PropertyPath(HeightProperty));
                Storyboard.SetTargetProperty(AnimationOpacity, new PropertyPath(OpacityProperty));

                Storyboard.SetTarget(AnimationX, this);
                Storyboard.SetTarget(AnimationY, this);
                Storyboard.SetTarget(AnimationWidth, this);
                Storyboard.SetTarget(AnimationHeight, this);
                Storyboard.SetTarget(AnimationOpacity, ParentDock.GridTopMenu);

                ExpandAnimation.Completed += (o, i) =>
                {
                    this.Width = Width;
                    this.Height = Height;
                    Canvas.SetLeft(this, X);
                    Canvas.SetTop(this, Y);
                    ParentDock.GridTopMenu.Opacity = Value ? 1 : 0;
                    ParentDock.GridTopMenu.Visibility = Value ? Visibility.Visible : Visibility.Collapsed;

                    Resizing = false;
                };

                ExpandAnimation.FillBehavior = FillBehavior.Stop;
                ExpandAnimation.Begin();
            }
        }
Exemplo n.º 27
0
        private void AnimateTabPageClose()
        {
            var animation = new DoubleAnimation();
            animation.From = 1;
            animation.To = 0;
            animation.Completed += AnimateTabPageClose_Completed;
            animation.Duration = new Duration(TimeSpan.FromMilliseconds(TAB_PAGE_CLOSE_ANIMATION_TIME));

            var ease = new CubicEase();
            ease.EasingMode = EasingMode.EaseOut;

            animation.EasingFunction = ease;
            CurrentPage_CONTENT.BeginAnimation(OpacityProperty, animation);
        }
        protected void ShowAll()
        {
            if(m_isOpen)
            {
                return;
            }

            Visibility = Visibility.Visible;

            var mainGrid = m_currentWindow.MainGrid;
            var screenWidth = mainGrid.ActualWidth;

            var db = new DoubleAnimation((screenWidth / 2) - (m_mainContainer.ActualWidth / 2), TimeSpan.FromMilliseconds(m_animationTimeMilliseconds));
            db.From = (screenWidth / 2) + (m_mainContainer.ActualWidth / 2);

            var easingFunction = new CubicEase();
            easingFunction.EasingMode = EasingMode.EaseInOut;
            db.EasingFunction = easingFunction;

            m_mainContainer.RenderTransform = new TranslateTransform();
            m_mainContainer.RenderTransform.BeginAnimation(TranslateTransform.XProperty, db);

            m_isOpen = true;
            m_isAnyPOIOpen = true;
        }
Exemplo n.º 29
0
        public static DoubleAnimation CreateOpacityAnimation(DependencyObject obj, double from, double value, double milliseconds, double beginTime, EasingMode easing = EasingMode.EaseIn)
        {
            CubicEase ease = new CubicEase() { EasingMode = easing };
            DoubleAnimation animation = new DoubleAnimation();

            PropertyPath propPath = new PropertyPath("(UIElement.Opacity)");

            //PropertyPath propPath = new PropertyPath(UIElement.OpacityProperty);
            animation.BeginTime = TimeSpan.FromMilliseconds(beginTime);
            animation.Duration = new Duration(TimeSpan.FromMilliseconds(milliseconds));
            animation.From = from;
            animation.To = Convert.ToDouble(value);
            animation.FillBehavior = FillBehavior.HoldEnd;
            animation.EasingFunction = ease;

            Storyboard.SetTarget(animation, obj);
            Storyboard.SetTargetProperty(animation, propPath);


            return animation;
        }
Exemplo n.º 30
0
        public void SetPosition(int Row, int Column, bool Animation = false)
        {
            if (ParentDock != null)
            {
                LastRow = Row;
                LastColumn = Column;

                if (Animation)
                {
                    Storyboard PositionAnimation = new Storyboard();
                    DoubleAnimation AnimationX = new DoubleAnimation();
                    DoubleAnimation AnimationY = new DoubleAnimation();
                    CubicEase AnimationEasing = new CubicEase();
                    TimeSpan AnimationDuration = TimeSpan.FromMilliseconds(300);

                    AnimationX.From = Canvas.GetLeft(this);
                    AnimationX.To = ParentDock.GridWidth * Column;
                    AnimationX.Duration = AnimationDuration;
                    AnimationX.EasingFunction = AnimationEasing;

                    AnimationY.From = Canvas.GetTop(this);
                    AnimationY.To = ParentDock.GridHeight * Row;
                    AnimationY.Duration = AnimationDuration;
                    AnimationY.EasingFunction = AnimationEasing;

                    PositionAnimation.Children.Add(AnimationX);
                    PositionAnimation.Children.Add(AnimationY);

                    Storyboard.SetTargetProperty(AnimationX, new PropertyPath(Canvas.LeftProperty));
                    Storyboard.SetTargetProperty(AnimationY, new PropertyPath(Canvas.TopProperty));

                    Storyboard.SetTarget(AnimationX, this);
                    Storyboard.SetTarget(AnimationY, this);

                    PositionAnimation.Completed += PositionAnimation_Completed;
                    PositionAnimation.FillBehavior = FillBehavior.Stop;
                    PositionAnimation.Begin();
                }
                else
                {
                    Canvas.SetLeft(this, ParentDock.GridWidth * LastColumn);
                    Canvas.SetTop(this, ParentDock.GridHeight * LastRow);
                }
            }
        }