예제 #1
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);
        }
예제 #2
0
        /// <summary>
        /// 获取模板控件
        /// </summary>
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            _valuePanel = GetTemplateChild("ValuePanel") as Path;
            _backPanel  = GetTemplateChild("BackPanel") as Path;
            if (_valuePanel is null)
            {
                _valuePanel = GetTemplateChild("ValuePanel") as Rectangle;
                _backPanel  = GetTemplateChild("BackPanel") as Rectangle;

                _e1frame1 = GetTemplateChild("E1Frame1") as SplineDoubleKeyFrame;
                _e1frame2 = GetTemplateChild("E1Frame2") as DiscreteDoubleKeyFrame;
                _e1frame3 = GetTemplateChild("E1Frame3") as SplineDoubleKeyFrame;

                _e2frame1 = GetTemplateChild("E2Frame1") as SplineDoubleKeyFrame;
                _e2frame2 = GetTemplateChild("E2Frame2") as DiscreteDoubleKeyFrame;
                _e2frame3 = GetTemplateChild("E2Frame3") as SplineDoubleKeyFrame;

                _e3frame1 = GetTemplateChild("E3Frame1") as SplineDoubleKeyFrame;
                _e3frame2 = GetTemplateChild("E3Frame2") as DiscreteDoubleKeyFrame;
                _e3frame3 = GetTemplateChild("E3Frame3") as SplineDoubleKeyFrame;

                _e4frame1 = GetTemplateChild("E4Frame1") as SplineDoubleKeyFrame;
                _e4frame2 = GetTemplateChild("E4Frame2") as DiscreteDoubleKeyFrame;
                _e4frame3 = GetTemplateChild("E4Frame3") as SplineDoubleKeyFrame;

                _e5frame1 = GetTemplateChild("E5Frame1") as SplineDoubleKeyFrame;
                _e5frame2 = GetTemplateChild("E5Frame2") as DiscreteDoubleKeyFrame;
                _e5frame3 = GetTemplateChild("E5Frame3") as SplineDoubleKeyFrame;

                _panelmove = GetTemplateChild("PanelMove") as DoubleAnimation;
            }
        }
예제 #3
0
        /// <summary>
        /// Applies the mouse down behavior.
        /// </summary>
        /// <param name="selectedIndex">The selected item index.</param>
        /// <param name="element">The element of concern.</param>
        public virtual void ApplyMouseDownBehavior(int selectedIndex, CoolMenuItem element)
        {
            if (!BounceEnabled)
            {
                return;
            }

            m_mouseCaptured = element.CaptureMouse();

            var da = new DoubleAnimationUsingKeyFrames();
            var k1 = new SplineDoubleKeyFrame
            {
                KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(100)),
                Value   = this.MaxItemHeight * 0.30
            };

            da.KeyFrames.Add(k1);

            Storyboard sb = new Storyboard();

            Storyboard.SetTarget(da, element);
            Storyboard.SetTargetProperty(da,
                                         new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(TranslateTransform.Y)"));
            sb.Children.Add(da);
            sb.Begin();
        }
예제 #4
0
        private void InitAnimation()
        {
            _row = new DoubleAnimationUsingKeyFrames();
            SplineDoubleKeyFrame _rowbegin = new SplineDoubleKeyFrame
            {
                KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(0)),
                Value   = 0
            };

            _rowover = new SplineDoubleKeyFrame
            {
                KeyTime   = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(500)),
                KeySpline = new KeySpline {
                    ControlPoint1 = new Point(0, 0.4), ControlPoint2 = new Point(1, 1)
                },
            };
            _row.KeyFrames.Add(_rowbegin);
            _row.KeyFrames.Add(_rowover);
            _rowani = new Storyboard
            {
                FillBehavior = FillBehavior.HoldEnd
            };

            Storyboard.SetTarget(_row, this);
            Storyboard.SetTargetProperty(_row, new PropertyPath(FluxDataProperty));

            _rowani.Children.Add(_row);
        }
예제 #5
0
        public Storyboard FadeInElement(UIElement element, double duration, double To, bool begin)
        {
            var storyboard = new Storyboard();
            SplineDoubleKeyFrame keyFrame1 = new SplineDoubleKeyFrame();

            keyFrame1.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0));
            keyFrame1.Value   = 0;
            SplineDoubleKeyFrame keyFrame2 = new SplineDoubleKeyFrame();

            keyFrame2.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(duration));
            keyFrame2.Value   = To;
            var visibility = new DoubleAnimationUsingKeyFrames();

            visibility.KeyFrames.Add(keyFrame1);
            visibility.KeyFrames.Add(keyFrame2);

            Storyboard.SetTargetProperty(visibility, new PropertyPath("(UIElement.Opacity)"));
            storyboard.Children.Add(visibility);
            Storyboard.SetTarget(storyboard, element);

            if (begin)
            {
                storyboard.Begin();
            }

            return(storyboard);
        }
예제 #6
0
        private void RotateToAngle(double pAngle)
        {
            SplineDoubleKeyFrame rotateKeyFrame = (_target.FindName("RotateKeyFrame") as SplineDoubleKeyFrame);

            rotateKeyFrame.Value = pAngle;
            _rotateToAngleStoryboard.Begin();
        }
