当前位置: 首页>>代码示例>>C#>>正文


C# SolidColorBrush.BeginAnimation方法代码示例

本文整理汇总了C#中System.Windows.Media.SolidColorBrush.BeginAnimation方法的典型用法代码示例。如果您正苦于以下问题:C# SolidColorBrush.BeginAnimation方法的具体用法?C# SolidColorBrush.BeginAnimation怎么用?C# SolidColorBrush.BeginAnimation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Media.SolidColorBrush的用法示例。


在下文中一共展示了SolidColorBrush.BeginAnimation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetColor

 public void SetColor(int index,bool isGreen=true)
 {
     var solidColorBrush = new SolidColorBrush();
     solidColorBrush.BeginAnimation(SolidColorBrush.ColorProperty,
         FindResource((isGreen ? "ColorAnimationGreen" : "ColorAnimationRed")) as ColorAnimation);
     var textEffect = mohamedAhmed.TextEffects[index];
     textEffect.Foreground = solidColorBrush;
 }
开发者ID:JackWangCUMT,项目名称:Playground,代码行数:8,代码来源:Window1.xaml.cs

示例2: AnimateColor

 public static void AnimateColor(SolidColorBrush from, SolidColorBrush to, UIElement control, double duration)
 {
     SolidColorBrush myBrush = new SolidColorBrush();
     myBrush = from;
     ColorAnimation myColorAnimation = new ColorAnimation();
     myColorAnimation.From = from.Color;
     myColorAnimation.To = to.Color;
     myColorAnimation.Duration = new Duration(TimeSpan.FromSeconds(duration));
     myBrush.BeginAnimation(SolidColorBrush.ColorProperty, myColorAnimation);
     control.GetType().GetProperty("Background").SetValue(control, myBrush);
 }
开发者ID:Sential,项目名称:WebExpress-beta,代码行数:11,代码来源:StaticFunctions.cs

示例3: animirajPromenu

        void animirajPromenu()
        {
            SolidColorBrush promena = new SolidColorBrush();
            promena.Color = Colors.Blue;

            ColorAnimation myColorAnimation = new ColorAnimation();
            myColorAnimation.From = Color.FromRgb(48,48,48);
            myColorAnimation.To = Colors.LightGray;
            myColorAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(100));
            myColorAnimation.AutoReverse = true;

            // Apply the animation to the brush's Color property.
            promena.BeginAnimation(SolidColorBrush.ColorProperty, myColorAnimation);
            gdMainTast.Background = promena;
        }
开发者ID:voxPopuli92,项目名称:ViserInformator,代码行数:15,代码来源:btnTasterTEMP.xaml.cs

示例4: OnRender

 protected override void OnRender(DrawingContext drawingContext)
 {
     var brush = new SolidColorBrush(Colors.Black);
     var animation = new ColorAnimationUsingKeyFrames();
     animation.KeyFrames.Add(new LinearColorKeyFrame(Colors.Black, KeyTime.FromPercent(0)));
     animation.KeyFrames.Add(new LinearColorKeyFrame(Colors.LightGray, KeyTime.FromPercent(1)));
     animation.Duration = new Duration(TimeSpan.FromSeconds(1));
     animation.AutoReverse = true;
     animation.RepeatBehavior = RepeatBehavior.Forever;
     brush.BeginAnimation(SolidColorBrush.ColorProperty, animation);
     var rect = new Rect(0, 0, ActualWidth, ActualHeight);
     var typeface = new Typeface(new FontFamily("Calibri"), FontStyles.Normal, FontWeights.Normal, FontStretches.Normal );
     var text = new FormattedText("Loading...", Thread.CurrentThread.CurrentUICulture, FlowDirection.LeftToRight, typeface,
         15, brush);
     drawingContext.DrawRectangle(new SolidColorBrush(Color.FromArgb(200, 255, 255, 255)), null, rect);
     drawingContext.DrawText(text, new Point((ActualWidth-text.Width)/2.0, (ActualHeight-text.Height)/2.0));
 }
开发者ID:Zagrebelin,项目名称:SideBar,代码行数:17,代码来源:LoaderAdorner.cs

示例5: animatePathBox

        private void animatePathBox(bool hasErrors)
        {
            var startColor = Colors.White;
            var endColor = Colors.LightPink;
            if( !hasErrors)
            {
                endColor = startColor;
                startColor = Colors.LightPink;
            }

            var brush = new SolidColorBrush(startColor);
            textBoxPathToProject.Background = brush;
            var colorAnimation = new ColorAnimation(startColor, endColor, new Duration(TimeSpan.FromSeconds(.25)))
                                 	{
                                 		AutoReverse = false
                                 	};

            brush.BeginAnimation(SolidColorBrush.ColorProperty, colorAnimation);
        }
