Example #1
0
 private void RightToLeftMarquee()
 {
     if (!IsLoaded)
     {
         return;
     }
     if (CalculateIsTextTrimmed())
     {
         //  IstbmarqueeVisible = Visibility.Collapsed;
         double height = tbmarqueeCanvas.ActualHeight - tbmarquee.ActualHeight;
         tbmarquee.Margin = new Thickness(0, 0, 0, 0);
         DoubleAnimation doubleAnimation = new DoubleAnimation
         {
             From           = -tbmarquee.ActualWidth,
             To             = tbmarqueeCanvas.ActualWidth,
             RepeatBehavior = RepeatBehavior.Forever,
             Duration       = new Duration(TimeSpan.FromSeconds(_marqueeTimeInSeconds))
         };
         tbmarquee.BeginAnimation(Canvas.RightProperty, doubleAnimation);
     }
     else
     {
         // IstbmarqueeVisible = Visibility.Visible;
         tbmarquee.BeginAnimation(Canvas.RightProperty, null);
     }
 }
Example #2
0
        public void Alert(string msg, StatusBlockStyle style = null)
        {
            if (statusTimer == null)
            {
                statusTimer          = new Timer(AlertDuration);
                statusTimer.Elapsed += AlertOffHandler;
            }
            if (style == null)
            {
                style = Default;
            }

            if (statusTimer.Enabled)
            {
                statusTimer.Stop();
            }
            statusTimer.Start();
            statusBar.Height     = 0;
            statusBar.Text       = msg;
            statusBar.Background = style.Background;
            statusBar.Foreground = style.Foreground;
            DoubleAnimation anim = new DoubleAnimation();

            anim.From     = 0;
            anim.To       = AlertHeight;
            anim.Duration = TimeSpan.FromSeconds(0.5);
            statusBar.BeginAnimation(TextBox.HeightProperty, anim);
        }
Example #3
0
        private void createAttributeForElement(TreeViewItem item, string attName, string attValue)
        {
            StackPanel panel = (StackPanel)item.Header;

            TextBlock attributeName  = new TextBlock();
            TextBlock attributeValue = new TextBlock();

            attributeName.Text  = attName;
            attributeName.Name  = "attributeName";
            attributeValue.Text = "=" + attValue;
            attributeValue.Name = "attributeValue";

            attributeName.Opacity  = 0.1;
            attributeValue.Opacity = 0.1;



            panel.Children.Insert(3, attributeName);
            panel.Children.Insert(4, attributeValue);

            attributeName.BeginAnimation(TextBlock.OpacityProperty, opacityAnimation);
            attributeValue.BeginAnimation(TextBlock.OpacityProperty, opacityAnimation1);

            TextSizeAnimation.AutoReverse  = true;
            TextSizeAnimation1.AutoReverse = true;

            attributeName.BeginAnimation(TextBlock.FontSizeProperty, TextSizeAnimation);
            attributeValue.BeginAnimation(TextBlock.FontSizeProperty, TextSizeAnimation1);

            TextSizeAnimation.AutoReverse  = false;
            TextSizeAnimation1.AutoReverse = false;
        }
Example #4
0
        private void ProceName_GotFocus_1(object sender, RoutedEventArgs e)
        {
            TextBlock       gg = e.OriginalSource as TextBlock;
            DoubleAnimation da = new DoubleAnimation();

            da.From     = 0;                                  //起始值
            da.To       = 1;                                  //结束值
            da.Duration = TimeSpan.FromSeconds(2);            //动画持续时间
            gg.BeginAnimation(TextBlock.OpacityProperty, da); //开始动画

            ThicknessAnimation ta = new ThicknessAnimation();

            ta.From     = new Thickness(200, 0, 0, 0);       //起始值
            ta.To       = new Thickness(0, 0, 0, 0);         //结束值
            ta.Duration = TimeSpan.FromSeconds(1);           //动画持续时间
            gg.BeginAnimation(TextBlock.MarginProperty, ta); //开始动画
            //ListViewItem fafa = this.listViewProcess.SelectedItem as ListViewItem;
            ContentPresenter cp = gg.TemplatedParent as ContentPresenter;

            object       y   = cp.Content as object;
            ListViewItem lvi = this.listViewProcess.ItemContainerGenerator.ContainerFromItem(y) as ListViewItem;

            //MessageBox.Show(y.ToString());

            // TextBlock fa = fafa.FindName("Prth") as TextBlock;
        }
