public MaterialSwitch()
        {
            InitializeComponent();

            On  = new ThicknessAnimationUsingKeyFrames();
            Off = new ThicknessAnimationUsingKeyFrames();
            var col = new Color();

            switch (TCTData.Settings.Theme)
            {
            case TCTData.Enums.Theme.Light:
                col = TCTData.Colors.LightTheme_Card;
                break;

            case TCTData.Enums.Theme.Dark:
                col = TCTData.Colors.DarkTheme_Card;

                break;

            default:
                break;
            }


            OnFill      = new ColorAnimation(col, TCTData.Colors.SolidAccentColor, TimeSpan.FromMilliseconds(150));
            OffFill     = new ColorAnimation(TCTData.Colors.SolidAccentColor, col, TimeSpan.FromMilliseconds(150));
            OnBackFill  = new ColorAnimation(TCTData.Colors.FadedGray, TCTData.Colors.FadedAccentColor, TimeSpan.FromMilliseconds(150));
            OffBackFill = new ColorAnimation(TCTData.Colors.FadedAccentColor, TCTData.Colors.FadedGray, TimeSpan.FromMilliseconds(150));
            On.KeyFrames.Add(new SplineThicknessKeyFrame(new Thickness(20, 0, 0, 0), TimeSpan.FromMilliseconds(220), new KeySpline(.5, 0, .3, 1)));
            Off.KeyFrames.Add(new SplineThicknessKeyFrame(new Thickness(-20, 0, 0, 0), TimeSpan.FromMilliseconds(220), new KeySpline(.5, 0, .3, 1)));
        }
Exemplo n.º 2
0
        private void dropFeedback(object sender, MouseButtonEventArgs e)
        {
            var g = (Grid)sender;

            if (g.Children.Contains(TeraMainWindow.FindChild <Ellipse>(g, "droplet")))
            {
                g.Children.Remove(TeraMainWindow.FindChild <Ellipse>(g, "droplet"));
            }
            var el = new Ellipse();

            el.Name = "droplet";
            el.BeginAnimation(WidthProperty, null);
            el.BeginAnimation(HeightProperty, null);
            el.BeginAnimation(MarginProperty, null);
            el.BeginAnimation(OpacityProperty, null);
            el.HorizontalAlignment = HorizontalAlignment.Left;
            el.VerticalAlignment   = VerticalAlignment.Top;
            el.Fill    = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
            el.Opacity = 1;
            Grid.SetColumnSpan(el, g.ColumnDefinitions.Count);

            g.Children.Add(el);


            var p        = Mouse.GetPosition(g);
            var animTime = 450;

            el.Width  = 1;
            el.Height = 1;
            el.Margin = new Thickness(p.X, p.Y, 0, 0);



            double x      = 500;
            var    sizeAn = new DoubleAnimationUsingKeyFrames();

            sizeAn.KeyFrames.Add(new SplineDoubleKeyFrame(x, TimeSpan.FromMilliseconds(animTime * 1.2), new KeySpline(.5, 0, .3, 1)));
            sizeAn.AutoReverse = true;

            sizeAn.Completed += (a, b) =>
            {
                g.Children.Remove(el);
            };

            var marginAn = new ThicknessAnimationUsingKeyFrames();

            marginAn.KeyFrames.Add(new SplineThicknessKeyFrame(new Thickness(p.X - (x / 2), p.Y - (x / 2), 0, 0), TimeSpan.FromMilliseconds(animTime * 1.1), new KeySpline(.5, 0, .3, 1)));
            marginAn.AutoReverse = true;

            var opacityAn = new DoubleAnimationUsingKeyFrames();

            opacityAn.KeyFrames.Add(new SplineDoubleKeyFrame(.1, TimeSpan.FromMilliseconds(animTime * .1), new KeySpline(.5, 0, .3, 1)));
            opacityAn.KeyFrames.Add(new SplineDoubleKeyFrame(0, TimeSpan.FromMilliseconds(animTime * .9), new KeySpline(.5, 0, .3, 1)));


            el.BeginAnimation(WidthProperty, sizeAn);
            el.BeginAnimation(HeightProperty, sizeAn);
            el.BeginAnimation(MarginProperty, marginAn);
            el.BeginAnimation(OpacityProperty, opacityAn);
        }
Exemplo n.º 3
0
        private void B_Snapshot_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                mainViewModel.TakeSnapshot();

                /*FLog.Log("B_Snapshot_Click");
                 * string dataName = FindLast_Photo(SavePhoto_dir, (TB_FIO.Text + "_" + TB_CurrentDate.Text + "_" + TB_HistoryNumber.Text), ".tiff");
                 * string FullPathAndName = dataName;
                 * IC_Control.MemorySaveImage(FullPathAndName);*/

                //запустить анимаицю
                ThicknessAnimationUsingKeyFrames thicknessAnimationUsingKeyFrames = new ThicknessAnimationUsingKeyFrames();
                thicknessAnimationUsingKeyFrames.KeyFrames.Add(new DiscreteThicknessKeyFrame(new Thickness(0, 0, 0, 0), KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0, 0, 50))));
                thicknessAnimationUsingKeyFrames.KeyFrames.Add(new DiscreteThicknessKeyFrame(new Thickness(4, 4, 4, 4), KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0, 0, 200))));
                thicknessAnimationUsingKeyFrames.KeyFrames.Add(new DiscreteThicknessKeyFrame(new Thickness(0, 0, 0, 0), KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0, 0, 50))));
                thicknessAnimationUsingKeyFrames.AutoReverse  = false;
                thicknessAnimationUsingKeyFrames.FillBehavior = FillBehavior.Stop;
                thicknessAnimationUsingKeyFrames.Duration     = new Duration(new TimeSpan(0, 0, 0, 0, 500));

                ThicknessAnimation thicknessAnimation = new ThicknessAnimation(new Thickness(0, 0, 0, 0),
                                                                               new Thickness(2, 2, 2, 2),
                                                                               new TimeSpan(0, 0, 0, 0, 300),
                                                                               FillBehavior.Stop);
                thicknessAnimation.AutoReverse = true;
                border_host.BeginAnimation(Border.BorderThicknessProperty, thicknessAnimationUsingKeyFrames);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 4