예제 #7
0
        private void InitMiniable()
        {
            _vScrollPanel             = GetTemplateChild("VerticalScrollBarPanel") as Grid;
            _vScrollPanel.MouseEnter += _ScrollPanel_MouseEnter;
            _vScrollPanel.MouseLeave += _ScrollPanel_MouseLeave;
            _hScrollPanel             = GetTemplateChild("HorizontalScrollBarPanel") as Grid;
            _hScrollPanel.MouseEnter += _ScrollPanel_MouseEnter;
            _hScrollPanel.MouseLeave += _ScrollPanel_MouseLeave;
            _verticalTranslate        = GetTemplateChild("VerticalTranslate") as TranslateTransform;
            _horizontalTranslate      = GetTemplateChild("HorizontalTranslate") as TranslateTransform;

            _fadeinanimation = new DoubleAnimationUsingKeyFrames {
                BeginTime = TimeSpan.FromMilliseconds(500),
            };
            _keyin1 = new SplineDoubleKeyFrame {
                KeySpline = new KeySpline(0, 0.4, 0.6, 1),
                KeyTime   = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(320)),
                Value     = ScrollbarThickness - ScrollbarMiniThickness,
            };
            _fadeinanimation.KeyFrames.Add(_keyin1);

            _fadeoutanimation = new DoubleAnimationUsingKeyFrames();
            _keyout1          = new SplineDoubleKeyFrame {
                KeySpline = new KeySpline(0, 0.4, 0.6, 1),
                KeyTime   = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(320)),
                Value     = 0,
            };
            _fadeoutanimation.KeyFrames.Add(_keyout1);

            ScrollBarMini();
        }
예제 #8
0
        private void SetIsExpand(bool value)
        {
            if (this.OriginTextBlock.ActualHeight != double.NaN)
            {
                if (this.OriginTextBlock.ActualHeight > this.DefaultHeight)
                {
                    if (value)
                    {
                        DoubleAnimation animation = new DoubleAnimation
                        {
                            Duration = new Duration(TimeSpan.FromSeconds(0.2)),
                            From     = this.DefaultHeight,
                            To       = this.OriginTextBlock.ActualHeight,
                            EnableDependentAnimation = true
                        };

                        Storyboard.SetTarget(animation, this.Grid);
                        Storyboard.SetTargetProperty(animation, "(UIElement.Height)");

                        Storyboard storyBoard = new Storyboard();
                        storyBoard.Children.Add(animation);
                        storyBoard.Begin();

                        this.OriginTextBlock.Opacity = 1;
                        this.TrimTextBlock.Opacity   = 0;

                        return;
                    }
                    else
                    {
                        DoubleAnimation animation = new DoubleAnimation
                        {
                            Duration = new Duration(TimeSpan.FromSeconds(0.2)),
                            From     = this.OriginTextBlock.ActualHeight,
                            To       = this.DefaultHeight,
                            EnableDependentAnimation = true
                        };
                        animation.EasingFunction = new CubicEase()
                        {
                            EasingMode = EasingMode.EaseOut
                        };

                        var hiuhi = new SplineDoubleKeyFrame();
                        Storyboard.SetTarget(animation, this.Grid);
                        Storyboard.SetTargetProperty(animation, "(UIElement.Height)");

                        Storyboard storyBoard = new Storyboard();
                        storyBoard.Children.Add(animation);
                        storyBoard.Begin();

                        this.OriginTextBlock.Opacity = 0;
                        this.TrimTextBlock.Opacity   = 1;

                        return;
                    }
                }
            }

            this.Grid.Height = this.DefaultHeight;
        }
예제 #9
0
        private static SplineDoubleKeyFrame CreateDoubleAnimation(ref Storyboard sb,
                                                                  TranslateTransform translation, PropertyPath property)
        {
            DoubleAnimationUsingKeyFrames da = new DoubleAnimationUsingKeyFrames();

            da.SetValue(NameProperty, string.Concat("da_", property));

            SplineDoubleKeyFrame sdkf = new SplineDoubleKeyFrame();

            sdkf.SetValue(NameProperty, string.Concat("sdkf_", property));

            sdkf.Value   = 0;
            sdkf.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.25));

            //define the KeySpline
            KeySpline ksX = new KeySpline();

            ksX.ControlPoint1 = new Point(1.0, 0.25);
            ksX.ControlPoint2 = new Point(0.75, 1.0);
            sdkf.KeySpline    = ksX;

            //add the SplineDoubleKeyFrame to the DoubleAnimationUsingKeyFrames
            da.KeyFrames.Add(sdkf);

            //define which TranslateTransform property will be targeted by the DoubleAnimation
            Storyboard.SetTarget(da, translation);
            Storyboard.SetTargetProperty(da, property);
            sb.Children.Add(da);
            return(sdkf);
        }
