Exemplo n.º 1
1
        public void StoryboardTargetTest()
        {
            XamlNamespaces namespaces = new XamlNamespaces("http://schemas.microsoft.com/winfx/2006/xaml/presentation");

            ColorAnimation colorAnimation = new ColorAnimation { From = Colors.Green, To = Colors.Blue };
            Storyboard.SetTargetProperty(colorAnimation, PropertyPath.Parse("(Control.Background).(SolidColorBrush.Color)", namespaces));

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

            TestRootClock rootClock = new TestRootClock();

            Control control = new Control();
            control.SetAnimatableRootClock(new AnimatableRootClock(rootClock, true));
            control.Background = new SolidColorBrush(Colors.Red);

            storyboard.Begin(control);

            rootClock.Tick(TimeSpan.FromSeconds(0));
            Assert.AreEqual(Colors.Green, ((SolidColorBrush)control.Background).Color);

            rootClock.Tick(TimeSpan.FromSeconds(0.5));
            Assert.IsTrue(Color.FromArgb(255, 0, (byte)(Colors.Green.G / 2), (byte)(Colors.Blue.B / 2)).IsClose(((SolidColorBrush)control.Background).Color));

            rootClock.Tick(TimeSpan.FromSeconds(1));
            Assert.AreEqual(Colors.Blue, ((SolidColorBrush)control.Background).Color);
        }
Exemplo n.º 2
0
        public Paddle()
        {
            // Sets up the body part's shape.
            this.Shape = new Polygon
            {
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment = VerticalAlignment.Top,
                StrokeThickness = 3.0,
                Opacity = 1.0,
                Fill = Brushes.Orange,
                Stroke = Brushes.Black
            };
            this.state = PaddleState.PreGame;

            // Sets up the appear animation.
            this.AppearAnimation = new Storyboard();
            DoubleAnimation da = new DoubleAnimation(1.0, new Duration(Paddle.AppearAnimationDuration));
            Storyboard.SetTarget(da, this.Shape);
            Storyboard.SetTargetProperty(da, new PropertyPath(Polygon.OpacityProperty));
            this.AppearAnimation.Children.Add(da);

            // Sets up the hit animation.
            this.FillAnimation = new Storyboard();
            ColorAnimation ca = new ColorAnimation(Colors.Red, Colors.Orange, new Duration(Paddle.HitAnimationDuration));
            Storyboard.SetTarget(ca, this.Shape);
            Storyboard.SetTargetProperty(ca, new PropertyPath("Fill.Color", new object[] { Polygon.FillProperty, SolidColorBrush.ColorProperty }));
            this.FillAnimation.Children.Add(ca);
            this.State = PaddleState.PreGame;
        }
Exemplo n.º 3
0
        /// <summary>  </summary>
        /// <param name="mapControl"></param>
        public MyVectorCanvas(MapView mapView)
            : base(mapView)
        {
            var myPolygon = new MapPolygon()
            {
                Points = new PointCollection{ new Point(20,40), new Point(20, 50), new Point(30,50), new Point(30,40) }
            };
            myPolygon.Fill = new SolidColorBrush(Colors.Blue);
            myPolygon.Stroke = new SolidColorBrush(Colors.Black);
            myPolygon.InvariantStrokeThickness = 3;
            Children.Add(myPolygon);

            //// http://msdn.microsoft.com/en-us/library/system.windows.media.animation.coloranimation.aspx
            SolidColorBrush myAnimatedBrush = new SolidColorBrush();
            myAnimatedBrush.Color = Colors.Blue;
            myPolygon.Fill = myAnimatedBrush;
            MapView.RegisterName("MyAnimatedBrush", myAnimatedBrush);
            ColorAnimation mouseEnterColorAnimation = new ColorAnimation();
            mouseEnterColorAnimation.From = Colors.Blue;
            mouseEnterColorAnimation.To = Colors.Red;
            mouseEnterColorAnimation.Duration = TimeSpan.FromMilliseconds(250);
            mouseEnterColorAnimation.AutoReverse = true;
            Storyboard.SetTargetName(mouseEnterColorAnimation, "MyAnimatedBrush");
            Storyboard.SetTargetProperty(mouseEnterColorAnimation, new PropertyPath(SolidColorBrush.ColorProperty));
            Storyboard mouseEnterStoryboard = new Storyboard();
            mouseEnterStoryboard.Children.Add(mouseEnterColorAnimation);
            myPolygon.MouseEnter += delegate(object msender, MouseEventArgs args)
            {
                mouseEnterStoryboard.Begin(MapView);
            };
        }