0
 // Token: 0x06005494 RID: 21652 RVA: 0x00176A14 File Offset: 0x00174C14
 private void UpdateAnimation()
 {
     if (this._glow != null)
     {
         if (base.IsVisible && this._glow.Width > 0.0 && this._indicator.Width > 0.0)
         {
             double   num      = this._indicator.Width + this._glow.Width;
             double   num2     = -1.0 * this._glow.Width;
             TimeSpan timeSpan = TimeSpan.FromSeconds((double)((int)(num - num2)) / 200.0);
             TimeSpan t        = TimeSpan.FromSeconds(1.0);
             TimeSpan value;
             if (DoubleUtil.GreaterThan(this._glow.Margin.Left, num2) && DoubleUtil.LessThan(this._glow.Margin.Left, num - 1.0))
             {
                 value = TimeSpan.FromSeconds(-1.0 * (this._glow.Margin.Left - num2) / 200.0);
             }
             else
             {
                 value = TimeSpan.Zero;
             }
             ThicknessAnimationUsingKeyFrames thicknessAnimationUsingKeyFrames = new ThicknessAnimationUsingKeyFrames();
             thicknessAnimationUsingKeyFrames.BeginTime      = new TimeSpan?(value);
             thicknessAnimationUsingKeyFrames.Duration       = new Duration(timeSpan + t);
             thicknessAnimationUsingKeyFrames.RepeatBehavior = RepeatBehavior.Forever;
             thicknessAnimationUsingKeyFrames.KeyFrames.Add(new LinearThicknessKeyFrame(new Thickness(num2, 0.0, 0.0, 0.0), TimeSpan.FromSeconds(0.0)));
             thicknessAnimationUsingKeyFrames.KeyFrames.Add(new LinearThicknessKeyFrame(new Thickness(num, 0.0, 0.0, 0.0), timeSpan));
             this._glow.BeginAnimation(FrameworkElement.MarginProperty, thicknessAnimationUsingKeyFrames);
             return;
         }
         this._glow.BeginAnimation(FrameworkElement.MarginProperty, null);
     }
 }
 private void UpdateAnimation(object sender, SizeChangedEventArgs e)
 {
     if (glow == null)
     {
         return;
     }
     if ((IsVisible && (glow.Width > 0.0)) && (indicator.Width > 0.0))
     {
         double   left = indicator.Width + glow.Width, num2 = -1.0 * glow.Width;
         TimeSpan keyTime = TimeSpan.FromSeconds((int)(left - num2) / 200.0), span2 = TimeSpan.FromSeconds(1.0), zero;
         if (glow.Margin.Left > num2 && glow.Margin.Left < left - 1.0)
         {
             zero = TimeSpan.FromSeconds((-1.0 * (glow.Margin.Left - num2)) / 200.0);
         }
         else
         {
             zero = TimeSpan.Zero;
         }
         var animation = new ThicknessAnimationUsingKeyFrames
         {
             BeginTime = zero, Duration = new Duration(keyTime + span2), RepeatBehavior = RepeatBehavior.Forever
         };
         animation.KeyFrames.Add(new LinearThicknessKeyFrame(new Thickness(num2, 0.0, 0.0, 0.0), TimeSpan.FromSeconds(0.0)));
         animation.KeyFrames.Add(new LinearThicknessKeyFrame(new Thickness(left, 0.0, 0.0, 0.0), keyTime));
         glow.BeginAnimation(MarginProperty, animation);
     }
     else
     {
         glow.BeginAnimation(MarginProperty, null);
     }
 }
        protected void PrepareAnimation(ContentControl view, double contentHeight, ChildWindowAnimation animationType = ChildWindowAnimation.None)
        {
            switch (animationType)
            {
            case ChildWindowAnimation.Fade:
                var fadeDa = new DoubleAnimation(0, 1, new Duration(defaultAnimationTime));
                Storyboard.SetTarget(fadeDa, view);
                Storyboard.SetTargetProperty(fadeDa, new PropertyPath("Opacity"));

                var fadeSb = new Storyboard();
                fadeSb.Children.Add(fadeDa);
                fadeSb.Begin();
                break;

            case ChildWindowAnimation.Grown:
                var scale          = new ScaleTransform(0.1, 0.1);
                var transformGroup = new TransformGroup();
                transformGroup.Children.Add(scale);
                view.RenderTransform       = transformGroup;
                view.RenderTransformOrigin = new Point(0.5, 0.5);

                var xScaleAnimation = new DoubleAnimationUsingKeyFrames();
                var xKeyFrame       = new EasingDoubleKeyFrame(1, KeyTime.FromTimeSpan(defaultAnimationTime));
                xScaleAnimation.KeyFrames = new DoubleKeyFrameCollection {
                    xKeyFrame
                };
                Storyboard.SetTarget(xScaleAnimation, view);
                Storyboard.SetTargetProperty(xScaleAnimation, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"));

                var yScaleAnimation = new DoubleAnimationUsingKeyFrames();
                var yKeyFrame       = new EasingDoubleKeyFrame(1, KeyTime.FromTimeSpan(defaultAnimationTime));
                yScaleAnimation.KeyFrames = new DoubleKeyFrameCollection {
                    yKeyFrame
                };
                Storyboard.SetTarget(yScaleAnimation, view);
                Storyboard.SetTargetProperty(yScaleAnimation, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"));

                var grownSb = new Storyboard();
                grownSb.Children.Add(xScaleAnimation);
                grownSb.Children.Add(yScaleAnimation);
                grownSb.Begin();
                break;

            case ChildWindowAnimation.Fall:
                view.Margin = new Thickness(0, (-1) * contentHeight, 0, contentHeight);

                var fallAnimation = new ThicknessAnimationUsingKeyFrames();
                var fallKeyFrame  = new EasingThicknessKeyFrame(new Thickness(0), KeyTime.FromTimeSpan(defaultAnimationTime));
                fallAnimation.KeyFrames = new ThicknessKeyFrameCollection {
                    fallKeyFrame
                };
                Storyboard.SetTarget(fallAnimation, view);
                Storyboard.SetTargetProperty(fallAnimation, new PropertyPath("(FrameworkElement.Margin)"));
                var fallSb = new Storyboard();
                fallSb.Children.Add(fallAnimation);
                fallSb.Begin();
                break;
            }
        }
Exemplo n.º 7
0
        private void ListBoxItem_MouseEnter(object sender, MouseEventArgs e)
        {
            if (TblockSongSelected != null)
            {
                storyboard.Pause(this);
                storyboard.Stop(this);
                TblockSongSelected.Text   = SourceTbTitleText;
                TblockSongSelected.Margin = SourceTbTitleMargin;
            }

            var item = e.OriginalSource as ListBoxItem;

            //set button trai tim
            SongModel songSelected = item.Content as SongModel;

            if (songSelected.IsFavorite == 1)
            {
                List <Control> list_button    = GetSpecificControl.AllChildren(item);
                Button         ButtonFavorite = list_button.Find(btn => btn.Name == "BtnFavorite") as Button;
                Style          newStyle       = (Style)FindResource("ButtonFavoriteSongFill");
                ButtonFavorite.Style = newStyle;
            }


            ListViewSong.SelectedItem = item;
            TblockSongSelected        = GetSpecificControl.GetChildOfType <TextBlock>(item);
            SourceTbTitleText         = TblockSongSelected.Text;


            Thickness originalMargin = TblockSongSelected.Margin;
            Thickness secondMargin   = originalMargin;

            TblockSongSelected.Text += "         ";
            secondMargin.Left        = -MyFunction.MeasureString(TblockSongSelected.Text, TblockSongSelected) + 20;
            TblockSongSelected.Text += TblockSongSelected.Text += TblockSongSelected.Text;



            myAnimation = new ThicknessAnimationUsingKeyFrames();
            Storyboard.SetTargetName(myAnimation, "test");
            Storyboard.SetTargetProperty(myAnimation, new PropertyPath(Rectangle.MarginProperty));

            myAnimation.KeyFrames.Add(new SplineThicknessKeyFrame(originalMargin, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0))));
            myAnimation.KeyFrames.Add(new SplineThicknessKeyFrame(secondMargin, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(5))));
            myAnimation.KeyFrames.Add(new SplineThicknessKeyFrame(secondMargin, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(6))));

            myAnimation.RepeatBehavior = RepeatBehavior.Forever;
            TblockSongSelected.Name    = "TB" + MyFunction.GenerateCode();
            this.RegisterName(TblockSongSelected.Name, TblockSongSelected);

            Storyboard.SetTargetName(myAnimation, TblockSongSelected.Name);
            Storyboard.SetTargetProperty(myAnimation, new PropertyPath(TextBlock.MarginProperty));

            storyboard = new Storyboard();
            storyboard.Children.Add(myAnimation);

            storyboard.Begin(this, true);
        }
        private void Play()
        {
            ThicknessAnimationUsingKeyFrames thicknessAnimation = new ThicknessAnimationUsingKeyFrames()
            {
                Duration       = TimeSpan.FromSeconds(6),
                RepeatBehavior = RepeatBehavior.Forever,
            };

            thicknessAnimation.KeyFrames.Add(new LinearThicknessKeyFrame(new Thickness(0, 20, 0, 0), KeyTime.FromTimeSpan(TimeSpan.FromSeconds(4))));
            thicknessAnimation.KeyFrames.Add(new LinearThicknessKeyFrame(new Thickness(0, 20, 0, 0), KeyTime.FromTimeSpan(TimeSpan.FromSeconds(5))));
            thicknessAnimation.KeyFrames.Add(new LinearThicknessKeyFrame(new Thickness(0, 100, 0, 0), KeyTime.FromTimeSpan(TimeSpan.FromSeconds(5.5))));
            this.tbName.BeginAnimation(TextBlock.MarginProperty, thicknessAnimation);
        }