예제 #10
0
        private void InitAutoHide()
        {
            _vScrollBar = GetTemplateChild("PART_VerticalScrollBar") as ScrollBar;
            _hScrollBar = GetTemplateChild("PART_HorizontalScrollBar") as ScrollBar;
            MouseEnter += YT_ScrollViewer_MouseEnter;
            MouseLeave += YT_ScrollViewer_MouseLeave;

            _hideanimation = new DoubleAnimationUsingKeyFrames();
            _keyhide1      = new SplineDoubleKeyFrame {
                KeySpline = new KeySpline(0, 0.4, 0.6, 1),
                KeyTime   = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(320)),
                Value     = 0,
            };
            _hideanimation.KeyFrames.Add(_keyhide1);

            _showanimation = new DoubleAnimationUsingKeyFrames();
            _keyshow1      = new SplineDoubleKeyFrame {
                KeySpline = new KeySpline(0, 0.4, 0.6, 1),
                KeyTime   = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(320)),
                Value     = 1,
            };
            _showanimation.KeyFrames.Add(_keyshow1);

            HideScrollbar();
        }
예제 #11
0
        private static void TranslateItem(FrameworkElement f, double yDelta, int milliseconds)
        {
            Storyboard           sb = (Storyboard)f.GetValue(s_dragPreviewStoryboardProperty);
            SplineDoubleKeyFrame k;

            if (sb == null)
            {
                TranslateTransform            t;
                DoubleAnimationUsingKeyFrames d;

                t = new TranslateTransform();
                f.RenderTransform = t;

                sb          = new Storyboard();
                k           = new SplineDoubleKeyFrame();
                k.KeySpline = new KeySpline(0, 0.7, 0.7, 1);
                d           = new DoubleAnimationUsingKeyFrames();
                d.KeyFrames.Add(k);

                Storyboard.SetTarget(d, f);
                Storyboard.SetTargetProperty(d, new PropertyPath("(RenderTransform).(TranslateTransform.Y)"));
                sb.Children.Add(d);

                f.SetValue(s_dragPreviewStoryboardProperty, sb);
            }
            else
            {
                k = (sb.Children[0] as DoubleAnimationUsingKeyFrames).KeyFrames[0] as SplineDoubleKeyFrame;
            }

            k.Value   = yDelta;
            k.KeyTime = TimeSpan.FromMilliseconds(milliseconds);
            f.BeginStoryboard(sb);
        }
예제 #12
0
        private void beginBezier(FrameworkElement target, double value, KeyTime keytime)
        {
            if (target != null)
            {
                Point p1 = new Point(Math.Round(Point1.X / Length, 3), Math.Round(Point1.Y / Length, 3));
                Point p2 = new Point(Math.Round(Point2.X / Length, 3), Math.Round(Point2.Y / Length, 3));
                SplineDoubleKeyFrame sdkf = new SplineDoubleKeyFrame(value, keytime);
                try
                {
                    sdkf.KeySpline = new KeySpline(p1, p2);
                }catch (Exception ex)
                {
                    MessageBox.Show("Error data : " + ex.Message, "Exception");
                    return;
                }

                DoubleAnimationUsingKeyFrames daukf = new DoubleAnimationUsingKeyFrames();
                daukf.KeyFrames.Add(sdkf);

                var board = new Storyboard();
                Storyboard.SetTarget(daukf, target);
                Storyboard.SetTargetProperty(daukf, new PropertyPath("(FrameworkElement.RenderTransform).(TranslateTransform.X)"));
                board.Children.Add(daukf);
                board.Begin();
            }
        }
예제 #13
0
        private Storyboard ResizeBox(float f, int num)
        {
            Storyboard sb = new Storyboard();
            DoubleAnimationUsingKeyFrames dauk1 = new DoubleAnimationUsingKeyFrames();

            dauk1.BeginTime = new TimeSpan(0);
            dauk1.SetValue(Storyboard.TargetNameProperty, "Box" + num.ToString());
            dauk1.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("RenderTransform.ScaleX"));
            SplineDoubleKeyFrame sdkf1 = new SplineDoubleKeyFrame();

            sdkf1.KeyTime = TimeSpan.FromSeconds(0.5);
            sdkf1.Value   = f;
            dauk1.KeyFrames.Add(sdkf1);
            sb.Children.Add(dauk1);

            DoubleAnimationUsingKeyFrames dauk2 = new DoubleAnimationUsingKeyFrames();

            dauk2.BeginTime = new TimeSpan(0);
            dauk2.SetValue(Storyboard.TargetNameProperty, "Box" + num.ToString());
            dauk2.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("RenderTransform.ScaleY"));
            SplineDoubleKeyFrame sdkf2 = new SplineDoubleKeyFrame();

            sdkf2.KeyTime = TimeSpan.FromSeconds(0.5);
            sdkf2.Value   = f;
            dauk2.KeyFrames.Add(sdkf2);
            sb.Children.Add(dauk2);
            return(sb);
        }
