예제 #1
0
        /// <summary>Makes this instance a modifiable deep copy of the specified <see cref="T:System.Windows.Media.Animation.ThicknessAnimationUsingKeyFrames" /> using current property values. Resource references, data bindings, and animations are not copied, but their current values are.</summary>
        /// <param name="sourceFreezable">The <see cref="T:System.Windows.Media.Animation.ThicknessAnimationUsingKeyFrames" /> to clone.</param>
        // Token: 0x0600175F RID: 5983 RVA: 0x0007268C File Offset: 0x0007088C
        protected override void CloneCurrentValueCore(Freezable sourceFreezable)
        {
            ThicknessAnimationUsingKeyFrames sourceAnimation = (ThicknessAnimationUsingKeyFrames)sourceFreezable;

            base.CloneCurrentValueCore(sourceFreezable);
            this.CopyCommon(sourceAnimation, true);
        }
예제 #2
0
        /// <summary>Makes this instance a clone of the specified <see cref="T:System.Windows.Media.Animation.ThicknessAnimationUsingKeyFrames" /> object. </summary>
        /// <param name="source">The <see cref="T:System.Windows.Media.Animation.ThicknessAnimationUsingKeyFrames" /> object to clone.</param>
        // Token: 0x06001760 RID: 5984 RVA: 0x000726B0 File Offset: 0x000708B0
        protected override void GetAsFrozenCore(Freezable source)
        {
            ThicknessAnimationUsingKeyFrames sourceAnimation = (ThicknessAnimationUsingKeyFrames)source;

            base.GetAsFrozenCore(source);
            this.CopyCommon(sourceAnimation, false);
        }
예제 #3
0
        /// <summary>
        /// Helper used by the four Freezable clone methods to copy the resolved key times and
        /// key frames. The Get*AsFrozenCore methods are implemented the same as the Clone*Core
        /// methods; Get*AsFrozen at the top level will recursively Freeze so it's not done here.
        /// </summary>
        /// <param name="sourceAnimation"></param>
        /// <param name="isCurrentValueClone"></param>
        private void CopyCommon(ThicknessAnimationUsingKeyFrames sourceAnimation, bool isCurrentValueClone)
        {
            _areKeyTimesValid = sourceAnimation._areKeyTimesValid;

            if (_areKeyTimesValid &&
                sourceAnimation._sortedResolvedKeyFrames != null)
            {
                // _sortedResolvedKeyFrames is an array of ResolvedKeyFrameEntry so the notion of CurrentValueClone doesn't apply
                _sortedResolvedKeyFrames = (ResolvedKeyFrameEntry[])sourceAnimation._sortedResolvedKeyFrames.Clone();
            }

            if (sourceAnimation._keyFrames != null)
            {
                if (isCurrentValueClone)
                {
                    _keyFrames = (ThicknessKeyFrameCollection)sourceAnimation._keyFrames.CloneCurrentValue();
                }
                else
                {
                    _keyFrames = (ThicknessKeyFrameCollection)sourceAnimation._keyFrames.Clone();
                }

                OnFreezablePropertyChanged(null, _keyFrames);
            }
        }
예제 #4
0
        public void Flush()
        {
            var thicknessAnimationUsingKeyFrames = new ThicknessAnimationUsingKeyFrames();
            thicknessAnimationUsingKeyFrames.KeyFrames = new ThicknessKeyFrameCollection();

            double delta = (Width - Height) / 2;

            var thicknessAnimation = new ThicknessAnimation()
            {
                From = new Thickness(delta, 0, delta, 0),
                To = new Thickness(delta - 500, -500, delta - 500, -500),
                Duration = new Duration(TimeSpan.FromSeconds(1)),
                AutoReverse = true
            };
            thicknessAnimation.Completed += new EventHandler(animation_Completed);

            _flushEllipse = new Ellipse()
            {
                Fill = new SolidColorBrush(Colors.LightBlue),
                Stroke = new SolidColorBrush(Colors.Orange),
                StrokeThickness = 5,
                Opacity = 0.5
            };

            Children.Add(_flushEllipse);
            _flushEllipse.BeginAnimation(Ellipse.MarginProperty, thicknessAnimation);
        }