Exemplo n.º 9
0
        private void tabSelected(object sender, MouseButtonEventArgs e)
        {
            string         x = (sender as Grid).Tag.ToString().ToLower();
            TeraMainWindow w = (TeraMainWindow)TeraMainWindow.GetWindow(this);
            // w.switchTab(x);

            /*close after choice*/
            ThicknessAnimationUsingKeyFrames an = new ThicknessAnimationUsingKeyFrames();

            an.KeyFrames.Add(new SplineThicknessKeyFrame(new Thickness(-420, 0, 0, 0), TimeSpan.FromMilliseconds(220), new KeySpline(.5, 0, .3, 1)));
            //TeraMainWindow.leftSlideIsOpen = false;
            this.BeginAnimation(MarginProperty, an);
        }
Exemplo n.º 10
0
        public void ShowErrorMsg(string msg) // maniulates with error msg label
        {
            var anim = new ThicknessAnimationUsingKeyFrames();

            errorTb.Text = msg;


            anim.KeyFrames.Add(new LinearThicknessKeyFrame(new Thickness(0, 60, 0, 0), KeyTime.FromPercent(0.4)));
            anim.Duration    = TimeSpan.FromSeconds(0.8);
            anim.AutoReverse = true;

            errorTb.BeginAnimation(TextBlock.MarginProperty, anim);
        }