Exemplo n.º 4
0
        /**
         * This class is intended to hold templates for any animations that need
         * to be created.
         * This was first created to allow easy creation of storyboards to be able
         * to highlight the board to show the ranks and files of the board seperately.
         */
        /// <summary>
        /// Highlights a square with a given colour. The square flashes this given colour
        /// </summary>
        public static Storyboard NewHighlighter(Square s, Brush brush, int delay)
        {
            int beginFadeIn = 0;
            int beginFadeOut = beginFadeIn + 300;

            Duration duration = new Duration(TimeSpan.FromMilliseconds(200));

            ColorAnimation fadeIn = new ColorAnimation()
            {
                From = ((SolidColorBrush)(s.rectangle.Fill)).Color,
                To = (brush as SolidColorBrush).Color,
                Duration = duration,
                BeginTime = TimeSpan.FromMilliseconds(beginFadeIn)
            };

            ColorAnimation fadeOut = new ColorAnimation()
            {
                From = (brush as SolidColorBrush).Color,
                To = (s.rectangle.Fill as SolidColorBrush).Color,
                Duration = duration,
                BeginTime = TimeSpan.FromMilliseconds(beginFadeOut)
            };

            Storyboard.SetTarget(fadeIn, s.rectangle);
            Storyboard.SetTargetProperty(fadeIn, new PropertyPath("Fill.Color"));
            Storyboard.SetTarget(fadeOut, s.rectangle);
            Storyboard.SetTargetProperty(fadeOut, new PropertyPath("Fill.Color"));

            Storyboard highlight = new Storyboard();
            highlight.Children.Add(fadeIn);
            highlight.Children.Add(fadeOut);

            return highlight;
        }
Exemplo n.º 5
0
        public void MatchFinished(bool isAccepted)
        {
            if (!isAccepted)
            {
                ColorAnimation opacityOut = new ColorAnimation(Colors.Transparent, new Duration(TimeSpan.FromSeconds(0.5)));
                card1.BeginAnimation(Rectangle.FillProperty, opacityOut, HandoffBehavior.SnapshotAndReplace);
                card2.BeginAnimation(Rectangle.FillProperty, opacityOut, HandoffBehavior.SnapshotAndReplace);
                card3.BeginAnimation(Rectangle.FillProperty, opacityOut, HandoffBehavior.SnapshotAndReplace);
            }
            else
            {
                ScaleTransform scale = new ScaleTransform(1.0, 1.0, card1.Width / 2, card1.Height / 2);
                DoubleAnimation scaleOutAnim = new DoubleAnimation(1.0, 10.0, new Duration(TimeSpan.FromSeconds(0.5)));
                card1.RenderTransform = scale;
                card2.RenderTransform = scale;
                card3.RenderTransform = scale;
                scale.BeginAnimation(ScaleTransform.ScaleXProperty, scaleOutAnim, HandoffBehavior.SnapshotAndReplace);
                scale.BeginAnimation(ScaleTransform.ScaleYProperty, scaleOutAnim, HandoffBehavior.SnapshotAndReplace);
                scaleOutAnim.Completed += new EventHandler(scaleOutAnim_Completed);

                DoubleAnimation opacityOutAnim = new DoubleAnimation(1.0, 0.0, new Duration(TimeSpan.FromSeconds(0.5)));
                card1.BeginAnimation(Rectangle.OpacityProperty, opacityOutAnim, HandoffBehavior.SnapshotAndReplace);
                card2.BeginAnimation(Rectangle.OpacityProperty, opacityOutAnim, HandoffBehavior.SnapshotAndReplace);
                card3.BeginAnimation(Rectangle.OpacityProperty, opacityOutAnim, HandoffBehavior.SnapshotAndReplace);
            }
        }