开发者ID:SteveDunn,项目名称:Find-Visual-Studio-Orphaned-Items,代码行数:19,代码来源:Window1.xaml.cs

示例6: LocalAnimationExample

        public LocalAnimationExample()
        {
            WindowTitle = "Local Animation Example";
            var myStackPanel = new StackPanel {Margin = new Thickness(20)};


            // Create and set the Button.
            var aButton = new Button {Content = "A Button"};

            // Animate the Button's Width.
            var myDoubleAnimation = new DoubleAnimation
            {
                From = 75,
                To = 300,
                Duration = new Duration(TimeSpan.FromSeconds(5)),
                AutoReverse = true,
                RepeatBehavior = RepeatBehavior.Forever
            };

            // Apply the animation to the button's Width property.
            aButton.BeginAnimation(WidthProperty, myDoubleAnimation);

            // Create and animate a Brush to set the button's Background.
            var myBrush = new SolidColorBrush {Color = Colors.Blue};

            var myColorAnimation = new ColorAnimation
            {
                From = Colors.Blue,
                To = Colors.Red,
                Duration = new Duration(TimeSpan.FromMilliseconds(7000)),
                AutoReverse = true,
                RepeatBehavior = RepeatBehavior.Forever
            };

            // Apply the animation to the brush's Color property.
            myBrush.BeginAnimation(SolidColorBrush.ColorProperty, myColorAnimation);
            aButton.Background = myBrush;

            // Add the Button to the panel.
            myStackPanel.Children.Add(aButton);
            Content = myStackPanel;
        }
开发者ID:ClemensT,项目名称:WPF-Samples,代码行数:42,代码来源:LocalAnimationExample.cs

示例7: DrawPoint

       public static void DrawPoint(DrawingContext dc, Point? point,string fromColor, string toColor, double duration, bool isAutoReverse)
       {
           SolidColorBrush scbW = new SolidColorBrush(Colors.Black);
           ColorAnimation myAnimation = new ColorAnimation((Color)ColorConverter.ConvertFromString(fromColor),
                                                           (Color)ColorConverter.ConvertFromString(toColor),
                                                           new Duration(TimeSpan.FromSeconds(duration)));
           myAnimation.AutoReverse = isAutoReverse;
           myAnimation.RepeatBehavior = RepeatBehavior.Forever;
           scbW.BeginAnimation(SolidColorBrush.ColorProperty, myAnimation);
           Pen wpen = new Pen(scbW, 1);
           Rect rectW = new Rect(point.Value.X, point.Value.Y, 0.1, 0.1);
           double halfPenWidth = wpen.Thickness / 2;
           GuidelineSet guidelines = new GuidelineSet();
           guidelines.GuidelinesX.Add(rectW.Left + halfPenWidth);
           guidelines.GuidelinesX.Add(rectW.Right + halfPenWidth);
           guidelines.GuidelinesY.Add(rectW.Top + halfPenWidth);
           guidelines.GuidelinesY.Add(rectW.Bottom + halfPenWidth);
           dc.PushGuidelineSet(guidelines);

           dc.DrawRectangle(null, wpen, rectW);
           dc.Pop();
       }
开发者ID:NightmareX1337,项目名称:lfs,代码行数:22,代码来源:Graphic.cs

示例8: ShowSearchProgressGrid

        /// <summary>
        /// Replaces the search controls with "search progress" controls when a user searches
        /// A cancel button and a text area that displays which items were excluded from the results.
        /// </summary>
        private void ShowSearchProgressGrid()
        {
            SearchLayoutGrid.Visibility = System.Windows.Visibility.Hidden;
            SearchProgressGrid.Visibility = System.Windows.Visibility.Visible;

            DataLayoutGrid.ColumnDefinitions[0].Width = new GridLength(84, GridUnitType.Star);
            DataLayoutGrid.ColumnDefinitions[1].Width = new GridLength(1, GridUnitType.Star);
            DataLayoutGrid.ColumnDefinitions[2].Width = new GridLength(15, GridUnitType.Star);

            // The initial page load can take a few moments, so make the
            // progress bar animate to show that work is being done.
            SolidColorBrush bg = new SolidColorBrush(Colors.Black);
            Progress.Background = bg;

            ColorAnimation animation = new ColorAnimation()
            {
                From = Colors.Black,
                To = Colors.Gray,
                Duration = TimeSpan.FromMilliseconds(750),
                RepeatBehavior = RepeatBehavior.Forever,
                AutoReverse = true,
            };

            bg.BeginAnimation(SolidColorBrush.ColorProperty, animation);

            CancelButton.Focus();
        }