Exemplo n.º 11
0
        void ChangeGrid(FrameworkElement firstElement, FrameworkElement secondElement, bool changeSide)
        {
            StBoard?.Begin(this, true);

            var ticknessLeft   = new Thickness(Width, 0, -Width, 0);
            var ticknessRight  = new Thickness(-Width, 0, Width, 0);
            var ticknessClient = new Thickness(0, 0, 0, 0);

            var timeSpanStarting = TimeSpan.FromSeconds(0);
            var timeSpanStopping = TimeSpan.FromSeconds(1);

            var keyTimeStarting = KeyTime.FromTimeSpan(timeSpanStarting);
            var keyTimeStopping = KeyTime.FromTimeSpan(timeSpanStopping);

            secondElement.Margin     = changeSide ? ticknessRight : ticknessLeft;
            secondElement.Visibility = Visibility.Visible;

            var storyboardTemp = new Storyboard();

            var currentThicknessAnimationUsingKeyFrames = new ThicknessAnimationUsingKeyFrames {
                BeginTime = timeSpanStarting
            };

            Storyboard.SetTargetName(currentThicknessAnimationUsingKeyFrames, firstElement.Name);
            Storyboard.SetTargetProperty(currentThicknessAnimationUsingKeyFrames, new PropertyPath("(FrameworkElement.Margin)"));
            currentThicknessAnimationUsingKeyFrames.KeyFrames.Add(new SplineThicknessKeyFrame(ticknessClient, keyTimeStarting));
            currentThicknessAnimationUsingKeyFrames.KeyFrames.Add(new SplineThicknessKeyFrame(changeSide ? ticknessLeft : ticknessRight, keyTimeStopping));

            storyboardTemp.Children.Add(currentThicknessAnimationUsingKeyFrames);

            var nextThicknessAnimationUsingKeyFrames = new ThicknessAnimationUsingKeyFrames {
                BeginTime = timeSpanStarting
            };

            Storyboard.SetTargetName(nextThicknessAnimationUsingKeyFrames, secondElement.Name);
            Storyboard.SetTargetProperty(nextThicknessAnimationUsingKeyFrames, new PropertyPath("(FrameworkElement.Margin)"));
            nextThicknessAnimationUsingKeyFrames.KeyFrames.Add(new SplineThicknessKeyFrame(changeSide ? ticknessRight : ticknessLeft, keyTimeStarting));
            nextThicknessAnimationUsingKeyFrames.KeyFrames.Add(new SplineThicknessKeyFrame(ticknessClient, keyTimeStopping));

            storyboardTemp.Children.Add(nextThicknessAnimationUsingKeyFrames);

            storyboardTemp.Completed += delegate

            {
                firstElement.Visibility = Visibility.Hidden;
                StBoard = null;
            };

            StBoard = storyboardTemp;
            BeginStoryboard(storyboardTemp);
        }
Exemplo n.º 12
0
 /// <summary>
 /// 提示
 /// </summary>
 /// <param name="element"></param>
 /// <param name="msg"></param>
 /// <param name="outMillisecond"></param>
 public static void Show(FrameworkElement element, string msg, double outMillisecond)
 {
     element?.Dispatcher.Invoke(() =>
     {
         FrameworkElement host = GetMessageWindow(element);
         var messagePanel      = GetMessagePanel(host);
         if (messagePanel != null)
         {
             var mimicryControl      = new MimicryControl();
             mimicryControl.Padding  = new Thickness(10, 5, 10, 5);
             mimicryControl.FontSize = 18;
             var tips                = new TextBlock();
             tips.Text               = msg;
             tips.TextWrapping       = TextWrapping.Wrap;
             mimicryControl.Content  = tips;
             mimicryControl.MinWidth = 120;
             mimicryControl.MaxWidth = 360;
             mimicryControl.Loaded  += (sen, r) =>
             {
                 mimicryControl.Margin     = new Thickness(0, -mimicryControl.ActualHeight - 10, 0, 0);
                 var moveTime              = 500;
                 var marginAnimation       = new ThicknessAnimationUsingKeyFrames();
                 marginAnimation.KeyFrames = new ThicknessKeyFrameCollection();
                 marginAnimation.KeyFrames.Add(new LinearThicknessKeyFrame {
                     KeyTime = TimeSpan.FromMilliseconds(moveTime), Value = new Thickness(0)
                 });
                 var opacityAnimation       = new DoubleAnimationUsingKeyFrames();
                 opacityAnimation.KeyFrames = new DoubleKeyFrameCollection();
                 opacityAnimation.KeyFrames.Add(new LinearDoubleKeyFrame()
                 {
                     KeyTime = TimeSpan.FromMilliseconds(moveTime), Value = 1
                 });
                 opacityAnimation.KeyFrames.Add(new LinearDoubleKeyFrame()
                 {
                     KeyTime = TimeSpan.FromMilliseconds(outMillisecond + moveTime - 500), Value = 0.7
                 });
                 opacityAnimation.KeyFrames.Add(new LinearDoubleKeyFrame()
                 {
                     KeyTime = TimeSpan.FromMilliseconds(outMillisecond + moveTime), Value = 0
                 });
                 opacityAnimation.Completed += (s, e) =>
                 {
                     messagePanel.Children.Remove(mimicryControl);
                 };
                 mimicryControl.BeginAnimation(FrameworkElement.MarginProperty, marginAnimation);
                 mimicryControl.BeginAnimation(UIElement.OpacityProperty, opacityAnimation);
             };
             messagePanel.Children.Add(mimicryControl);
         }
     });
 }