Exemplo n.º 6
0
        internal void SetRadius(double radius, string foreTo,
         TimeSpan duration)
        {
            if (radius > 200)
             {
            radius = 200;
             }
             Color foreToColor = Colors.Red;
             try
             {
            foreToColor =
               (Color)ColorConverter.ConvertFromString(foreTo);
             }
             catch
             {
            // Ignore color conversion failure.
             }
             Duration animationLength = new Duration(duration);

             DoubleAnimation radiusAnimation = new DoubleAnimation(
            radius * 2, animationLength);
             ColorAnimation colorAnimation = new ColorAnimation(
            foreToColor, animationLength);
             AnimatableEllipse.BeginAnimation(Ellipse.HeightProperty,
            radiusAnimation);
             AnimatableEllipse.BeginAnimation(Ellipse.WidthProperty,
            radiusAnimation);
             ((RadialGradientBrush)AnimatableEllipse.Fill).GradientStops[1]
            .BeginAnimation(GradientStop.ColorProperty, colorAnimation);
        }
        public OnlineStatusControl()
        {
            InitializeComponent();
            story = new Storyboard();
            ColorAnimation animation1 = new ColorAnimation();
            Storyboard.SetTarget(animation1, ((RadialGradientBrush)this.ellipse.Fill).GradientStops[0]);
            Storyboard.SetTargetProperty(
               animation1, new PropertyPath(GradientStop.ColorProperty));
            animation1.Duration = new Duration(new TimeSpan(0, 0, 1)); ;
            animation1.To = Colors.White;
            story.Stop();
            story.Children.Add(animation1);

            ColorAnimation animation2 = new ColorAnimation();
            Storyboard.SetTarget(animation2, ((RadialGradientBrush)this.ellipse.Fill).GradientStops[1]);
            Storyboard.SetTargetProperty(
               animation2, new PropertyPath(GradientStop.ColorProperty));
            animation2.Duration = new Duration(new TimeSpan(0, 0, 1)); ;
            animation2.To = Common.MyColor.ConvertColor("#ff2ADC16");
            story.Stop();
            story.Children.Add(animation2);

            story.AutoReverse = true;
            story.RepeatBehavior = RepeatBehavior.Forever;
            this.LayoutRoot.Resources.Add("sotry_", story);

            OnlineStatus = 1;
        }
 private void BtnColorAnimationStart_Click(object sender, RoutedEventArgs e)
 {
     ColorAnimation animation = new ColorAnimation(Colors.Blue, new Duration(TimeSpan.FromSeconds(5)));
     animation.AutoReverse = true;
     SolidColorBrush brush = (sender as FrameworkElement).FindResource("brush") as SolidColorBrush;
     brush.BeginAnimation(SolidColorBrush.ColorProperty, animation);
 }
Exemplo n.º 9
0
        private void AddClicked(object sender, RoutedEventArgs e)
        {
            e.Handled = true;

            // A double-click can only select a marker in its own list
            // (Little bug here: double-clicking in the empty zone of a list with a selected marker adds it)
            if (sender is ListBox && ((ListBox) sender).SelectedIndex == -1) return;

            if (recentList.SelectedIndex != -1) MarkerModel = (DataNew.Entities.Marker)recentList.SelectedItem;
            if (allList.SelectedIndex != -1) MarkerModel = (DataNew.Entities.Marker)allList.SelectedItem;
            if (defaultList.SelectedIndex != -1)
            {
                var m = ((DefaultMarkerModel) defaultList.SelectedItem);
                m.Name = nameBox.Text;
                MarkerModel = m.Clone();
            }

            if (MarkerModel == null) return;

            int qty;
            if (!int.TryParse(quantityBox.Text, out qty) || qty < 0)
            {
                var anim = new ColorAnimation(Colors.Red, new Duration(TimeSpan.FromMilliseconds(800)))
                               {AutoReverse = true};
                validationBrush.BeginAnimation(SolidColorBrush.ColorProperty, anim, HandoffBehavior.Compose);
                return;
            }

            Program.GameEngine.AddRecentMarker(MarkerModel);
            DialogResult = true;
        }
Exemplo n.º 10
0
        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            if (SourceShadow == null && TargetShadow == null)
            {
                throw new InvalidOperationException(@"TargetShadow and/or SourceShadow properties must be setted.");
            }
            if (TargetProperty == null)
            {
                throw new InvalidOperationException(@"TargetProperty property must be setted.");
            }

            var sb            = new Storyboard();
            var blurAnimation = new DoubleAnimation()
            {
                From           = SourceShadow != null ? SourceShadow.BlurRadius : (double?)null,
                To             = TargetShadow != null ? TargetShadow.BlurRadius : (double?)null,
                Duration       = new Duration(_duration),
                EasingFunction = new ExponentialEase {
                    EasingMode = EasingMode.EaseInOut
                },
                BeginTime = BeginTime,
            };
            var depthAnimation = new DoubleAnimation()
            {
                From           = SourceShadow != null ? SourceShadow.ShadowDepth : (double?)null,
                To             = TargetShadow != null ? TargetShadow.ShadowDepth : (double?)null,
                Duration       = new Duration(_duration),
                EasingFunction = new ExponentialEase {
                    EasingMode = EasingMode.EaseInOut
                },
                BeginTime = BeginTime
            };
            var colorAnimation = new System.Windows.Media.Animation.ColorAnimation()
            {
                From           = SourceShadow != null ? SourceShadow.Color : (Color?)null,
                To             = TargetShadow != null ? TargetShadow.Color : (Color?)null,
                Duration       = new Duration(_duration),
                EasingFunction = new ExponentialEase {
                    EasingMode = EasingMode.EaseInOut
                },
                BeginTime = BeginTime
            };

            if (TargetName != null)
            {
                Storyboard.SetTargetName(blurAnimation, TargetName);
                Storyboard.SetTargetName(depthAnimation, TargetName);
                Storyboard.SetTargetName(colorAnimation, TargetName);
            }

            Storyboard.SetTargetProperty(blurAnimation, new PropertyPath(TargetProperty.Path + @"." + DropShadowEffect.BlurRadiusProperty.Name));
            Storyboard.SetTargetProperty(depthAnimation, new PropertyPath(TargetProperty.Path + @"." + DropShadowEffect.ShadowDepthProperty.Name));
            Storyboard.SetTargetProperty(colorAnimation, new PropertyPath(TargetProperty.Path + @"." + DropShadowEffect.ColorProperty.Name));

            sb.Children.Add(blurAnimation);
            sb.Children.Add(depthAnimation);
            sb.Children.Add(colorAnimation);
            return(sb);
        }