예제 #5
0
 private void butPlayQuick_IsEnabledChanged (object sender, DependencyPropertyChangedEventArgs e)
 {
     if (butPlayQuick.IsEnabled)
     {
         var ani1 = new ThicknessAnimationUsingKeyFrames();
         ani1.KeyFrames.Add(new EasingThicknessKeyFrame(new Thickness(0, 0, 0, 105), TimeSpan.FromSeconds(0.25), new CubicEase() { EasingMode = EasingMode.EaseInOut }));
         var ani2 = new ThicknessAnimationUsingKeyFrames();
         ani2.KeyFrames.Add(new EasingThicknessKeyFrame(new Thickness(0, -105, 0, 210), TimeSpan.FromSeconds(0.25), new CubicEase() { EasingMode = EasingMode.EaseInOut }));
         var ani3 = new ThicknessAnimationUsingKeyFrames();
         ani3.KeyFrames.Add(new EasingThicknessKeyFrame(new Thickness(0, 105, 0, 0), TimeSpan.FromSeconds(0.25), new CubicEase() { EasingMode = EasingMode.EaseInOut }));
         butPlayQuick_a.BeginAnimation(MarginProperty, ani1);
         butPlayQuick_c.BeginAnimation(MarginProperty, ani2);
         butPlayQuick_b.BeginAnimation(MarginProperty, ani3);
     }
     else
     {
         var ani1 = new ThicknessAnimationUsingKeyFrames();
         //ani1.KeyFrames.Add(new EasingThicknessKeyFrame(new Thickness(0, -25, 0, 125), TimeSpan.FromSeconds(0.15), new QuarticEase() { EasingMode = EasingMode.EaseIn}));
         ani1.KeyFrames.Add(new EasingThicknessKeyFrame(new Thickness(0, 105, 0, 0), TimeSpan.FromSeconds(0.25), new QuarticEase() { EasingMode = EasingMode.EaseInOut }));
         var ani2 = new ThicknessAnimationUsingKeyFrames();
         //ani2.KeyFrames.Add(new EasingThicknessKeyFrame(new Thickness(0, 75, 0, 25), TimeSpan.FromSeconds(0.15), new QuarticEase() { EasingMode = EasingMode.EaseIn }));
         ani2.KeyFrames.Add(new EasingThicknessKeyFrame(new Thickness(0, 0, 0, 105), TimeSpan.FromSeconds(0.25), new QuarticEase() { EasingMode = EasingMode.EaseInOut }));
         var ani3 = new ThicknessAnimationUsingKeyFrames();
         ani3.KeyFrames.Add(new EasingThicknessKeyFrame(new Thickness(0, 210, 0, -105), TimeSpan.FromSeconds(0.25), new CubicEase() { EasingMode = EasingMode.EaseInOut }));
         butPlayQuick_a.BeginAnimation(MarginProperty, ani1);
         butPlayQuick_c.BeginAnimation(MarginProperty, ani2);
         butPlayQuick_b.BeginAnimation(MarginProperty, ani3);
     }
 }
예제 #6
0
        /// <summary>
        /// Implementation of <see cref="System.Windows.Freezable.GetCurrentValueAsFrozenCore(Freezable)">Freezable.GetCurrentValueAsFrozenCore</see>.
        /// </summary>
        protected override void GetCurrentValueAsFrozenCore(Freezable source)
        {
            ThicknessAnimationUsingKeyFrames sourceAnimation = (ThicknessAnimationUsingKeyFrames)source;

            base.GetCurrentValueAsFrozenCore(source);

            CopyCommon(sourceAnimation, /* isCurrentValueClone = */ true);
        }
        private void StoryBoardInit(double left)
        {
            QuinticEase SineEase = new QuinticEase { EasingMode = EasingMode.EaseIn };
            ThicknessAnimationUsingKeyFrames keyFrames = new ThicknessAnimationUsingKeyFrames();
            EasingThicknessKeyFrame keyFrame = new EasingThicknessKeyFrame(new Thickness(left, this.Margin.Top, this.Margin.Right, this.Margin.Bottom), KeyTime.FromTimeSpan(TimeSpan.FromSeconds(5)), SineEase);
            EasingThicknessKeyFrame keyFrame1 = new EasingThicknessKeyFrame(new Thickness(0, this.Margin.Top, this.Margin.Right, this.Margin.Bottom), KeyTime.FromTimeSpan(TimeSpan.FromSeconds(10)), SineEase);

            this.Margin = new Thickness(0,this.Margin.Top,this.Margin.Right,this.Margin.Bottom);
            keyFrames.RepeatBehavior = RepeatBehavior.Forever;
            StoryBoard.Children.Clear();
            keyFrames.KeyFrames.Add(keyFrame);
            keyFrames.KeyFrames.Add(keyFrame1);
            StoryBoard.Children.Add(keyFrames);
            Storyboard.SetTargetProperty(keyFrames, new PropertyPath("(FrameworkElement.Margin)"));
            Storyboard.SetTarget(keyFrames, this);

            StoryBoard.FillBehavior = FillBehavior.HoldEnd;
            StoryBoard.Begin();
        }
예제 #8
0
 // Token: 0x06001762 RID: 5986 RVA: 0x000726F8 File Offset: 0x000708F8
 private void CopyCommon(ThicknessAnimationUsingKeyFrames sourceAnimation, bool isCurrentValueClone)
 {
     this._areKeyTimesValid = sourceAnimation._areKeyTimesValid;
     if (this._areKeyTimesValid && sourceAnimation._sortedResolvedKeyFrames != null)
     {
         this._sortedResolvedKeyFrames = (ResolvedKeyFrameEntry[])sourceAnimation._sortedResolvedKeyFrames.Clone();
     }
     if (sourceAnimation._keyFrames != null)
     {
         if (isCurrentValueClone)
         {
             this._keyFrames = (ThicknessKeyFrameCollection)sourceAnimation._keyFrames.CloneCurrentValue();
         }
         else
         {
             this._keyFrames = sourceAnimation._keyFrames.Clone();
         }
         base.OnFreezablePropertyChanged(null, this._keyFrames);
     }
 }