Example #5
0
        private void createValue(TreeViewItem parentItem, string value)
        {
            parentItem.IsExpanded = true;

            TreeViewItem valueItem = new TreeViewItem();
            StackPanel   panel     = new StackPanel();

            TextBlock block1 = new TextBlock();
            TextBlock block2 = new TextBlock();
            TextBlock block3 = new TextBlock();

            block1.Name = "value1";
            block2.Name = "value2";
            block3.Name = "value3";

            block1.Opacity = 0.1;
            block1.Text    = value;

            panel.Children.Insert(0, block1);

            valueItem.Header = panel;
            parentItem.Items.Add(valueItem);

            block1.BeginAnimation(TextBlock.OpacityProperty, opacityAnimation);
            TextSizeAnimation.AutoReverse = true;

            block1.BeginAnimation(TextBlock.FontSizeProperty, TextSizeAnimation);
            TextSizeAnimation.AutoReverse = false;
        }
Example #6
0
        private void AnimarTextBlock(TextBlock t)
        {
            ThicknessAnimation ida = new ThicknessAnimation(new Thickness(0), new Thickness(5, 0, 0, 0), TimeSpan.FromSeconds(0.1));

            ida.Completed += (s, e) =>
            {
                ThicknessAnimation vuelta = new ThicknessAnimation(new Thickness(5, 0, 0, 0), new Thickness(0, 0, 0, 0), TimeSpan.FromSeconds(0.1));
                t.BeginAnimation(MarginProperty, vuelta);
            };
            t.BeginAnimation(MarginProperty, ida);
        }
        private void Animation_Completed(object sender, EventArgs e)
        {
            AnimationTimeline timeline    = (sender as AnimationClock).Timeline;
            TextBlock         tb          = (TextBlock)Storyboard.GetTarget(timeline);
            double            currentLeft = Canvas.GetLeft(tb);
            double            currentTop  = Canvas.GetTop(tb);

            tb.BeginAnimation(Canvas.LeftProperty, null);
            tb.BeginAnimation(Canvas.TopProperty, null);
            Canvas.SetLeft(tb, currentLeft);
            Canvas.SetTop(tb, currentTop);
        }
        public void disparaitre(double time)
        {
            DoubleAnimation da1 = new DoubleAnimation();
            DoubleAnimation da2 = new DoubleAnimation();

            da1.From     = 0.7;
            da1.To       = 0;
            da1.Duration = TimeSpan.FromSeconds(time);
            da2.From     = 1;
            da2.To       = 0;
            da2.Duration = TimeSpan.FromSeconds(time);
            champ.BeginAnimation(Rectangle.OpacityProperty, da1);
            textBlock.BeginAnimation(TextBlock.OpacityProperty, da2);
        }
Example #9
0
        private void InitUI()
        {
            label2.Margin     = new Thickness(-200, 0, 0, 0);
            label2.Opacity    = 0;
            CurrentShownLabel = label1;

            MainColor = Color.FromArgb(0xaa, 0xc8, 0xc8, 0xff);
            string color = GetSetting("Color");

            if (color != null)
            {
                string[] rgb = color.Split(' ');
                MainColor.R = Byte.Parse(rgb[0]);
                MainColor.G = Byte.Parse(rgb[1]);
                MainColor.B = Byte.Parse(rgb[2]);
            }
            RSldr.Value = MainColor.R;
            GSldr.Value = MainColor.G;
            BSldr.Value = MainColor.B;

            string interval = GetSetting("Interval");

            if (interval == null)
            {
                IntSldr.Value = Interval / 5;
            }
            else
            {
                IntSldr.Value = Double.Parse(interval) * 2;
            }

            string pos  = GetSetting("Pos");
            string size = GetSetting("Size");

            if (pos != null && size != null)
            {
                string[] szarr  = size.Split(' ');
                string[] posarr = pos.Split(' ');
                this.Width  = Double.Parse(szarr[0]);
                this.Height = Double.Parse(szarr[1]);
                this.Left   = Double.Parse(posarr[0]);
                this.Top    = Double.Parse(posarr[1]);
            }

            var curanim1 = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(0.3)));
            var curanim2 = new ThicknessAnimation(new Thickness(200, 10, 0, 0), new Thickness(10, 10, 0, 0), new Duration(TimeSpan.FromSeconds(0.3)));

            CurrentShownLabel.BeginAnimation(TextBlock.OpacityProperty, curanim1);
            CurrentShownLabel.BeginAnimation(TextBlock.MarginProperty, curanim2);
        }
