コード例 #1
0
        public async Task BubbleSort(int[] arr, Button[] button)
        {
            int i, j;
            // loop count
            int loopcnt = 0;

            loopCount.Visibility = Visibility.Visible;
            loopCount.Content    = "Loop: " + loopcnt;

            // step count
            int stepcnt = 0;

            stepCount.Visibility = Visibility.Visible;
            stepCount.Content    = "Steps: " + stepcnt;

            for (i = 0; i < arr.Length; i++)
            {
                for (j = 0; j < arr.Length - 1; j++)
                {
                    // animation begin
                    SolidColorBrush brush = new SolidColorBrush(Colors.White);
                    button[j].Background     = brush;
                    button[j + 1].Background = brush;
                    ColorAnimation anima = new ColorAnimation(Colors.White, Colors.Orange, new Duration(TimeSpan.FromSeconds(0.5)));
                    brush.BeginAnimation(SolidColorBrush.ColorProperty, anima);
                    // animation end
                    await Task.Delay(1000);

                    if (arr[j] > arr[j + 1]) // if current is bigger then next
                    {
                        // animation begin
                        button[j].Background     = brush;
                        button[j + 1].Background = brush;
                        brush.BeginAnimation(SolidColorBrush.ColorProperty, anima);
                        // animation end
                        await Task.Delay(1000);

                        (button[j].Content, button[j + 1].Content) = (button[j + 1].Content, button[j].Content); // shifts button
                        (arr[j], arr[j + 1]) = (arr[j + 1], arr[j]);                                             // shifts array

                        button[j].Background     = Brushes.White;
                        button[j + 1].Background = Brushes.White;

                        // update step count
                        stepcnt++;
                        stepCount.Content = "Steps: " + stepcnt;
                    }

                    button[j].Background     = Brushes.White;
                    button[j + 1].Background = Brushes.White;
                }
                // update loop count
                loopcnt++;
                loopCount.Content = "Loop: " + loopcnt;
            }

            // enable all buttons
            selBtn.IsEnabled = true;
            bblBtn.IsEnabled = true;
        }
コード例 #2
0
        static void AnimateColorAndOpacity(SolidColorBrush targetBrush, Color startColor, Color endColor, double startOpacity, double endOpacity)
        {
            ColorAnimation  colorAnimation   = new ColorAnimation(startColor, endColor, TimeSpan.FromMilliseconds(200));
            DoubleAnimation opacityAnimation = new DoubleAnimation(startOpacity, endOpacity, TimeSpan.FromMilliseconds(200));

            targetBrush.BeginAnimation(SolidColorBrush.OpacityProperty, opacityAnimation);
            targetBrush.BeginAnimation(SolidColorBrush.ColorProperty, colorAnimation);
        }
コード例 #3
0
        public InputTab()
        {
            InitializeComponent();

            colorAnimation = new ColorAnimation()
            {
                From     = Brushes.LightGreen.Color,
                To       = Brushes.Black.Color,
                Duration = TimeSpan.FromSeconds(0.6)
            };
            animatedBrush.BeginAnimation(SolidColorBrush.ColorProperty, colorAnimation);
        }
コード例 #4
0
        private void AnimateFinishedBrighten()
        {
            ColorAnimation colorAnim = new ColorAnimation
            {
                To                = (Color)FindResource("AccentColor"),
                Duration          = new TimeSpan(0, 0, 0, 0, 200),
                AutoReverse       = false,
                AccelerationRatio = 0.1
            };

            SolidColorBrush brush = new SolidColorBrush(((SolidColorBrush)MainGrid.Background).Color);

            MainGrid.Background = brush;

            brush.BeginAnimation(SolidColorBrush.ColorProperty, colorAnim);

            Timer bgBackTimer = new Timer()
            {
                Interval  = 200,
                AutoReset = false
            };

            bgBackTimer.Elapsed += BgBackTimer_Elapsed;
            bgBackTimer.Start();
        }