예제 #9
0
 private async void AuthButton_Click(object sender, RoutedEventArgs e) {
     if (e.Source is ButtonMenu)
     {
         if ((bool)toggleDetele.IsChecked)
         {
             var ani = new ThicknessAnimationUsingKeyFrames();
             ani.KeyFrames.Add(new LinearThicknessKeyFrame(new Thickness(-20, ((ButtonMenu)e.Source).Margin.Top, 20, ((ButtonMenu)e.Source).Margin.Bottom), TimeSpan.FromSeconds(0.2)));
             ani.KeyFrames.Add(new LinearThicknessKeyFrame(new Thickness(-100, ((ButtonMenu)e.Source).Margin.Top, 100, ((ButtonMenu)e.Source).Margin.Bottom), TimeSpan.FromSeconds(0.3)));
             ani.KeyFrames.Add(new LinearThicknessKeyFrame(new Thickness(-465, ((ButtonMenu)e.Source).Margin.Top, 465, ((ButtonMenu)e.Source).Margin.Bottom), TimeSpan.FromSeconds(0.5)));
             ((ButtonMenu)e.Source).BeginAnimation(MarginProperty, ani);
             foreach (ButtonMenu button in gridscrolllist.Children)
             {
                 if (button != ((ButtonMenu)e.Source))
                 {
                     var ani1 = new ThicknessAnimationUsingKeyFrames();
                     ani1.KeyFrames.Add(new LinearThicknessKeyFrame(button.Margin, TimeSpan.FromSeconds(0.5)));
                     ani1.KeyFrames.Add(new LinearThicknessKeyFrame(new Thickness(button.Margin.Left, button.Margin.Top - 60, button.Margin.Right, button.Margin.Bottom + 60), TimeSpan.FromSeconds(0.8)));
                     button.BeginAnimation(MarginProperty, ani1);
                 }
             }
             MeCore.Config.SavedAuths.Remove(((ButtonMenu)e.Source).Content as string);
             if (MeCore.Config.DefaultAuth.Equals(((ButtonMenu)e.Source).Content as string))
             {
                 MeCore.Config.DefaultAuth = "";
             }
             MeCore.Config.Save();
             await System.Threading.Tasks.TaskEx.Delay(2000);
             CreateCustomAuth();
             return;
         }
         SavedAuth auth; string name = ((ButtonMenu)e.Source).Content as string;
         MeCore.Config.SavedAuths.TryGetValue(name, out auth);
         this.auth = auth.AuthType.Equals("Yggdrasil") ? new  Launch.Login.YggdrasilRefreshAuth(Guid.Parse(auth.AccessToken).ToString()) : new Launch.Login.OfflineAuth(name) as Launch.Login.IAuth;
         MeCore.Config.QuickChange("DefaultAuth", name);
         Close();
     }
 }
        /// <summary>Creates the actual visual elements that make up the animation</summary>
        /// <param name="circleCount">Number of circles to use in the animation</param>
        private void CreateVisuals(int circleCount)
        {
            Children.Clear();
            _storyboards.Clear();

            var slowDistance = DotCount * (DotDiameter + 10);
            var fastDistance = (ActualWidth - slowDistance) / 2;
            var widthSpeedFactor = 1d;
            if (fastDistance < slowDistance * 2) widthSpeedFactor = .5d;
            else if (fastDistance < slowDistance * 3) widthSpeedFactor = .6d;
            // Additional speed adjustment needed for number of dots
            widthSpeedFactor = widthSpeedFactor * (7d / DotCount);

            for (int counter = 0; counter < circleCount; counter++)
            {
                var ellipse = new Ellipse
                {
                    Height = DotDiameter,
                    Width = DotDiameter,
                    Fill = DotBrush,
                    HorizontalAlignment = HorizontalAlignment.Left,
                    VerticalAlignment = VerticalAlignment.Center,
                    Margin = new Thickness(DotDiameter * -1, 0, 0, 0)
                };
                Children.Add(ellipse);

                var a1 = new ThicknessAnimationUsingKeyFrames
                {
                    RepeatBehavior = RepeatBehavior.Forever,
                    BeginTime = TimeSpan.FromMilliseconds(DotSpaceFactor * 175 * counter * widthSpeedFactor)
                };
                Storyboard.SetTargetProperty(a1, new PropertyPath("(FrameworkElement.Margin)"));
                Storyboard.SetTarget(a1, ellipse);
                var storyboard = new Storyboard();
                storyboard.Children.Add(a1);
                a1.KeyFrames.Add(new SplineThicknessKeyFrame
                {
                    KeyTime = KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0, 0, 0)),
                    Value = new Thickness(DotDiameter * -1, 0, 0, 0)
                });
                var keytime = (long)(15000000 * DotAnimationSpeedFactor * widthSpeedFactor);
                a1.KeyFrames.Add(new SplineThicknessKeyFrame
                {
                    KeyTime = KeyTime.FromTimeSpan(new TimeSpan(keytime)),
                    Value = new Thickness(fastDistance, 0, 0, 0)
                });
                keytime += (long)(10000000 * DotAnimationSpeedFactor); // No speec factor here!!!
                a1.KeyFrames.Add(new SplineThicknessKeyFrame
                {
                    KeyTime = KeyTime.FromTimeSpan(new TimeSpan(keytime)),
                    Value = new Thickness(fastDistance + slowDistance, 0, 0, 0)
                });
                keytime += (long)(10000000 * DotAnimationSpeedFactor * widthSpeedFactor);
                a1.KeyFrames.Add(new SplineThicknessKeyFrame
                {
                    KeyTime = KeyTime.FromTimeSpan(new TimeSpan(keytime)),
                    Value = new Thickness(fastDistance + slowDistance + fastDistance, 0, 0, 0)
                });
                keytime += (long)(10000000 * DotAnimationSpeedFactor * widthSpeedFactor);
                a1.KeyFrames.Add(new SplineThicknessKeyFrame
                {
                    KeyTime = KeyTime.FromTimeSpan(new TimeSpan(keytime)),
                    Value = new Thickness(ActualWidth + DotDiameter, 0, 0, 0)
                });
                _storyboards.Add(storyboard);
            }
        }
        /// <summary>
        /// Helper used by the four Freezable clone methods to copy the resolved key times and 
        /// key frames. The Get*AsFrozenCore methods are implemented the same as the Clone*Core
        /// methods; Get*AsFrozen at the top level will recursively Freeze so it's not done here.
        /// </summary>
        /// <param name="sourceAnimation"></param>
        /// <param name="isCurrentValueClone"></param>
        private void CopyCommon(ThicknessAnimationUsingKeyFrames sourceAnimation, bool isCurrentValueClone)
        {    
            _areKeyTimesValid = sourceAnimation._areKeyTimesValid;

            if (   _areKeyTimesValid 
                && sourceAnimation._sortedResolvedKeyFrames != null)
            {
                // _sortedResolvedKeyFrames is an array of ResolvedKeyFrameEntry so the notion of CurrentValueClone doesn't apply
                _sortedResolvedKeyFrames = (ResolvedKeyFrameEntry[])sourceAnimation._sortedResolvedKeyFrames.Clone(); 
            }

            if (sourceAnimation._keyFrames != null)
            {
                if (isCurrentValueClone)
                {
                    _keyFrames = (ThicknessKeyFrameCollection)sourceAnimation._keyFrames.CloneCurrentValue();
                }
                else
                {
                    _keyFrames = (ThicknessKeyFrameCollection)sourceAnimation._keyFrames.Clone();
                }

                OnFreezablePropertyChanged(null, _keyFrames);
            }
        }