Exemplo n.º 11
0
        public void Dispose()
        {
            _control = null;
            brush = null;

            this.ca = null;
            this.sb = null;
        }
Exemplo n.º 12
0
        /// <summary>
        /// Constructor! Hurrah!
        /// </summary>
        /// <param name="feeditem"></param>
        public FeedWin(FeedConfigItem feeditem)
        {
            Log.Debug("Constructing feedwin. GUID:{0} URL: {1}", feeditem.Guid, feeditem.Url);
            InitializeComponent();

            fci = feeditem;
            Width = fci.Width;
            Left = fci.Position.X;
            Top = fci.Position.Y;
            //Kick of thread to figure out what sort of plugin to load for this sort of feed.
            ThreadPool.QueueUserWorkItem(state => GetFeedType(fci));

            //Set up the animations for the mouseovers
            fadein = new ColorAnimation { AutoReverse = false, From = fci.DefaultColor, To = fci.HoverColor, Duration = new Duration(TimeSpan.FromMilliseconds(200)), RepeatBehavior = new RepeatBehavior(1) };
            fadeout = new ColorAnimation { AutoReverse = false, To = fci.DefaultColor, From = fci.HoverColor, Duration = new Duration(TimeSpan.FromMilliseconds(200)), RepeatBehavior = new RepeatBehavior(1) };

            textbrush = new SolidColorBrush(feeditem.DefaultColor);

            //Add the right number of textblocks to the form, depending on what the user asked for.
            for (var ii = 0; ii < fci.DisplayedItems; ii++)
            {
                maingrid.RowDefinitions.Add(new RowDefinition());
                var textblock = new TextBlock
                                    {
                                        Style = (Style)FindResource("linkTextStyle"),
                                        Name = string.Format("TextBlock{0}", ii + 1),
                                        TextTrimming = TextTrimming.CharacterEllipsis,
                                        Foreground = textbrush.Clone(),
                                        Background = new SolidColorBrush(Color.FromArgb(1, 0, 0, 0)),
                                        FontFamily = fci.FontFamily,
                                        FontSize = fci.FontSize,
                                        FontStyle = fci.FontStyle,
                                        FontWeight = fci.FontWeight,
                                        Visibility = Visibility.Collapsed
                                    };

                textblock.SetValue(Grid.ColumnSpanProperty, 2);
                RegisterName(textblock.Name, textblock);
                maingrid.Children.Add(textblock);
                Grid.SetRow(textblock, ii + 1);
            }

            maingrid.RowDefinitions.Add(new RowDefinition());
            movehandle = new Image();
            movehandle.Width = movehandle.Height = 16;
            movehandle.Name = "movehandle";

            movehandle.HorizontalAlignment = HorizontalAlignment.Left;

            movehandle.Cursor = Cursors.SizeAll;
            movehandle.Source = new BitmapImage(new Uri("/Feedling;component/Resources/move-icon.png", UriKind.Relative));
            movehandle.SetValue(Grid.ColumnSpanProperty, 2);
            RegisterName(movehandle.Name, movehandle);
            maingrid.Children.Add(movehandle);
            movehandle.MouseDown += movehandle_MouseDown;
            movehandle.Visibility = Visibility.Collapsed;
            Grid.SetRow(movehandle, maingrid.RowDefinitions.Count);
        }