コード例 #5
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            foreach (var oItem in oCanvas_Image.Children)
            {
                var oItemEl = (oItem as Ellipse);

                if (oItem.GetType().ToString().Contains("Ellipse") &&
                    oItemEl.Name == "")
                {
                    ColorAnimation oColorAnimation = new ColorAnimation();
                    oColorAnimation.From = Colors.Transparent;
                    oColorAnimation.To   = Color.FromArgb((byte)rnd.Next(256),
                                                          (byte)rnd.Next(256),
                                                          (byte)rnd.Next(256),
                                                          (byte)rnd.Next(256));
                    oColorAnimation.Duration       = TimeSpan.FromSeconds(rnd.Next(1, 6));
                    oColorAnimation.AutoReverse    = true;
                    oColorAnimation.RepeatBehavior = RepeatBehavior.Forever;

                    SolidColorBrush oSolidColorBursh = new SolidColorBrush();

                    oItemEl.Fill = oSolidColorBursh;
                    oSolidColorBursh.BeginAnimation(SolidColorBrush.ColorProperty, oColorAnimation);
                }
            }
        }
コード例 #6
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();
        }
コード例 #7
0
        /// <summary>
        /// updates the current algorithm status
        /// </summary>
        /// <param name="pStatus">current algorithm</param>
        void LogManager_OnAlgorithmStatusChangeEvent(String pStatus)
        {
            this.Dispatcher.Invoke(() =>
            {
                // Create and configure a simple color animation sequence.  Timespan is in 100ns ticks.
                ColorAnimation blackToWhite = new ColorAnimation(Colors.DarkGray, Colors.Black, new Duration(new TimeSpan(10000000)));
                blackToWhite.AutoReverse    = true;
                blackToWhite.RepeatBehavior = RepeatBehavior.Forever;

                // Create a new brush and apply the color animation.
                SolidColorBrush scb = new SolidColorBrush(Colors.Black);
                scb.BeginAnimation(SolidColorBrush.ColorProperty, blackToWhite);

                // Create a new TextEffect object; set foreground brush to the previously created brush.
                TextEffect tfe = new TextEffect();
                tfe.Foreground = scb;
                // Range of text to apply effect to (all).
                tfe.PositionStart = 0;
                tfe.PositionCount = int.MaxValue;

                // adds the blinking to the current algorithm
                this._Txtblck_CurrentAlgorithm.TextEffects = new TextEffectCollection();
                this._Txtblck_CurrentAlgorithm.TextEffects.Add(tfe);
                this._Txtblck_CurrentAlgorithm.Text = "Current Algorithm: " + pStatus;

                // removes the blinking of the current algorithm when done
                if (pStatus.Contains("Done"))
                {
                    this._Txtblck_CurrentAlgorithm.TextEffects.Remove(tfe);
                }
            });
        }
コード例 #8
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            // Create and configure a simple color animation sequence.  Timespan is in 1000ns ticks.
            ColorAnimation colorAnimation = new ColorAnimation(Colors.Maroon, Colors.White, new Duration(new TimeSpan(1000000)));

            colorAnimation.AutoReverse    = true;
            colorAnimation.RepeatBehavior = RepeatBehavior.Forever;

            // Create a new brush and apply the color animation.
            SolidColorBrush solidColorBrush = new SolidColorBrush(Colors.Black);

            solidColorBrush.BeginAnimation(SolidColorBrush.ColorProperty, colorAnimation);

            // Create a new TextEffect object. Set the foreground to the color-animated brush.
            TextEffect textEffect = new TextEffect();

            textEffect.Foreground = solidColorBrush;

            // Apply the TextEffect to the entire range of characters.
            textEffect.PositionStart = 0;
            textEffect.PositionCount = int.MaxValue;

            // Create a new text Run, and add the TextEffect to the TextEffectCollection of the Run.
            //取得或設定要套用至項目內容的文字效果集合。
            Run flickerRun = new Run("Text that flickers...");

            flickerRun.TextEffects = new TextEffectCollection();
            flickerRun.TextEffects.Add(textEffect);

            this.textBlock1.Inlines.Clear();
            this.textBlock1.Inlines.Add(flickerRun);
        }