예제 #12
0
        private void TextBox_GotFocus(object sender, RoutedEventArgs e)
        {
            double fleft, ftop, fbottom, fright, fwidth;
            TextBox ntb = (TextBox)sender;
            if (tb == null)
            {
                fleft = ntb.Margin.Left;
                ftop = ntb.Margin.Top;
                fbottom = ntb.Margin.Bottom;
                fright = ntb.Margin.Right;
                fwidth = ntb.Width;
            }
            else
            {
                //获得失去焦点的文本框的位置
                fleft = tb.Margin.Left;
                ftop = tb.Margin.Top;
                fbottom = tb.Margin.Bottom;
                fright = tb.Margin.Right;
                fwidth = tb.Width;

            }
            //获得获得焦点的文本框的位置
            double nleft = ntb.Margin.Left;
            double ntop = ntb.Margin.Top;
            double nbottom = ntb.Margin.Bottom;
            double nright = ntb.Margin.Right;
            double nwidth = ntb.Width;
            //调整提示图片位置
            Image_Small_Tip.Margin = new Thickness(0, 0, nright, nbottom - 23);
            Image_Small_Tip.Visibility = System.Windows.Visibility.Visible;
            //开启动画效果

            //ThicknessAnimation ta = new ThicknessAnimation();
            SplineThicknessKeyFrame stk1 = new SplineThicknessKeyFrame();
            SplineThicknessKeyFrame stk2 = new SplineThicknessKeyFrame();
            ThicknessAnimationUsingKeyFrames du = new ThicknessAnimationUsingKeyFrames();

            stk1.Value = new Thickness(fleft, ftop, fright, fbottom);
            stk2.Value = new Thickness(nleft, ntop, nright, nbottom);

            stk1.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(0));
            stk2.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(400));
            stk2.KeySpline = new KeySpline(0, 0, 0, 1);

            du.KeyFrames.Add(stk1);
            du.KeyFrames.Add(stk2);

            //ta.From = new Thickness(fleft,ftop,0,0);
            //ta.To = new Thickness(nleft, ntop, 0, 0);
            //ta.Duration = new Duration(TimeSpan.FromMilliseconds(200));

            Storyboard.SetTargetName(du, "Margin");
            Storyboard.SetTargetProperty(du, new PropertyPath(Border.MarginProperty));

            Storyboard storyBoard = new Storyboard();

            storyBoard.Children.Add(du);

            this.RegisterName("Margin", this.ColorFulBorder);

            DoubleAnimation ta = new DoubleAnimation();
            ta.From = 0;
            ta.To = 0.25;
            ta.Duration = new Duration(TimeSpan.FromMilliseconds(100));
            Storyboard.SetTargetName(ta, "Opacity");
            Storyboard.SetTargetProperty(ta, new PropertyPath(Border.OpacityProperty));
            Storyboard storyBoard2 = new Storyboard();
            storyBoard2.Children.Add(ta);
            this.RegisterName("Opacity", this.ColorFulBorder);
            storyBoard2.Begin(this, true);

            DoubleAnimation tw = new DoubleAnimation();
            tw.From = fwidth;
            tw.To = nwidth;
            tw.Duration = new Duration(TimeSpan.FromMilliseconds(100));
            Storyboard.SetTargetName(tw, "Width");
            Storyboard.SetTargetProperty(tw, new PropertyPath(Border.WidthProperty));
            Storyboard storyBoard3 = new Storyboard();
            storyBoard3.Children.Add(tw);
            this.RegisterName("Width", this.ColorFulBorder);
            storyBoard3.Begin(this, true);
            storyBoard.Begin(this, true);
        }
        private void CreateAnimations()
        {
            if (_storyboard != null) _storyboard.Stop();

            if (ContentTop == null || ContentBottom == null) return;

            _storyboard = new Storyboard();
            var a1 = new ThicknessAnimationUsingKeyFrames {RepeatBehavior = RepeatBehavior.Forever, BeginTime = TimeSpan.FromMilliseconds(AnimationStartDelay + GetRandomAddition(AnimationStartDelayRandomAddition))};
            Storyboard.SetTargetProperty(a1, new PropertyPath("(FrameworkElement.Margin)"));
            Storyboard.SetTarget(a1, _animationContainer);
            _storyboard.Children.Add(a1);

            var position1 = StartWithTopContent ? new Thickness() : new Thickness(0, VerticalSlide*-1, 0, 0);
            var position2 = StartWithTopContent ? new Thickness(0, VerticalSlide*-1, 0, 0) : new Thickness();

            _animationContainer.Margin = position1;

            var move1 = TopContentDisplayDuration + GetRandomAddition(TopContentDisplayDurationRandomAddition);
            var move2 = move1 + ContentTransitionDuration;
            var move3 = move2 + BottomContentDisplayDuration + GetRandomAddition(BottomContentDisplayDurationRandomAddition);
            var move4 = move3 + ContentTransitionDuration;

            a1.KeyFrames.Add(new SplineThicknessKeyFrame(position1, KeyTime.FromTimeSpan(new TimeSpan(0)), new KeySpline(.75d, 0d, 0d, .75d)));
            a1.KeyFrames.Add(new SplineThicknessKeyFrame(position1, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(move1)), new KeySpline(.75d, 0d, 0d, .75d)));
            a1.KeyFrames.Add(new SplineThicknessKeyFrame(position2, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(move2)), new KeySpline(.75d, 0d, 0d, .75d)));
            a1.KeyFrames.Add(new SplineThicknessKeyFrame(position2, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(move3)), new KeySpline(.75d, 0d, 0d, .75d)));
            a1.KeyFrames.Add(new SplineThicknessKeyFrame(position1, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(move4)), new KeySpline(.75d, 0d, 0d, .75d)));

            _storyboard.Begin();
        }