开发者ID:ThomasRush,项目名称:AmazonScrape,代码行数:31,代码来源:MainWindow.xaml.cs

示例9: CreateAnimBrush

        private Brush CreateAnimBrush(Color fromColor, Color toColor, double seconds)
        {
            ColorAnimation ani = new ColorAnimation();
            ani.From = fromColor;
            ani.To = toColor;
            ani.RepeatBehavior = RepeatBehavior.Forever;
            ani.Duration = new Duration(TimeSpan.FromSeconds(seconds));
            ani.AutoReverse = true;

            SolidColorBrush brush = new SolidColorBrush(fromColor);
            brush.BeginAnimation(SolidColorBrush.ColorProperty, ani);

            return brush;
        }
开发者ID:sommerschnee,项目名称:JuFu,代码行数:14,代码来源:Monster.cs

示例10: CreateCursorPanel

 private FrameworkElement CreateCursorPanel( )
 {
     var cursorBrush = new SolidColorBrush( );
     var panel = GuiUtils.WrapToBorder( new Label {
         Content = _pinyinInput,
         VerticalContentAlignment = VerticalAlignment.Center,
         Background = cursorBrush
     } );
     var cursorAnimation = new ColorAnimation( Color.FromRgb( 192, 192, 255 ), Colors.White,
         new Duration( TimeSpan.FromSeconds( 0.5 ) ),
         FillBehavior.HoldEnd ) {
             AutoReverse = true,
             RepeatBehavior = RepeatBehavior.Forever
         };
     cursorBrush.BeginAnimation( SolidColorBrush.ColorProperty, cursorAnimation );
     return panel;
 }
开发者ID:rbrother,项目名称:ChineseWriter,代码行数:17,代码来源:ChineseWriterWindow.xaml.cs

示例11: Move

    public void Move(Point[] path, ushort color)
    {
      m_movePath = path;
      m_moveColor = color;

      m_brush.BeginAnimation(SolidColorBrush.ColorProperty, null);

      // intermediate animation
      // starts immediately. fades in and out
      ColorAnimation ca1 = new ColorAnimation();
      ca1.From = m_ColorBrushes[0].Color;
      // ca1.From = Brushes.LightSteelBlue.Color;
      ca1.To = m_ColorBrushes[m_moveColor].Color;
      // ca1.To = Brushes.Red.Color;
      ca1.Duration = new Duration(TimeSpan.FromMilliseconds(500));
      ca1.BeginTime = TimeSpan.FromMilliseconds(0);
      ca1.AutoReverse = true;

      ColorAnimation ca2 = new ColorAnimation();
      ca2.From = m_ColorBrushes[m_moveColor].Color;
      ca2.To = m_ColorBrushes[0].Color;
      ca2.Duration = new Duration(TimeSpan.FromMilliseconds(500));
      ca2.BeginTime = ca1.BeginTime + TimeSpan.FromMilliseconds(500);

      ColorAnimation ca3 = new ColorAnimation();
      ca3.From = m_ColorBrushes[0].Color;
      ca3.To = m_ColorBrushes[m_moveColor].Color;
      ca3.Duration = new Duration(TimeSpan.FromMilliseconds(250));
      ca1.BeginTime = ca1.BeginTime;


      SolidColorBrush br1 = new SolidColorBrush();
      SolidColorBrush br2 = new SolidColorBrush();
      br2.Color = m_ColorBrushes[m_moveColor].Color;
      SolidColorBrush br3 = new SolidColorBrush();

      foreach(Point p in m_movePath) {
        if (p == m_movePath.First())
          m_Rectangles[p.Row, p.Col].Fill = br2;
        else if (p == m_movePath.Last())
          m_Rectangles[p.Row, p.Col].Fill = br3;
        else
        {
          // Border b = m_Borders[p.Row, p.Col];
          // b.BorderBrush = br1;
          // b.BorderThickness = new Thickness(2);
          m_Borders[p.Row, p.Col].Padding = new Thickness(20);
          m_Rectangles[p.Row, p.Col].Fill = br1;
        }
      }

      /*
      Point last = m_movePath.Last();
      m_Rectangles[last.Row, last.Col].Fill = br2;
      */

      // deselect the starting point
      Select(m_movePath.First(), false);

      ca1.Completed += moveAnimation_OnCompleted;

      br1.BeginAnimation(SolidColorBrush.ColorProperty, ca1);
      br2.BeginAnimation(SolidColorBrush.ColorProperty, ca2);
      br3.BeginAnimation(SolidColorBrush.ColorProperty, ca3);
    }