Example #10
0
        private void HeightDoubleAnimationStart <T>(object obj, double oldValue, double newValue, double duration)
        {
            DoubleAnimation animation = new DoubleAnimation(oldValue, newValue, TimeSpan.FromSeconds(duration));

            if (typeof(T) == typeof(TextBlock))
            {
                TextBlock textBlock = (TextBlock)obj;
                textBlock.BeginAnimation(TextBlock.HeightProperty, animation);
            }
            else if (typeof(T) == typeof(Grid))
            {
                Grid grid = (Grid)obj;
                grid.BeginAnimation(Grid.HeightProperty, animation);
            }
            else if (typeof(T) == typeof(Separator))
            {
                Separator separator = (Separator)obj;
                separator.BeginAnimation(HeightProperty, animation);
            }
            else if (typeof(T) == typeof(Button))
            {
                Button button = (Button)obj;
                button.BeginAnimation(HeightProperty, animation);
            }
        }
        /// <summary>
        /// 在Window界面上显示弹幕信息,速度和位置随机产生
        /// </summary>
        /// <param name="contentlist"></param>
        public void Barrage(string item)
        {
            //获取位置随机数
            double randomtop = random.NextDouble();
            double inittop   = (canvas.ActualHeight - 100) * randomtop;
            //获取速度随机数
            //double randomspeed = random.NextDouble();
            //double initspeed = 50 * randomspeed;
            double initspeed = 20;
            //实例化TextBlock和设置基本属性,并添加到Canvas中
            TextBlock textblock = new TextBlock();

            textblock.Text       = item;
            textblock.FontSize   = 20;
            textblock.Foreground = new SolidColorBrush(ColorUtils.GetRandomColor(random));
            Canvas.SetTop(textblock, inittop);
            canvas.Children.Add(textblock);
            //实例化动画
            DoubleAnimation animation = new DoubleAnimation();

            Timeline.SetDesiredFrameRate(animation, 60);  //如果有性能问题,这里可以设置帧数
            animation.From        = canvas.ActualWidth;
            animation.To          = 0;
            animation.Duration    = TimeSpan.FromSeconds(initspeed);
            animation.AutoReverse = false;
            //animation.RepeatBehavior = RepeatBehavior.Forever;
            animation.Completed += (object sender, EventArgs e) =>
            {
                canvas.Children.Remove(textblock);
            };
            //启动动画
            textblock.BeginAnimation(Canvas.LeftProperty, animation);
        }
Example #12
0
        private void Remove(Chart chart, Axis axis)
        {
            if (axis.DisableAnimations || chart.DisableAnimations)
            {
                chart.Canvas.Children.Remove(TextBlock);
                chart.Canvas.Children.Remove(Line);
                return;
            }

            var anim = new DoubleAnimation
            {
                From     = 1,
                To       = 0,
                Duration = _anSpeed
            };

            anim.Completed += (sender, args) =>
            {
                Application.Current.Dispatcher.Invoke(new Action(() =>
                {
                    chart.Canvas.Children.Remove(TextBlock);
                    chart.Canvas.Children.Remove(Line);
                }));
            };

            TextBlock.BeginAnimation(UIElement.OpacityProperty, anim);
            Line.BeginAnimation(UIElement.OpacityProperty, new DoubleAnimation(1, 0, _anSpeed));
        }