コード例 #9
0
    private void AnimateFill(Color toValue, TimeSpan duration)
    {
        path.Fill = _brush;
        ColorAnimation colorAnimation = new ColorAnimation(toValue, new Duration(duration));

        _brush.BeginAnimation(SolidColorBrush.ColorProperty, colorAnimation);
    }
コード例 #10
0
        private void colorSwitcher(object o, Brush br2)
        {
            SolidColorBrush rootElementBrush = new SolidColorBrush();
            ColorAnimation  animation;

            if (o is Rectangle)
            {
                Rectangle rectangle = (Rectangle)o;
                rootElementBrush.Color = ((SolidColorBrush)rectangle.Fill).Color;
                rectangle.Fill         = rootElementBrush;
            }
            else if (o is Label)
            {
                Label label = (Label)o;
                rootElementBrush.Color = ((SolidColorBrush)label.Foreground).Color;
                label.Foreground       = rootElementBrush;
            }


            // Animate the brush
            animation          = new ColorAnimation();
            animation.To       = ((SolidColorBrush)br2).Color;
            animation.Duration = new Duration(TimeSpan.FromSeconds(3));
            rootElementBrush.BeginAnimation(SolidColorBrush.ColorProperty, animation);
        }
コード例 #11
0
        public void EditDataBase(object sender, MouseButtonEventArgs e)
        {
            string    name      = "";
            Border    border    = sender as Border;
            Grid      grid      = border.Parent as Grid;
            Grid      grid1     = grid.Parent as Grid;
            TextBlock textBlock = grid1.Children[1] as TextBlock;

            name = textBlock.Text.ToLower();
            vieModel_DBManagement.CurrentDataBase = name;
            for (int i = 0; i < vieModel_DBManagement.DataBases.Count; i++)
            {
                if (vieModel_DBManagement.DataBases[i] == name)
                {
                    comboBox.SelectedIndex = i;
                    break;
                }
            }

            var brush = new SolidColorBrush(Colors.Red);

            NameBorder.Background = brush;
            Color TargColor = new SolidColorBrush((Color)ColorConverter.ConvertFromString(Application.Current.Resources["BackgroundMain"].ToString())).Color;
            var   ca        = new ColorAnimation(TargColor, TimeSpan.FromSeconds(0.75));

            brush.BeginAnimation(SolidColorBrush.ColorProperty, ca);
        }
コード例 #12
0
        public static SolidColorBrush CreateAnimatedBrush(SolidColorBrush from, SolidColorBrush to, TimeSpan timeSpan)
        {
            SolidColorBrush brush = new SolidColorBrush
            {
                Color   = from.Color,
                Opacity = from.Opacity,
            };

            ColorAnimation  colorAnim   = new ColorAnimation(to.Color, timeSpan);
            DoubleAnimation opacityAnim = new DoubleAnimation(to.Opacity, timeSpan);

            brush.BeginAnimation(Brush.OpacityProperty, opacityAnim);
            brush.BeginAnimation(SolidColorBrush.ColorProperty, colorAnim);

            return(brush);
        }
コード例 #13
0
ファイル: Window1.xaml.cs プロジェクト: Astn/austris
        void tgb_ScoreChangedEvent(ScoreChangedEventArgs args)
        {
            txtScore.Text = string.Format("Score {0} Level {1} " + Environment.NewLine + "Lines {2} ", args.Score, args.Level, args.Lines);

            if (oldScore != args.Score)
            {
                int howmanyNewPoints = args.Score - oldScore;
                txtNewPoints.Text = howmanyNewPoints.ToString();

                ColorAnimation ForeColorAnim = new ColorAnimation(Colors.Black, Colors.Red, TimeSpan.FromMilliseconds(500));
                ForeColorAnim.AutoReverse = true;
                ScoreColorBrush.BeginAnimation(SolidColorBrush.ColorProperty, ForeColorAnim);

                DoubleAnimation fontSizeAnim = new DoubleAnimation(8, 36, TimeSpan.FromMilliseconds(500));
                fontSizeAnim.AutoReverse = true;
                txtNewPoints.BeginAnimation(TextBlock.FontSizeProperty, fontSizeAnim);

                DoubleAnimation rightPosition = new DoubleAnimation(10, 30, TimeSpan.FromMilliseconds(500));
                rightPosition.AutoReverse = true;
                txtNewPoints.BeginAnimation(Canvas.RightProperty, rightPosition);
            }

            oldScore = args.Score;
            testGameOver(args);
        }
