public static Storyboard GetCollapsingAnimation(HamburgerMenu target)
        {
            var storyboard = new Storyboard();

            storyboard.AutoReverse = false;
            var widthAnimation = new DoubleAnimationUsingKeyFrames();

            Storyboard.SetTarget(widthAnimation, target);
            Storyboard.SetTargetProperty(widthAnimation, new PropertyPath(FrameworkElement.WidthProperty));
            var widthEasing = new EasingDoubleKeyFrame(target.CompactPaneWidth, TimeSpan.FromMilliseconds(300));

            widthAnimation.KeyFrames.Add(widthEasing);
            storyboard.Children.Add(widthAnimation);
            var opacityAnimation = new DoubleAnimationUsingKeyFrames();

            Storyboard.SetTarget(opacityAnimation, target);
            Storyboard.SetTargetProperty(opacityAnimation, new PropertyPath(HamburgerMenu.TextOpacityProperty));
            var opacityEasingA = new EasingDoubleKeyFrame(1.0, TimeSpan.FromMilliseconds(0));
            var opacityEasingB = new EasingDoubleKeyFrame(0.0, TimeSpan.FromMilliseconds(200));

            opacityAnimation.KeyFrames.Add(opacityEasingA);
            opacityAnimation.KeyFrames.Add(opacityEasingB);
            storyboard.Children.Add(opacityAnimation);

            return(storyboard);
        }
Beispiel #2
0
    private static DoubleAnimationUsingKeyFrames CreateRotation(TimeSpan duration, double degreesFrom, double degreesMid, double degreesTo, PlaneProjection projection)
    {
        var _One = new EasingDoubleKeyFrame {
            KeyTime = new TimeSpan(0), Value = degreesFrom, EasingFunction = new CubicEase()
            {
                EasingMode = EasingMode.EaseIn
            }
        };
        var _Two = new EasingDoubleKeyFrame {
            KeyTime = new TimeSpan(duration.Ticks / 2), Value = degreesMid, EasingFunction = new CubicEase()
            {
                EasingMode = EasingMode.EaseIn
            }
        };
        var _Three = new EasingDoubleKeyFrame {
            KeyTime = new TimeSpan(duration.Ticks), Value = degreesTo, EasingFunction = new CubicEase()
            {
                EasingMode = EasingMode.EaseOut
            }
        };
         
        var _Animation = new DoubleAnimationUsingKeyFrames {
            BeginTime = new TimeSpan(0)
        };

        _Animation.KeyFrames.Add(_One);
        _Animation.KeyFrames.Add(_Two);
        _Animation.KeyFrames.Add(_Three);
        Storyboard.SetTargetProperty(_Animation, new PropertyPath("RotationY"));
        Storyboard.SetTarget(_Animation, projection);
        return(_Animation);
    }
Beispiel #3
0
        private DoubleAnimationUsingKeyFrames GetTimeline(double y)
        {
            DoubleAnimationUsingKeyFrames daTranslate = new DoubleAnimationUsingKeyFrames();

            Storyboard.SetTargetProperty(daTranslate, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)"));
            Storyboard.SetTarget(daTranslate, this);
            DiscreteDoubleKeyFrame keyframe2_1 = new DiscreteDoubleKeyFrame()
            {
                KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)),
                Value   = y + LINEHEGHT
            };
            DiscreteDoubleKeyFrame keyframe2_2 = new DiscreteDoubleKeyFrame()
            {
                KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.4)),
                Value   = y + LINEHEGHT
            };
            EasingDoubleKeyFrame keyframe2_3 = new EasingDoubleKeyFrame()
            {
                KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.8)),
                Value   = y
            };

            keyframe2_3.EasingFunction = new CubicEase()
            {
                EasingMode = EasingMode.EaseOut
            };
            daTranslate.KeyFrames.Add(keyframe2_1);
            daTranslate.KeyFrames.Add(keyframe2_2);
            daTranslate.KeyFrames.Add(keyframe2_3);
            return(daTranslate);
        }
        Storyboard GetCollapseControlStoryboard()
        {
            if (_storyCollapseControl == null)
            {
                _storyCollapseControl = new Storyboard();
                //sb.Duration = new Duration(TimeSpan.FromSeconds(5));

                DoubleAnimationUsingKeyFrames anim = new DoubleAnimationUsingKeyFrames();
                //anim.Duration = new Duration(TimeSpan.FromMilliseconds(400));

                EasingDoubleKeyFrame key = new EasingDoubleKeyFrame();
                key.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0));
                key.Value   = 145;
                anim.KeyFrames.Add(key);

                key         = new EasingDoubleKeyFrame();
                key.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(400));
                key.Value   = 76;
                anim.KeyFrames.Add(key);

                _storyCollapseControl.Children.Add(anim);

                Storyboard.SetTarget(anim, this);
                Storyboard.SetTargetProperty(anim, new PropertyPath(UserControl.HeightProperty));

                _storyCollapseControl.Completed += (a, b) => { UpdateView(false); };
            }

            return(_storyCollapseControl);
        }