Example #13
0
        public void ShowMsg(string msg, Color c)
        {
            TextBlock tb = new TextBlock();

            tb.Text                = msg;
            tb.FontSize            = 12;
            tb.FontWeight          = FontWeights.Bold;
            tb.Foreground          = new SolidColorBrush(c);
            tb.Margin              = new Thickness(5);
            tb.TextWrapping        = TextWrapping.Wrap;
            tb.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            sp.Children.Add(tb);
            sv.ScrollToBottom();

            win.Left = SystemParameters.WorkArea.Width - win.Width;
            win.Top  = SystemParameters.WorkArea.Height - win.Height - 20;

            DoubleAnimation daOpacity = new DoubleAnimation(1, 0, TimeSpan.FromSeconds(1));

            daOpacity.BeginTime = TimeSpan.FromSeconds(3);

            //DoubleAnimation daHeight = new DoubleAnimation(1, TimeSpan.FromSeconds(0.5));
            //daHeight.BeginTime = TimeSpan.FromSeconds(4);

            daOpacity.Completed += new EventHandler(da_Completed);
            Storyboard.SetTarget(daOpacity, tb);

            tb.BeginAnimation(TextBlock.OpacityProperty, daOpacity);
            //tb.BeginAnimation(TextBlock.HeightProperty, daHeight);

            win.Show();
        }
Example #14
0
        private void Option_MouseEnter(object sender, MouseEventArgs e)
        {
            Entered?.Invoke(sender, e);

            if (!this.OptionCanvas.Children.Contains(_selector))
            {
                this.OptionCanvas.Children.Add(_selector);
            }

            TextBlock senderTextBlock = sender as TextBlock;

            Point location      = senderTextBlock.TranslatePoint(new Point(0, 0), OptionCanvas);
            Point arrowLocation = _selector.TranslatePoint(new Point(0, 0), OptionCanvas);

            // Don't redraw the arrow if it's already where it should be
            if (location.Y + 8.0 != arrowLocation.Y)
            {
                _selector.BeginBounceAnimation(new Point(location.X - 20.0, location.Y + 8.0));
            }

            foreach (var child in CurrentOptions.Children)
            {
                TextBlock option = child as TextBlock;

                DoubleAnimation deselect = new DoubleAnimation(0.8, new Duration(TimeSpan.FromSeconds(0.0)));
                option.BeginAnimation(TextBlock.OpacityProperty, deselect);
            }

            DoubleAnimation select = new DoubleAnimation(1.0, new Duration(TimeSpan.FromSeconds(0.0)));

            senderTextBlock.BeginAnimation(TextBlock.OpacityProperty, select);
        }
        public void ResetColors()
        {
            //используются анимации, тк свойства не работают после использованной анимации

            if (dockPanel != null)
            {
                BrushAnimation backgroundAnimation = new BrushAnimation
                {
                    From     = IsSelected ? SelectedItemBackground : ItemBackground,
                    To       = IsSelected ? SelectedItemBackground : ItemBackground,
                    Duration = new Duration(TimeSpan.FromMilliseconds(0))
                };
                dockPanel.BeginAnimation(DockPanel.BackgroundProperty, backgroundAnimation);
            }


            if (textBlock != null)
            {
                BrushAnimation textAnimation = new BrushAnimation
                {
                    From     = IsSelected ? SelectedTextBrush : TextBrush,
                    To       = IsSelected ? SelectedTextBrush : TextBrush,
                    Duration = new Duration(TimeSpan.FromMilliseconds(0))
                };
                textBlock.BeginAnimation(TextBlock.ForegroundProperty, textAnimation);
            }
        }
Example #16
0
        private void Animate(TextBlock target, double oldHeight, double newHeight, TimeSpan duration)
        {
            target.Height = oldHeight;
            DoubleAnimation animation = new DoubleAnimation(newHeight, duration);

            target.BeginAnimation(TextBlock.HeightProperty, animation);
        }
        /// <summary>
        /// Fades the out and remove.
        /// </summary>
        /// <param name="chart">The chart.</param>
        public void FadeOutAndRemove(ChartCore chart)
        {
            if (TextBlock.Visibility == Visibility.Collapsed &&
                Line.Visibility == Visibility.Collapsed)
            {
                return;
            }

            var anim = new DoubleAnimation
            {
                From     = 1,
                To       = 0,
                Duration = chart.View.AnimationsSpeed
            };

            var dispatcher = ((Chart)chart.View).Dispatcher;

            anim.Completed += (sender, args) =>
            {
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    chart.View.RemoveFromView(TextBlock);
                    chart.View.RemoveFromView(Line);
                });
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
            };

            TextBlock.BeginAnimation(anim, "Opacity");

            Line.BeginDoubleAnimation("Opacity", 1, 0, chart.View.AnimationsSpeed);
        }