예제 #14
0
        protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
        {
            if (IsClosing)
            {
                e.Cancel = !AllowClose;
            }
            else
            {
                IsClosing = true;
                AllowClose = false;

                e.Cancel = true;

                if (PopupBoard is Storyboard)
                {
                    PopupBoard.Stop(this);
                    PopupBoard = null;
                }
                HideBoard = new Storyboard();
                HideBoard.Completed += new EventHandler((od, ed) =>
                {
                    AllowClose = true;
                    Close();
                });

                var rect = DockIcon.IconRect;

                var delay = Config.HideDelay;
                if ((System.Windows.Forms.Control.ModifierKeys & System.Windows.Forms.Keys.Shift) == System.Windows.Forms.Keys.Shift)
                {
                    delay = 5000;
                }

                for (var i = 0; i < spContent.Children.Count; i++)
                {
                    var ctrl = spContent.Children[i] as FanIconControl;

                    ctrl.GridContent.Effect = null;

                    var animRotate = new DoubleAnimationUsingKeyFrames();
                    animRotate.SetValue(Storyboard.TargetNameProperty, ctrl.Name);
                    animRotate.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(RotateTransform.Angle)"));
                    animRotate.KeyFrames.Add(new SplineDoubleKeyFrame(0, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(delay))));
                    animRotate.DecelerationRatio = 0.8;

                    var animMargin = new ThicknessAnimationUsingKeyFrames();
                    animMargin.SetValue(Storyboard.TargetNameProperty, ctrl.Name);
                    animMargin.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(FrameworkElement.Margin)"));
                    animMargin.KeyFrames.Add(new SplineThicknessKeyFrame(
                        new Thickness(0),
                        KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(delay))));
                    animMargin.DecelerationRatio = 0.8;

                    var animOpacity = new DoubleAnimationUsingKeyFrames();
                    animOpacity.SetValue(Storyboard.TargetNameProperty, ctrl.BorderTitle.Tag);
                    animOpacity.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(FrameworkElement.Opacity)"));
                    animOpacity.KeyFrames.Add(new SplineDoubleKeyFrame(0, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(delay))));
                    animOpacity.DecelerationRatio = 1;

                    var animIconSize = new Int32AnimationUsingKeyFrames();
                    animIconSize.SetValue(Storyboard.TargetNameProperty, ctrl.Name);
                    animIconSize.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(FrameworkElement.IconSize)"));
                    animIconSize.KeyFrames.Add(new SplineInt32KeyFrame(rect.Width, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(delay))));
                    animIconSize.DecelerationRatio = 1;

                    HideBoard.Children.Add(animRotate);
                    HideBoard.Children.Add(animMargin);
                    HideBoard.Children.Add(animOpacity);
                    HideBoard.Children.Add(animIconSize);
                }

                HideBoard.Begin(this);
            }
            base.OnClosing(e);
        }