Exemplo n.º 13
0
        public void mouseDown(object sender, MouseButtonEventArgs e)
        {
            Cell c = sender as Cell;
            Color color = c.color;
            if (color == Colors.White)
            {
                ColorAnimation a = new ColorAnimation();
                a.From = Colors.White;
                a.To = Colors.Red;
                a.Duration = TimeSpan.FromSeconds(0.2);
                a.RepeatBehavior = new RepeatBehavior(3);
                a.Completed += (s, ev) => {
                    End.Visibility = System.Windows.Visibility.Visible;
                    EndScore.Content = score;
                };
                c.Background.BeginAnimation(SolidColorBrush.ColorProperty, a);
                Playground.IsEnabled = false;
                return;
            }
            else if (color == Colors.Black)
            {
                if (!lines[3].Contains(c))
                {
                    return;
                }
                ColorAnimation a = new ColorAnimation();
                a.From = color;
                a.To = c.color = Colors.Gray;
                a.Duration = TimeSpan.FromSeconds(0.2);
                c.Background.BeginAnimation(SolidColorBrush.ColorProperty, a);
                score++;
                Score.Content = score;
            }

            Cell[] line4 = lines[3];
            ThicknessAnimation animation = new ThicknessAnimation();
            for (int i = 4; i >= 0; i--)
            {
                Cell[] line;
                if (i >= 4) line = line4;
                else if (i > 0) line = lines[i] = lines[i - 1];
                else line = lines[0] = newLine(0);
                for (int j = 0; j < 4; j++)
                {
                    Cell cell = line[j];
                    animation.From = new Thickness(j * cellWidth, (i - 1) * cellHeight, 0, 0);
                    animation.To = new Thickness(j * cellWidth, i * cellHeight, 0, 0);
                    animation.Duration = TimeSpan.FromSeconds(0.2);
                    animation.Completed += (s, ev) => cell.Margin = new Thickness(j * cellWidth, (i + 1) * cellHeight, 0, 0);
                    if (i == 4)
                    {
                        animation.Completed += (s, ev) => Playground.Children.Remove(cell);
                    }
                    cell.BeginAnimation(Grid.MarginProperty, animation);
                }
            }
        }
Exemplo n.º 14
0
        public void Verify(DPFP.Sample Sample)
        {
            DPFP.FeatureSet features = ExtractFeatures(Sample, DPFP.Processing.DataPurpose.Verification);

            // Check quality of the sample and start verification if it's good
            // TODO: move to a separate task
            if (features != null)
            {
                // Compare the feature set with our template
                DPFP.Verification.Verification.Result result = new DPFP.Verification.Verification.Result();
                Verificator.Verify(features, Template, ref result);
                if (result.Verified)
                {
                    this.Dispatcher.Invoke(() =>
                    {
                        if (this.ClockShow != null)
                            this.ClockShow.Controller.Pause();
                        ColorAnimation animation = new ColorAnimation();
                        animation.From = (this.UIFinger_Printer.Foreground as SolidColorBrush).Color;
                        animation.To = Colors.Green;
                        animation.Duration = new Duration(TimeSpan.FromMilliseconds(450));
                        animation.EasingFunction = new PowerEase() { Power = 5, EasingMode = EasingMode.EaseInOut };
                        animation.Completed += (s,e) => 
                        {
                            App.curUser = UserData.Info(this.cacheName);
                            App.curUserID = App.curUser.ID;
                            if (this.UIAutoLogin.IsChecked.Value)
                            {
                                App.cache.hashUserName = App.getHash(App.curUserID);
                                App.cache.userName = Encrypt.EncryptString(this.UITxtName.Text.Trim(), FunctionStatics.getCPUID());
                                AltaCache.Write(App.CacheName, App.cache);
                            }
                            else
                            {
                                App.cache.userName = string.Empty;
                                App.cache.hashUserName = string.Empty;
                            }
                            this.UIFullName.Text = App.curUser.Full_Name;
                            this.UILoginFinger.Animation_Translate_Frame(double.NaN, double.NaN, 400, double.NaN, 500);
                            this.UILoginSusscess.Animation_Translate_Frame(-400, double.NaN, 0, double.NaN, 500, () => { LoadData(); });
                        };
                        this.ClockHide = animation.CreateClock();
                        this.UIFinger_Printer.Foreground.ApplyAnimationClock(SolidColorBrush.ColorProperty, ClockHide);
                        this.UIFinger_Status.Text = string.Empty;
                    });                   
                    this.Stop();
                }
                else
                {
                    this.Dispatcher.Invoke(() =>
                    {
                        this.UIFinger_Status.Text = "Try again ...";
                    });
                }
            }
        }
Exemplo n.º 15
0
        public WrittenCheckControl()
        {
            InitializeComponent();

            m_textBoxAnswerAnimation = new ColorAnimation();
            m_textBoxAnswerAnimation.Duration = new TimeSpan(0, 0, 0, 0, 300);
            m_textBoxAnswerAnimation.To = Colors.White;

            textBoxAnswer.Background = new SolidColorBrush(Colors.White);
        }
Exemplo n.º 16
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);
 }