Example #18
0
 /// <summary>
 /// 歌词TextBlock字体动画:字体渐变到指定小的动画函数
 /// </summary>
 public static void fontSizeToSmall(TextBlock tb)
 {
     fontSizeChangeSmallA.From     = fontBigA;
     fontSizeChangeSmallA.To       = fontSmallA;
     fontSizeChangeSmallA.Duration = new Duration(TimeSpan.Parse("0:0:0.5"));
     tb.BeginAnimation(TextBlock.FontSizeProperty, fontSizeChangeSmallA);
 }
        public void FadeOutAndRemove(ChartCore chart)
        {
            if (TextBlock.Visibility == Visibility.Collapsed &&
                Line.Visibility == Visibility.Collapsed)
            {
                return;
            }

            var anim = new DoubleAnimation
            {
                From     = 1,
                To       = 0,
                Duration = chart.View.AnimationsSpeed
            };

            anim.Completed += (sender, args) =>
            {
                if (Application.Current == null)
                {
                    chart.View.RemoveFromView(TextBlock);
                    chart.View.RemoveFromView(Line);
                    return;
                }

                TextBlock.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    chart.View.RemoveFromView(TextBlock);
                    chart.View.RemoveFromView(Line);
                });
            };

            TextBlock.BeginAnimation(anim, "Opacity");

            Line.BeginDoubleAnimation("Opacity", 1, 0, chart.View.AnimationsSpeed);
        }
Example #20
0
        /// <summary>
        /// 文字列のアニメーション
        /// </summary>
        private void MoveText(TextBlock textBlock)
        {
            var random = new Random();

            Canvas.SetTop(textBlock, random.Next((int)textBlock.ActualHeight, (int)(Height * 0.9))); // タスクバーを隠さないランダムな高さに出現
            var time      = random.Next(9000, 13000);                                                // ランダムな時間の間流れる
            var animation = new DoubleAnimation                                                      // 右画面外から左画面外へのアニメーション
            {
                From     = Width,
                To       = -1 * textBlock.ActualWidth - 10,
                Duration = TimeSpan.FromMilliseconds(time)
            };
            var deleteTimer = new DispatcherTimer(DispatcherPriority.SystemIdle) // 流れたら削除する
            {
                Interval = TimeSpan.FromMilliseconds(time),
            };

            deleteTimer.Tick += (s, e) =>
            {
                deleteTimer.Stop();
                Root.Children.Remove(textBlock);
            };
            textBlock.BeginAnimation(LeftProperty, animation); // そぉぃ
            deleteTimer.Start();
            textBlock.Opacity = 100;
        }