Exemplo n.º 13
0
        //This creates the repeating animation
        private void UpdateAnimation()
        {
            if (_glow != null)
            {
                if (IsVisible &&
                    (_glow.Width > 0) &&
                    (_indicator.Width > 0) &&
                    (_value < Max || StepItems.Any(s => s.Value > 0 && s.KeepGlowEffect && IsUserVisible(s, this))))
                {
                    //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 (_glow.Margin.Left >= startPos && _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);
                }
            }
        }
Exemplo n.º 14
0
        void ScreenSelector(FrameworkElement currentElement, FrameworkElement toNextElement, bool side)
        {
            _storyboard?.Begin(this, true);
            var ticknessLeft   = new Thickness(Width, 0, -Width, 0);
            var ticknessRight  = new Thickness(-Width, 0, Width, 0);
            var ticknessClient = new Thickness(0, 0, 0, 0);

            var timeSpanStarting = TimeSpan.FromSeconds(0);
            var timeSpanStopping = TimeSpan.FromSeconds(0.5);

            var keyTimeStarting = KeyTime.FromTimeSpan(timeSpanStarting);
            var keyTimeStopping = KeyTime.FromTimeSpan(timeSpanStopping);

            toNextElement.Margin     = side ? ticknessRight : ticknessLeft;
            toNextElement.Visibility = Visibility.Visible;

            var storyboardTemp = new Storyboard();

            var currentThicknessAnimationUsingKeyFrames = new ThicknessAnimationUsingKeyFrames {
                BeginTime = timeSpanStarting
            };

            Storyboard.SetTargetName(currentThicknessAnimationUsingKeyFrames, currentElement.Name);
            Storyboard.SetTargetProperty(currentThicknessAnimationUsingKeyFrames, new PropertyPath("(FrameworkElement.Margin)"));
            currentThicknessAnimationUsingKeyFrames.KeyFrames.Add(new SplineThicknessKeyFrame(ticknessClient, keyTimeStarting));
            currentThicknessAnimationUsingKeyFrames.KeyFrames.Add(new SplineThicknessKeyFrame(side ? ticknessLeft : ticknessRight, keyTimeStopping));

            storyboardTemp.Children.Add(currentThicknessAnimationUsingKeyFrames);

            var nextThicknessAnimationUsingKeyFrames = new ThicknessAnimationUsingKeyFrames {
                BeginTime = timeSpanStarting
            };

            Storyboard.SetTargetName(nextThicknessAnimationUsingKeyFrames, toNextElement.Name);
            Storyboard.SetTargetProperty(nextThicknessAnimationUsingKeyFrames, new PropertyPath("(FrameworkElement.Margin)"));
            nextThicknessAnimationUsingKeyFrames.KeyFrames.Add(new SplineThicknessKeyFrame(side ? ticknessRight : ticknessLeft, keyTimeStarting));
            nextThicknessAnimationUsingKeyFrames.KeyFrames.Add(new SplineThicknessKeyFrame(ticknessClient, keyTimeStopping));

            storyboardTemp.Children.Add(nextThicknessAnimationUsingKeyFrames);

            storyboardTemp.Completed += (EventHandler) delegate
            {
                currentElement.Visibility = Visibility.Hidden;
                _storyboard = null;
            };

            _storyboard = storyboardTemp;
            BeginStoryboard(storyboardTemp);
        }
Exemplo n.º 15
0
        public override void CreateStoryboard()
        {
            ThicknessAnimationUsingKeyFrames dau = new ThicknessAnimationUsingKeyFrames();

            EasingThicknessKeyFrame fromk = null;

            if (FromThickness.HasValue)
            {
                fromk = new EasingThicknessKeyFrame(FromThickness.Value, TimeSpan.FromMilliseconds(AniTime(0)));
                dau.KeyFrames.Add(fromk);
            }
            EasingThicknessKeyFrame tok = null;

            if (ToThickness.HasValue)
            {
                tok = new EasingThicknessKeyFrame(ToThickness.Value, TimeSpan.FromMilliseconds(AniTime(1)));
                dau.KeyFrames.Add(tok);
            }


            if (AniEasingFunction != null)
            {
                if (fromk != null)
                {
                    fromk.EasingFunction = AniEasingFunction;
                }
                if (tok != null)
                {
                    tok.EasingFunction = AniEasingFunction;
                }
            }
            else if (CirDefault != null)
            {
                if (fromk != null)
                {
                    fromk.EasingFunction = CirDefault;
                }
                if (tok != null)
                {
                    tok.EasingFunction = CirDefault;
                }
            }


            Storyboard.SetTarget(dau, Element);
            SetPropertyPath(FrameworkElement.MarginProperty);
            Storyboard.SetTargetProperty(dau, AniPropertyPath);
            Story.Children.Add(dau);
        }