예제 #15
0
        private void Window_Activated(object sender, EventArgs e)
        {
            if (IsClosing || IsOpened)
            {
                return;
            }
            IsOpened = true;

            DockIcon.IconName = App.StartupPath + "Container-Opened.png";

            PopupBoard = new Storyboard();
            PopupBoard.Completed += new EventHandler(PopupAnimation_Completed);

            var rect = DockIcon.IconRect;

            var delay = Config.PopupDelay;
            if ((System.Windows.Forms.Control.ModifierKeys & System.Windows.Forms.Keys.Shift) == System.Windows.Forms.Keys.Shift)
            {
                delay = 5000;
            }

            for (var i = 0; i < spContent.Children.Count; i++)
            {
                var ctrl = spContent.Children[i] as FanIconControl;

                var k = (double)(spContent.Children.Count - 1 - i) / MaxItems;

                var animRotate = new DoubleAnimationUsingKeyFrames();
                animRotate.SetValue(Storyboard.TargetNameProperty, ctrl.Name);
                animRotate.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(RotateTransform.Angle)"));
                animRotate.KeyFrames.Add(new SplineDoubleKeyFrame(k * Angle, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(delay))));
                animRotate.DecelerationRatio = 0.8;

                var animMargin = new ThicknessAnimationUsingKeyFrames();
                animMargin.SetValue(Storyboard.TargetNameProperty, ctrl.Name);
                animMargin.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(FrameworkElement.Margin)"));
                animMargin.KeyFrames.Add(new SplineThicknessKeyFrame(
                    new Thickness(0, 0, -IconSize / 2 * (1 - Math.Sin((1 - k) * Math.PI / 2)) - (IconSize - rect.Width) / 2,
                        rect.Height + IconSize * (spContent.Children.Count - 1 - i)),
                    KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(delay))));
                animMargin.DecelerationRatio = 0.8;

                var animOpacity = new DoubleAnimationUsingKeyFrames();
                animOpacity.SetValue(Storyboard.TargetNameProperty, ctrl.BorderTitle.Tag);
                animOpacity.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(FrameworkElement.Opacity)"));
                animOpacity.KeyFrames.Add(new SplineDoubleKeyFrame(1, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(delay))));
                animOpacity.DecelerationRatio = 1;

                var animIconSize = new Int32AnimationUsingKeyFrames();
                animIconSize.SetValue(Storyboard.TargetNameProperty, ctrl.Name);
                animIconSize.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(FrameworkElement.IconSize)"));
                animIconSize.KeyFrames.Add(new SplineInt32KeyFrame(rect.Width, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(0))));
                animIconSize.KeyFrames.Add(new SplineInt32KeyFrame(IconSize, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(delay))));
                animIconSize.DecelerationRatio = 1;

                PopupBoard.Children.Add(animRotate);
                PopupBoard.Children.Add(animMargin);
                PopupBoard.Children.Add(animOpacity);
                PopupBoard.Children.Add(animIconSize);
            }

            PopupBoard.Begin(this);
        }
예제 #16
0
 private void button_Loaded(object sender, RoutedEventArgs e)
 {
     int i = System.Windows.Forms.TextRenderer.MeasureText(txtPreview.Text, new System.Drawing.Font(txtPreview.FontFamily.Source, (float)txtPreview.FontSize)).Width;
     if (i > lblPreview.ActualWidth)
     {
         var a = new Storyboard() { RepeatBehavior = RepeatBehavior.Forever};
         var b = new ThicknessAnimationUsingKeyFrames();
         b.KeyFrames.Add(new LinearThicknessKeyFrame(new Thickness(0, 0, -(i - lblPreview.ActualWidth), 0), TimeSpan.FromSeconds(0)));
         b.KeyFrames.Add(new LinearThicknessKeyFrame(new Thickness(-(i - lblPreview.ActualWidth), 0, 0, 0), TimeSpan.FromSeconds(5/2)));
         b.KeyFrames.Add(new LinearThicknessKeyFrame(new Thickness(-(i - lblPreview.ActualWidth), 0, 0, 0), TimeSpan.FromSeconds(10/2)));
         b.KeyFrames.Add(new LinearThicknessKeyFrame(new Thickness(0, 0, -(i - lblPreview.ActualWidth), 0), TimeSpan.FromSeconds(15/2)));
         b.KeyFrames.Add(new LinearThicknessKeyFrame(new Thickness(0, 0, -(i - lblPreview.ActualWidth), 0), TimeSpan.FromSeconds(20/2)));
         a.Children.Add(b);
         Storyboard.SetTarget(b, txtPreview);
         Storyboard.SetTargetProperty(b, new PropertyPath("Margin"));
         //txtPreview.BeginStoryboard(a, HandoffBehavior.Compose);
     }
 }
예제 #17
0
        void Grow()
        {
            Target.BeginAnimation(UIElement.OpacityProperty, null);

            Storyboard sb = new Storyboard();
            ThicknessAnimationUsingKeyFrames taNew = new ThicknessAnimationUsingKeyFrames();

            TimeSpan endTime = TimeSpan.FromSeconds(0.5);
            KeyTime kEnd = KeyTime.FromTimeSpan(endTime);

            taNew.BeginTime = TimeSpan.FromSeconds(0);
            Storyboard.SetTargetName(taNew, Target.Name);
            Storyboard.SetTargetProperty(taNew, new PropertyPath("(FrameworkElement.Margin)"));
            taNew.KeyFrames.Add(new SplineThicknessKeyFrame(old, TimeSpan.FromSeconds(0)));
            taNew.KeyFrames.Add(new SplineThicknessKeyFrame(novo, kEnd));
            sb.Children.Add(taNew);
            sb.BeginTime = TimeSpan.FromMilliseconds(Delay);

            sb.Begin(Target);
        }