Example #21
0
        private void animateElement(string itemName)
        {
            TreeViewItem item      = findItem(presentation.SecuredSoapItem, itemName);
            TreeViewItem closeItem = findItem(presentation.SecuredSoapItem, "/" + itemName);

            StackPanel panel      = (StackPanel)item.Header;
            StackPanel panel2     = (StackPanel)closeItem.Header;
            TextBlock  textblock1 = new TextBlock();
            TextBlock  textblock2 = new TextBlock();
            TextBlock  textblock3 = new TextBlock();
            TextBlock  textblock4 = new TextBlock();


            TextBlock closetextblock1 = new TextBlock();
            TextBlock closetextblock2 = new TextBlock();
            TextBlock closetextblock3 = new TextBlock();
            TextBlock closetextblock4 = new TextBlock();


            TextSizeAnimation.AutoReverse = true;

            if (panel.Children.Count > 0)
            {
                textblock1 = (TextBlock)panel.Children[0];
                textblock1.BeginAnimation(TextBlock.FontSizeProperty, TextSizeAnimation);
            }
            if (panel.Children.Count > 1)
            {
                textblock2 = (TextBlock)panel.Children[1];
                textblock2.BeginAnimation(TextBlock.FontSizeProperty, TextSizeAnimation);
            }
            if (panel.Children.Count > 2)
            {
                textblock3 = (TextBlock)panel.Children[2];
                textblock3.BeginAnimation(TextBlock.FontSizeProperty, TextSizeAnimation);
            }
            //if (panel.Children.Count > 3)
            //{
            //    textblock4 = (TextBlock)panel.Children[3];
            //    textblock4.BeginAnimation(TextBlock.FontSizeProperty, TextSizeAnimation);
            //}


            if (panel2.Children.Count > 0)
            {
                closetextblock1 = (TextBlock)panel2.Children[0];
                closetextblock1.BeginAnimation(TextBlock.FontSizeProperty, TextSizeAnimation);
            }
            if (panel2.Children.Count > 1)
            {
                closetextblock2 = (TextBlock)panel2.Children[1];
                closetextblock2.BeginAnimation(TextBlock.FontSizeProperty, TextSizeAnimation);
            }
            if (panel2.Children.Count > 2)
            {
                closetextblock3 = (TextBlock)panel2.Children[2];
                closetextblock3.BeginAnimation(TextBlock.FontSizeProperty, TextSizeAnimation);
            }
            TextSizeAnimation.AutoReverse = false;
        }
Example #22
0
 public void t_Tick(object sender, EventArgs e)
 {
     if ((DateTime.Now - dt).Seconds >= 2)
     {
         if (gameListView.Items.Count != 0)
         {
             for (int i = 0; i < gameListView.Items.Count; i++)
             {
                 ContentPresenter c                 = (ContentPresenter)gameListView.ItemContainerGenerator.ContainerFromItem(gameListView.Items[i]);
                 TextBlock        title             = c.ContentTemplate.FindName("PosterGameTitle", c) as TextBlock;
                 Canvas           canvas            = c.ContentTemplate.FindName("canvasTitle", c) as Canvas;
                 MaterialDesignThemes.Wpf.Card card = c.ContentTemplate.FindName("gameCard", c) as MaterialDesignThemes.Wpf.Card;
                 if (card.IsMouseOver == true)
                 {
                     if (title.Text.ToString().Length > 22)
                     {
                         doubleAnimation.From           = 0;
                         doubleAnimation.To             = canvas.ActualWidth;
                         doubleAnimation.RepeatBehavior = RepeatBehavior.Forever;
                         doubleAnimation.Duration       = new Duration(TimeSpan.Parse("0:0:5"));
                         title.BeginAnimation(Canvas.RightProperty, doubleAnimation);
                     }
                 }
             }
         }
     }
 }
Example #23
0
        private void WidthDoubleAnimationStart <T>(object obj, double oldValue, double newValue, double duration)
        {
            DoubleAnimation animation = new DoubleAnimation(oldValue, newValue, TimeSpan.FromSeconds(duration));

            if (typeof(T) == typeof(TextBlock))
            {
                TextBlock textBlock = (TextBlock)obj;
                textBlock.BeginAnimation(TextBlock.WidthProperty, animation);
            }
            else if (typeof(T) == typeof(Grid))
            {
                Grid grid = (Grid)obj;
                grid.BeginAnimation(Grid.WidthProperty, animation);
            }
            else if (typeof(T) == typeof(Separator))
            {
                Separator separator = (Separator)obj;
                separator.BeginAnimation(WidthProperty, animation);
            }
            else if (typeof(T) == typeof(Window))
            {
                Window window = (Window)obj;
                window.BeginAnimation(WidthProperty, animation);
            }
        }