Exemplo n.º 16
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);
            }
        }
Exemplo n.º 17
0
        public void ShowSuccessMsg(string msg)
        {
            if (errorTb.Margin == (new Thickness(0, 70, 0, 0)))
            {
                var anim = new ThicknessAnimationUsingKeyFrames();

                errorTb.Text       = msg;
                errorTb.Background = new SolidColorBrush(SuccessBackgroundColor);
                errorTb.Foreground = new SolidColorBrush(SuccessForegroundColor);

                anim.KeyFrames.Add(new LinearThicknessKeyFrame(new Thickness(0, 0, 0, 0), KeyTime.FromPercent(0.4)));
                anim.Duration    = TimeSpan.FromSeconds(0.8);
                anim.AutoReverse = true;

                errorTb.BeginAnimation(TextBlock.MarginProperty, anim);
            }
        }
Exemplo n.º 18
0
        private void LeftSlideToggle(object sender, MouseButtonEventArgs e)
        {
            ThicknessAnimationUsingKeyFrames an = new ThicknessAnimationUsingKeyFrames();

            if (!leftSlideIsOpen)
            {
                an.KeyFrames.Add(new SplineThicknessKeyFrame(new Thickness(0), TimeSpan.FromMilliseconds(220), new KeySpline(.5, 0, .3, 1)));
                leftSlideIsOpen = true;
            }
            else
            {
                an.KeyFrames.Add(new SplineThicknessKeyFrame(new Thickness(-420, 0, 0, 0), TimeSpan.FromMilliseconds(220), new KeySpline(.5, 0, .3, 1)));
                leftSlideIsOpen = false;
            }

            leftSlide1.BeginAnimation(MarginProperty, an);
        }
Exemplo n.º 19
0
        /// <summary>
        /// 生成一个 ThicknessAnimationUsingKeyFrames 对象
        /// </summary>
        /// <param name="dWeight">当前位置时间间隔系数的权重加值</param>
        /// <returns>返回一个新的 ThicknessAnimationUsingKeyFrames 对象</returns>
        private ThicknessAnimationUsingKeyFrames CreateThicknessAnimationUsingKeyFrames(double dWeight)
        {
            ThicknessAnimationUsingKeyFrames thicknessAUKF = new ThicknessAnimationUsingKeyFrames();

            thicknessAUKF.BeginTime = TimeSpan.Zero;
            string[] ellipseXNames = Enum.GetNames(typeof(ProgressBarEnum));
            foreach (string xName in ellipseXNames)
            {
                KeyValuePair <Thickness, double> thicknessDic =
                    this.GetEllipseLeftMargin((ProgressBarEnum)Enum.Parse(typeof(ProgressBarEnum), xName)).FirstOrDefault();
                Thickness ellipseLeftMargin = thicknessDic.Key;
                KeyTime   kTime             = this.GetKeyTime(thicknessDic.Value + dWeight);

                thicknessAUKF.KeyFrames.Add(CreateSplineThicknessKeyFrame(kTime, ellipseLeftMargin));
            }

            return(thicknessAUKF);
        }
Exemplo n.º 20
0
        /// <summary>
        /// 窗体加载完成后初始化故事板:Storyboard
        /// </summary>
        private void InitializeStoryboard()
        {
            this._storyboard.RepeatBehavior = RepeatBehavior.Forever;
            this._storyboard.Name           = "ellipseStoryLeftToRight";

            double dWeight = 0d;

            foreach (Ellipse e in this._ellipses)
            {
                dWeight += 0.4;
                ThicknessAnimationUsingKeyFrames thicknessAUKF = CreateThicknessAnimationUsingKeyFrames(dWeight);

                Storyboard.SetTarget(thicknessAUKF, e);
                Storyboard.SetTargetName(thicknessAUKF, e.Name);
                Storyboard.SetTargetProperty(thicknessAUKF, new PropertyPath(Ellipse.MarginProperty));
                this._storyboard.Children.Add(thicknessAUKF);
            }
        }
Exemplo n.º 21
0
        public void addThicknessAnimation(String control, double a, double b, double c, double d, int duration)
        {
            ThicknessAnimationUsingKeyFrames anim = new ThicknessAnimationUsingKeyFrames();
            EasingThicknessKeyFrame          edkf = new EasingThicknessKeyFrame();

            edkf.Value   = new Thickness(a, b, c, d);
            edkf.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(duration));
            anim.KeyFrames.Add(edkf);
            anim.BeginTime = TimeSpan.FromSeconds(beginTime);
            beginTime     += duration;
            if (duration > 0)
            {
                animTimer.Add(beginTime);
            }
            Storyboard.SetTargetName(anim, control);
            Storyboard.SetTargetProperty(anim, new PropertyPath(Control.MarginProperty));
            sb.Children.Add(anim);
        }