예제 #18
0
 private void SwitchBetweenHomeAndMenu(bool toHome) {
     gridMa.Visibility = Visibility.Visible;
     var aniHome1 = new DoubleAnimation(toHome ? 1 : 0, TimeSpan.FromSeconds(0.15));
     var aniHome2 = new ThicknessAnimationUsingKeyFrames();
     aniHome2.KeyFrames.Add(new EasingThicknessKeyFrame(toHome ? new Thickness(0) : new Thickness(0, 410, 0, -410), TimeSpan.FromSeconds(0.15), new CubicEase() { EasingMode = EasingMode.EaseInOut}));
     var aniMenu1 = new ThicknessAnimationUsingKeyFrames();
     aniMenu1.KeyFrames.Add( new EasingThicknessKeyFrame( !toHome ? new Thickness(0) : new Thickness(0, 410, 0, -410), TimeSpan.FromSeconds(0.15), new CubicEase() { EasingMode = EasingMode.EaseInOut}));
     var aniMenu2 = new DoubleAnimation(!toHome ? 1 : 0, TimeSpan.FromSeconds(0.15));
     aniMenu2.Completed += delegate {
         gridMa.Visibility = toHome ? Visibility.Collapsed : Visibility.Visible;
     };
     //gridMa.BeginAnimation(MarginProperty, aniMenu1);
     gridMa.BeginAnimation(OpacityProperty, aniMenu2);
     gridHome.BeginAnimation(OpacityProperty, aniHome1);
     gridHome.BeginAnimation(MarginProperty, aniHome2);
 }
예제 #19
0
        private void SetGlowAnimation()
        {
            if (Indicator == null || glow == null || Indicator.ActualWidth.IsClose(currentAnimatedIndicatorWidth))
            {
                return;
            }

            currentAnimatedIndicatorWidth = Indicator.ActualWidth;

            double currentOffset = glow.Margin.Left;

            if (currentAnimationClock != null)
            {
                ((IAnimatable)glow).RootClock.RemoveClock(currentAnimationClock);
                currentAnimationClock = null;
            }

            if (Indicator.ActualWidth > 0)
            {
                double startOffset = -glow.ActualWidth;
                double endOffset = Indicator.ActualWidth;

                TimeSpan time = TimeSpan.FromSeconds((endOffset - startOffset) / 200);

                ThicknessAnimationUsingKeyFrames thicknessAnimation = new ThicknessAnimationUsingKeyFrames();

                thicknessAnimation.KeyFrames.Add(new LinearThicknessKeyFrame { Value = new Thickness(startOffset, 0, 0, 0), KeyTime = KeyTime.FromTimeSpan(TimeSpan.Zero) });
                thicknessAnimation.KeyFrames.Add(new LinearThicknessKeyFrame { Value = new Thickness(endOffset, 0, 0, 0), KeyTime = KeyTime.FromTimeSpan(time) });

                thicknessAnimation.Duration = new Duration(time + TimeSpan.FromSeconds(1));

                thicknessAnimation.RepeatBehavior = RepeatBehavior.Forever;
                thicknessAnimation.BeginTime = -time.Scale((currentOffset - startOffset) / (endOffset - startOffset));

                currentAnimationClock = (AnimationTimelineClock)thicknessAnimation.CreateClock();

                glow.ApplyAnimationClock(FrameworkElement.MarginProperty, currentAnimationClock);
                currentAnimationClock.Begin(((IAnimatable)glow).RootClock);
            }
            else
            {
                glow.ClearAnimationClocks(FrameworkElement.MarginProperty);
            }
        }
예제 #20
0
 public void addBalloonNotice(Notice.NoticeBalloon balloon) {
     panelBalloon.Children.Add(balloon);
     balloon.Margin = new Thickness(250, 0, -250, 0);
     var ani = new ThicknessAnimationUsingKeyFrames();
     ani.KeyFrames.Add(new EasingThicknessKeyFrame(new Thickness(250, 0, -250, 0), TimeSpan.FromSeconds(0)) { EasingFunction = new SineEase() {EasingMode = EasingMode.EaseInOut } });
     ani.KeyFrames.Add(new EasingThicknessKeyFrame(new Thickness(0), TimeSpan.FromSeconds(0.5)) { EasingFunction = new SineEase() { EasingMode = EasingMode.EaseInOut } });
     ani.KeyFrames.Add(new EasingThicknessKeyFrame(new Thickness(0), TimeSpan.FromSeconds(2.5)) { EasingFunction = new SineEase() { EasingMode = EasingMode.EaseInOut } });
     ani.KeyFrames.Add(new EasingThicknessKeyFrame(new Thickness(250, 0, -250, 0), TimeSpan.FromSeconds(3)) { EasingFunction = new SineEase() { EasingMode = EasingMode.EaseInOut } });
     ani.Completed += (obj, e)=> {
         panelBalloon.Children.Remove(balloon);
     };
     balloon.BeginAnimation(MarginProperty, ani);
 }