Beispiel #5
0
        /// <summary>
        /// Fade in opacity of the window, let the progress ring appear and collapse the NoMouvieFound label when loading movies
        /// </summary>
        /// <param name="sender">Sender object</param>
        /// <param name="e">EventArgs</param>
        private void OnMoviesLoading(object sender, EventArgs e)
        {
            // We have to deal with the DispatcherHelper, otherwise we're having the classic cross-thread access exception
            DispatcherHelper.CheckBeginInvokeOnUI(() =>
            {
                ProgressRing.IsActive = true;

                #region Fade in opacity
                DoubleAnimationUsingKeyFrames opacityAnimation = new DoubleAnimationUsingKeyFrames();
                opacityAnimation.Duration               = new Duration(TimeSpan.FromSeconds(0.5));
                PowerEase opacityEasingFunction         = new PowerEase();
                opacityEasingFunction.EasingMode        = EasingMode.EaseInOut;
                EasingDoubleKeyFrame startOpacityEasing = new EasingDoubleKeyFrame(1, KeyTime.FromPercent(0));
                EasingDoubleKeyFrame endOpacityEasing   = new EasingDoubleKeyFrame(0.2, KeyTime.FromPercent(1.0),
                                                                                   opacityEasingFunction);
                opacityAnimation.KeyFrames.Add(startOpacityEasing);
                opacityAnimation.KeyFrames.Add(endOpacityEasing);
                ItemsList.BeginAnimation(OpacityProperty, opacityAnimation);
                #endregion

                if (NoMouvieFound.Visibility == Visibility.Visible)
                {
                    NoMouvieFound.Visibility = Visibility.Collapsed;
                }
            });
        }
        private Timeline CreateExpandIn(ITransitionEffectSubject effectSubject)
        {
            var scaleXAnimation = new DoubleAnimationUsingKeyFrames();
            var zeroFrame       = new DiscreteDoubleKeyFrame(0.0);
            var startFrame      = new DiscreteDoubleKeyFrame(.5, effectSubject.Offset + OffsetTime);
            var endFrame        = new EasingDoubleKeyFrame(1, effectSubject.Offset + OffsetTime + Duration)
            {
                EasingFunction = new SineEase()
            };

            scaleXAnimation.KeyFrames.Add(zeroFrame);
            scaleXAnimation.KeyFrames.Add(startFrame);
            scaleXAnimation.KeyFrames.Add(endFrame);

            Storyboard.SetTargetName(scaleXAnimation, effectSubject.ScaleTransformName);
            Storyboard.SetTargetProperty(scaleXAnimation, new PropertyPath(ScaleTransform.ScaleXProperty));

            var scaleYAnimation = scaleXAnimation.Clone();

            Storyboard.SetTargetName(scaleYAnimation, effectSubject.ScaleTransformName);
            Storyboard.SetTargetProperty(scaleYAnimation, new PropertyPath(ScaleTransform.ScaleYProperty));

            var parallelTimeline = new ParallelTimeline();

            parallelTimeline.Children.Add(scaleXAnimation);
            parallelTimeline.Children.Add(scaleYAnimation);

            return(parallelTimeline);
        }
        Storyboard GetExpandControlStoryboard()
        {
            if (_storyExpandControl == null)
            {
                _storyExpandControl = new Storyboard();

                DoubleAnimationUsingKeyFrames anim = new DoubleAnimationUsingKeyFrames();

                EasingDoubleKeyFrame key = new EasingDoubleKeyFrame();
                key.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0));
                key.Value   = 76;
                anim.KeyFrames.Add(key);

                key         = new EasingDoubleKeyFrame();
                key.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(400));
                key.Value   = 145;
                anim.KeyFrames.Add(key);

                _storyExpandControl.Children.Add(anim);

                Storyboard.SetTarget(anim, this);
                Storyboard.SetTargetProperty(anim, new PropertyPath(UserControl.HeightProperty));
            }

            return(_storyExpandControl);
        }
        public override Storyboard GetAnimationStoryboard(DependencyObject animationTarget)
        {
            var storyboard = new Storyboard {
                FillBehavior = FillBehavior.HoldEnd
            };
            var opacityKeyFrames    = new DoubleAnimationUsingKeyFrames();
            var visibilityKeyFrames = new ObjectAnimationUsingKeyFrames();

            var visibilityFrame = new DiscreteObjectKeyFrame()
            {
                KeyTime = KeyTime.FromTimeSpan(TimeSpan.Zero),
                Value   = Visibility.Visible
            };

            var opacityStartFrame = new EasingDoubleKeyFrame
            {
                KeyTime = KeyTime.FromTimeSpan(TimeSpan.Zero),
                Value   = 0,
            };

            var opacityEndFrame = new EasingDoubleKeyFrame
            {
                KeyTime = KeyTime.FromTimeSpan(Duration),
                Value   = 1,
            };

            visibilityKeyFrames.KeyFrames.Add(visibilityFrame);
            opacityKeyFrames.KeyFrames.Add(opacityStartFrame);
            opacityKeyFrames.KeyFrames.Add(opacityEndFrame);

            SetStoryboardBindings(animationTarget, visibilityKeyFrames, VISIBILITY_PROPERTY_PATH, storyboard);
            SetStoryboardBindings(animationTarget, opacityKeyFrames, OPACITY_PROPERTY_PATH, storyboard);

            return(storyboard);
        }