Exemplo n.º 17
0
 public void FadeOut()
 {
     FadeLabel FadeLabel = this;
     var changeColorAnimation = new ColorAnimation(Color.FromRgb(NoHoverColor, NoHoverColor, NoHoverColor), TimeSpan.FromSeconds(0.5));
     Storyboard s = new Storyboard();
     s.Duration = new Duration(new TimeSpan(0, 0, 1));
     s.Children.Add(changeColorAnimation);
     Storyboard.SetTarget(changeColorAnimation, FadeLabel);
     Storyboard.SetTargetProperty(changeColorAnimation, new PropertyPath("Foreground.Color"));
     s.Begin();
 }
Exemplo n.º 18
0
 void FadeLabel_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
 {
     FadeLabel RegionLabel = this;
     var changeColorAnimation = new ColorAnimation(Color.FromRgb(HoverColor, HoverColor, HoverColor), TimeSpan.FromSeconds(0.5));
     Storyboard s = new Storyboard();
     s.Duration = new Duration(new TimeSpan(0, 0, 1));
     s.Children.Add(changeColorAnimation);
     Storyboard.SetTarget(changeColorAnimation, RegionLabel);
     Storyboard.SetTargetProperty(changeColorAnimation, new PropertyPath("Foreground.Color"));
     s.Begin();
 }
Exemplo n.º 19
0
 static Animation()
 {
     ca = new ColorAnimation();
     ta = new ThicknessAnimation();
     da = new DoubleAnimation();
     sbOnce = new Storyboard();
     sbForever = new Storyboard();
     sbForever.RepeatBehavior = RepeatBehavior.Forever;
     sbForever.Children.Add(new DoubleAnimation());
     sb = sbOnce;
     sb.Children.Add(new DoubleAnimation());
 }
Exemplo n.º 20
0
        public override IEnumerable <AnimationTimeline> GetTimeline()
        {
            if (!(To is Color) || Path == null)
            {
                return(null);
            }

            var a = new System.Windows.Media.Animation.ColorAnimation((Color)To, TimeSpan.FromSeconds(0.2));

            Storyboard.SetTargetProperty(a, Path);
            return(new[] { a });
        }
 public static void Animation_Color_Repeat(this SolidColorBrush E, Color from, Color to, double time = 500)
 {
     if (from == null)
     {
         from = E.GetColor();
     }
     ColorAnimation animation = new ColorAnimation();
     animation.From = from;
     animation.To = to;
     animation.Duration = TimeSpan.FromMilliseconds(time);
     animation.RepeatBehavior = RepeatBehavior.Forever;
     animation.EasingFunction = new PowerEase() { EasingMode = EasingMode.EaseInOut, Power = 3 };
     E.BeginAnimation(SolidColorBrush.ColorProperty, animation);
 }
Exemplo n.º 22
0
 public InvalidateControl(Control control)
 {
     _control = control;
     sb = new Storyboard();
     ca = new ColorAnimation();
     sb.Children.Add(ca);
     Storyboard.SetTarget(ca, control);
     Storyboard.SetTargetProperty(ca, new PropertyPath("(Background).(Color)"));
     ca.Duration = App.COLOR_ALARMDURATION;
     ca.To = App.GetResourceByKey<SolidColorBrush>("COLOR_PRIMARY").Color;
     ca.AutoReverse = true;
     ca.RepeatBehavior = new RepeatBehavior(2);
     sb.Completed += sb_Completed;
 }
        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;
        }
Exemplo n.º 24
0
        private void CurrentTrackAnimation(TextBlock txt, Polygon poly, bool inAnimate)
        {
            Storyboard story = new Storyboard();

            ColorAnimation coloranimation2 = new ColorAnimation(inAnimate ? ((SolidColorBrush)Application.Current.Resources["AccentColorBrush"]).Color : (Color)Application.Current.Resources["BlackColor"], TimeSpan.FromMilliseconds(250));
            Storyboard.SetTarget(coloranimation2, txt);
            Storyboard.SetTargetProperty(coloranimation2, new PropertyPath("Foreground.Color"));

            ThicknessAnimation thicknessanimation = new ThicknessAnimation(inAnimate ? new Thickness(3, 2, -3, 0) : new Thickness(0, 2, 0, 0), TimeSpan.FromMilliseconds(250));
            Storyboard.SetTarget(thicknessanimation, poly);
            Storyboard.SetTargetProperty(thicknessanimation, new PropertyPath(MarginProperty));

            story.Children.Add(coloranimation2);
            story.Children.Add(thicknessanimation);
            story.Begin(this);
        }