Exemplo n.º 22
0
        public void CloseAnim()
        {
            this.Dispatcher.Invoke(() =>
            {
                ThicknessAnimationUsingKeyFrames close = new ThicknessAnimationUsingKeyFrames();
                close.KeyFrames.Add(new SplineThicknessKeyFrame(new Thickness(StartingThickness, 0, 0, 0), TimeSpan.FromMilliseconds(300), new KeySpline(.5, 0, .3, 1)));
                close.Completed += (s, o) =>
                {
                    NotificationHolder.BeginAnimation(Grid.MarginProperty, null);
                    Hide();
                    ni.SetDelivered();
                    NotificationProvider.deliveredNotifications.Add(ni);
                    NotificationProvider.NQ.Remove(ni);
                    NotificationProvider.NQ.SetBusyToFalseOnEnd();
                };

                NotificationHolder.BeginAnimation(Grid.MarginProperty, close);
            });
        }
Exemplo n.º 23
0
        private void UpdateAnimation()
        {
            if (_track == null || _indicator == null)
            {
                return;
            }

            if (!IsVisible || !IsInProgress || IsErrored)
            {
                _indicator.BeginAnimation(MarginProperty, null);

                return;
            }

            var to   = _track.ActualWidth;
            var from = -1 * _indicator.Width;

            var translateTime = TimeSpan.FromSeconds((int)(to - from) / 200.0);
            var pauseTime     = TimeSpan.FromSeconds(1.0);

            TimeSpan startTime;

            if (_indicator.Margin.Left > from && _indicator.Margin.Left < to - 1)
            {
                startTime = TimeSpan.FromSeconds(-1 * (_indicator.Margin.Left - from) / 200.0);
            }
            else
            {
                startTime = TimeSpan.Zero;
            }

            var animation = new ThicknessAnimationUsingKeyFrames
            {
                BeginTime      = startTime,
                Duration       = new Duration(translateTime + pauseTime),
                RepeatBehavior = RepeatBehavior.Forever
            };

            animation.KeyFrames.Add(new LinearThicknessKeyFrame(new Thickness(from, 0, 0, 0), TimeSpan.FromSeconds(0)));
            animation.KeyFrames.Add(new LinearThicknessKeyFrame(new Thickness(to, 0, 0, 0), translateTime));

            _indicator.BeginAnimation(MarginProperty, animation);
        }
Exemplo n.º 24
0
        public static Storyboard GetHide(AirspacePanel tbMarkdownPanel, Grid gridNote, Rectangle gridSplitterMarkdown)
        {
            tbMarkdownPanel.Width = tbMarkdownPanel.ActualWidth;

            var visAnim = new ObjectAnimationUsingKeyFrames()
            {
                KeyFrames = new ObjectKeyFrameCollection()
                {
                    new DiscreteObjectKeyFrame(Visibility.Collapsed, KeyTime.FromPercent(0))
                }
            };

            Storyboard.SetTarget(visAnim, gridSplitterMarkdown);
            Storyboard.SetTargetProperty(visAnim, new PropertyPath("(FrameworkElement.Visibility)"));

            var marginAnim = new ThicknessAnimationUsingKeyFrames()
            {
                Duration  = new Duration(TimeSpan.FromMilliseconds(500)),
                KeyFrames = new ThicknessKeyFrameCollection()
                {
                    new EasingThicknessKeyFrame(new Thickness(0, 0, -tbMarkdownPanel.ActualWidth, 0), KeyTime.FromPercent(1))
                    {
                        EasingFunction = new SineEase()
                        {
                            EasingMode = EasingMode.EaseOut
                        }
                    }
                }
            };

            Storyboard.SetTarget(marginAnim, tbMarkdownPanel);
            Storyboard.SetTargetProperty(marginAnim, new PropertyPath("(FrameworkElement.Margin)"));

            var sb = new Storyboard()
            {
                Children = new TimelineCollection()
                {
                    visAnim, marginAnim
                }
            };

            return(sb);
        }
Exemplo n.º 25
0
    public static void AddEasyThicknessAnime(this Storyboard sb, DependencyObject target, Thickness fromValue, Thickness toValue, double timeSec, string property)
    {
        var path = "";

        switch (property)
        {
        case "margin":
            path = "(FrameworkElement.Margin)";
            break;
        }

        var el = (UIElement)target;

        if (el.RenderTransform == null)
        {
            var group = new TransformGroup {
                Children = { [3] = new TranslateTransform() }
            };
            el.RenderTransform = group;
        }


        var animation = new ThicknessAnimationUsingKeyFrames()
        {
            KeyFrames =
            {
                new EasingThicknessKeyFrame(fromValue, KeyTime.FromTimeSpan(TimeSpan.Zero)),
                new EasingThicknessKeyFrame(toValue,   KeyTime.FromTimeSpan(TimeSpan.FromSeconds(timeSec)))
                {
                    EasingFunction = new ExponentialEase {
                        EasingMode = EasingMode.EaseOut
                    }
                }
            },
        };

        Storyboard.SetTargetProperty(animation, new PropertyPath(path));
        Storyboard.SetTarget(animation, target);
        sb.Children.Add(animation);
    }