Beispiel #9
0
        /// <summary>
        /// y轴缩放动画
        /// </summary>
        /// <returns></returns>
        Timeline BuildScaleYAnimation()
        {
            DoubleAnimationUsingKeyFrames timeline = new DoubleAnimationUsingKeyFrames();

            Storyboard.SetTarget(timeline, this);
            Storyboard.SetTargetProperty(timeline, "(UIElement.RenderTransform).(CompositeTransform.ScaleY)");
            EasingDoubleKeyFrame frame3 = new EasingDoubleKeyFrame();

            frame3.KeyTime = (KeyTime)TimeSpan.FromSeconds(0.0);
            frame3.Value   = 1.0;
            EasingDoubleKeyFrame frame  = frame3;
            EasingDoubleKeyFrame frame4 = new EasingDoubleKeyFrame();

            frame4.KeyTime = _tilePressDuration;
            frame4.Value   = _scaleDepth;
            EasingDoubleKeyFrame frame2 = frame4;

            timeline.KeyFrames.Add(frame);
            timeline.KeyFrames.Add(frame2);
            CompositeTransform transform = new CompositeTransform();

            RenderTransform       = transform;
            RenderTransformOrigin = new Point(0.5, 0.5);
            return(timeline);
        }
Beispiel #10
0
        private void SlideBack()
        {
            _isAnimating = true;

            if (ZoomOnDrag)
            {
                ScaleTransform transform            = (ScaleTransform)_overlayElement.LayoutTransform;
                DoubleAnimationUsingKeyFrames anim  = new DoubleAnimationUsingKeyFrames();
                EasingDoubleKeyFrame          frame = new EasingDoubleKeyFrame(1, Settings.AnimationsEnabled ? KeyTime.FromTimeSpan(AnimationHelpers.AnimationDuration.TimeSpan) : KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(0)));
                frame.EasingFunction = AnimationHelpers.EasingFunction;
                anim.KeyFrames.Add(frame);
                transform.BeginAnimation(ScaleTransform.ScaleXProperty, anim);
                transform.BeginAnimation(ScaleTransform.ScaleYProperty, anim);
                _overlayElement.BeginAnimation(OpacityProperty, anim);
            }

            if (Settings.AnimationsEnabled)
            {
                DispatcherTimer timer = new DispatcherTimer();
                timer.Interval = TimeSpan.FromMilliseconds(10);
                timer.Tick    += timer_Tick;
                timer.Start();
            }
            else
            {
                AdornerLayer.GetAdornerLayer(PART_ItemsHost).Remove(_overlayElement);
                _originalElement.Opacity = 1;
                _overlayElement          = null;
                _isAnimating             = false;

                Mouse.Capture(null);
            }
        }
Beispiel #11
0
        private static DoubleKeyFrame CreateDoubleKeyFrmas(KeyFrames <double> Model)
        {
            DoubleKeyFrame frame = null;

            switch (Model.Type)
            {
            case KeyFramesType.Spline: frame = new SplineDoubleKeyFrame()
            {
                    KeySpline = Model.Spline
            }; break;

            case KeyFramesType.Linear: frame = new LinearDoubleKeyFrame(); break;

            case KeyFramesType.Easing: frame = new EasingDoubleKeyFrame()
            {
                    EasingFunction = Model.EasingFunction
            }; break;

            case KeyFramesType.Discrete: frame = new DiscreteDoubleKeyFrame(); break;

            default: break;
            }
            frame.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(Model.KeyTime));
            frame.Value   = Model.Value;
            return(frame);
        }
Beispiel #12
0
        private void DragStarted()
        {
            _isDragging = true;

            if (ZoomOnDrag)
            {
                _originalElement.Opacity = 0.6;
            }

            _overlayElement = new DragDropImage(_originalElement);

            if (ZoomOnDrag)
            {
                _overlayElement.TopOffset  -= 0.05 * _originalElement.ActualHeight;
                _overlayElement.LeftOffset -= 0.05 * _originalElement.ActualWidth;

                ScaleTransform transform = new ScaleTransform(1, 1);
                _overlayElement.LayoutTransform = transform;
                DoubleAnimationUsingKeyFrames anim  = new DoubleAnimationUsingKeyFrames();
                EasingDoubleKeyFrame          frame = new EasingDoubleKeyFrame(1.1, Settings.AnimationsEnabled ? KeyTime.FromTimeSpan(AnimationHelpers.AnimationDuration.TimeSpan) : KeyTime.FromTimeSpan(TimeSpan.Zero));
                frame.EasingFunction = AnimationHelpers.EasingFunction;
                anim.KeyFrames.Add(frame);
                transform.BeginAnimation(ScaleTransform.ScaleXProperty, anim);
                transform.BeginAnimation(ScaleTransform.ScaleYProperty, anim);
            }

            AdornerLayer layer = AdornerLayer.GetAdornerLayer(PART_ItemsHost);

            layer.Add(_overlayElement);

            RaiseDragStartEvent();
        }