开发者ID:cudima,项目名称:lines,代码行数:65,代码来源:View.cs

示例12: prepareCanvas

        public void prepareCanvas()
        {
            //Clear the canvas
            StpScr.Children.Clear();

            //Margins
            double marginX = columnSpace * 0.33;
            double marginY = rowSpace * 0.27;

            //For each case
            for (int i = 0; i < 9; i++)
            {
                if (i != 4)
                {

                    Ellipse circle = new Ellipse();
                    circle.Width = rowSpace * 0.5;
                    circle.Height = rowSpace * 0.5;
                    circle.StrokeThickness = 10;

                    //circle.Stroke = new LinearGradientBrush(Colors.Snow, Colors.SkyBlue, 90);
                    ColorAnimation animeStroke = new ColorAnimation(Colors.White, Colors.Orange, TimeSpan.FromSeconds(3));
                    animeStroke.AutoReverse = true;
                    animeStroke.RepeatBehavior = RepeatBehavior.Forever;
                    SolidColorBrush myBrushStroke = new SolidColorBrush();
                    myBrushStroke.BeginAnimation(SolidColorBrush.ColorProperty, animeStroke);
                    circle.Stroke = myBrushStroke;

                    circle.RenderTransform = new TranslateTransform(columnSpace * (i % 3) + marginX, rowSpace * (i / 3) + marginY);

                    //Add it to the canvas
                    StpScr.Children.Add(circle);
                }
            }

            // current score display
            score = new TextBox();

            score.Background = null;
            score.BorderBrush = null;
            score.TextAlignment = System.Windows.TextAlignment.Center;
            score.Width = columnSpace * 0.8;

            score.FontSize = 36;
            score.FontFamily = new FontFamily("MV Boli");
            score.Foreground = Brushes.Snow;

            score.RenderTransform = new TranslateTransform(columnSpace * 2.2, 0);
            score.Text = "Score : " + currentScore;

            StpScr.Children.Add(score);
            //drawWithLabel(score);

            combo = new TextBox();

            combo.Background = null;
            combo.BorderBrush = null;
            combo.TextAlignment = System.Windows.TextAlignment.Center;
            combo.Width = columnSpace;

            combo.FontSize = 60;
            combo.FontFamily = new FontFamily("Jokerman");
            //combo.Foreground = new RadialGradientBrush(Colors.Red, Colors.DarkRed);
            ColorAnimation anime = new ColorAnimation(Colors.Red, Colors.Orange, TimeSpan.FromSeconds(3));
            anime.AutoReverse = true;
            anime.RepeatBehavior = RepeatBehavior.Forever;
            SolidColorBrush myBrush = new SolidColorBrush();
            myBrush.BeginAnimation(SolidColorBrush.ColorProperty, anime);
            combo.Foreground = myBrush;

            combo.RenderTransform = new TranslateTransform(columnSpace, rowSpace * 1.2);
            combo.Text = "Combo " + currentCombo + "!!";

            //StpScr.Children.Add(combo);
            comboBorder = drawWithLabel(combo);
        }
开发者ID:handrianj,项目名称:Maestro,代码行数:76,代码来源:ActionDisplay.cs

示例13: AnimEdge

 /// <summary>
 /// Animates a single edge
 /// </summary>
 /// <param name="edge">Edge to be animated</param>
 /// <param name="opacityAnim">Animation to be used</param>
 /// <param name="animatedBrush">Brush to be used</param>
 /// <param name="colorAnim">Color to be used</param>
 private void AnimEdge(Line edge, DoubleAnimation opacityAnim, SolidColorBrush animatedBrush, ColorAnimation colorAnim)
 {
     animatedBrush.BeginAnimation(SolidColorBrush.ColorProperty, colorAnim);
     edge.Stroke = animatedBrush;
     edge.BeginAnimation(Line.OpacityProperty, opacityAnim);
 }
开发者ID:AndrejKolar,项目名称:GraphDecomposition,代码行数:13,代码来源:MainWindow.xaml.cs