Exemplo n.º 25
0
        /// <summary>
        /// Создание анимации цвета
        /// </summary>
        /// <param name="from">Исходный цвет</param>
        /// <param name="to">Целевой цвет</param>
        /// <param name="targetName">Имя Brush</param>
        /// <param name="reversed">Наоборот</param>
        /// <param name="durationMs">Продолжительность</param>
        /// <param name="autoreverse">Авторазворот</param>
        /// <param name="repeat">Повтор</param>
        /// <returns></returns>
        public static ColorAnimation CreateColorAnimation(Color from, Color to, string targetName, bool reversed,
            int durationMs = 175, bool autoreverse = false, bool repeat = false)
        {
            var duration = TimeSpan.FromMilliseconds(durationMs);
            var animation = new ColorAnimation(reversed ? @from : to, reversed ? to : @from, duration)
            {
                AutoReverse = autoreverse
            };

            if (repeat) animation.RepeatBehavior = RepeatBehavior.Forever;

            Storyboard.SetTargetName(animation, targetName);
            Storyboard.SetTargetProperty(animation, new PropertyPath(SolidColorBrush.ColorProperty));

            return animation;
        }
Exemplo n.º 26
0
        public override IEnumerable <AnimationTimeline> GetTimeline()
        {
            var target = To as DropShadowEffect;

            if (!(To is DropShadowEffect) || Path == null)
            {
                return(null);
            }

            var blurAnimation = new DoubleAnimation()
            {
                To             = target.BlurRadius,
                Duration       = TimeSpan.FromSeconds(0.2),
                EasingFunction = new ExponentialEase {
                    EasingMode = EasingMode.EaseInOut
                },
                BeginTime = TimeSpan.Zero,
            };
            var depthAnimation = new DoubleAnimation()
            {
                To             = target.ShadowDepth,
                Duration       = TimeSpan.FromSeconds(0.2),
                EasingFunction = new ExponentialEase {
                    EasingMode = EasingMode.EaseInOut
                },
                BeginTime = TimeSpan.Zero
            };
            var colorAnimation = new System.Windows.Media.Animation.ColorAnimation()
            {
                To             = target.Color,
                Duration       = TimeSpan.FromSeconds(0.2),
                EasingFunction = new ExponentialEase {
                    EasingMode = EasingMode.EaseInOut
                },
                BeginTime = TimeSpan.Zero
            };

            var converter = new PropertyPathConverter();
            var pathStr   = converter.ConvertToString(Path);

            Storyboard.SetTargetProperty(blurAnimation, CombinePath(converter, pathStr, DropShadowEffect.BlurRadiusProperty));   //new PropertyPath(Path.Path + @"." + DropShadowEffect.BlurRadiusProperty.Name));
            Storyboard.SetTargetProperty(depthAnimation, CombinePath(converter, pathStr, DropShadowEffect.ShadowDepthProperty)); //new PropertyPath(Path.Path + @"." + DropShadowEffect.ShadowDepthProperty.Name));
            Storyboard.SetTargetProperty(colorAnimation, CombinePath(converter, pathStr, DropShadowEffect.ColorProperty));       //new PropertyPath(Path.Path + @"." + DropShadowEffect.ColorProperty.Name));

            return(new AnimationTimeline[] { blurAnimation, depthAnimation, colorAnimation });
        }
        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);
        }
        public DwellTimeButton()
        {
            InitializeComponent();

            _isClicked = false;

            _buttonList.Add(this);

            _timer = new DispatcherTimer();
            _timer.Interval = new TimeSpan(0, 0, 0, 0, 10);
            _timer.Tick += _timer_Tick;

            #region MOUSE EVENTS
            _mouseEnterArgs = new MouseEventArgs(Mouse.PrimaryDevice, 0);
            _mouseEnterArgs.RoutedEvent = Mouse.MouseEnterEvent;

            _mouseLeaveArgs = new MouseEventArgs(Mouse.PrimaryDevice, 0);
            _mouseLeaveArgs.RoutedEvent = Mouse.MouseLeaveEvent;
            #endregion

            #region ANIMATION COLORS
            _redBrush = (Color)ColorConverter.ConvertFromString("#fe2712");
            _greenBrush = (Color)ColorConverter.ConvertFromString("#ffffff");
            #endregion

            #region COLOR ANIMATION
            _animatedBrush = new SolidColorBrush {Color = _greenBrush};

            _enterColorAnimation = new ColorAnimation
                                       {To = _redBrush, Duration = TimeSpan.FromMilliseconds(_DWELL_TIME)};
            _enterClock = _enterColorAnimation.CreateClock();
            _enterClock.CurrentTimeInvalidated += new EventHandler(EnterClockCurrentTimeInvalidated);

            _leavecolorAnimation = new ColorAnimation {Duration = TimeSpan.FromMilliseconds(_DWELL_TIME/2)};
            _leaveClock = _leavecolorAnimation.CreateClock();

            #endregion

            _dwelltime = _DWELL_TIME; //set the value for the dwell time

            Background = whiteBackground();
        }
Exemplo n.º 29
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;
        }