Beispiel #13
0
        private void ReShow()
        {
            void DoAnimate(PropertyPath propertyPath, Double to, EventHandler completed = null)
            {
                DoubleAnimationUsingKeyFrames easing = new DoubleAnimationUsingKeyFrames {
                    Duration = TimeSpan.FromMilliseconds(300)
                };
                SineEase efb = new SineEase {
                    EasingMode = EasingMode.EaseOut
                };
                EasingDoubleKeyFrame edkf = new EasingDoubleKeyFrame(to)
                {
                    EasingFunction = efb
                };

                easing.KeyFrames.Add(edkf);
                Storyboard sb = new Storyboard();

                Storyboard.SetTarget(easing, mainShow);
                Storyboard.SetTargetProperty(easing, propertyPath);
                if (completed != null)
                {
                    sb.Completed += completed;
                }
                sb.Children.Add(easing);
                sb.Begin();
            }

            DoAnimate(new PropertyPath(Image.OpacityProperty), 0, (sender, o) =>
            {
                mainShow.Source = images.GetWordCloud(year, season);
                DoAnimate(new PropertyPath(Image.OpacityProperty), 1);
            });
        }
        protected override Storyboard CreateStoryboard()
        {
            var transform = Transform;

            Storyboard board    = new Storyboard();
            var        timeline = new DoubleAnimationUsingKeyFrames();

            Storyboard.SetTarget(timeline, transform);
            Storyboard.SetTargetProperty(timeline, "ScaleX");
            var frame = new EasingDoubleKeyFrame()
            {
                KeyTime = Duration, Value = ScaleX, EasingFunction = Easing
            };

            timeline.KeyFrames.Add(frame);
            board.Children.Add(timeline);

            timeline = new DoubleAnimationUsingKeyFrames();
            Storyboard.SetTarget(timeline, transform);
            Storyboard.SetTargetProperty(timeline, "ScaleY");
            frame = new EasingDoubleKeyFrame()
            {
                KeyTime = Duration, Value = ScaleY, EasingFunction = Easing
            };
            timeline.KeyFrames.Add(frame);
            board.Children.Add(timeline);

            return(board);
        }
        public Storyboard GetAnimation(DependencyObject target, double to, double from, Orientation orientation)
        {
            Storyboard story = new Storyboard();

            Storyboard.SetTargetProperty(story, new PropertyPath($"(TextBlock.RenderTransform).(TranslateTransform.{(orientation == Orientation.Horizontal ? "X" : "Y")})"));
            Storyboard.SetTarget(story, target);

            var doubleAnimation = new DoubleAnimationUsingKeyFrames();

            EasingDoubleKeyFrame fromFrame = new EasingDoubleKeyFrame(from);

            fromFrame.EasingFunction = new ExponentialEase()
            {
                EasingMode = EasingMode.EaseOut
            };
            fromFrame.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(0));

            EasingDoubleKeyFrame toFrame = new EasingDoubleKeyFrame(to);

            toFrame.EasingFunction = new ExponentialEase()
            {
                EasingMode = EasingMode.EaseOut
            };
            toFrame.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(200));

            doubleAnimation.KeyFrames.Add(fromFrame);
            doubleAnimation.KeyFrames.Add(toFrame);
            story.Children.Add(doubleAnimation);

            return(story);
        }
Beispiel #16
0
        private Storyboard GetAngleStoryboard()
        {
            _currentStoryboard = new Storyboard();
            DoubleAnimationUsingKeyFrames da = new DoubleAnimationUsingKeyFrames();
            var from = new EasingDoubleKeyFrame()
            {
                KeyTime = TimeSpan.FromSeconds(0),
                Value   = _ellapsedCircle.EndAngle
            };
            var to = new EasingDoubleKeyFrame()
            {
                KeyTime        = TimeSpan.FromMilliseconds(300),
                EasingFunction = new ExponentialEase()
                {
                    EasingMode = EasingMode.EaseOut
                },
                Value = _ellapsedCircle.EndAngle + (360 / this.GetDurationInSeconds())
            };

            da.FillBehavior = FillBehavior.HoldEnd;
            da.KeyFrames.Add(from);
            da.KeyFrames.Add(to);
            _currentStoryboard.Children.Add(da);
            da.EnableDependentAnimation = true;
            Storyboard.SetTarget(da, _ellapsedCircle);
            Storyboard.SetTargetProperty(da, "(RingSlice.EndAngle)");
            return(_currentStoryboard);
        }