Example #24
0
        public void Move(ChartCore chart, AxisCore axis, AxisOrientation direction, int axisIndex, double toLabel, double toLine, double tab)
        {
            if (direction == AxisOrientation.Y)
            {
                Line.BeginAnimation(Line.X1Property,
                                    new DoubleAnimation(chart.DrawMargin.Left, chart.View.AnimationsSpeed));
                Line.BeginAnimation(Line.X2Property,
                                    new DoubleAnimation(chart.DrawMargin.Left + chart.DrawMargin.Width, chart.View.AnimationsSpeed));
                Line.BeginAnimation(Line.Y1Property,
                                    new DoubleAnimation(toLine, chart.View.AnimationsSpeed));
                Line.BeginAnimation(Line.Y2Property,
                                    new DoubleAnimation(toLine, chart.View.AnimationsSpeed));

                TextBlock.BeginAnimation(Canvas.TopProperty,
                                         new DoubleAnimation(toLabel, chart.View.AnimationsSpeed));
                TextBlock.BeginAnimation(Canvas.LeftProperty,
                                         new DoubleAnimation(tab, chart.View.AnimationsSpeed));
            }
            else
            {
                Line.BeginAnimation(Line.X1Property,
                                    new DoubleAnimation(toLine, chart.View.AnimationsSpeed));
                Line.BeginAnimation(Line.X2Property,
                                    new DoubleAnimation(toLine, chart.View.AnimationsSpeed));
                Line.BeginAnimation(Line.Y1Property,
                                    new DoubleAnimation(chart.DrawMargin.Top, chart.View.AnimationsSpeed));
                Line.BeginAnimation(Line.Y2Property,
                                    new DoubleAnimation(chart.DrawMargin.Top + chart.DrawMargin.Height, chart.View.AnimationsSpeed));

                TextBlock.BeginAnimation(Canvas.LeftProperty,
                                         new DoubleAnimation(toLabel, chart.View.AnimationsSpeed));
                TextBlock.BeginAnimation(Canvas.TopProperty,
                                         new DoubleAnimation(tab, chart.View.AnimationsSpeed));
            }
        }
Example #25
0
        public void BeginAnimation(TextBlock textBlock, double initFontSize = 0)
        {
            if (IsAnimFontSize)
            {
                _daSize.From = (initFontSize == 0) ? textBlock.FontSize : initFontSize;
                _daSize.To   = FontSizeKoef * _daSize.From;
                textBlock.BeginAnimation(TextBlock.FontSizeProperty, _daSize);
            }

            if (IsAnimTextBlur)
            {
                if (textBlock.Effect == null)
                {
                    textBlock.Effect = new BlurEffect()
                    {
                        Radius = 0
                    }
                }
                ;
                _daBlur.From = 0;
                _daBlur.To   = TextBlurTo;
                textBlock.Effect.BeginAnimation(BlurEffect.RadiusProperty, _daBlur);
            }
        }
    } // class
Example #26
0
        public void FadeOutAndRemove(ChartCore chart)
        {
            if (TextBlock.Visibility == Visibility.Collapsed &&
                Line.Visibility == Visibility.Collapsed)
            {
                return;
            }

            var anim = new DoubleAnimation
            {
                From     = 1,
                To       = 0,
                Duration = chart.View.AnimationsSpeed
            };

            anim.Completed += (sender, args) =>
            {
                if (Application.Current == null)
                {
                    chart.View.RemoveFromView(TextBlock);
                    chart.View.RemoveFromView(Line);
                    return;
                }

                Application.Current.Dispatcher.Invoke(new Action(() =>
                {
                    chart.View.RemoveFromView(TextBlock);
                    chart.View.RemoveFromView(Line);
                }));
            };

            TextBlock.BeginAnimation(UIElement.OpacityProperty, anim);
            Line.BeginAnimation(UIElement.OpacityProperty,
                                new DoubleAnimation(1, 0, chart.View.AnimationsSpeed));
        }
Example #27
0
        private void animateElement(TreeViewItem item)
        {
            StackPanel panel = (StackPanel)item.Header;

            TextBlock textblock1 = new TextBlock();
            TextBlock textblock2 = new TextBlock();
            TextBlock textblock3 = new TextBlock();
            TextBlock textblock4 = new TextBlock();



            TextSizeAnimation.AutoReverse = true;

            if (panel.Children.Count > 0)
            {
                textblock1 = (TextBlock)panel.Children[0];
                textblock1.BeginAnimation(TextBlock.FontSizeProperty, TextSizeAnimation);
            }
            if (panel.Children.Count > 1)
            {
                textblock2 = (TextBlock)panel.Children[1];
                textblock2.BeginAnimation(TextBlock.FontSizeProperty, TextSizeAnimation);
            }
            if (panel.Children.Count > 2)
            {
                textblock3 = (TextBlock)panel.Children[2];
                textblock3.BeginAnimation(TextBlock.FontSizeProperty, TextSizeAnimation);
            }
            TextSizeAnimation.AutoReverse = false;
        }