예제 #14
0
        /// <summary>
        /// 初始化动画
        /// </summary>
        private void InitAnimate()
        {
            //弹出动画
            _toNormal  = new DoubleAnimationUsingKeyFrames();
            _normalkey = new SplineDoubleKeyFrame {
                KeySpline = new KeySpline(0, 0.5, 0.5, 1),
                Value     = 0,
            };
            _toNormal.KeyFrames.Add(_normalkey);

            _showstory = new Storyboard();
            Storyboard.SetTargetName(_toNormal, "PART_MaskTranslate");
            _showstory.Children.Add(_toNormal);

            //隐藏动画
            _toHide  = new DoubleAnimationUsingKeyFrames();
            _hidekey = new SplineDoubleKeyFrame {
                KeySpline = new KeySpline(0, 0.5, 0.5, 1),
            };
            _toHide.KeyFrames.Add(_hidekey);

            _hidestory = new Storyboard();
            Storyboard.SetTargetName(_toHide, "PART_MaskTranslate");
            _hidestory.Children.Add(_toHide);
            _hidestory.Completed += _toHide_Completed;

            SetDelay(AnimationDelay);
        }
예제 #15
0
 public override void OnApplyTemplate()
 {
     base.OnApplyTemplate();
     this.root = (Grid)base.GetTemplateChild("root");
     if (this.root == null)
     {
         return;
     }
     this.PART_Header      = (ContentPresenter)base.GetTemplateChild("PART_Header");
     this.PART_Content     = (ContentPresenter)base.GetTemplateChild("PART_Content");
     this.windowTitleThumb = base.GetTemplateChild("PART_WindowTitleThumb") as Thumb;
     if (this.windowTitleThumb != null)
     {
         this.windowTitleThumb.PreviewMouseLeftButtonUp -= new MouseButtonEventHandler(this.WindowTitleThumbOnPreviewMouseLeftButtonUp);
         this.windowTitleThumb.DragDelta                -= new DragDeltaEventHandler(this.WindowTitleThumbMoveOnDragDelta);
         this.windowTitleThumb.MouseDoubleClick         -= new MouseButtonEventHandler(this.WindowTitleThumbChangeWindowStateOnMouseDoubleClick);
         this.windowTitleThumb.MouseRightButtonUp       -= new MouseButtonEventHandler(this.WindowTitleThumbSystemMenuOnMouseRightButtonUp);
         this.windowTitleThumb.PreviewMouseLeftButtonUp += new MouseButtonEventHandler(this.WindowTitleThumbOnPreviewMouseLeftButtonUp);
         this.windowTitleThumb.DragDelta                += new DragDeltaEventHandler(this.WindowTitleThumbMoveOnDragDelta);
         this.windowTitleThumb.MouseDoubleClick         += new MouseButtonEventHandler(this.WindowTitleThumbChangeWindowStateOnMouseDoubleClick);
         this.windowTitleThumb.MouseRightButtonUp       += new MouseButtonEventHandler(this.WindowTitleThumbSystemMenuOnMouseRightButtonUp);
     }
     this.hideStoryboard = (Storyboard)base.GetTemplateChild("HideStoryboard");
     this.hideFrame      = (SplineDoubleKeyFrame)base.GetTemplateChild("hideFrame");
     this.hideFrameY     = (SplineDoubleKeyFrame)base.GetTemplateChild("hideFrameY");
     this.showFrame      = (SplineDoubleKeyFrame)base.GetTemplateChild("showFrame");
     this.showFrameY     = (SplineDoubleKeyFrame)base.GetTemplateChild("showFrameY");
     this.fadeOutFrame   = (SplineDoubleKeyFrame)base.GetTemplateChild("fadeOutFrame");
     if (this.hideFrame == null || this.showFrame == null || this.hideFrameY == null || this.showFrameY == null || this.fadeOutFrame == null)
     {
         return;
     }
     this.ApplyAnimation(this.Position, this.AnimateOpacity, true);
 }
        /// <summary>
        /// Gets the template parts from the template.
        /// </summary>
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            FrameworkElement layoutRoot = this.GetTemplateChild(AnimatedExpander.ElementLayoutRoot) as FrameworkElement;

            if (layoutRoot != null)
            {
                if (layoutRoot.Resources.Contains(AnimatedExpander.ElementExpandStoryboard))
                {
                    this.expandStoryboard = layoutRoot.Resources[AnimatedExpander.ElementExpandStoryboard] as Storyboard;
                }

                if (layoutRoot.Resources.Contains(AnimatedExpander.ElementCollapseStoryboard))
                {
                    this.collapseStoryboard = layoutRoot.Resources[AnimatedExpander.ElementCollapseStoryboard] as Storyboard;
                }

                this.expandKeyFrame = layoutRoot.FindName(AnimatedExpander.ElementExpandKeyFrame) as SplineDoubleKeyFrame;
            }

            this.expandToggleButton = this.GetTemplateChild(AnimatedExpander.ElementExpandToggleButton) as ToggleButton;
            if (this.expandToggleButton != null)
            {
                this.expandToggleButton.Checked   += new RoutedEventHandler(this.ExpandToggleButton_Checked);
                this.expandToggleButton.Unchecked += new RoutedEventHandler(this.ExpandToggleButton_Unchecked);
            }

            ContentPresenter contentContentPresenter = this.GetTemplateChild(AnimatedExpander.ElementContentContentPresenter) as ContentPresenter;

            if (contentContentPresenter != null)
            {
                contentContentPresenter.SizeChanged += new SizeChangedEventHandler(this.ContentContentPresenter_SizeChanged);
            }
        }