Beispiel #17
0
        private async void Page_Loaded(object sender, RoutedEventArgs e)
        {
            width  = Btn_Load.ActualWidth / 2;
            height = Btn_Load.ActualHeight / 2;

            //radius of button
            radius = Math.Sqrt(Math.Pow(width, 2) + Math.Pow(height, 2)) + 6;

            //Center of btn
            c.X = width;
            c.Y = height;

            //動態改變storyboard的特性值
            EasingDoubleKeyFrame keyFrame = ((this.Resources["Bar_Volumn"]
                                              as Storyboard).Children[1]
                                             as DoubleAnimationUsingKeyFrames).KeyFrames[0]
                                            as EasingDoubleKeyFrame;

            keyFrame.Value = Slider_volume.ActualWidth * -1;

            EasingDoubleKeyFrame keyFrame2 = ((this.Resources["Bar_Volumn_mouse_leave"]
                                               as Storyboard).Children[1]
                                              as DoubleAnimationUsingKeyFrames).KeyFrames[0]
                                             as EasingDoubleKeyFrame;

            keyFrame2.Value = Slider_volume.ActualWidth * -1;

            //await main_Command.mediaVolume_ReadArduino();   //開始讀Arduino旋鈕
        }
Beispiel #18
0
        /// <summary>
        /// 使用透明度和显示状态的改变来进行动画隐藏该控件
        /// </summary>
        /// <param name="element">要执行动画的控件</param>
        /// <param name="duration">持续时间</param>
        /// <param name="completed">执行完成后的行为</param>
        public static void BeginHideWithOpacityAndVisibility(this DependencyObject element, TimeSpan duration, Action completed)
        {
            Storyboard sb = new Storyboard();
            DoubleAnimationUsingKeyFrames daukf = new DoubleAnimationUsingKeyFrames();

            daukf.SetValue(Storyboard.TargetProperty, element);
            daukf.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(FrameworkElement.Opacity)"));
            EasingDoubleKeyFrame f1 = new EasingDoubleKeyFrame(1, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)));
            EasingDoubleKeyFrame f2 = new EasingDoubleKeyFrame(0, KeyTime.FromTimeSpan(duration));

            daukf.KeyFrames.Add(f1);
            daukf.KeyFrames.Add(f2);
            ObjectAnimationUsingKeyFrames oaukf = new ObjectAnimationUsingKeyFrames();

            oaukf.SetValue(Storyboard.TargetProperty, element);
            oaukf.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(UIElement.Visibility)"));
            DiscreteObjectKeyFrame f3 = new DiscreteObjectKeyFrame(Visibility.Visible, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)));
            DiscreteObjectKeyFrame f4 = new DiscreteObjectKeyFrame(Visibility.Collapsed, KeyTime.FromTimeSpan(duration));

            oaukf.KeyFrames.Add(f3);
            oaukf.KeyFrames.Add(f4);
            sb.Children.Add(daukf);
            sb.Children.Add(oaukf);

            sb.Completed += (s, e) =>
            {
                if (completed != null)
                {
                    completed();
                }
            };
            sb.Begin();
        }
        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            this.livePreviewTapTarget         = (FrameworkElement)this.MediaViewer.FindNameInFooter("LivePreviewTapTarget");
            this.pointFocusBrackets           = (FrameworkElement)this.MediaViewer.FindNameInFooter("PointFocusBrackets");
            this.reviewImageSlideOff          = (Storyboard)this.MediaViewer.FindNameInFooter("ReviewImageSlideOff");
            this.pointFocusInProgress         = (Storyboard)this.MediaViewer.FindNameInFooter("PointFocusInProgress");
            this.pointFocusLocked             = (Storyboard)this.MediaViewer.FindNameInFooter("PointFocusLocked");
            this.autoFocusInProgress          = (Storyboard)this.MediaViewer.FindNameInFooter("AutoFocusInProgress");
            this.autoFocusLocked              = (Storyboard)this.MediaViewer.FindNameInFooter("AutoFocusLocked");
            this.rotateArrowButtonToPortrait  = (Storyboard)this.MediaViewer.FindNameInFooter("RotateArrowButtonToPortrait");
            this.rotateArrowButtonToLandscape = (Storyboard)this.MediaViewer.FindNameInFooter("RotateArrowButtonToLandscape");
            this.displayFlashOn       = (Storyboard)this.MediaViewer.FindNameInFooter("DisplayFlashOn");
            this.displayFlashOff      = (Storyboard)this.MediaViewer.FindNameInFooter("DisplayFlashOff");
            this.displayFlashAuto     = (Storyboard)this.MediaViewer.FindNameInFooter("DisplayFlashAuto");
            this.livePreviewTransform = (CompositeTransform)this.MediaViewer.FindNameInFooter("LivePreviewTransform");
            this.reviewImage          = (Image)this.MediaViewer.FindNameInFooter("ReviewImage");
            this.reviewImageSlideOffTranslateStart = (EasingDoubleKeyFrame)this.MediaViewer.FindNameInFooter("ReviewImageSlideOffTranslateStart");
            this.reviewImageSlideOffTranslateEnd   = (EasingDoubleKeyFrame)this.MediaViewer.FindNameInFooter("ReviewImageSlideOffTranslateEnd");
            this.leftArrowButtonPanel = (FrameworkElement)this.MediaViewer.FindNameInFooter("LeftArrowButtonCanvas");
            this.flashAutoText        = (FrameworkElement)this.MediaViewer.FindNameInFooter("FlashAuto");
            this.flashOnText          = (FrameworkElement)this.MediaViewer.FindNameInFooter("FlashOn");
            this.flashOffText         = (FrameworkElement)this.MediaViewer.FindNameInFooter("FlashOff");

            this.reviewImageSlideOff.Completed += OnReviewImageSlideOffCompleted;
            this.livePreviewTapTarget.Tap      += OnViewfinderTap;

            this.viewModel.Orientation = this.Orientation;
            ApplyRotation();

            // Ensure the page is fully loaded before handling orientation changes for this page
            this.OrientationChanged += new EventHandler <OrientationChangedEventArgs>(OnOrientationChanged);
        }
        private void Window_MouseDown(object sender, MouseButtonEventArgs e)
        {
            var dta = new DoubleAnimation(1, 0, TimeSpan.FromMilliseconds(300));

            dta.Completed += async delegate {
                await Task.Delay(500);

                var value = 0 - SystemParameters.PrimaryScreenHeight;
                var ti    = TimeSpan.FromSeconds(0.8);
                var da    = new DoubleAnimationUsingKeyFrames();
                var ed    = new EasingDoubleKeyFrame(value, ti);
                ed.EasingFunction = new QuinticEase()
                {
                    EasingMode = EasingMode.EaseInOut
                };
                da.KeyFrames.Add(ed);
                da.Completed += async delegate {
                    await Task.Delay(1000);

                    System.Windows.Application.Current.Shutdown();
                };
                BeginAnimation(TopProperty, da);
            };
            bn.BeginAnimation(OpacityProperty, dta);
        }
        Storyboard GetCollapseParentGridStoryboard()
        {
            if (_storyCollapseParentGrid == null)
            {
                _storyCollapseParentGrid = new Storyboard();

                DoubleAnimationUsingKeyFrames anim = new DoubleAnimationUsingKeyFrames();

                EasingDoubleKeyFrame key = new EasingDoubleKeyFrame();
                key.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0));
                key.Value   = 290;
                anim.KeyFrames.Add(key);

                key         = new EasingDoubleKeyFrame();
                key.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(400));
                key.Value   = 220;;
                anim.KeyFrames.Add(key);

                _storyCollapseParentGrid.Children.Add(anim);

                Storyboard.SetTarget(anim, this);
                Storyboard.SetTargetProperty(anim, new PropertyPath(SavedCommandsControl.GridHeightProperty));
            }

            return(_storyCollapseParentGrid);
        }
        /// <summary>
        /// Gets the template parts and sets event handlers.
        /// </summary>
        protected override void OnApplyTemplate()
        {
            if (_expanderPanel != null)
            {
                _expanderPanel.Tapped -= OnExpanderPanelTap;
            }

            base.OnApplyTemplate();

            _expanderPanel            = base.GetTemplateChild(ExpanderPanel) as Grid;
            _expandedToCollapsedFrame = base.GetTemplateChild(ExpandedToCollapsedKeyFrame) as EasingDoubleKeyFrame;
            _collapsedToExpandedFrame = base.GetTemplateChild(CollapsedToExpandedKeyFrame) as EasingDoubleKeyFrame;
            _itemsCanvas = base.GetTemplateChild("ItemsCanvas") as Canvas;

            VisualState expandedState = (base.GetTemplateChild(ExpandedState) as VisualState);

            if (expandedState != null)
            {
                _expandedStateAnimation = expandedState.Storyboard.Children[0] as DoubleAnimation;
            }

            _presenter = base.GetTemplateChild(Presenter) as ItemsPresenter;
            if (_presenter != null)
            {
                _presenter.SizeChanged += OnPresenterSizeChanged;
            }

            if (_expanderPanel != null)
            {
                _expanderPanel.Tapped += OnExpanderPanelTap;
            }
            UpdateVisualState(false);
            _useTransitions = true;
        }