Exemplo n.º 26
0
        public void GridDown(Grid grid, ScrollViewer scrollViewer, Rectangle border)
        {
            Thickness from = new Thickness();

            from.Bottom = 314;
            from.Right  = 28;
            Thickness to = new Thickness();

            to.Bottom = 19;
            to.Right  = 28;
            ThicknessAnimation downAnimation       = new ThicknessAnimation();
            ThicknessAnimation downAnimationScroll = new ThicknessAnimation();

            Thickness top = new Thickness();

            to.Bottom = 29;
            to.Right  = 28;
            ThicknessAnimationUsingKeyFrames jumpAnimation = new ThicknessAnimationUsingKeyFrames();

            downAnimation.Completed += new EventHandler((o, ex) =>
            {
                scrollViewer.Visibility = Visibility.Hidden;
                border.Visibility       = Visibility.Hidden;
            });

            downAnimation.Duration = new Duration(TimeSpan.FromSeconds(0.5));
            downAnimation.From     = to;
            downAnimation.To       = from;
            grid.BeginAnimation(Grid.MarginProperty, downAnimation);
            Thickness from2 = new Thickness();

            from2.Bottom = 100;
            Thickness to2 = new Thickness();

            to2.Bottom         = 11;
            downAnimation.From = to2;
            downAnimation.To   = from2;
            scrollViewer.BeginAnimation(ScrollViewer.MarginProperty, downAnimation);
            border.BeginAnimation(Border.MarginProperty, downAnimation);
        }
Exemplo n.º 27
0
        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();
        }
Exemplo n.º 28
0
        private void InitAnimation()
        {
            this.storyboard = new Storyboard();
            var frame = new ThicknessAnimationUsingKeyFrames()
            {
                BeginTime = TimeSpan.Zero
            };

            frame.KeyFrames.Add(new SplineThicknessKeyFrame(new Thickness(0, -26, 0, 0), KeyTime.FromTimeSpan(TimeSpan.Zero)));
            frame.KeyFrames.Add(new SplineThicknessKeyFrame(new Thickness(0, -13, 0, 0), KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0, 0, 250))));
            frame.KeyFrames.Add(new SplineThicknessKeyFrame(new Thickness(0, 0, 0, 0), KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0, 0, 500))));
            frame.KeyFrames.Add(new SplineThicknessKeyFrame(new Thickness(0, 0, 0, 0), KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0, 1, 500))));
            frame.KeyFrames.Add(new SplineThicknessKeyFrame(new Thickness(0, -13, 0, 0), KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0, 1, 750))));
            frame.KeyFrames.Add(new SplineThicknessKeyFrame(new Thickness(0, -26, 0, 0), KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0, 2, 0))));
            this.storyboard.Children.Add(frame);
            Storyboard.SetTarget(frame, this.NoticeBar);
            Storyboard.SetTargetProperty(frame, new PropertyPath(MarginProperty));
            this.storyboard.Completed += new EventHandler((obj, arg) =>
            {
                this.NoticeBar.Visibility = Visibility.Hidden;
            });
        }
Exemplo n.º 29
0
        public void Pop(NotificationInfo Ni)
        {
            ni = Ni;

            if (ni.Right)
            {
                NotificationHolder.Margin = new Thickness {
                    Left = 220, Top = 0, Right = 0, Bottom = 0
                };
                Left = SystemParameters.FullPrimaryScreenWidth - 200;
                StartingThickness = 200;
                EndThickness      = 0;
            }
            else
            {
                NotificationHolder.Margin = new Thickness {
                    Left = -200, Top = 0, Right = 0, Bottom = 0
                };
                Left = 0;
                StartingThickness = -200;
                EndThickness      = 0;
            }

            this.Dispatcher.Invoke(() =>
            {
                ThicknessAnimationUsingKeyFrames open = new ThicknessAnimationUsingKeyFrames();
                open.KeyFrames.Add(new SplineThicknessKeyFrame(new Thickness(EndThickness), TimeSpan.FromMilliseconds(300), new KeySpline(.5, 0, .3, 1)));
                NotificationHolder.BeginAnimation(Grid.MarginProperty, open);
                if (TCTData.Settings.NotificationSound)
                {
                    if (ni.Sound)
                    {
                        System.Media.SoundPlayer sp = new System.Media.SoundPlayer(Environment.CurrentDirectory + "\\content\\served.wav");
                        sp.Load();
                        sp.Play();
                    }
                }
            });
        }
Exemplo n.º 30
0
        private void buttonAVsShowHidden_Click(object sender, RoutedEventArgs e)
        {
            Storyboard storyboard = new Storyboard();

            ThicknessAnimationUsingKeyFrames takf = new ThicknessAnimationUsingKeyFrames();

            if (gridAVs.Margin.Right < 0)
            {
                takf.KeyFrames.Add(new SplineThicknessKeyFrame(new Thickness(0, 0, -130, 0), KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0))));
                takf.KeyFrames.Add(new SplineThicknessKeyFrame(new Thickness(0, 0, 0, 0), KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0, 0, 750)), new KeySpline(0.5, 0.75, 0, 1)));
            }
            else
            {
                takf.KeyFrames.Add(new SplineThicknessKeyFrame(new Thickness(0, 0, 0, 0), KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0))));
                takf.KeyFrames.Add(new SplineThicknessKeyFrame(new Thickness(0, 0, -130, 0), KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0, 0, 750)), new KeySpline(0.5, 0.75, 0, 1)));
            }


            Storyboard.SetTargetProperty(takf, new PropertyPath("Margin"));
            storyboard.Children.Add(takf);
            storyboard.Begin(gridAVs);
        }