コード例 #14
0
        void TextEffectsProp()
        {
            // <Snippet_TextElement_TextEffects>
            // Create and configure a simple color animation sequence.  Timespan is in 100ns ticks.
            ColorAnimation blackToWhite = new ColorAnimation(Colors.White, Colors.Black, new Duration(new TimeSpan(100000)));

            blackToWhite.AutoReverse    = true;
            blackToWhite.RepeatBehavior = RepeatBehavior.Forever;

            // Create a new brush and apply the color animation.
            SolidColorBrush scb = new SolidColorBrush(Colors.Black);

            scb.BeginAnimation(SolidColorBrush.ColorProperty, blackToWhite);

            // Create a new TextEffect object; set foreground brush to the previously created brush.
            TextEffect tfe = new TextEffect();

            tfe.Foreground = scb;
            // Range of text to apply effect to (all).
            tfe.PositionStart = 0;
            tfe.PositionCount = int.MaxValue;

            // Create a new text run, and add the previously created text effect to the run's effects collection.
            Run flickerRun = new Run("Text that flickers...");

            flickerRun.TextEffects = new TextEffectCollection();
            flickerRun.TextEffects.Add(tfe);
            // </Snippet_TextElement_TextEffects>

            flowDoc.Blocks.Add(new Paragraph(flickerRun));
        }
コード例 #15
0
ファイル: TextEffect.xaml.cs プロジェクト: zhimaqiao51/docs
        void Stub3()
        {
            // Create and configure a simple color animation sequence.  Timespan is in 1000ns ticks.
            ColorAnimation colorAnimation =
                new ColorAnimation(Colors.Maroon, Colors.White, new Duration(new TimeSpan(1000000)));

            colorAnimation.AutoReverse    = true;
            colorAnimation.RepeatBehavior = RepeatBehavior.Forever;

            // Create a new brush and apply the color animation.
            SolidColorBrush solidColorBrush = new SolidColorBrush(Colors.Black);

            solidColorBrush.BeginAnimation(SolidColorBrush.ColorProperty, colorAnimation);

            // <SnippetTextEffectSnippet3>
            // Create a new TextEffect object, setting only the foreground brush, position start, and position count.
            TextEffect textEffect = new TextEffect(null, solidColorBrush, null, 0, int.MaxValue);
            // </SnippetTextEffectSnippet3>

            // Create a new text Run, and add the TextEffect to the TextEffectCollection of the Run.
            Run flickerRun = new Run("Text that flickers...");

            flickerRun.TextEffects = new TextEffectCollection();
            flickerRun.TextEffects.Add(textEffect);

            MyFlowDocument.Blocks.Add(new Paragraph(flickerRun));
        }
コード例 #16
0
        private void Sb_Completed(object sender, EventArgs e)
        {
            //AnimationTimeline timeline = (sender as AnimationClock).Timeline;
            //int position = Storyboard.GetTargetName(timeline)[8] - 48;
            position = position % points.Count;
            var solid = new SolidColorBrush(Colors.Transparent);

            var polygon = new Polygon {
                Fill = solid
            };

            for (int i = 0; i < points[position].Count; i++)
            {
                polygon.Points.Add(points[position][i]);
            }
            cMain.Children.Add(polygon);
            ColorAnimation colorAnimation = new ColorAnimation
            {
                From     = Color.FromRgb(19, 25, 30),
                To       = colors[position],
                Duration = TimeSpan.FromMilliseconds(500),
            };

            solid.BeginAnimation(SolidColorBrush.ColorProperty, colorAnimation);
            position++;
        }