예제 #17
0
        private void Level2IconSelected(Grid selectedGridContainer)
        {
            //SET SELECTED ICON
            if (lastSelectedMeuItemLabel != null)
            {
                lastSelectedMeuItemLabel.Foreground = TabLabelColor_Grey;
            }
            Grid root = (Grid)selectedGridContainer.Parent;

            TextBlock label = root.Children[1] as TextBlock;

            lastSelectedMeuItemLabel = label;


            GeneralTransform gt  = layoutRoot.TransformToVisual(selectedGridContainer);
            Point            pt1 = gt.TransformPoint(new Point(0, 0));

            gt = layoutRoot.TransformToVisual(label);
            Point pt2 = gt.TransformPoint(new Point(0, 0));



            selectedMenuItemRectangle.Fill = TabLabelColor_Blue;
            label.Foreground = TabLabelColor_White;

            double leftToUse  = Math.Min(Math.Abs(pt1.X), Math.Abs(pt2.X)) - 10;
            double widthToUse = Math.Abs(pt1.X) < Math.Abs(pt2.X) ? selectedGridContainer.ActualWidth + 20 : label.ActualWidth + 20;


            SplineDoubleKeyFrame kf1 = (SplineDoubleKeyFrame)((DoubleAnimationUsingKeyFrames)sbHighlightMenuItemSelected.Children[0]).KeyFrames[0];

            kf1.Value = leftToUse;
            this.SelectedMenuItemWidth = widthToUse;
            sbHighlightMenuItemSelected.Begin();
        }
예제 #18
0
        public override void OnApplyTemplate()
        {
            Expand_Trans_A1    = GetTemplateChild("Expand_Trans_A1") as DoubleAnimationUsingKeyFrames;
            Expand_Trans_A2    = GetTemplateChild("Expand_Trans_A2") as DoubleAnimationUsingKeyFrames;
            Collapsed_Trans_A1 = GetTemplateChild("Collapsed_Trans_A1") as DoubleAnimationUsingKeyFrames;
            Collapsed_Trans_A2 = GetTemplateChild("Collapsed_Trans_A2") as DoubleAnimationUsingKeyFrames;

            //Expand_A1 = GetTemplateChild("Expand_A1") as DoubleAnimationUsingKeyFrames;
            Expand_A2 = GetTemplateChild("Expand_A2") as DoubleAnimationUsingKeyFrames;
            //Collapsed_A1 = GetTemplateChild("Collapsed_A1") as DoubleAnimationUsingKeyFrames;
            Collapsed_A2 = GetTemplateChild("Collapsed_A2") as DoubleAnimationUsingKeyFrames;

            Expand_Trans_F1    = GetTemplateChild("Expand_Trans_F1") as SplineDoubleKeyFrame;
            Expand_Trans_F3    = GetTemplateChild("Expand_Trans_F3") as DiscreteDoubleKeyFrame;
            Collapsed_Trans_F1 = GetTemplateChild("Collapsed_Trans_F1") as SplineDoubleKeyFrame;
            Collapsed_Trans_F3 = GetTemplateChild("Collapsed_Trans_F3") as DiscreteDoubleKeyFrame;
            Expand_Trans_F2    = GetTemplateChild("Expand_Trans_F2") as DiscreteDoubleKeyFrame;
            Collapsed_Trans_F2 = GetTemplateChild("Collapsed_Trans_F2") as DiscreteDoubleKeyFrame;
            //Expand_F1 = GetTemplateChild("Expand_F1") as DiscreteDoubleKeyFrame;
            Expand_F2 = GetTemplateChild("Expand_F2") as DiscreteDoubleKeyFrame;
            //Collapsed_F1 = GetTemplateChild("Collapsed_F1") as DiscreteDoubleKeyFrame;
            Collapsed_F2 = GetTemplateChild("Collapsed_F2") as DiscreteDoubleKeyFrame;


            ClipMask = GetTemplateChild("ClipMask") as RectangleGeometry;
            base.OnApplyTemplate();

            var root = GetTemplateChild("rootborder") as FrameworkElement;

            _visualstates = VisualStateManager.GetVisualStateGroups(root)[0] as VisualStateGroup;
        }
        /// <summary>
        /// This will create a fade-in-out effect on the opacity of the given element.
        /// </summary>
        /// <param name="fe">The framework element you wish to apply the effect on.</param>
        public static void ApplyFade(FrameworkElement fe)
        {
            var da = new DoubleAnimationUsingKeyFrames {
                Duration = new TimeSpan(0, 0, 0, 4, 0)
            };
            var kf0 = new SplineDoubleKeyFrame {
                Value = 0D, KeyTime = TimeSpan.FromSeconds(0)
            };
            var kf1 = new SplineDoubleKeyFrame {
                Value = 1D, KeyTime = TimeSpan.FromSeconds(2)
            };
            var kf3 = new SplineDoubleKeyFrame {
                Value = 0D, KeyTime = TimeSpan.FromSeconds(4)
            };

            da.KeyFrames.Add(kf0);
            da.KeyFrames.Add(kf1);
            da.KeyFrames.Add(kf3);

            var sb = new Storyboard();

            Storyboard.SetTarget(da, fe);
            Storyboard.SetTargetProperty(da, new PropertyPath("Opacity"));
            sb.Children.Add(da);
            sb.Begin();
        }
