Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
 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);
 }
        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;
        }
Ejemplo n.º 4
0
 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));
 }
        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);
        }
Ejemplo n.º 6
0
        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;
        }
Ejemplo n.º 7
0
       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();
       }
Ejemplo n.º 8
0
        /// <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();
        }
Ejemplo n.º 9
0
        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;
        }
 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;
 }
Ejemplo n.º 11
0
Archivo: View.cs Proyecto: cudima/lines
    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);
    }
Ejemplo n.º 12
0
        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);
        }
 /// <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);
 }
        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;
        }
Ejemplo n.º 15
0
        //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);
        }
        private void ShowInfo(string msg, Color color)
        {
            ShowInfo(msg);

            // Create and animate a Brush to set the button's Background.
            SolidColorBrush myBrush = new SolidColorBrush();
            myBrush.Color = Colors.Black;
            ColorAnimation myColorAnimation = new ColorAnimation();
            myColorAnimation.From = Colors.Black;
            myColorAnimation.To = color;
            myColorAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(200));
            myColorAnimation.AutoReverse = true;
            myColorAnimation.RepeatBehavior = new RepeatBehavior(3);

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

            lbInfo.Foreground = myBrush;
        }
Ejemplo n.º 17
0
Archivo: View.cs Proyecto: cudima/lines
    public void Disappear(Point[] lines)
    {
      m_disappearPath = lines;

      var linesByBrush = new List<Point>[m_ColorBrushes.Length];
      foreach (Point p in lines)
      {
        SolidColorBrush b = m_Rectangles[p.Row, p.Col].Fill as SolidColorBrush;
        for (int i = 1; i < m_ColorBrushes.Length; i++)
        {
          if (b == m_ColorBrushes[i])
          {
            if (linesByBrush[i] == null)
              linesByBrush[i] = new List<Point>();
            linesByBrush[i].Add(p);
            break;
          }
        }
      }

      bool first = true;
      for (int i = 1; i < linesByBrush.Length; i++)
      {
        if (linesByBrush[i] == null)
          continue;

        ColorAnimation ca = new ColorAnimation();
        ca.From = m_ColorBrushes[i].Color;
        ca.To = m_ColorBrushes[0].Color;
        ca.Duration = new Duration(TimeSpan.FromMilliseconds(500));
        // ca1.From = Brushes.LightSteelBlue.Color;
        // ca1.To = Brushes.Red.Color;

        SolidColorBrush br = new SolidColorBrush();
        br.Color = m_ColorBrushes[i].Color;

        foreach (Point p in linesByBrush[i])
          m_Rectangles[p.Row, p.Col].Fill = br;

        if (first)
        {
          ca.Completed += disappearAnimation_OnCompleted;
          first = false;
        }

        br.BeginAnimation(SolidColorBrush.ColorProperty, ca);
      }
    }
Ejemplo n.º 18
0
		private PiePiece CreatePiePiece(int rad, double wedgeAngle, double rotationAngle, int level, CallTreeNodeViewModel node)
		{
			// prevent exception when ProfilerHook screws up and children are larger than their parent (e.g. when process is killed)
			if (rotationAngle > 360)
				rotationAngle %= 360;
			
			PiePiece p = new PiePiece();

			p.Radius = 20 + level * rad;
			p.InnerRadius = level * rad;
			p.WedgeAngle = wedgeAngle;
			p.RotationAngle = rotationAngle;
			p.Stroke = Brushes.Black;
			p.ToolTip = node.CreateToolTip(Translation);
			p.VerticalAlignment = VerticalAlignment.Center;
			p.HorizontalAlignment = HorizontalAlignment.Center;
			p.Tag = node;

			p.MouseLeftButtonDown += new MouseButtonEventHandler(
				delegate(object sender, MouseButtonEventArgs e)	{					
					node.IsExpanded = true;
					node.IsSelected = true; // expand the path to the node so that the treeview can select it
					var oldNode = SelectedRoot;
					SelectedRoot = node;
					oldNode.IsSelected = false;
				}
			);
			
			HSVColor hsv = new HSVColor {
				Hue = (float)rotationAngle,
				Saturation = 0.5f,
				Value = 0.6f - level / 50f
			};
			
			SolidColorBrush brush = new SolidColorBrush();
			p.Fill = brush;
			
			Color normalColor = hsv.ToColor();
			hsv.Value = 0.8f;
			Color highlightColor = hsv.ToColor();
			brush.Color = normalColor;
			
			p.IsMouseDirectlyOverChanged += (sender, e) => {
				if (p.IsMouseDirectlyOver) {
					brush.BeginAnimation(SolidColorBrush.ColorProperty,
					                     new ColorAnimation(highlightColor, new Duration(TimeSpan.FromSeconds(0.5)),
					                                        FillBehavior.HoldEnd));
				} else {
					brush.BeginAnimation(SolidColorBrush.ColorProperty,
					                     new ColorAnimation(normalColor, new Duration(TimeSpan.FromSeconds(0.5)),
					                                        FillBehavior.Stop));
				}
			};

			return p;
		}
Ejemplo n.º 19
0
        /// <summary>
        /// 1ポモドーロが終わった際に、ユーザーに通知するための画面処理を行います。
        /// </summary>
        private void Alert()
        {
            this.LocateWindowCenter();
            this.label1.Content = "End";
            this.label1.Margin = new Thickness(40, 20, 40, 20);
            this.label2.Margin = new Thickness(40, 20, 40, 20);

            // Create and animate a Brush to set the button's Background.
            SolidColorBrush myBrush = new SolidColorBrush();
            myBrush.Color = Colors.White;

            ColorAnimation myBackColorAnimation = new ColorAnimation();
            myBackColorAnimation.From = Colors.Black;
            myBackColorAnimation.To = Colors.Yellow;
            myBackColorAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(20));
            myBackColorAnimation.AutoReverse = true;
            myBackColorAnimation.RepeatBehavior = RepeatBehavior.Forever;

            // Apply the animation to the brush's Color property.
            myBrush.BeginAnimation(SolidColorBrush.ColorProperty, myBackColorAnimation);
            this.label1.Foreground = myBrush;
        }
        /// <summary>
        /// Create the specified brush. The opacity is set based on the 
        /// current filtered state. The brush contains an animation if 
        /// the filtered state has changed.
        /// </summary>
        protected SolidColorBrush GetBrush(Color color)
        {
            // Create the brush.
            SolidColorBrush brush = new SolidColorBrush(color);

            // Set the opacity based on the filtered state.
            brush.Opacity = (this.isFiltered) ? Const.OpacityFiltered : Const.OpacityNormal;

            // Create animation if the filtered state has changed.
            if (animation != null)
                brush.BeginAnimation(Brush.OpacityProperty, animation);

            return brush;
        }
Ejemplo n.º 21
0
        /* Methods
           ---------------------------------------------------------------------------------------*/
        // Animates a brush to gradually fade from one color to another.
        private SolidColorBrush EaseBrush( SolidColorBrush brush, Color finish, Duration time )
        {
            ColorAnimation ca = new ColorAnimation {
                To = finish,
                Duration = time
            };

            // Since the Color property is sealed create a new SolidBrush with the originals Color
            var tmp = new SolidColorBrush( brush.Color );
            tmp.BeginAnimation( SolidColorBrush.ColorProperty, ca );

            return tmp;
        }