コード例 #17
0
ファイル: Chamber.xaml.cs プロジェクト: Egorrrrr/CoffeeV2
        public void GoAtIt(bool milk, int sugar, Color cup)
        {
            ccolor = cup;
            if (othercolor == Colors.Transparent)
            {
                if (!milk)
                {
                    scbs.Color = Color.FromArgb(255, 46, 29, 3);
                }
                else
                {
                    scbs.Color = Color.FromArgb(255, 217, 185, 145);
                }
            }
            else
            {
                scbs.Color = othercolor;
            }

            if (!commenced && !prepd)
            {
                ColorAnimation sd = new ColorAnimation();
                sd.Completed += new EventHandler(Cup_Completed);
                sd.Completed += new EventHandler(TimeForSugar);
                SolidColorBrush sc = clr;
                sd.From     = Colors.Transparent;
                sd.Duration = TimeSpan.FromSeconds(2);
                sd.To       = ccolor;
                sc.BeginAnimation(SolidColorBrush.ColorProperty, sd);
                commenced = true;
            }
        }
コード例 #18
0
        void TextEffectsStuff()
        {
            // Create and configure a simple color animation sequence.  Timespan in 100 nanosecond ticks.
            ColorAnimation blackToWhite = new ColorAnimation(Colors.White, Colors.Black, new Duration(new TimeSpan(10000000)));

            blackToWhite.AutoReverse    = true;
            blackToWhite.RepeatBehavior = RepeatBehavior.Forever;

            // Create a new brush and apply the color animation.
            SolidColorBrush scb = new SolidColorBrush(Colors.Black);

            scb.BeginAnimation(SolidColorBrush.ColorProperty, blackToWhite);

            // Create a new TextEffect object; set foreground brush to the previously created brush.
            TextEffect tfe = new TextEffect();

            tfe.Foreground = scb;
            // Range of text to apply (all).
            tfe.PositionStart = 0;
            tfe.PositionCount = int.MaxValue;

            // Add this text effect to the FlowDocument's effects colleciton.
            fd.TextEffects = new TextEffectCollection();
            fd.TextEffects.Add(tfe);

            fd.Blocks.Add(new Paragraph(new Run("Blah blah animate me")));

            Run runx = new Run("Blah blah animate me");

            runx.TextEffects = new TextEffectCollection();
            runx.TextEffects.Add(tfe);
            fd.Blocks.Add(new Paragraph(runx));
        }
コード例 #19
0
        void TextBlockTextEffectsProp()
        {
            // <Snippet_TextBlock_TextEffects>
            // Create and configure a simple color animation sequence.  Timespan is in 100ns ticks.
            ColorAnimation blackToWhite = new ColorAnimation(Colors.White, Colors.Black, new Duration(new TimeSpan(100000)));

            blackToWhite.AutoReverse    = true;
            blackToWhite.RepeatBehavior = RepeatBehavior.Forever;

            // Create a new brush and apply the color animation.
            SolidColorBrush scb = new SolidColorBrush(Colors.Black);

            scb.BeginAnimation(SolidColorBrush.ColorProperty, blackToWhite);

            // Create a new TextEffect object; set foreground brush to the previously created brush.
            TextEffect tfe = new TextEffect();

            tfe.Foreground = scb;
            // Range of text to apply effect to (all).
            tfe.PositionStart = 0;
            tfe.PositionCount = int.MaxValue;

            // Create a new TextBlock with some text.
            TextBlock textBlock = new TextBlock();

            textBlock.Text = "Text that flickers...";

            // The TextEffects property is null (no collection) by default.  Create a new one.
            textBlock.TextEffects = new TextEffectCollection();

            // Add the previously created effect to the TextEffects collection.
            textBlock.TextEffects.Add(tfe);
            // </Snippet_TextBlock_TextEffects>
        }
コード例 #20
0
        public static SolidColorBrush AnimaPropDaPassiColore(Dictionary <Double, Color> passiColore, Double valore, SolidColorBrush propDaAnimare, TimeSpan tempo = default)
        {
            byte intero = Convert.ToByte(Math.Round(valore, 0));

            if (passiColore.ContainsKey(intero) == false)
            {
                return(propDaAnimare);
            }
            Color colore = passiColore[intero];

            if (colore == propDaAnimare.Color)
            {
                return(propDaAnimare);
            }
            if (tempo == TimeSpan.FromSeconds(0))
            {
                tempo = TimeSpan.FromSeconds(0.4);
            }
            ColorAnimation colorAnim = new ColorAnimation(colore, tempo);

            //Dim eccoloo As New SolidColorBrush(CType(Me.Foreground, SolidColorBrush).Color)
            SolidColorBrush colorBrush = new SolidColorBrush(propDaAnimare.Color);

            colorBrush.BeginAnimation(SolidColorBrush.ColorProperty, colorAnim);
            //Me.Foreground = eccoloo
            //propDaAnimare = colorBrush;
            return(colorBrush);
            //Me.Foreground.BeginAnimation(SolidColorBrush.ColorProperty, ciao)
        }