예제 #20
0
        private void ResetRotation_Click(object sender, RoutedEventArgs e)
        {
            Storyboard s = new Storyboard {
                Duration = TimeSpan.FromMilliseconds(500.0)
            };
            DoubleAnimationUsingKeyFrames frames = new DoubleAnimationUsingKeyFrames();
            SplineDoubleKeyFrame          frame2 = new SplineDoubleKeyFrame {
                KeyTime = s.Duration.TimeSpan,
                Value   = 0.0
            };
            KeySpline spline = new KeySpline {
                ControlPoint1 = new Point(0.0, 0.1),
                ControlPoint2 = new Point(0.1, 1.0)
            };

            frame2.KeySpline = spline;
            SplineDoubleKeyFrame keyFrame = frame2;

            frames.KeyFrames.Add(keyFrame);
            keyFrame.Value = 0.0;
            frames.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("Rotation", new object[0]));
            s.Children.Add(frames);
            Storyboard.SetTarget(frames, this.Map);
            s.Completed += delegate(object sender2, EventArgs e2) {
                s.Stop();
                this.Map.Rotation = 0.0;
            };
            s.Begin();
        }
예제 #21
0
        private void OpacityAnimation(UIElement child)
        {
            DoubleAnimationUsingKeyFrames keyFrames1 = new DoubleAnimationUsingKeyFrames();
            SplineDoubleKeyFrame          frame1     = new SplineDoubleKeyFrame();

            frame1.KeyTime = TimeSpan.FromSeconds(0);
            frame1.Value   = 0;
            keyFrames1.KeyFrames.Add(frame1);

            frame1         = new SplineDoubleKeyFrame();
            frame1.KeyTime = AnimationDuration;
            frame1.Value   = 0;
            keyFrames1.KeyFrames.Add(frame1);

            frame1         = new SplineDoubleKeyFrame();
            frame1.KeyTime = TimeSpan.FromSeconds(AnimationDuration.TotalSeconds + 1);
            frame1.Value   = 1;
            keyFrames1.KeyFrames.Add(frame1);

            KeySpline keySpline = new KeySpline();

            keySpline.ControlPoint1 = new Point(0.64, 0.84);

            keySpline.ControlPoint2             = new Point(0, 1); // Animation have to provide same easing effect in all platforms.
            keyFrames1.EnableDependentAnimation = true;
            Storyboard.SetTargetProperty(keyFrames1, "(Opacity)");
            frame1.KeySpline = keySpline;

            Storyboard.SetTarget(keyFrames1, child);
            sb.Children.Add(keyFrames1);
        }
예제 #22
0
        private void ResetRotation_Click(object sender, RoutedEventArgs e)
        {
            Storyboard s = new Storyboard();

            s.Duration = TimeSpan.FromMilliseconds(500);
            DoubleAnimationUsingKeyFrames anim   = new DoubleAnimationUsingKeyFrames();
            SplineDoubleKeyFrame          spline = new SplineDoubleKeyFrame()
            {
                KeyTime = s.Duration.TimeSpan, Value = 0, KeySpline = new KeySpline()
                {
                    ControlPoint1 = new System.Windows.Point(0, 0.1), ControlPoint2 = new System.Windows.Point(0.1, 1)
                }
            };

            anim.KeyFrames.Add(spline);
            spline.Value = 0;
            anim.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("Rotation"));
            s.Children.Add(anim);
            Storyboard.SetTarget(anim, Map);
            s.Completed += (sender2, e2) =>
            {
                s.Stop();
                Map.Rotation = 0;
            };
            s.Begin();
        }
예제 #23
0
        private void AddRenderTransform(UIElement line, double startPosition)
        {
            TransformGroup     tg        = new TransformGroup();
            TranslateTransform translate = new TranslateTransform();

            translate.Y = startPosition;
            tg.Children.Add(translate);
            line.RenderTransform = tg;

            DoubleAnimationUsingKeyFrames da   = new DoubleAnimationUsingKeyFrames();
            SplineDoubleKeyFrame          sdkf = new SplineDoubleKeyFrame();

            sdkf.KeyTime   = TimeSpan.FromSeconds(.5);
            sdkf.KeySpline = new KeySpline();
            sdkf.KeySpline.ControlPoint1 = new Point(0.80, 0.004);
            sdkf.KeySpline.ControlPoint1 = new Point(0.080, 1);

            sdkf.Value = startPosition - 20;
            da.KeyFrames.Add(sdkf);
            Storyboard.SetTarget(da, translate);
            Storyboard.SetTargetProperty(da, new PropertyPath("(Y)"));

            DiscreteDoubleKeyFrame ddkf = new DiscreteDoubleKeyFrame();

            ddkf.KeyTime = TimeSpan.FromSeconds(_Speed);
            ddkf.Value   = startPosition - 20;
            da.KeyFrames.Add(ddkf);

            _sb.Children.Add(da);

            _doubleAnimations.Add(line, da);
        }