示例14: EaseBrush

        private SolidColorBrush EaseBrush( SolidColorBrush brush, Color finish, Duration time )
        {
            ColorAnimation ca = new ColorAnimation {
                To = finish,
                Duration = time
            };

            var tmp = new SolidColorBrush( brush.Color );
            tmp.BeginAnimation( SolidColorBrush.ColorProperty, ca );

            return tmp;
        }
开发者ID:austinedeveloper,项目名称:Metro-UI-Toolkit,代码行数:12,代码来源:WinStatesButton.xaml.cs

示例15: CardDragAdorner

        //fix MAINWINDOW bug
        public CardDragAdorner(CardControl anchor, CardControl sourceCard, Vector mousePoint)
            : base(Program.PlayWindow.Content as UIElement)
        {
            SourceCard = sourceCard;
            bool isCardInverted = anchor.IsOnTableCanvas && (Player.LocalPlayer.InvertedTable ^ anchor.IsInverted);
            Point cardOrigin;
            if (isCardInverted)
            {
                CardDef cardDef = Program.Game.Definition.CardDefinition;
                cardOrigin = new Point(cardDef.Width, cardDef.Height);
                _mouseOffset = new Vector(cardDef.Width - mousePoint.X, cardDef.Height - mousePoint.Y);
            }
            else
            {
                cardOrigin = new Point();
                _mouseOffset = mousePoint;
            }
            //fix MAINWINDOW bug
            _basePt = anchor.TranslatePoint(cardOrigin, Program.PlayWindow.Content as UIElement);

            _faceUp = sourceCard.IsAlwaysUp || sourceCard.Card.FaceUp;
            _lightRedBrush = Brushes.Red.Clone();
            _faceDownBrush = new ImageBrush(sourceCard.Card.GetBitmapImage(false));
            _faceUpBrush = _faceUp
                               ? new VisualBrush(sourceCard.GetCardVisual())
                                     {
                                         Viewbox = new Rect(0, 0, sourceCard.ActualWidth, sourceCard.ActualHeight),
                                         ViewboxUnits = BrushMappingMode.Absolute
                                     }
                               : (Brush)
                                 new ImageBrush(new BitmapImage(new Uri(Program.Game.Definition.CardDefinition.Front)));
            _invertTransform = new ScaleTransform {CenterX = 0.5, CenterY = 0.5};
            _faceUpBrush.RelativeTransform = _invertTransform;
            if (_faceUpBrush is VisualBrush)
                RenderOptions.SetCachingHint(_faceUpBrush, CachingHint.Cache);

            _child.BeginInit();
            _child.Width = anchor.ActualWidth*CardControl.ScaleFactor.Width;
            _child.Height = anchor.ActualHeight*CardControl.ScaleFactor.Height;
            _child.Fill = _faceUp ? _faceUpBrush : _faceDownBrush;
            _child.StrokeThickness = 3;

            var transforms = new TransformGroup();
            _child.RenderTransform = transforms;
            _rot = sourceCard.Card.Orientation;
            if ((_rot & CardOrientation.Rot180) != 0)
            {
                _rot180Transform = new RotateTransform(180, _child.Width/2, _child.Height/2);
                transforms.Children.Add(_rot180Transform);
            }
            if ((_rot & CardOrientation.Rot90) != 0)
            {
                _rot90Transform = isCardInverted
                                      ? new RotateTransform(90, _child.Width/2, _child.Width/2)
                                      : new RotateTransform(90, _child.Width/2, _child.Height - _child.Width/2);
                transforms.Children.Add(_rot90Transform);
            }
            _translate = new TranslateTransform();
            transforms.Children.Add(_translate);

            _child.IsHitTestVisible = false;
            _child.EndInit();
            AddVisualChild(_child);

            var animation = new DoubleAnimation(0.55, 0.75, new Duration(TimeSpan.FromMilliseconds(500)))
                                {AutoReverse = true, RepeatBehavior = RepeatBehavior.Forever};
            animation.Freeze();

            _faceUpBrush.BeginAnimation(Brush.OpacityProperty, animation);
            _faceDownBrush.BeginAnimation(Brush.OpacityProperty, animation);
            _lightRedBrush.BeginAnimation(Brush.OpacityProperty, animation);
        }
开发者ID:BastienDurel,项目名称:OCTGN,代码行数:73,代码来源:CardDragAdorner.cs


注:本文中的System.Windows.Media.SolidColorBrush.BeginAnimation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。