コード例 #21
0
        private void Grid_MouseUp(object sender, MouseButtonEventArgs e)
        {
            var targetColor = (Color)ColorConverter.ConvertFromString("#F44336");

            if (IsClicked)
            {
                targetColor = Colors.Gray;
            }

            IsClicked = !IsClicked;
            ThicknessAnimation ta = new ThicknessAnimation();

            ta.To                = new Thickness(5);
            ta.Duration          = new Duration(TimeSpan.FromSeconds(.1));
            ta.AccelerationRatio = 1;
            ta.Completed        += Ta_Completed;

            ColorAnimation ca = new ColorAnimation();

            ca.To       = targetColor;
            ca.Duration = new Duration(TimeSpan.FromSeconds(.1));

            SolidColorBrush tmp = new SolidColorBrush(Colors.Gray);

            path.Fill = tmp;

            vBox.BeginAnimation(Grid.MarginProperty, ta);
            tmp.BeginAnimation(SolidColorBrush.ColorProperty, ca);

            OnClick?.Invoke(IsClicked);
        }
コード例 #22
0
ファイル: TextEffect.xaml.cs プロジェクト: zhimaqiao51/docs
        void TextEffectsProp()
        {
            // <SnippetTextEffectSnippet1>
            // Create and configure a simple color animation sequence.  Timespan is in 1000ns ticks.
            ColorAnimation colorAnimation =
                new ColorAnimation(Colors.Maroon, Colors.White, new Duration(new TimeSpan(1000000)));

            colorAnimation.AutoReverse    = true;
            colorAnimation.RepeatBehavior = RepeatBehavior.Forever;

            // Create a new brush and apply the color animation.
            SolidColorBrush solidColorBrush = new SolidColorBrush(Colors.Black);

            solidColorBrush.BeginAnimation(SolidColorBrush.ColorProperty, colorAnimation);

            // Create a new TextEffect object. Set the foreground to the color-animated brush.
            TextEffect textEffect = new TextEffect();

            textEffect.Foreground = solidColorBrush;

            // Apply the TextEffect to the entire range of characters.
            textEffect.PositionStart = 0;
            textEffect.PositionCount = int.MaxValue;

            // Create a new text Run, and add the TextEffect to the TextEffectCollection of the Run.
            Run flickerRun = new Run("Text that flickers...");

            flickerRun.TextEffects = new TextEffectCollection();
            flickerRun.TextEffects.Add(textEffect);

            MyFlowDocument.Blocks.Add(new Paragraph(flickerRun));
            // </SnippetTextEffectSnippet1>
        }
コード例 #23
0
        public void WriteMessage(string message, Color color)
        {
            SolidColorBrush colorBrush = new SolidColorBrush(color);

            validationField.Text       = message;
            validationField.Foreground = colorBrush;

            //Выключаем сообщение через 10 сек
            ColorAnimationUsingKeyFrames colorAnimation = new ColorAnimationUsingKeyFrames();

            colorAnimation.Duration = TimeSpan.FromSeconds(10);
            colorAnimation.KeyFrames.Add(
                new LinearColorKeyFrame(
                    color,
                    KeyTime.FromTimeSpan(TimeSpan.FromSeconds(9.5)))
                );

            colorAnimation.KeyFrames.Add(
                new LinearColorKeyFrame(
                    Colors.Transparent,
                    KeyTime.FromTimeSpan(TimeSpan.FromSeconds(10)))
                );

            colorBrush.BeginAnimation(SolidColorBrush.ColorProperty, colorAnimation);
        }