예제 #24
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            rightButton   = (RepeatButton)GetTemplateChild(PART_rightButton);
            downButton    = (RepeatButton)GetTemplateChild(PART_downButton);
            leftButton    = (RepeatButton)GetTemplateChild(PART_leftButton);
            upButton      = (RepeatButton)GetTemplateChild(PART_upButton);
            spinButton    = (Button)GetTemplateChild(PART_spinButton);
            zoomOutButton = (RepeatButton)GetTemplateChild(PART_zoomOutButton);
            zoomInButton  = (RepeatButton)GetTemplateChild(PART_zoomInButton);
            horizontalSplineDoubleKeyFrame = (SplineDoubleKeyFrame)GetTemplateChild(PART_horizontalSplineDoubleKeyFrame);
            borderHorizontalToolbar        = (Border)GetTemplateChild(PART_borderHorizontalToolbar);
            navigationGrid = (Panel)GetTemplateChild(PART_NavigationGrid);

            NavCircleScale = NavCircleScale;

            //events
            rightButton.Click   += rightButton_Click;
            downButton.Click    += downButton_Click;
            leftButton.Click    += leftButton_Click;
            upButton.Click      += upButton_Click;
            spinButton.Click    += spinButton_Click;
            zoomOutButton.Click += zoomOutButton_Click;
            zoomInButton.Click  += zoomInButton_Click;
            IsEnabled            = true;
        }
예제 #25
0
        public void PlayMessageAnimation(string imagePath)
        {
            DoubleAnimationUsingKeyFrames anim           = new DoubleAnimationUsingKeyFrames();
            DoubleAnimationUsingKeyFrames animBG         = new DoubleAnimationUsingKeyFrames();
            DoubleKeyFrameCollection      kfCollection   = new DoubleKeyFrameCollection();
            DoubleKeyFrameCollection      kfBGCollection = new DoubleKeyFrameCollection();

            DoubleKeyFrame[] aFrames = new SplineDoubleKeyFrame[2]
            {
                new SplineDoubleKeyFrame(), new SplineDoubleKeyFrame()
            };

            DoubleKeyFrame[] aBGFrames = new SplineDoubleKeyFrame[2]
            {
                new SplineDoubleKeyFrame(), new SplineDoubleKeyFrame()
            };

            messageCanvas.IsHitTestVisible = true;
            m_bIgnoreAnimEnd = false;

            messageImage.Source = ResourceController.GetResourceBitmap(imagePath);

            aFrames[0].KeyTime = TimeSpan.FromSeconds(0.0);
            aFrames[0].Value   = 0.0;
            aFrames[1].KeyTime = TimeSpan.FromSeconds(1.0);
            aFrames[1].Value   = 1.0;

            /* aFrames[2].KeyTime = TimeSpan.FromSeconds(3.0);
             * aFrames[2].Value   = 1.0;
             * aFrames[3].KeyTime = TimeSpan.FromSeconds(4.0);
             * aFrames[3].Value   = 0.0;*/

            aBGFrames[0].KeyTime = TimeSpan.FromSeconds(0.0);
            aBGFrames[0].Value   = 1.0;
            aBGFrames[1].KeyTime = TimeSpan.FromSeconds(1.0);
            aBGFrames[1].Value   = 0.0;

            /*aBGFrames[2].KeyTime = TimeSpan.FromSeconds(3.0);
             * aBGFrames[2].Value = 0.0;
             * aBGFrames[3].KeyTime = TimeSpan.FromSeconds(4.0);
             * aBGFrames[3].Value = 1.0;*/

            for (int i = 0; i < aFrames.Length; i++)
            {
                kfCollection.Add(aFrames[i]);
                kfBGCollection.Add(aBGFrames[i]);
            }

            anim.KeyFrames  = kfCollection;
            anim.Duration   = TimeSpan.FromSeconds(1.0);
            anim.Completed += OnFirstMessageAnimationComplete;

            animBG.KeyFrames  = kfBGCollection;
            animBG.Duration   = TimeSpan.FromSeconds(1.0);
            animBG.Completed += OnFirstMessageAnimationComplete;


            messageCanvas.BeginAnimation(Canvas.OpacityProperty, anim);
            pageMainGrid.BeginAnimation(Grid.OpacityProperty, animBG);
        }
예제 #26
0
        /// <summary>
        /// Generates a Double animation sequence with fixed parameters
        /// </summary>
        /// <param name="target">Animation target object</param>
        /// <param name="property">Animation target property</param>
        /// <param name="from">Start value</param>
        /// <param name="to">End value</param>
        /// <param name="begin">Animation begin time</param>
        /// <param name="duration">Animation duration</param>
        /// <returns>DoubleAnimationUsingKeyFrames</returns>
        internal DoubleAnimationUsingKeyFrames CreateDoubleAnimation(DependencyObject target, String property, Double from, Double to, Double begin, Double duration)
        {
            DoubleAnimationUsingKeyFrames da = new DoubleAnimationUsingKeyFrames();

            da.BeginTime = TimeSpan.FromSeconds(begin);
#if WPF
            target.SetValue(NameProperty, target.GetType().Name + Guid.NewGuid().ToString().Replace('-', '_'));
            Storyboard.SetTargetName(da, target.GetValue(NameProperty).ToString());

            Chart._rootElement.RegisterName((string)target.GetValue(NameProperty), target);
#else
            Storyboard.SetTarget(da, target);
#endif
            Storyboard.SetTargetProperty(da, new PropertyPath(property));

            SplineDoubleKeyFrame keyFrame = new SplineDoubleKeyFrame();
            keyFrame.KeySpline = new KeySpline()
            {
                ControlPoint1 = new Point(0, 0), ControlPoint2 = new Point(1, 1)
            };
            keyFrame.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0));
            keyFrame.Value   = from;
            da.KeyFrames.Add(keyFrame);

            keyFrame           = new SplineDoubleKeyFrame();
            keyFrame.KeySpline = new KeySpline()
            {
                ControlPoint1 = new Point(0.5, 0), ControlPoint2 = new Point(0.5, 1)
            };
            keyFrame.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(duration));
            keyFrame.Value   = to;
            da.KeyFrames.Add(keyFrame);

            return(da);
        }