Beispiel #23
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            ContentPresenter = (ContentControl)GetTemplateChild("ContentPresenter");
            planeProjection  = (PlaneProjection)GetTemplateChild("Rotator");
            LayoutRoot       = (FrameworkElement)GetTemplateChild("LayoutRoot");

            Animation            = (Storyboard)GetTemplateChild("Animation");
            Animation.Completed += Animation_Completed;
            rotationKeyFrame     = (EasingDoubleKeyFrame)GetTemplateChild("rotationKeyFrame");
            offestZKeyFrame      = (EasingDoubleKeyFrame)GetTemplateChild("offestZKeyFrame");
            scaleXKeyFrame       = (EasingDoubleKeyFrame)GetTemplateChild("scaleXKeyFrame");
            scaleYKeyFrame       = (EasingDoubleKeyFrame)GetTemplateChild("scaleYKeyFrame");
            scaleTransform       = (ScaleTransform)GetTemplateChild("scaleTransform");

            planeProjection.RotationY    = yRotation;
            planeProjection.LocalOffsetZ = zOffset;
            if (ContentPresenter != null)
            {
                ContentPresenter.Tapped += ContentPresenter_Tapped;
            }

            if (Animation != null)
            {
                xAnimation = new DoubleAnimation();
                Animation.Children.Add(xAnimation);

                Storyboard.SetTarget(xAnimation, this);
                Storyboard.SetTargetProperty(xAnimation, "(Canvas.Left)");
            }
        }