コード例 #24
0
        public static SolidColorBrush GetAnimatedBrush(Color color_from, Color color_to, int milliseconds)
        {
            SolidColorBrush border_brush = new SolidColorBrush(color_from);
            ColorAnimation  ca           = new ColorAnimation(color_from, color_to, new Duration(TimeSpan.FromMilliseconds(milliseconds)));

            border_brush.BeginAnimation(SolidColorBrush.ColorProperty, ca);
            return(border_brush);
        }
コード例 #25
0
        public static void AnimateBrush(BrushSetter brushSetter, Color to, TimeSpan duration)
        {
            ColorAnimation  color_animation = new ColorAnimation(to, duration);
            SolidColorBrush brush           = new SolidColorBrush();

            brushSetter(brush);
            brush.BeginAnimation(SolidColorBrush.ColorProperty, color_animation);
        }
コード例 #26
0
 static void AnimateHighlight(SolidColorBrush targetBrush, double start, double end)
 {
     if (targetBrush != null)
     {
         DoubleAnimation animation = new DoubleAnimation(start, end, TimeSpan.FromMilliseconds(50));
         targetBrush.BeginAnimation(SolidColorBrush.OpacityProperty, animation);
     }
 }
コード例 #27
0
        public static void AnimateBackground(this Border border, Color from, Color to, TimeSpan duration)
        {
            ColorAnimation  color_animation = new ColorAnimation(from, to, duration);
            SolidColorBrush brush           = new SolidColorBrush();

            border.Background = brush;
            brush.BeginAnimation(SolidColorBrush.ColorProperty, color_animation);
        }
コード例 #28
0
        static async Task Merge(int[] arr, int firstIdx, int midIdx, int lastIdx, int[] tmp, Button[] button)
        {
            int i = firstIdx;
            int j = midIdx + 1;
            int k = firstIdx;

            while (i <= midIdx && j <= lastIdx)
            {
                if (arr[i] <= arr[j])
                {
                    tmp[k] = arr[i];
                    k++;
                    i++;
                }
                else
                {
                    tmp[k] = arr[j];
                    k++;
                    j++;
                }
            }
            //copy leftovers
            while (i <= midIdx)
            {
                tmp[k] = arr[i];
                k++;
                i++;
            }
            while (j <= lastIdx)
            {
                tmp[k] = arr[j];
                k++;
                j++;
            }

            for (k = firstIdx; k <= lastIdx; k++) //push elements from tmp back into arr
            {
                // animation begin
                SolidColorBrush brush = new SolidColorBrush(Colors.White);
                button[k].Background = brush;

                int temp = Array.IndexOf(arr, tmp[k]);
                button[temp].Background = brush;

                int tempK = arr[k];
                button[k].Content = tmp[k];
                arr[temp]         = tempK;

                ColorAnimation anima = new ColorAnimation(Colors.White, Colors.Orange, new Duration(TimeSpan.FromSeconds(0.5)));
                brush.BeginAnimation(SolidColorBrush.ColorProperty, anima);
                // animation end
                await Task.Delay(1000);

                arr[k] = tmp[k];
                button[k].Background    = Brushes.White;
                button[temp].Background = Brushes.White;
            }
        }
コード例 #29
0
        public static void AnimationGoToSpace()
        {
            SolidColorBrush rootElementBrush = (Application.Current.MainWindow as MainWindow).Resources["CanvasBrush"] as SolidColorBrush;

            ColorAnimation da_c = new ColorAnimation();

            da_c.To       = Colors.Black;
            da_c.Duration = TimeSpan.FromSeconds(5);
            rootElementBrush.BeginAnimation(SolidColorBrush.ColorProperty, da_c);
        }
コード例 #30
0
        public static SolidColorBrush CreateAnimatedBrush(Color fromValue, Color toValue, TimeSpan duration)
        {
            var brush = new SolidColorBrush(Colors.Purple);

            brush.BeginAnimation(SolidColorBrush.ColorProperty, new ColorAnimation(fromValue, toValue, new Duration(duration))
            {
                RepeatBehavior = RepeatBehavior.Forever, AutoReverse = true
            });
            return(brush);
        }