Example #28
0
        private void SendDanmu()
        {
            TextBlock text = new TextBlock();

            text.Text = danMu;
            text.AddHandler(TextBlock.LoadedEvent, new RoutedEventHandler(GetActualWidthOfDanMu));


            text.FontSize = 30;

            //text.Style = Resources["TextBlockStyle"] as Style;
            text.Style = (Style)this.FindResource("TextBlockStyle");
            //text.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("White"));
            //System.Windows.Media.Effects.DropShadowEffect ds = new System.Windows.Media.Effects.DropShadowEffect();
            //ds.Color = (Color)ColorConverter.ConvertFromString("#FF616161");
            //ds.ShadowDepth = 1.5;
            //ds.Opacity = 1;
            //text.Effect = ds;
            myCanvas.Children.Add(text);

            DoubleAnimation doubleAnimation = new DoubleAnimation();

            doubleAnimation.From     = myWin.ActualWidth;
            doubleAnimation.To       = -danMuActualWidth;
            doubleAnimation.Duration = TimeSpan.FromSeconds(10);
            text.BeginAnimation(Canvas.LeftProperty, doubleAnimation);
        }
Example #29
0
        /// <summary>
        /// 在Window界面上显示弹幕信息,速度和位置随机产生
        /// </summary>
        /// <param name="contentlist"></param>
        public void Barrage(IEnumerable <string> contentlist)
        {
            Random random = new Random();

            foreach (var item in contentlist)
            {   //获取位置随机数
                double randomtop = random.NextDouble();
                double inittop   = canvas.ActualHeight * randomtop;
                //获取速度随机数
                double randomspeed = random.NextDouble();
                double initspeed   = 50 * randomspeed;
                //实例化TextBlock和设置基本属性,并添加到Canvas中
                TextBlock textblock = new TextBlock();
                textblock.Text     = item;
                textblock.FontSize = 50;
                Canvas.SetTop(textblock, inittop);
                canvas.Children.Add(textblock);
                //实例化动画
                DoubleAnimation animation = new DoubleAnimation();
                Timeline.SetDesiredFrameRate(animation, 60);  //如果有性能问题,这里可以设置帧数
                animation.From           = 0;
                animation.To             = canvas.ActualWidth;
                animation.Duration       = TimeSpan.FromSeconds(initspeed);
                animation.AutoReverse    = true;
                animation.RepeatBehavior = RepeatBehavior.Forever;
                animation.Completed     += (object sender, EventArgs e) =>
                {
                    canvas.Children.Remove(textblock);
                };
                //启动动画
                textblock.BeginAnimation(Canvas.LeftProperty, animation);
                Process.GetCurrentProcess().Kill();
            }
        }
Example #30
0
        public void MenuOptions_Loaded(object sender, RoutedEventArgs e)
        {
            NextTitle.Text = TitleText;
            NextTitle.BeginAnimation(TextBlock.OpacityProperty, new DoubleAnimation(1.0, TimeSpan.FromSeconds(0.1)));

            for (Int32 i = 0; i < OptionNames.Count; i++)
            {
                TextBlock textBlock = new TextBlock()
                {
                    Text = OptionNames[i], Foreground = Brushes.White, FontSize = 18, Opacity = 0.0, Margin = new Thickness(12, 4, 0, 0)
                };

                DoubleAnimation appear = new DoubleAnimation(0.8, TimeSpan.FromSeconds(0.1));
                appear.BeginTime = TimeSpan.FromSeconds(i * 0.1);

                if (i == OptionNames.Count - 1)
                {
                    appear.Completed += (s, args) => {
                        _selector.Opacity = 1.0;
                        Shown?.Invoke(this, new EventArgs());
                    };
                }

                textBlock.BeginAnimation(TextBlock.OpacityProperty, appear);

                NextOptions.Children.Add(textBlock);
            }

            _selector.Opacity = 0.0;
            MenuOptions_Transitioned(this, new EventArgs());
        }