Beispiel #24
0
        private void Animate(double begin, double end)
        {
            var da = new DoubleAnimationUsingKeyFrames();

            da.Completed += (s, e) =>
            {
                foreach (object ob in Items)
                {
                    (ob as PanoramaItem).RenderTransform = new TranslateTransform(RenderTranslateTransform(ob).X, RenderTranslateTransform(ob).Y);
                }
            };

            var e0 = new EasingDoubleKeyFrame(begin, KeyTime.FromTimeSpan(TimeSpan.Zero))
            {
                EasingFunction = new BackEase {
                    EasingMode = EasingMode.EaseOut, Amplitude = 0.5
                }
            };

            da.KeyFrames.Add(e0);

            var e1 = new EasingDoubleKeyFrame(end, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.6)))
            {
                EasingFunction = new BackEase {
                    EasingMode = EasingMode.EaseOut, Amplitude = 0.5
                }
            };

            da.KeyFrames.Add(e1);

            foreach (object ob in Items)
            {
                RenderTranslateTransform(ob).BeginAnimation(TranslateTransform.XProperty, da, HandoffBehavior.SnapshotAndReplace);
            }
        }
Beispiel #25
0
        /// <summary>
        /// Fade out opacity of the window, let the progress ring disappear and set to visible the NoMouvieFound label when movies are loaded
        /// </summary>
        /// <param name="sender">Sender object</param>
        /// <param name="e">EventArgs</param>
        private void OnMoviesLoaded(object sender, NumberOfLoadedMoviesEventArgs e)
        {
            // We have to deal with the DispatcherHelper, otherwise we're having the classic cross-thread access exception
            DispatcherHelper.CheckBeginInvokeOnUI(() =>
            {
                // We exclude exceptions like TaskCancelled when getting back results
                if ((e.NumberOfMovies == 0 && !e.IsExceptionThrown) || (e.NumberOfMovies != 0 && !e.IsExceptionThrown))
                {
                    ProgressRing.IsActive = false;

                    #region Fade out opacity
                    DoubleAnimationUsingKeyFrames opacityAnimation = new DoubleAnimationUsingKeyFrames();
                    opacityAnimation.Duration               = new Duration(TimeSpan.FromSeconds(0.5));
                    PowerEase opacityEasingFunction         = new PowerEase();
                    opacityEasingFunction.EasingMode        = EasingMode.EaseInOut;
                    EasingDoubleKeyFrame startOpacityEasing = new EasingDoubleKeyFrame(0.2, KeyTime.FromPercent(0));
                    EasingDoubleKeyFrame endOpacityEasing   = new EasingDoubleKeyFrame(1, KeyTime.FromPercent(1.0),
                                                                                       opacityEasingFunction);
                    opacityAnimation.KeyFrames.Add(startOpacityEasing);
                    opacityAnimation.KeyFrames.Add(endOpacityEasing);
                    ItemsList.BeginAnimation(OpacityProperty, opacityAnimation);
                    #endregion
                }

                var vm = DataContext as MoviesViewModel;
                if (vm != null)
                {
                    // If we searched movies and there's no result, display the NoMovieFound label (we exclude exceptions like TaskCancelled when getting back results)
                    if (!vm.Movies.Any() && e.NumberOfMovies == 0 && !e.IsExceptionThrown)
                    {
                        NoMouvieFound.Visibility = Visibility.Visible;
                    }
                }
            });
        }
Beispiel #26
0
 private void LargeMsg3()
 {
     System.Windows.Application.Current.Dispatcher.Invoke(new Action(() =>
     {
         if (txtMsg3.Text.Length > 0)
         {
             cancasNoticeMsg.Visibility = System.Windows.Visibility.Visible;
             sbNoticeMsg.Stop();
             sbNoticeMsg.Children.Clear();
             //消息的长度
             double msgWidth = MeasureTextWidth(txtMsg3.Text, txtMsg3.FontSize, txtMsg3.FontFamily.ToString());
             //滚动的时间
             double runTime = 11 * (880 > msgWidth ? 880 : msgWidth) / 880;
             txtMsg3.Margin = new Thickness(txtMsg3.Margin.Left, txtMsg3.Margin.Top, txtMsg3.Margin.Right > msgWidth ? txtMsg3.Margin.Right : -msgWidth, txtMsg3.Margin.Bottom);
             DoubleAnimationUsingKeyFrames doubleAnimationUsingKeyFrames = new DoubleAnimationUsingKeyFrames();
             sbNoticeMsg.Children.Add(doubleAnimationUsingKeyFrames);
             Storyboard.SetTarget(doubleAnimationUsingKeyFrames, txtMsg3);
             Storyboard.SetTargetProperty(doubleAnimationUsingKeyFrames, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(TranslateTransform.X)"));
             EasingDoubleKeyFrame keyFrame1 = new EasingDoubleKeyFrame(880, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)));
             EasingDoubleKeyFrame keyFrame2 = new EasingDoubleKeyFrame(-(this.txtMsg3.ActualWidth), KeyTime.FromTimeSpan(TimeSpan.FromSeconds(runTime)));
             doubleAnimationUsingKeyFrames.KeyFrames.Add(keyFrame1);
             doubleAnimationUsingKeyFrames.KeyFrames.Add(keyFrame2);
             sbNoticeMsg.RepeatBehavior = RepeatBehavior.Forever;
             sbNoticeMsg.Begin();
         }
         else
         {
             cancasNoticeMsg.Visibility = System.Windows.Visibility.Hidden;
         }
     }));
 }