예제 #27
0
        public static Storyboard To(UIElement target, double to, double duration,
                                    double delay, string prop, SplineDoubleKeyFrame ease = null,
                                    Action <object, object> onCompleteFunc = null)
        {
            if (ease == null)
            {
                ease = Easing.Linear();
            }

            KeySpline ks = new KeySpline();

            ks.ControlPoint1 = ease.KeySpline.ControlPoint1;
            ks.ControlPoint2 = ease.KeySpline.ControlPoint2;

            SplineDoubleKeyFrame endFrame = new SplineDoubleKeyFrame();

            endFrame.KeySpline = ks;
            endFrame.Value     = to;
            endFrame.KeyTime   = TimeSpan.FromMilliseconds(duration);

            DoubleAnimationUsingKeyFrames anim = new DoubleAnimationUsingKeyFrames();

            anim.BeginTime = TimeSpan.FromMilliseconds(delay);
            anim.EnableDependentAnimation = true;
            anim.KeyFrames.Add(endFrame);

            Storyboard.SetTarget(anim, target);
            Storyboard.SetTargetProperty(anim, prop);
            Storyboard sb = new Storyboard();

            sb.Children.Add(anim);
            sb.Completed += onCompleteFunc == null ? null : new EventHandler <object>(onCompleteFunc);
            return(sb);
        }
예제 #28
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            root = (Grid)GetTemplateChild("root");
            if (root == null)
            {
                return;
            }

            PART_Header  = (ContentPresenter)GetTemplateChild("PART_Header");
            PART_Content = (ContentPresenter)GetTemplateChild("PART_Content");

            hideStoryboard = (Storyboard)GetTemplateChild("HideStoryboard");
            hideFrame      = (SplineDoubleKeyFrame)GetTemplateChild("hideFrame");
            hideFrameY     = (SplineDoubleKeyFrame)GetTemplateChild("hideFrameY");
            showFrame      = (SplineDoubleKeyFrame)GetTemplateChild("showFrame");
            showFrameY     = (SplineDoubleKeyFrame)GetTemplateChild("showFrameY");
            fadeOutFrame   = (SplineDoubleKeyFrame)GetTemplateChild("fadeOutFrame");

            if (hideFrame == null || showFrame == null || hideFrameY == null || showFrameY == null || fadeOutFrame == null)
            {
                return;
            }

            ApplyAnimation(Position, AnimateOpacity);
        }
 void _SetupYTranslationStoryboard(TranslateTransform transform, string sbName, double translation)
 {
     if (Resources.Contains(sbName))
     {
         Storyboard sb = Resources[sbName] as Storyboard;
         DoubleAnimationUsingKeyFrames anim     = sb.Children[0] as DoubleAnimationUsingKeyFrames;
         SplineDoubleKeyFrame          keyFrame = anim.KeyFrames[0] as SplineDoubleKeyFrame;
         keyFrame.Value = translation;
     }
     else
     {
         Storyboard sb = new Storyboard();
         sb.SetValue(FrameworkElement.NameProperty, sbName);
         DoubleAnimationUsingKeyFrames anim = new DoubleAnimationUsingKeyFrames();
         sb.Children.Add(anim);
         Storyboard.SetTarget(anim, transform);
         Storyboard.SetTargetProperty(anim, new PropertyPath("Y"));
         anim.BeginTime = new TimeSpan(0, 0, 0);
         SplineDoubleKeyFrame keyFrame = new SplineDoubleKeyFrame();
         KeySpline            spline   = new KeySpline();
         spline.ControlPoint1 = new Point(0, 1);
         spline.ControlPoint2 = new Point(1, 1);
         keyFrame.KeySpline   = spline;
         keyFrame.KeyTime     = new TimeSpan(0, 0, 1);
         keyFrame.Value       = translation;
         anim.KeyFrames.Add(keyFrame);
         Resources.Add(sbName, sb);
     }
 }
예제 #30
0
        private void AnimateToPosition(double posX, double posY)
        {
            SplineDoubleKeyFrame animateXKeyFrame = (_target.FindName("AnimatePositionX") as SplineDoubleKeyFrame);
            SplineDoubleKeyFrame animateYKeyFrame = (_target.FindName("AnimatePositionY") as SplineDoubleKeyFrame);

            animateXKeyFrame.Value = posX;
            animateYKeyFrame.Value = posY;
            _animateToPositionStoryboard.Begin();
        }