예제 #21
0
        //This creates the repeating animation
        private void UpdateAnimation()
        {
            if (_glow != null) 
            {
                if(IsVisible && (_glow.Width > 0) && (_indicator.Width > 0 ))
                {                
                    //Set up the animation
                    double endPos = _indicator.Width + _glow.Width; 
                    double startPos = -1 * _glow.Width;

                    TimeSpan translateTime = TimeSpan.FromSeconds(((int)(endPos - startPos) / 200.0)); // travel at 200px /second
                    TimeSpan pauseTime = TimeSpan.FromSeconds(1.0);  // pause 1 second between animations
                    TimeSpan startTime;

                    //Is the animation currenly running (with one pixel fudge factor)
                    if (DoubleUtil.GreaterThan( _glow.Margin.Left,startPos) && ( DoubleUtil.LessThan(_glow.Margin.Left, endPos-1)))
                    {
                        // make it appear that the timer already started.
                        // To do this find out how many pixels the glow has moved and divide by the speed to get time.
                        startTime = TimeSpan.FromSeconds(-1*(_glow.Margin.Left-startPos)/200.0);
                    }
                    else
                    {

                        startTime = TimeSpan.Zero;
                    }

                    ThicknessAnimationUsingKeyFrames animation = new ThicknessAnimationUsingKeyFrames();
                    
                    animation.BeginTime = startTime;
                    animation.Duration = new Duration(translateTime + pauseTime);
                    animation.RepeatBehavior = RepeatBehavior.Forever;
                    
                    //Start with the glow hidden on the left.
                    animation.KeyFrames.Add(new LinearThicknessKeyFrame(new Thickness(startPos,0,0,0), TimeSpan.FromSeconds(0)));
                    //Move to the glow hidden on the right.
                    animation.KeyFrames.Add(new LinearThicknessKeyFrame(new Thickness(endPos,0,0,0), translateTime));
                    //There is a pause after the glow is off screen

                    _glow.BeginAnimation(FrameworkElement.MarginProperty, animation); 
                }
                else
                {
                    _glow.BeginAnimation(FrameworkElement.MarginProperty, null);
                }
            }
        }
예제 #22
0
 internal async System.Threading.Tasks.Task<Grid> ChangePage(string type, bool required0Margin = false)
 {
     MahApps.Metro.Controls.Tile tile;
     Grid grid;
     switch (type)
     {
         case "settings":
         case "setting":
             tile = butSetting;
             grid = new Settings();
             break;
         case "play":
             tile = butPlay;
             grid = new PlayNew();
             break;
         case "download":
             tile = butDL;
             grid = reserve_dl ?? (reserve_dl = new Download());
             break;
         case "tasklist":
             tile = butTask;
             grid = new TaskList();
             break;
         case "notice":
             tile = butNotice;
             grid = new Notice.Notice();
             break;
         case "server":
             tile = butServer;
             grid = new Server.Server();
             break;
         case "install":
             tile = butInstall;
             grid = new Install.GridInstall();
             break;
         case "gradle":
             tile = butGradle;
             grid = new Gradle.GridGradle();
             break;
         case "help":
             tile = butHelp;
             grid = new Help.GridHelp();
             break;
         default:
             return new Grid();
     }
     gridOthers.Children.Clear();
     ((Rectangle)gridLoadingScreen.Children[0]).OpacityMask = ((Rectangle)tile.GetValue(ContentProperty)).OpacityMask;
     ((Rectangle)gridLoadingScreen.Children[0]).Width = ((Rectangle)tile.GetValue(ContentProperty)).Width * 2;
     ((Rectangle)gridLoadingScreen.Children[0]).Height = ((Rectangle)tile.GetValue(ContentProperty)).Height * 2;
     gridLoadingScreen.Margin = new Thickness(gridMain.Margin.Left + gridMenu.Margin.Left + tile.Margin.Left, gridMain.Margin.Top + gridMenu.Margin.Top + tile.Margin.Top, gridMain.Margin.Right + gridMenu.Margin.Right + (gridMenu.Width - tile.Width - tile.Margin.Left), gridMain.Margin.Bottom + gridMenu.Margin.Bottom + (gridMenu.Height - tile.Height - tile.Margin.Top));
     gridLoadingScreen.Background = new SolidColorBrush(Color.FromRgb(((SolidColorBrush)tile.Background).Color.R, ((SolidColorBrush)tile.Background).Color.G, ((SolidColorBrush)tile.Background).Color.B));
     gridLoadingScreen.Visibility = Visibility.Visible;
     var ani = new ThicknessAnimationUsingKeyFrames();
     ani.KeyFrames.Add(new EasingThicknessKeyFrame(new Thickness(gridMain.Margin.Left + gridMenu.Margin.Left + tile.Margin.Left, gridMain.Margin.Top + gridMenu.Margin.Top + tile.Margin.Top, gridMain.Margin.Right + gridMenu.Margin.Right + (gridMenu.Width - tile.Width - tile.Margin.Left), gridMain.Margin.Bottom + gridMenu.Margin.Bottom + (gridMenu.Height - tile.Height - tile.Margin.Top)), KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)), new ExponentialEase() { EasingMode = EasingMode.EaseInOut, Exponent = 9 }));
     ani.KeyFrames.Add(new EasingThicknessKeyFrame(new Thickness(0), KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.2)), new ExponentialEase() { EasingMode = EasingMode.EaseInOut, Exponent = 9 }));
     gridLoadingScreen.BeginAnimation(MarginProperty, ani);
     await System.Threading.Tasks.TaskEx.Delay(1000);
     gridMain.Visibility = Visibility.Collapsed;
     gridLoadingScreen.Visibility = Visibility.Collapsed;
     gridOthers.Visibility = Visibility.Visible;
     gridOthers.Children.Add(grid);
     gridOthers.Margin = required0Margin ? new Thickness(0) : new Thickness(30, 0, 30, 30);
     var ani2 = new DoubleAnimationUsingKeyFrames();
     ani2.KeyFrames.Add(new LinearDoubleKeyFrame(0, TimeSpan.FromSeconds(0)));
     ani2.KeyFrames.Add(new LinearDoubleKeyFrame(1, TimeSpan.FromSeconds(0.2)));
     gridOthers.BeginAnimation(OpacityProperty, ani2);
     return grid;
 }