Beispiel #27
0
        private Storyboard GetAnimation(DependencyObject target, double to, double from)
        {
            Storyboard story = new Storyboard();

            Storyboard.SetTargetProperty(story, new PropertyPath("(UIElement.RenderTransform).(TranslateTransform.X)"));
            Storyboard.SetTarget(story, target);

            var doubleAnimation = new DoubleAnimationUsingKeyFrames();

            EasingDoubleKeyFrame fromFrame = new EasingDoubleKeyFrame(from);

            fromFrame.EasingFunction = new ExponentialEase()
            {
                EasingMode = EasingMode.EaseOut
            };
            fromFrame.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(0));

            EasingDoubleKeyFrame toFrame = new EasingDoubleKeyFrame(to);

            toFrame.EasingFunction = new ExponentialEase()
            {
                EasingMode = EasingMode.EaseOut
            };
            toFrame.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(200));

            doubleAnimation.KeyFrames.Add(fromFrame);
            doubleAnimation.KeyFrames.Add(toFrame);
            story.Children.Add(doubleAnimation);

            return(story);
        }
Beispiel #28
0
        public static Timeline GetTranslateXAnimation(UIElement target, TimeSpan timeSpan, double to, double?fromValue = null)
        {
            var animation = new DoubleAnimationUsingKeyFrames();

            if (fromValue != null)
            {
                var beginFrame = new EasingDoubleKeyFrame((double)fromValue, KeyTime.FromTimeSpan(TimeSpan.Zero));
                animation.KeyFrames.Add(beginFrame);
            }
            var edkf = new EasingDoubleKeyFrame(to, KeyTime.FromTimeSpan(timeSpan), new PowerEase {
                EasingMode = EasingMode.EaseOut
            });

            animation.KeyFrames.Add(edkf);

            var hasGroup = target.RenderTransform is TransformGroup;

            if (!hasGroup)
            {
                var transformGroup = new TransformGroup();
                transformGroup.Children.Add(new ScaleTransform());
                transformGroup.Children.Add(new SkewTransform());
                transformGroup.Children.Add(new RotateTransform());
                transformGroup.Children.Add(new TranslateTransform());
                target.RenderTransform = transformGroup;
            }

            // 给dakf设置目标和属性
            Storyboard.SetTarget(animation, target);
            Storyboard.SetTargetProperty(animation, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)"));

            return(animation);
        }
        public horizon()
        {
            InitializeComponent();
            this.DataContext = this;
            sb       = Grd.Resources["rotate"] as Storyboard;
            keyFrame = (sb.Children[0]
                        as DoubleAnimationUsingKeyFrames).KeyFrames[0]
                       as EasingDoubleKeyFrame;
            keyFrame1 = (sb.Children[1]
                         as DoubleAnimationUsingKeyFrames).KeyFrames[0]
                        as EasingDoubleKeyFrame;
            keyFrame2 = (sb.Children[2]
                         as DoubleAnimationUsingKeyFrames).KeyFrames[0]
                        as EasingDoubleKeyFrame;

            keyFrame.Value  = 0;
            keyFrame1.Value = 0;
            keyFrame2.Value = 0;


            sbtranslate       = Grd.Resources["translate"] as Storyboard;
            keyFrametranslate = (sbtranslate.Children[0]
                                 as DoubleAnimationUsingKeyFrames).KeyFrames[0]
                                as EasingDoubleKeyFrame;
        }
Beispiel #30
0
        protected override void Init()
        {
            SetBaseView();

            dau = new DoubleAnimationUsingKeyFrames();

            var k2 = new EasingDoubleKeyFrame(0, TimeSpan.FromMilliseconds(AniTime(0.5)));
            var k3 = new EasingDoubleKeyFrame(1, TimeSpan.FromMilliseconds(AniTime(1)));

            dau.KeyFrames.Add(k2);
            dau.KeyFrames.Add(k3);
            if (FlashCount < 0)
            {
                dau.RepeatBehavior = RepeatBehavior.Forever;
            }
            else
            {
                dau.RepeatBehavior = new RepeatBehavior(FlashCount);
            }
            Story = (Storyboard)Story.CloneCurrentValue();
            Story.Children.Add(dau);

            Storyboard.SetTarget(dau, Element);
            Storyboard.SetTargetProperty(dau, new PropertyPath(UIElement.OpacityProperty));
            Story.Completed -= Story_Completed;
            Story.Completed += Story_Completed;
        }