Exemplo n.º 30
0
        internal void AnimateLabel(Label label, Color color) {
            // Attaching the NameScope to the label makes sense if you're only animating
            // things that belong to that label; this allows you to animate any number
            // of labels simultaneously with this method without SetTargetName setting
            // the wrong thing as the target.
            NameScope.SetNameScope(label, new NameScope());
            label.Background = new SolidColorBrush(color);
            label.RegisterName("Brush", label.Background);

            ColorAnimation highlightAnimation = new ColorAnimation();
            highlightAnimation.To = Colors.Transparent;
            highlightAnimation.Duration = TimeSpan.FromSeconds(3);

            Storyboard.SetTargetName(highlightAnimation, "Brush");
            Storyboard.SetTargetProperty(highlightAnimation, new PropertyPath(SolidColorBrush.ColorProperty));

            Storyboard sb = new Storyboard();
            sb.Children.Add(highlightAnimation);
            sb.Begin(label);
        }
Exemplo n.º 31
0
        public BodyPart()
        {
            // Sets up the body part's shape.
            this.Shape = new Polygon
            {
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment = VerticalAlignment.Top,
                StrokeThickness = 2.0,
                Fill = Brushes.Black,
                Stroke = Brushes.White
            };
            this.state = BodyPartState.PreGame;

            // Sets up the animation for the body part.
            this.FillAnimation = new Storyboard();
            ColorAnimation ca = new ColorAnimation(Colors.White, new Duration(BodyPart.AnimationDuration));
            Storyboard.SetTarget(ca, this.Shape);
            Storyboard.SetTargetProperty(ca, new PropertyPath("Fill.Color", new object[] { Polygon.FillProperty, SolidColorBrush.ColorProperty }));
            this.FillAnimation.Children.Add(ca);
        }
Exemplo n.º 32
0
        private void SetUpAnimations()
        {
            RegisterName("ArrowAnimatedBrush", viewModel.ArrowAnimatedBrush);

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

            Storyboard.SetTargetName(animation, "ArrowAnimatedBrush");
            Storyboard.SetTargetProperty(animation, new PropertyPath(SolidColorBrush.ColorProperty));

            var sb = new Storyboard();
            sb.Children.Add(animation);
            sb.Begin(this);
        }
 public static void Animation_Color(this SolidColorBrush E, Color from, Color to, double time = 500, Action CompleteAction = null)
 {
     if (from == null)
     {
         from = E.GetColor();
     }
     ColorAnimation animation = new ColorAnimation();
     animation.From = from;
     animation.To = to;
     animation.Duration = TimeSpan.FromMilliseconds(time);
     animation.Completed += (s,e) =>
     {
         if (CompleteAction != null)
         {
             CompleteAction();
         }
     };
     animation.EasingFunction = new PowerEase() { EasingMode = EasingMode.EaseInOut, Power = 3 };
     E.BeginAnimation(SolidColorBrush.ColorProperty, animation);
 }
Exemplo n.º 34
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:

            #line 8 "..\..\MainWindow.xaml"
                ((_3DCubeImages.MainWindow)(target)).Loaded += new System.Windows.RoutedEventHandler(this.Window_Loaded);

            #line default
            #line hidden
                return;

            case 2:
                this.ColorLight = ((System.Windows.Media.Media3D.DirectionalLight)(target));
                return;

            case 3:
                this.imageBrush1 = ((System.Windows.Media.ImageBrush)(target));
                return;

            case 4:
                this.myRotate3D = ((System.Windows.Media.Media3D.RotateTransform3D)(target));
                return;

            case 5:
                this.rotate = ((System.Windows.Media.Media3D.AxisAngleRotation3D)(target));
                return;

            case 6:
                this.rotateAnimation = ((System.Windows.Media.Animation.Rotation3DAnimation)(target));
                return;

            case 7:
                this.ColorAnimation1 = ((System.Windows.Media.Animation.ColorAnimation)(target));
                return;

            case 8:
                this.ColorAnimation2 = ((System.Windows.Media.Animation.ColorAnimation)(target));
                return;

            case 9:
                this.ColorAnimation3 = ((System.Windows.Media.Animation.ColorAnimation)(target));
                return;

            case 10:
                this.listFile1 = ((System.Windows.Controls.ListView)(target));

            #line 116 "..\..\MainWindow.xaml"
                this.listFile1.MouseUp += new System.Windows.Input.MouseButtonEventHandler(this.ListFile1_MouseUp);

            #line default
            #line hidden
                return;

            case 11:
                this.button2 = ((System.Windows.Controls.Button)(target));

            #line 123 "..\..\MainWindow.xaml"
                this.button2.Click += new System.Windows.RoutedEventHandler(this.Button2_Click);

            #line default
            #line hidden
                return;
            }
            this._contentLoaded = true;
        }