Example #1
0
 protected override void OnInitialized()
 {
     base.OnInitialized();
     ColorAnimation colorAnim;
     this.ColorAnimation = Storyboard.Register(this);
     colorAnim = new ColorAnimation();
     colorAnim.From = Color.Blue;
     colorAnim.To = Color.Magenta;
     colorAnim.Duration = TimeSpan.FromSeconds(2);
     colorAnim.AutoReverse = true;
     colorAnim.RepeatBehavior = RepeatBehavior.Forever;
     this.ColorAnimation.Children.Add(colorAnim);
     Storyboard.SetTarget(colorAnim, this);
     Storyboard.SetTargetProperty(colorAnim, new PropertyPath(new DependencyProperty[] { Window.BackgroundProperty, Photon.Media.SolidColorBrush.ColorProperty }));
 }
Example #2
0
        public static void AnimateRow(DataGrid dg, object element)
        {
            if (!(dg?.ItemContainerGenerator.ContainerFromItem(element) is DataGridRow row))
            {
                return;
            }
            var switchOnAnimation = new ColorAnimation
            {
                From        = Colors.White,
                To          = Colors.Pink,
                Duration    = TimeSpan.FromSeconds(1),
                AutoReverse = true
            };

            var blinkStoryboard = new Storyboard();


            blinkStoryboard.Children.Add(switchOnAnimation);
            Storyboard.SetTargetProperty(switchOnAnimation, new PropertyPath("Background.Color"));
            //animate changed server
            Storyboard.SetTarget(switchOnAnimation, row);

            row.BeginStoryboard(blinkStoryboard);
        }
Example #3
0
        private void OnFishingEvent(object stateObj, FishingEventArgs e)
        {
            switch (e.Event)
            {
            case FishingEvent.FishHooked: goto case FishingEvent.FishEaten;

            case FishingEvent.FishEaten:
                Vector2 vibration = GetLureFeedback(e.Fish);
                _context.Input.AddVibration(Vibrations.Constant(vibration.X, vibration.Y, 0.5f));
                _lureHookedEffect.Play(0.3f, 0f, 0f);
                break;

            case FishingEvent.FishCaught:
                _caughtEffect.Play(0.4f, 0f, 0f);
                break;

            case FishingEvent.LureBroke:
                _context.Input.AddVibration(Vibrations.FadeOut(0.2f, 0.3f, 1f, Easing.Uniform));
                _lureAnimation = new ColorAnimation(_lure, Color.TransparentWhite, 0.5f, InterpolateColor);
                _lureBrokeEffect.Play(0.8f, 0f, 0f);
                break;

            case FishingEvent.LureChanged:
                _lure = _state.LureSprites[_state.Lure];
                _lureChangeEffect.Play(0.4f, 0f, 0f);
                break;

            case FishingEvent.RodChanged:
                _rod = _state.RodSprites[_state.Rod];
                break;

            case FishingEvent.LureIsland:
                _islandEffect.Play(1f, 0f, 0f);
                break;
            }
        }
        public AlertWindow()
        {
            InitializeComponent();

            Title = LocaleSelector.GetLocaleString("AlertWindow_Title");


            _glowFadeOutAnimation = new ColorAnimation(Colors.WindowActiveGlow, Colors.WindowInactiveGlow, new Duration(new TimeSpan(0, 0, 0, 0, 150)));
            _glowFadeInAnimation  = new ColorAnimation(Colors.WindowInactiveGlow, Colors.WindowActiveGlow, new Duration(new TimeSpan(0, 0, 0, 0, 150)));

            var borderActivateAnimation   = new ColorAnimation(Colors.WindowInactiveBorder, Colors.WindowActiveBorder, new Duration(new TimeSpan(0, 0, 0, 0, 150)));
            var borderDeactivateAnimation = new ColorAnimation(Colors.WindowActiveBorder, Colors.WindowInactiveBorder, new Duration(new TimeSpan(0, 0, 0, 0, 150)));

            _borderActivateStoryboard   = new Storyboard();
            _borderDeactivateStoryboard = new Storyboard();

            Storyboard.SetTarget(borderActivateAnimation, WindowBorder);
            Storyboard.SetTargetProperty(borderActivateAnimation, new PropertyPath("(Border.BorderBrush).(SolidColorBrush.Color)"));
            _borderActivateStoryboard.Children.Add(borderActivateAnimation);

            Storyboard.SetTarget(borderDeactivateAnimation, WindowBorder);
            Storyboard.SetTargetProperty(borderDeactivateAnimation, new PropertyPath("(Border.BorderBrush).(SolidColorBrush.Color)"));
            _borderDeactivateStoryboard.Children.Add(borderDeactivateAnimation);
        }
Example #5
0
            public virtual void ReadChildData(BinaryReader reader)
            {
                int x = 0;

                _gelMap.ReadString(reader);
                _lensFlare.ReadString(reader);
                _lightVolume.ReadString(reader);
                for (x = 0; (x < _brightnessAnimation.Count); x = (x + 1))
                {
                    BrightnessAnimation.Add(new LightBrightnessAnimationBlockBlock());
                    BrightnessAnimation[x].Read(reader);
                }
                for (x = 0; (x < _brightnessAnimation.Count); x = (x + 1))
                {
                    BrightnessAnimation[x].ReadChildData(reader);
                }
                for (x = 0; (x < _colorAnimation.Count); x = (x + 1))
                {
                    ColorAnimation.Add(new LightColorAnimationBlockBlock());
                    ColorAnimation[x].Read(reader);
                }
                for (x = 0; (x < _colorAnimation.Count); x = (x + 1))
                {
                    ColorAnimation[x].ReadChildData(reader);
                }
                for (x = 0; (x < _gelAnimation.Count); x = (x + 1))
                {
                    GelAnimation.Add(new LightGelAnimationBlockBlock());
                    GelAnimation[x].Read(reader);
                }
                for (x = 0; (x < _gelAnimation.Count); x = (x + 1))
                {
                    GelAnimation[x].ReadChildData(reader);
                }
                _shader.ReadString(reader);
            }
Example #6
0
        private void button2_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            ca = new ColorAnimation();
            ep = new Ellipse();
            double cx = this.image.ActualWidth;           //image的宽、高
            double cy = this.image.ActualHeight;

            ep.Width  = cx;
            ep.Height = cy;
            a         = 255; r = 0; g = 0; b = 255;      //不透明度和色彩初始值设置
            SolidColorBrush scb = new SolidColorBrush(); //创建纯色画刷

            scb.Color = Color.FromArgb(a, r, g, b);      //色彩设置
            ep.Fill   = scb;                             //椭圆填充色
            this.canvas1.Children.Add(ep);               //椭圆作为canvas1的子对象
            sb2 = new Storyboard();
            this.sb2.Completed    += new System.EventHandler(Storyboard2_Completed);
            this.button1.IsEnabled = false;
            this.button2.IsEnabled = false;
            this.button3.IsEnabled = false;
            this.button4.IsEnabled = false;
            ca.From = Color.FromArgb(255, r, g, b);     //动画不透明度和起点颜色
            ca.To   = Color.FromArgb(0, 255, 0, 0);     //动画终点不透明度和颜色
            //动画持续时间5000毫秒
            ca.Duration        = new Duration(TimeSpan.FromMilliseconds(5000));
            sb2.Duration       = ca.Duration;           //故事板时间间隔
            sb2.AutoReverse    = true;                  //故事板翻转
            sb2.RepeatBehavior = new RepeatBehavior(1); //故事板运行1次
            sb2.Children.Add(ca);                       //故事板添加对象
            sb2.BeginTime = TimeSpan.FromSeconds(0.5);  //故事板延时0.5秒开始
            //故事板引起动画对象ca1的Color属性改变
            Storyboard.SetTargetProperty(ca, new PropertyPath("Color"));
            //设置故事板启动的动画及目标对象
            Storyboard.SetTarget(ca, scb);
            sb2.Begin();            //故事板启动
        }
Example #7
0
        protected void ReplaceEntry(string entryName, object newValue, ResourceDictionary parentDictionary = null)
        {
            if (parentDictionary == null)
            {
                parentDictionary = Application.Current.Resources;
            }

            if (parentDictionary.Contains(entryName))
            {
                if (parentDictionary[entryName] is SolidColorBrush brush && newValue is Color newColor)
                {
                    var animation = new ColorAnimation
                    {
                        From     = brush.Color,
                        To       = newColor,
                        Duration = new Duration(TimeSpan.FromMilliseconds(300))
                    };
                    brush.BeginAnimation(SolidColorBrush.ColorProperty, animation);
                }
                else
                {
                    parentDictionary[entryName] = newValue; //Set value normally
                }
            }
Example #8
0
        /// <summary>
        /// 创建Color值之间的线性动画
        /// </summary>
        public static ColorAnimation BuildColorAnimation(ColorModel Model)
        {
            ColorAnimation _colorAnimation = new ColorAnimation();

            _colorAnimation.From           = Model.From;
            _colorAnimation.To             = Model.To;
            _colorAnimation.Duration       = new Duration(TimeSpan.FromSeconds(Model.Duration));
            _colorAnimation.AutoReverse    = Model.AutoReverse;
            _colorAnimation.BeginTime      = TimeSpan.FromSeconds(Model.BeginTime);
            _colorAnimation.By             = Model.By;
            _colorAnimation.FillBehavior   = Model.FillBehavior;
            _colorAnimation.RepeatBehavior = Model.RepeatBehavior;
            _colorAnimation.SpeedRatio     = Model.SpeedRatio;

            if (Model.EasingFunction != null)
            {
                _colorAnimation.EasingFunction = Model.EasingFunction;
            }


            Storyboard.SetTarget(_colorAnimation, Model.Target);
            Storyboard.SetTargetProperty(_colorAnimation, new PropertyPath(Model.PropertyPath));
            return(_colorAnimation);
        }
Example #9
0
        private SolidColorBrush highlightBrush()
        {
            storyboard.Stop();
            if (storyboard.Children.Count > 0)
            {
                storyboard.Children.RemoveAt(0);
                highlightedBrush.Color = Colors.Transparent;
            }
            highlightedBrush = new SolidColorBrush(Colors.LightGoldenrodYellow);

            var colorBreath = new ColorAnimation()
            {
                From           = Colors.LightYellow,
                To             = Colors.DarkOrange,
                AutoReverse    = true,
                RepeatBehavior = RepeatBehavior.Forever
            };

            storyboard.Children.Add(colorBreath);
            Storyboard.SetTargetProperty(colorBreath, "Color");
            Storyboard.SetTarget(colorBreath, highlightedBrush);
            storyboard.Begin();
            return(highlightedBrush);
        }
Example #10
0
 private static void ThreadSys(Brush bg, Dispatcher dispatcher, Color defaultColor)
 {
     try
     {
         while (ShouldRun)
         {
             while (Changing)
             {
                 dispatcher.Invoke(() =>
                 {
                     Random random            = new Random();
                     ColorAnimation animation = new ColorAnimation();
                     animation.From           = ((SolidColorBrush)bg).Color;
                     animation.To             = Color.FromRgb((byte)random.Next(0, 255), (byte)random.Next(0, 255),
                                                              (byte)random.Next(0, 255));
                     animation.Duration = new Duration(TimeSpan.FromSeconds(1));
                     bg.BeginAnimation(SolidColorBrush.ColorProperty, animation);
                 });
                 Thread.Sleep(1000);
             }
             if (!Changing)
             {
                 dispatcher.Invoke(() =>
                 {
                     // Random random = new Random();
                     ColorAnimation animation = new ColorAnimation();
                     animation.From           = ((SolidColorBrush)bg).Color;
                     animation.To             = defaultColor;
                     animation.Duration       = new Duration(TimeSpan.FromSeconds(1));
                     bg.BeginAnimation(SolidColorBrush.ColorProperty, animation);
                 });
             }
         }
     }
     catch (TaskCanceledException) { }
 }
Example #11
0
        private ColorAnimation NewColorAnimation(object colorFrom, object colorTo)
        {
            var ca = new ColorAnimation
            {
                Duration =
                    new Duration(
                        TimeSpan.FromSeconds(1))
            };
            var convertFrom =
                new ColorConverter().ConvertFrom(colorFrom);

            ca.From = convertFrom != null
                ? (Color)convertFrom
                : Colors.Transparent;

            var convertTo =
                new ColorConverter().ConvertFrom(colorTo);

            ca.To = convertTo != null
                ? (Color)convertTo
                : Colors.Transparent;

            return(ca);
        }
        /// <summary>
        /// Erzeugt Storyboard für Übergang.
        /// </summary>
        private void CreateTouchedToNormalAnimation()
        {
            animatedTouchedToNormalBrush = new SolidColorBrush((Color)FindResource("InstanceWidgetBackgroundTouched"));
            this.RegisterName("AnimatedTouchedToNormalBrush", animatedTouchedToNormalBrush);
            ColorAnimation AsNormalAnimation = new ColorAnimation();

            AsNormalAnimation.To       = (Color)FindResource("InstanceBackgroundColor");
            AsNormalAnimation.Duration = TimeSpan.FromSeconds(0.4);

            //animatedBorderTouchedToNormalBrush = new SolidColorBrush((Color)FindResource("InstanceWidgetBorderTouchedOrRelative"));
            //this.RegisterName("AnimatedBorderTouchedToNormalBrush", animatedBorderTouchedToNormalBrush);
            //ColorAnimation BorderAsNormalAnimation = new ColorAnimation();
            //BorderAsNormalAnimation.To = Colors.Black;
            //BorderAsNormalAnimation.Duration = TimeSpan.FromSeconds(0.4);

            DoubleAnimation strokeAnimation = new DoubleAnimation();

            strokeAnimation.From     = 4;
            strokeAnimation.To       = 1;
            strokeAnimation.Duration = new Duration(TimeSpan.FromSeconds(0.4));

            Storyboard.SetTargetName(AsNormalAnimation, "AnimatedTouchedToNormalBrush");
            Storyboard.SetTargetProperty(AsNormalAnimation, new PropertyPath(SolidColorBrush.ColorProperty));
            //Storyboard.SetTargetName(BorderAsNormalAnimation, "AnimatedBorderTouchedToNormalBrush");
            //Storyboard.SetTargetProperty(BorderAsNormalAnimation, new PropertyPath(SolidColorBrush.ColorProperty));
            Storyboard.SetTargetName(strokeAnimation, BackgroundRectangle.Name);
            Storyboard.SetTargetProperty(strokeAnimation, new PropertyPath(Rectangle.StrokeThicknessProperty));
            TouchedToNormalStoryboard = new Storyboard();
            TouchedToNormalStoryboard.Children.Add(AsNormalAnimation);
            //TouchedToNormalStoryboard.Children.Add(BorderAsNormalAnimation);
            TouchedToNormalStoryboard.Children.Add(strokeAnimation);
            TouchedToNormalStoryboard.Completed += delegate(System.Object o, System.EventArgs e)
            {
                BackgroundRectangle.Stroke = new SolidColorBrush(Colors.Black);
            };
        }
Example #13
0
        private void MoveListFragment(double left, Color color)
        {
            var s = new Storyboard();

            var doubleAnimation = new DoubleAnimation
            {
                Duration = new Duration(new TimeSpan(0, 0, 0, 0, 200)),
                To       = left
            };

            Storyboard.SetTarget(doubleAnimation, _listFragment);
            Storyboard.SetTargetProperty(doubleAnimation, TranslatePath.Path);
            s.Children.Add(doubleAnimation);

            var colorAnimation = new ColorAnimation {
                Duration = new Duration(new TimeSpan(0, 0, 0, 0, 200)), To = color
            };

            Storyboard.SetTarget(colorAnimation, _shadowFragment);
            Storyboard.SetTargetProperty(colorAnimation, ColorPath.Path);
            s.Children.Add(colorAnimation);

            s.Begin();
        }
Example #14
0
        private void SetColor(ColorPicker b)
        {
            if (ReferenceEquals(_selectedColor, b))
            {
                return;
            }
            var solidColorBrush = b.Background as SolidColorBrush;

            if (solidColorBrush == null)
            {
                return;
            }

            var ani = new ColorAnimation(solidColorBrush.Color, Duration3);

            MainInkCanvas.DefaultDrawingAttributes.Color = solidColorBrush.Color;
            brushPreview.Background.BeginAnimation(SolidColorBrush.ColorProperty, ani);
            b.IsActived = true;
            if (_selectedColor != null)
            {
                _selectedColor.IsActived = false;
            }
            _selectedColor = b;
        }
        // These methods are used when generating a transition animation between states.
        // The timeline is the "to" state, and we need to find the To value for the
        // animation we're generating.
        private static Color?GetTargetColor(Timeline timeline, bool isEntering)
        {
            ColorAnimation ca = timeline as ColorAnimation;

            if (ca != null)
            {
                return(ca.From.HasValue ? ca.From : ca.To);
            }

            ColorAnimationUsingKeyFrames cak = timeline as ColorAnimationUsingKeyFrames;

            if (cak != null)
            {
                if (cak.KeyFrames.Count == 0)
                {
                    return(null);
                }

                ColorKeyFrame keyFrame = cak.KeyFrames[isEntering ? 0 : cak.KeyFrames.Count - 1];
                return(keyFrame.Value);
            }

            return(null);
        }
Example #16
0
        private void CreateAnimation()
        {
            myBackgroundBrush.Color    = Colors.White;
            this.textBlock1.Background = myBackgroundBrush;
            this.textBlock1.RegisterName("TextBlockBackgroundBrush", myBackgroundBrush);

            Duration dTime1 = new Duration(TimeSpan.FromMilliseconds(1000));

            colorAnimation1 = new ColorAnimation(Colors.Red, Colors.Green, dTime1);
            Storyboard.SetTargetName(colorAnimation1, "TextBlockBackgroundBrush");
            Storyboard.SetTargetProperty(colorAnimation1, new PropertyPath("Color"));

            Duration dTime2 = new Duration(TimeSpan.FromMilliseconds(2000));

            colorAnimation2 = new ColorAnimation(Colors.Red, Colors.White, dTime2);
            Storyboard.SetTargetName(colorAnimation2, "TextBlockBackgroundBrush");
            Storyboard.SetTargetProperty(colorAnimation2, new PropertyPath("Color"));

            // you can't have a storyboard with two animations in it that target the same property!
            // For this use KeyFrames
            storyboard = new Storyboard();
            //storyboard.Children.Add(colorAnimation1);
            storyboard.Children.Add(colorAnimation2);
        }
Example #17
0
        public ScoreDomainLabel2D(ALayer2D parentLayer, Player player1, Player player2)
            : base(parentLayer)
        {
            this.ownerName        = null;
            this.isTemporaryOwner = false;
            this.zoomState        = ZoomVSState.STOP;

            this.Canevas = new IntRect(0, 0, 500, 200);

            this.CreateTextParagraph2D(new Vector2f(0, 0), new Vector2f(0, 0), TextParagraph2D.Alignment.CENTER, 20);
            this.CreateTextParagraph2D(new Vector2f(0, 50), new Vector2f(0, 0), TextParagraph2D.Alignment.CENTER, 60);
            this.UpdateTextOfParagraph(0, "score_domain_label");
            this.UpdateTextOfParagraph(1, "score_domain_vs");


            this.CreateTextParagraph2D(new Vector2f(0, 100), new Vector2f(0, 0), TextParagraph2D.Alignment.LEFT, 20);
            this.CreateTextParagraph2D(new Vector2f(0, 100), new Vector2f(0, 0), TextParagraph2D.Alignment.RIGHT, 20);

            SequenceAnimation sequence = new SequenceAnimation(Time.FromSeconds(4), AnimationType.ONETIME);

            IAnimation anim = new ColorAnimation(new Color(0, 0, 0, 0), new Color(0, 0, 0, 255), Time.FromSeconds(2f), AnimationType.ONETIME, InterpolationMethod.LINEAR);

            sequence.AddAnimation(0.001f, anim);

            anim = new ZoomAnimation(2, 1, Time.FromSeconds(4f), AnimationType.ONETIME, InterpolationMethod.LINEAR);
            sequence.AddAnimation(0, anim);
            this.animationsList.Add(sequence);

            anim = new ColorAnimation(new Color(0, 0, 0, 255), new Color(0, 0, 0, 0), Time.FromSeconds(1f), AnimationType.ONETIME, InterpolationMethod.LINEAR);
            this.animationsList.Add(anim);

            this.InitializeScoreDomainLabel(parentLayer, player1, player2);
            this.Position = new Vector2f(0, 0);

            this.IsActive = false;
        }
Example #18
0
        static void IsOnChangeFunc(DependencyObject target,
                                   DependencyPropertyChangedEventArgs e)
        {
            var of  = (bool)e.OldValue;
            var nf  = (bool)e.NewValue;
            var obj = (ToggleSwitch)target;

            if (nf)
            {
                obj.borderTrack.Background = new SolidColorBrush(obj.TrackBackgroundOffColor);
                var ca = new ColorAnimation(obj.TrackBackgroundOnColor, TimeSpan.FromSeconds(obj.Duration));
                obj.borderTrack.Background.BeginAnimation(SolidColorBrush.ColorProperty, ca);
                var da = new DoubleAnimation(10, TimeSpan.FromSeconds(obj.Duration));
                obj.translateTransform.BeginAnimation(TranslateTransform.XProperty, da);
            }
            else
            {
                obj.borderTrack.Background = new SolidColorBrush(obj.TrackBackgroundOnColor);
                var ca = new ColorAnimation(obj.TrackBackgroundOffColor, TimeSpan.FromSeconds(obj.Duration));
                obj.borderTrack.Background.BeginAnimation(SolidColorBrush.ColorProperty, ca);
                var da = new DoubleAnimation(-10, TimeSpan.FromSeconds(obj.Duration));
                obj.translateTransform.BeginAnimation(TranslateTransform.XProperty, da);
            }
        }
Example #19
0
        /// <summary>
        /// Replaces a certain entry anywhere in the parent dictionary and its merged dictionaries
        /// </summary>
        /// <param name="entryName">The entry to replace</param>
        /// <param name="newValue">The new entry value</param>
        /// <param name="parentDictionary">The root dictionary to start searching at. Null means using Application.Current.Resources</param>
        private static void ReplaceEntry(object entryName, object newValue, ResourceDictionary parentDictionary = null)
        {
            if (parentDictionary == null)
            {
                parentDictionary = Application.Current.Resources;
            }

            if (parentDictionary.Contains(entryName))
            {
                if (parentDictionary[entryName] is SolidColorBrush brush && !brush.IsFrozen)
                {
                    var animation = new ColorAnimation
                    {
                        From     = ((SolidColorBrush)parentDictionary[entryName]).Color,
                        To       = ((SolidColorBrush)newValue).Color,
                        Duration = new Duration(TimeSpan.FromMilliseconds(300))
                    };
                    brush.BeginAnimation(SolidColorBrush.ColorProperty, animation);
                }
                else
                {
                    parentDictionary[entryName] = newValue; //Set value normally
                }
            }
Example #20
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            for (var i = 0; i < 30; i++)
            {
                var bd = new Border();
                bd.Width             = 4;
                bd.Height            = 0;
                bd.Background        = new SolidColorBrush(Colors.White);
                bd.BorderBrush       = null;
                bd.VerticalAlignment = VerticalAlignment.Bottom;
                bd.Opacity           = 0.7;
                spTrade.Children.Add(bd);
            }
            ContainerTB       = new TextBlock();;
            ContainerTB.Width = 0;

            ContainerTBBtc       = new TextBlock();;
            ContainerTBBtc.Width = 0;
            var quoteTimer = new Timer(1000);
            var binding    = new Binding
            {
                Source    = ContainerTB,
                Path      = new PropertyPath("Width"),
                Converter = new DoubleToStringConverter()
            };

            var bindingBtc = new Binding
            {
                Source    = ContainerTBBtc,
                Path      = new PropertyPath("Width"),
                Converter = new DoubleToStringConverter()
            };

            BindingOperations.SetBinding(tbEthPrice, TextBlock.TextProperty, binding);
            BindingOperations.SetBinding(tbBtcPrice, TextBlock.TextProperty, bindingBtc);
            quoteTimer.Elapsed += (qsender, qe) =>
            {
                quoteTimer.Stop();
                try
                {
                    var     jss      = new JavaScriptSerializer();
                    var     client   = new WebClient();
                    var     ethPrice = 0.0;
                    var     btcPrice = 0.0;
                    var     progress = 0.5;
                    dynamic trades   = null;
                    using (var data = client.OpenRead("https://www.okex.com/api/futures/v3/instruments/ETH-USDT-201225/trades?after=2517062044057601&limit=1"))
                    {
                        using (var reader = new StreamReader(data))
                        {
                            var s    = reader.ReadToEnd();
                            var dict = jss.Deserialize <dynamic>(s);
                            ethPrice = double.Parse(dict[0]["price"]);
                        }
                    }
                    using (var data = client.OpenRead("https://www.okex.com/api/futures/v3/instruments/BTC-USDT-201225/trades?after=2517062044057601&limit=1"))
                    {
                        using (var reader = new StreamReader(data))
                        {
                            var s    = reader.ReadToEnd();
                            var dict = jss.Deserialize <dynamic>(s);
                            btcPrice = double.Parse(dict[0]["price"]);
                        }
                    }

                    tbEthPrice.Dispatcher.Invoke(() =>
                    {
                        //Topmost = true;
                        Activate();

                        if (trades != null)
                        {
                            var j   = 0;
                            var max = 0.0;
                            foreach (var i in trades)
                            {
                                if ((double)i[5] > max)
                                {
                                    max = (double)i[5];
                                }
                            }
                            if (max == 0)
                            {
                                max = 20;
                            }
                            foreach (var i in trades)
                            {
                                var bd = spTrade.Children[j] as Border;
                                if ((double)i[4] >= (double)i[1])
                                {
                                    (bd.Background as SolidColorBrush).Color = Colors.DodgerBlue;
                                }
                                else
                                {
                                    (bd.Background as SolidColorBrush).Color = Colors.Crimson;
                                }

                                bd.Height = (double)i[5] / max * 20;
                                j++;
                            }
                        }
                        var stop           = (bdAskPower.Background as LinearGradientBrush).GradientStops[2];
                        var powerAnim      = new DoubleAnimation();
                        powerAnim.Duration = TimeSpan.FromMilliseconds(1000);
                        if (!double.IsNaN(progress))
                        {
                            powerAnim.To = progress;
                        }
                        (bdAskPower.Background as LinearGradientBrush).GradientStops[2].BeginAnimation(GradientStop.OffsetProperty, powerAnim);

                        stop      = (bdAskPower.Background as LinearGradientBrush).GradientStops[1];
                        powerAnim = new DoubleAnimation();
                        if (progress < 0.5)
                        {
                            powerAnim.Duration = TimeSpan.FromMilliseconds(100);
                        }
                        else
                        {
                            powerAnim.Duration = new TimeSpan(0, 0, 1);
                        }
                        powerAnim.To = 0.45;
                        if (!double.IsNaN(progress))
                        {
                            powerAnim.To = progress - 0.05;
                        }
                        if (powerAnim.To < 0)
                        {
                            powerAnim.To = 0;
                        }
                        (bdAskPower.Background as LinearGradientBrush).GradientStops[1].BeginAnimation(GradientStop.OffsetProperty, powerAnim);

                        stop      = (bdAskPower.Background as LinearGradientBrush).GradientStops[3];
                        powerAnim = new DoubleAnimation();
                        if (progress > 0.5)
                        {
                            powerAnim.Duration = TimeSpan.FromMilliseconds(100);
                        }
                        else
                        {
                            powerAnim.Duration = new TimeSpan(0, 0, 1);
                        }
                        powerAnim.To = 0.55;
                        if (!double.IsNaN(progress))
                        {
                            powerAnim.To = progress + 0.05;
                        }
                        if (powerAnim.To > 1)
                        {
                            powerAnim.To = 1;
                        }
                        (bdAskPower.Background as LinearGradientBrush).GradientStops[3].BeginAnimation(GradientStop.OffsetProperty, powerAnim);

                        var borderAnim = new ColorAnimation();
                        if (ethPrice > ContainerTB.Width)
                        {
                            borderAnim.To = Color.FromArgb(255, 137, 249, 96);
                        }
                        else if (ethPrice < ContainerTB.Width)
                        {
                            borderAnim.To = Color.FromArgb(255, 255, 65, 65);
                        }
                        else
                        {
                            borderAnim.To = Colors.CadetBlue;
                        }
                        borderAnim.Duration = TimeSpan.FromMilliseconds(300);
                        (bdFlag.BorderBrush as SolidColorBrush).BeginAnimation(SolidColorBrush.ColorProperty, borderAnim);
                        var priceAnim = new DoubleAnimation {
                            To = ethPrice, Duration = new TimeSpan(0, 0, 1)
                        };
                        ContainerTB.BeginAnimation(TextBlock.WidthProperty, priceAnim);
                    });
                    tbEthPrice.Dispatcher.Invoke(() =>
                    {
                        if (trades != null)
                        {
                            var j   = 0;
                            var max = 0.0;
                            foreach (var i in trades)
                            {
                                if ((double)i[5] > max)
                                {
                                    max = (double)i[5];
                                }
                            }
                            if (max == 0)
                            {
                                max = 20;
                            }
                            foreach (var i in trades)
                            {
                                var bd = spTrade.Children[j] as Border;
                                if ((double)i[4] >= (double)i[1])
                                {
                                    (bd.Background as SolidColorBrush).Color = Colors.DodgerBlue;
                                }
                                else
                                {
                                    (bd.Background as SolidColorBrush).Color = Colors.Crimson;
                                }

                                bd.Height = (double)i[5] / max * 20;
                                j++;
                            }
                        }
                        var stop           = (bdAskPower.Background as LinearGradientBrush).GradientStops[2];
                        var powerAnim      = new DoubleAnimation();
                        powerAnim.Duration = TimeSpan.FromMilliseconds(1000);
                        if (!double.IsNaN(progress))
                        {
                            powerAnim.To = progress;
                        }
                        (bdAskPower.Background as LinearGradientBrush).GradientStops[2].BeginAnimation(GradientStop.OffsetProperty, powerAnim);

                        stop      = (bdAskPower.Background as LinearGradientBrush).GradientStops[1];
                        powerAnim = new DoubleAnimation();
                        if (progress < 0.5)
                        {
                            powerAnim.Duration = TimeSpan.FromMilliseconds(100);
                        }
                        else
                        {
                            powerAnim.Duration = new TimeSpan(0, 0, 1);
                        }
                        powerAnim.To = 0.45;
                        if (!double.IsNaN(progress))
                        {
                            powerAnim.To = progress - 0.05;
                        }
                        if (powerAnim.To < 0)
                        {
                            powerAnim.To = 0;
                        }
                        (bdAskPower.Background as LinearGradientBrush).GradientStops[1].BeginAnimation(GradientStop.OffsetProperty, powerAnim);

                        stop      = (bdAskPower.Background as LinearGradientBrush).GradientStops[3];
                        powerAnim = new DoubleAnimation();
                        if (progress > 0.5)
                        {
                            powerAnim.Duration = TimeSpan.FromMilliseconds(100);
                        }
                        else
                        {
                            powerAnim.Duration = new TimeSpan(0, 0, 1);
                        }
                        powerAnim.To = 0.55;
                        if (!double.IsNaN(progress))
                        {
                            powerAnim.To = progress + 0.05;
                        }
                        if (powerAnim.To > 1)
                        {
                            powerAnim.To = 1;
                        }
                        (bdAskPower.Background as LinearGradientBrush).GradientStops[3].BeginAnimation(GradientStop.OffsetProperty, powerAnim);

                        var borderAnim = new ColorAnimation();
                        if (btcPrice > ContainerTBBtc.Width)
                        {
                            borderAnim.To = Color.FromArgb(255, 137, 249, 96);
                        }
                        else if (btcPrice < ContainerTBBtc.Width)
                        {
                            borderAnim.To = Color.FromArgb(255, 255, 65, 65);
                        }
                        else
                        {
                            borderAnim.To = Colors.CadetBlue;
                        }
                        borderAnim.Duration = TimeSpan.FromMilliseconds(300);
                        (bdFlag.BorderBrush as SolidColorBrush).BeginAnimation(SolidColorBrush.ColorProperty, borderAnim);
                        var priceAnim = new DoubleAnimation {
                            To = btcPrice, Duration = new TimeSpan(0, 0, 1)
                        };
                        ContainerTBBtc.BeginAnimation(TextBlock.WidthProperty, priceAnim);
                    });
                }
                catch
                { }
                quoteTimer.Start();
            };
            quoteTimer.Start();
        }
Example #21
0
        public FileProgress(string filename, int type, string header)
        {
            InitializeComponent();
            ColorAnimation BlueToWhite = new ColorAnimation((Color)ColorConverter.ConvertFromString("#CC5FCFFF"), Colors.White, TimeSpan.FromSeconds(1));

            BlueToWhite.AutoReverse    = true;
            BlueToWhite.RepeatBehavior = new RepeatBehavior(3);

            ColorAnimation WhiteToBlue = new ColorAnimation(Colors.White, (Color)ColorConverter.ConvertFromString("#CC5FCFFF"), TimeSpan.FromSeconds(1));

            WhiteToBlue.AutoReverse    = true;
            WhiteToBlue.RepeatBehavior = new RepeatBehavior(3);

            image.Source = Function.img2source(Properties.Resources.header7);
            switch (header)
            {
            case "1":
                image.Source = Function.img2source(Properties.Resources.header1);
                break;

            case "2":
                image.Source = Function.img2source(Properties.Resources.header2);
                break;

            case "3":
                image.Source = Function.img2source(Properties.Resources.header3);
                break;

            case "4":
                image.Source = Function.img2source(Properties.Resources.header4);
                break;

            case "5":
                image.Source = Function.img2source(Properties.Resources.header5);
                break;

            case "6":
                image.Source = Function.img2source(Properties.Resources.header6);
                break;

            case "7":
                image.Source = Function.img2source(Properties.Resources.header7);
                break;

            default:
                image.Source = Function.img2source(Properties.Resources.header7);
                break;
            }
            textblock.Text = filename;
            if (type == 1)
            {
                image.HorizontalAlignment        = HorizontalAlignment.Right;
                label.HorizontalAlignment        = HorizontalAlignment.Right;
                label.HorizontalContentAlignment = HorizontalAlignment.Left;
                textblock.TextAlignment          = TextAlignment.Left;
                label.Margin       = new Thickness(5, 0, 55, 15);
                progressbar.Margin = new Thickness(5, 0, 55, 5);
                SolidColorBrush scb = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#CC5FCFFF"));
                scb.BeginAnimation(SolidColorBrush.ColorProperty, BlueToWhite);
                label.BorderBrush     = scb;
                label.Background      = Function.str2color("#FFFFFFFF");
                label.BorderThickness = new Thickness(2, 2, 2, 2);
            }
            else
            {
                SolidColorBrush scb = new SolidColorBrush(Colors.White);
                scb.BeginAnimation(SolidColorBrush.ColorProperty, WhiteToBlue);
                label.BorderBrush     = scb;
                label.Background      = Function.str2color("#CC5FCFFF");
                label.Foreground      = new SolidColorBrush(Colors.White);
                label.BorderThickness = new Thickness(2, 2, 2, 2);
            }
        }
Example #22
0
        public static void ColorAnimate(Grid c, Color to)
        {
            ColorAnimation ca = new ColorAnimation(to, new Duration(TimeSpan.FromMilliseconds(100)));

            c.Background.BeginAnimation(SolidColorBrush.ColorProperty, ca);
        }
Example #23
0
        public StoryboardExample()
        {
            // Create a name scope for the page.
            NameScope.SetNameScope(this, new NameScope());

            this.WindowTitle = "Animate Properties using Storyboards";
            StackPanel myStackPanel = new StackPanel();

            myStackPanel.MinWidth            = 500;
            myStackPanel.Margin              = new Thickness(30);
            myStackPanel.HorizontalAlignment = HorizontalAlignment.Left;
            TextBlock myTextBlock = new TextBlock();

            myTextBlock.Text = "Storyboard Animation Example";
            myStackPanel.Children.Add(myTextBlock);

            //
            // Create and animate the first button.
            //

            // Create a button.
            Button myWidthAnimatedButton = new Button();

            myWidthAnimatedButton.Height = 30;
            myWidthAnimatedButton.Width  = 200;
            myWidthAnimatedButton.HorizontalAlignment = HorizontalAlignment.Left;
            myWidthAnimatedButton.Content             = "A Button";

            // Set the Name of the button so that it can be referred
            // to in the storyboard that's created later.
            // The ID doesn't have to match the variable name;
            // it can be any unique identifier.
            myWidthAnimatedButton.Name = "myWidthAnimatedButton";

            // Register the name with the page to which the button belongs.
            this.RegisterName(myWidthAnimatedButton.Name, myWidthAnimatedButton);

            // Create a DoubleAnimation to animate the width of the button.
            DoubleAnimation myDoubleAnimation = new DoubleAnimation();

            myDoubleAnimation.From     = 200;
            myDoubleAnimation.To       = 300;
            myDoubleAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(3000));

            // Configure the animation to target the button's Width property.
            Storyboard.SetTargetName(myDoubleAnimation, myWidthAnimatedButton.Name);
            Storyboard.SetTargetProperty(myDoubleAnimation, new PropertyPath(Button.WidthProperty));

            // Create a storyboard to contain the animation.
            Storyboard myWidthAnimatedButtonStoryboard = new Storyboard();

            myWidthAnimatedButtonStoryboard.Children.Add(myDoubleAnimation);

            // Animate the button width when it's clicked.
            myWidthAnimatedButton.Click += delegate(object sender, RoutedEventArgs args)
            {
                myWidthAnimatedButtonStoryboard.Begin(myWidthAnimatedButton);
            };


            myStackPanel.Children.Add(myWidthAnimatedButton);

            //
            // Create and animate the second button.
            //

            // Create a second button.
            Button myColorAnimatedButton = new Button();

            myColorAnimatedButton.Height = 30;
            myColorAnimatedButton.Width  = 200;
            myColorAnimatedButton.HorizontalAlignment = HorizontalAlignment.Left;
            myColorAnimatedButton.Content             = "Another Button";

            // Create a SolidColorBrush to paint the button's background.
            SolidColorBrush myBackgroundBrush = new SolidColorBrush();

            myBackgroundBrush.Color = Colors.Blue;

            // Because a Brush isn't a FrameworkElement, it doesn't
            // have a Name property to set. Instead, you just
            // register a name for the SolidColorBrush with
            // the page where it's used.
            this.RegisterName("myAnimatedBrush", myBackgroundBrush);

            // Use the brush to paint the background of the button.
            myColorAnimatedButton.Background = myBackgroundBrush;

            // Create a ColorAnimation to animate the button's background.
            ColorAnimation myColorAnimation = new ColorAnimation();

            myColorAnimation.From     = Colors.Red;
            myColorAnimation.To       = Colors.Blue;
            myColorAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(7000));

            // Configure the animation to target the brush's Color property.
            Storyboard.SetTargetName(myColorAnimation, "myAnimatedBrush");
            Storyboard.SetTargetProperty(myColorAnimation, new PropertyPath(SolidColorBrush.ColorProperty));

            // Create a storyboard to contain the animation.
            Storyboard myColorAnimatedButtonStoryboard = new Storyboard();

            myColorAnimatedButtonStoryboard.Children.Add(myColorAnimation);

            // Animate the button background color when it's clicked.
            myColorAnimatedButton.Click += delegate(object sender, RoutedEventArgs args)
            {
                myColorAnimatedButtonStoryboard.Begin(myColorAnimatedButton);
            };


            myStackPanel.Children.Add(myColorAnimatedButton);
            this.Content = myStackPanel;
        }
        private void begin(object sender, RoutedEventArgs e)
        {
            champAdressePhysique.Text = "";
            champAux.Text             = "";
            champRam.Text             = "";
            champTPages.Text          = "";
            deroulement.Text          = "";

            stop.IsEnabled             = true;
            suivant.IsEnabled          = true;
            suiteReferences.IsReadOnly = true;
            if (iteration == 0)
            {
                sauvSuite = suiteReferences.Text;
                requete   = sauvSuite.Split(' ').ToList <String>();
            }
            if (iteration < suiteReferences.Text.Split(' ').Length)
            {
                sequence.Push(new List <object> {
                    systemExploitation.Clone(), ram.Clone(), diskDur.Clone(), new List <EntreeTablePage>(tablePages.Select(x => x.Clone())), requete, sauvSuite
                });
                if (requete.Count != 0)
                {
                    String r = requete[iteration];
                    demande.Text = "Demande de l'adresse virtuelle: " + r;
                    try
                    {
                        int tmp = Convert.ToInt32(r);
                        switch (choixAlgorithme.SelectedIndex)
                        {
                        case 3:
                            affichMatriceAging();
                            break;
                        }

                        int             sDefaut = systemExploitation.getDefautDePage();
                        int             sNbpage = ram.getNombrepagesLibres();
                        SolidColorBrush myBrush = new SolidColorBrush();
                        myBrush.Color = Colors.White;
                        ColorAnimation ba = new ColorAnimation()
                        {
                            Duration = TimeSpan.FromMilliseconds(1000)
                        };
                        if (tablePages[tmp].getDisponible() == true)
                        {
                            ba.To = Colors.Green;
                        }
                        else
                        {
                            ba.To = Colors.Red;
                        }
                        myBrush.BeginAnimation(SolidColorBrush.ColorProperty, ba);
                        oTable.RowGroups[0].Rows[tmp].Background = myBrush;
                        systemExploitation.gestionRequete(choixAlgorithme.SelectedIndex, tablePages, tmp, ram, diskDur);
                        Line line = new Line()
                        {
                            X1 = 150, Y1 = (tmp + 1) * 51 + 25, Stroke = new SolidColorBrush(Colors.Black), StrokeThickness = 2
                        };
                        DoubleAnimation animation = new DoubleAnimation(260, TimeSpan.FromSeconds(0.5))
                        {
                            From = 150, AutoReverse = true
                        };

                        memVirtuelle.Children.Add(line);
                        line.BeginAnimation(Line.X2Property, animation);
                        animation.From = line.Y1;
                        animation.To   = 200 + (51) * tablePages[tmp].getPageCorrespandante();
                        line.BeginAnimation(Line.Y2Property, animation);



                        switch (choixAlgorithme.SelectedIndex)
                        {
                        case 0:
                            if (sDefaut < systemExploitation.getDefautDePage() && sNbpage == 0)
                            {
                                aux.Children.RemoveAt(0);
                                aux.Children.RemoveAt(0);
                            }
                            else
                            {
                                if (sDefaut == systemExploitation.getDefautDePage())
                                {
                                    for (int i = 1; i < aux.Children.Count; i = i + 2)
                                    {
                                        if (((TextBlock)aux.Children[i]).Text == r)
                                        {
                                            aux.Children.RemoveRange(i - 1, 2);
                                            for (int k = i - 1; k < aux.Children.Count; k++)
                                            {
                                                DoubleAnimation db = new DoubleAnimation
                                                {
                                                    To       = Canvas.GetLeft(aux.Children[k]) + 10,
                                                    Duration = new Duration(new TimeSpan(1000000))
                                                };
                                                aux.Children[k].BeginAnimation(Canvas.LeftProperty, db);
                                            }

                                            break;
                                        }
                                    }
                                }
                            }
                            ajoutFileLru();
                            break;

                        case 1:
                            if (sDefaut < systemExploitation.getDefautDePage())
                            {
                                if (sNbpage == 0)
                                {
                                    aux.Children.RemoveAt(0);
                                    aux.Children.RemoveAt(0);
                                }

                                ajoutFileFifo();
                            }

                            break;

                        case 2:
                            affichLfu();
                            break;

                        case 3:
                            affichMatriceAging();
                            break;
                        }
                        champTPages.Text = "Mise a jour de la table de pages ";
                        afficherRam(ram);
                        champAdressePhysique.Text = "L'adresse physique de la page " + r + " est: " + tablePages[Convert.ToInt32(r)].getPageCorrespandante().ToString();
                        deroulement.Text          = "Nombre de defauts de page: " + systemExploitation.getDefautDePage().ToString();
                        majTablePage();
                        iteration++;
                    }
                    catch (FormatException)
                    {
                        msgErreur.Text = "erreur dans la suite entrée.";
                    }

                    precedent.IsEnabled = true;
                    if (iteration == suiteReferences.Text.Split(' ').Length)
                    {
                        lancer.IsEnabled  = false;
                        suivant.IsEnabled = false;
                    }
                }
            }
        }
Example #25
0
 private void EmbiggenBarcode_Up(object sender, EventArgs e)
 {
     if (EmbiggenBarcode.IsEnabled == false)
     {
         return;
     }
     EmbiggenBarcode.IsEnabled = false;
     if (BarcodeEmbiggened)
     {
         EmbiggenBarcode.Source = new BitmapImage(new Uri("Expand-76.png", UriKind.Relative));
         PowerEase pe = new PowerEase();
         pe.Power = 2.5;
         Size            bigSize           = new Size(Barcode.Width / 2.25, Barcode.Height / 3);
         Duration        animationDuration = new Duration(TimeSpan.FromSeconds(0.5));
         DoubleAnimation dw = new DoubleAnimation();
         dw.EasingFunction = pe;
         dw.From           = Barcode.Width;
         dw.To             = bigSize.Width;
         dw.Duration       = animationDuration;
         DoubleAnimation dh = new DoubleAnimation();
         dh.EasingFunction = pe;
         dh.From           = Barcode.Height;
         dh.To             = bigSize.Height;
         dh.Duration       = animationDuration;
         ThicknessAnimation dm = new ThicknessAnimation();
         dm.EasingFunction = pe;
         dm.From           = Barcode.Margin;
         dm.To             = BarcodeMargin;
         dm.Duration       = animationDuration;
         ColorAnimation pc = new ColorAnimation();
         pc.EasingFunction = pe;
         Color blackFrom = Colors.Black;
         blackFrom.A = 153;
         pc.From     = blackFrom;
         blackFrom.A = 0;
         pc.To       = blackFrom;
         pc.Duration = animationDuration;
         DelayCall(500, new Action(() => { BarcodeSplash.Visibility = Visibility.Hidden; }));
         BarcodeSplash.Background.BeginAnimation(SolidColorBrush.ColorProperty, pc);
         Barcode.BeginAnimation(Grid.HeightProperty, dh);
         Barcode.BeginAnimation(Grid.WidthProperty, dw);
         Barcode.BeginAnimation(Grid.MarginProperty, dm);
     }
     else
     {
         EmbiggenBarcode.Source = new BitmapImage(new Uri("Retract-76.png", UriKind.Relative));
         BarcodeMargin          = Barcode.Margin;
         PowerEase pe = new PowerEase();
         pe.Power = 2.5;
         Size            bigSize = new Size(Barcode.Width * 2.25, Barcode.Height * 3);
         DoubleAnimation dw      = new DoubleAnimation();
         dw.EasingFunction = pe;
         dw.From           = Barcode.Width;
         dw.To             = bigSize.Width;
         dw.Duration       = AnimationDuration;
         DoubleAnimation dh = new DoubleAnimation();
         dh.EasingFunction = pe;
         dh.From           = Barcode.Height;
         dh.To             = bigSize.Height;
         dh.Duration       = AnimationDuration;
         ThicknessAnimation dm = new ThicknessAnimation();
         dm.EasingFunction = pe;
         dm.From           = Barcode.Margin;
         dm.To             = new Thickness((this.Width - bigSize.Width) / 2, Barcode.Margin.Top, Barcode.Margin.Right, (this.Height - bigSize.Height) / 2);
         dm.Duration       = AnimationDuration;
         ColorAnimation pc = new ColorAnimation();
         pc.EasingFunction = pe;
         Color blackFrom = Colors.Black;
         blackFrom.A = 0;
         pc.From     = blackFrom;
         blackFrom.A = 153;
         pc.To       = blackFrom;
         pc.Duration = AnimationDuration;
         BarcodeSplash.Visibility = Visibility.Visible;
         BarcodeSplash.Background.BeginAnimation(SolidColorBrush.ColorProperty, pc);
         Barcode.BeginAnimation(Grid.HeightProperty, dh);
         Barcode.BeginAnimation(Grid.WidthProperty, dw);
         Barcode.BeginAnimation(Grid.MarginProperty, dm);
     }
     DelayCall(510, new Action(() => { EmbiggenBarcode.IsEnabled = true; }));
     BarcodeEmbiggened = !BarcodeEmbiggened;
 }
Example #26
0
        private Style InizializzaAnimazioni(Style newStyle)
        {
            if (newStyle == null)
            {
                newStyle = new Style();
            }

            //***Animazione colore OFF
            ColorAnimation claColoreStelo = new ColorAnimation(ColoreStelo.Color, TimeSpan.FromSeconds(0.2));

            Storyboard.SetTargetProperty(claColoreStelo, new PropertyPath("ColoreStelo.Color"));

            ColorAnimation claColoreToggle = new ColorAnimation(ColoreToggle.Color, TimeSpan.FromSeconds(0.2));

            Storyboard.SetTargetProperty(claColoreToggle, new PropertyPath("ColoreToggle.Color"));

            ColorAnimation claColoreBordo = new ColorAnimation(ColoreBordo.Color, TimeSpan.FromSeconds(0.2));

            Storyboard.SetTargetProperty(claColoreBordo, new PropertyPath("ColoreBordo.Color"));

            Anim.CreaBloccoAnimazioni(newStyle, new List <Condition> {
                new Condition(IsCheckedProperty, false), new Condition(IsEnabledProperty, true)
            },
                                      new List <Timeline> {
                claColoreStelo, claColoreToggle, claColoreBordo
            });


            //***Animazione colore ON
            claColoreStelo = new ColorAnimation(ColoreSteloOn.Color, TimeSpan.FromSeconds(0.2));
            Storyboard.SetTargetProperty(claColoreStelo, new PropertyPath("ColoreStelo.Color"));

            claColoreToggle = new ColorAnimation(ColoreToggleOn.Color, TimeSpan.FromSeconds(0.2));
            Storyboard.SetTargetProperty(claColoreToggle, new PropertyPath("ColoreToggle.Color"));

            claColoreBordo = new ColorAnimation(ColoreBordoOn.Color, TimeSpan.FromSeconds(0.2));
            Storyboard.SetTargetProperty(claColoreBordo, new PropertyPath("ColoreBordo.Color"));

            ColorAnimation claColoreTesto = new ColorAnimation(ColoreTestoOn.Color, TimeSpan.FromSeconds(0.2));

            Storyboard.SetTargetProperty(claColoreTesto, new PropertyPath("Foreground.Color"));

            Anim.CreaBloccoAnimazioni(newStyle, new List <Condition> {
                new Condition(IsCheckedProperty, true), new Condition(IsEnabledProperty, true)
            },
                                      new List <Timeline> {
                claColoreStelo, claColoreToggle, claColoreBordo, claColoreTesto
            });


            //***Animazione colore DISABLED
            claColoreStelo = new ColorAnimation(ColoreSteloDisabled.Color, TimeSpan.FromSeconds(0.1));
            Storyboard.SetTargetProperty(claColoreStelo, new PropertyPath("ColoreStelo.Color"));

            claColoreToggle = new ColorAnimation(ColoreToggleDisabled.Color, TimeSpan.FromSeconds(0.1));
            Storyboard.SetTargetProperty(claColoreToggle, new PropertyPath("ColoreToggle.Color"));

            claColoreBordo = new ColorAnimation(ColoreBordoDisabled.Color, TimeSpan.FromSeconds(0.1));
            Storyboard.SetTargetProperty(claColoreBordo, new PropertyPath("ColoreBordo.Color"));

            claColoreTesto = new ColorAnimation(ColoreTestoDisabled.Color, TimeSpan.FromSeconds(0.1));
            Storyboard.SetTargetProperty(claColoreTesto, new PropertyPath("Foreground.Color"));

            Anim.CreaBloccoAnimazioni(newStyle, new List <Condition> {
                new Condition(IsEnabledProperty, false)
            },
                                      new List <Timeline> {
                claColoreStelo, claColoreToggle, claColoreBordo, claColoreTesto
            });

            //Dim ellips As Ellipse = Me.Template.FindName("llpToggle", Me)
            //ellips.BeginStoryboard(stbScorri)

            //this.Style = stile;
            return(newStyle);
        }
Example #27
0
 /// <summary>
 /// Function launching animation color of PasswordBox.
 /// </summary>
 /// <param name="passwordBox">PasswordBox to animate.</param>
 /// <param name="errorTextBoxStoryboard">Storyboard to launch.</param>
 /// <param name="color">The chosen color.</param>
 /// <param name="btnDisabled">Button that will be disabled.</param>
 public static void AnimationErrorTextBox(PasswordBox passwordBox, Storyboard errorTextBoxStoryboard, ColorAnimation color, Button btnDisabled)
 {
     Storyboard.SetTargetName(color, passwordBox.Name); //Change TargetName of the Storyboard by the PasswordBox
     errorTextBoxStoryboard.Begin();                    //Start the animation
     btnDisabled.IsEnabled = false;                     //Disable the button
 }
Example #28
0
        private async void Properties_Loaded(object sender, RoutedEventArgs e)
        {
            AppSettings.ThemeModeChanged += AppSettings_ThemeModeChanged;
            if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
            {
                // Set window size in the loaded event to prevent flickering
                if (WindowDecorationsHelper.IsWindowDecorationsAllowed)
                {
                    appWindow.TitleBar.SetPreferredVisibility(AppWindowTitleBarVisibility.AlwaysHidden);
                    appWindow.Frame.DragRegionVisuals.Add(TitleBarDragArea);

                    crossIcon.Foreground = ThemeHelper.RootTheme switch
                    {
                        ElementTheme.Default => new SolidColorBrush((Color)Application.Current.Resources["SystemBaseHighColor"]),
                        ElementTheme.Light => new SolidColorBrush(Colors.Black),
                        ElementTheme.Dark => new SolidColorBrush(Colors.White),
                        _ => new SolidColorBrush((Color)Application.Current.Resources["SystemBaseHighColor"])
                    };

                    var micaIsSupported = ApiInformation.IsMethodPresent("Windows.UI.Composition.Compositor", "TryCreateBlurredWallpaperBackdropBrush");
                    if (micaIsSupported)
                    {
                        micaBrush = new Brushes.MicaBrush(false);
                        (micaBrush as Brushes.MicaBrush).SetAppWindow(appWindow);
                        Frame.Background = micaBrush;
                    }
                    else
                    {
                        Microsoft.UI.Xaml.Controls.BackdropMaterial.SetApplyToRootOrPageBackground(sender as Control, true);
                    }

                    var duration = new Duration(TimeSpan.FromMilliseconds(280));

                    RectHoverAnim = new Storyboard();
                    var RectHoverColorAnim = new ColorAnimation();
                    RectHoverColorAnim.Duration       = duration;
                    RectHoverColorAnim.From           = Colors.Transparent;
                    RectHoverColorAnim.To             = Color.FromArgb(255, 232, 17, 35);
                    RectHoverColorAnim.EasingFunction = new SineEase();
                    Storyboard.SetTarget(RectHoverColorAnim, CloseRect);
                    Storyboard.SetTargetProperty(RectHoverColorAnim, "(Rectangle.Fill).(SolidColorBrush.Color)");
                    RectHoverAnim.Children.Add(RectHoverColorAnim);

                    RectUnHoverAnim = new Storyboard();
                    var RectUnHoverColorAnim = new ColorAnimation();
                    RectUnHoverColorAnim.Duration       = duration;
                    RectUnHoverColorAnim.To             = Colors.Transparent;
                    RectUnHoverColorAnim.From           = Color.FromArgb(255, 232, 17, 35);
                    RectUnHoverColorAnim.EasingFunction = new SineEase();
                    Storyboard.SetTarget(RectUnHoverColorAnim, CloseRect);
                    Storyboard.SetTargetProperty(RectUnHoverColorAnim, "(Rectangle.Fill).(SolidColorBrush.Color)");
                    RectUnHoverAnim.Children.Add(RectUnHoverColorAnim);

                    CrossHoverAnim = new Storyboard();
                    var CrossHoverColorAnim = new ColorAnimation();
                    CrossHoverColorAnim.Duration       = duration;
                    CrossHoverColorAnim.From           = ((SolidColorBrush)crossIcon.Foreground).Color;
                    CrossHoverColorAnim.To             = Colors.White;
                    CrossHoverColorAnim.EasingFunction = new SineEase();
                    Storyboard.SetTarget(CrossHoverColorAnim, crossIcon);
                    Storyboard.SetTargetProperty(CrossHoverColorAnim, "(PathIcon.Foreground).(SolidColorBrush.Color)");
                    CrossHoverAnim.Children.Add(CrossHoverColorAnim);

                    CrossUnHoverAnim = new Storyboard();
                    var CrossUnHoverColorAnim = new ColorAnimation();
                    CrossUnHoverColorAnim.Duration       = duration;
                    CrossUnHoverColorAnim.To             = ((SolidColorBrush)crossIcon.Foreground).Color;
                    CrossUnHoverColorAnim.From           = Colors.White;
                    CrossUnHoverColorAnim.EasingFunction = new SineEase();
                    Storyboard.SetTarget(CrossUnHoverColorAnim, crossIcon);
                    Storyboard.SetTargetProperty(CrossUnHoverColorAnim, "(PathIcon.Foreground).(SolidColorBrush.Color)");
                    CrossUnHoverAnim.Children.Add(CrossUnHoverColorAnim);
                }
                else
                {
                    Microsoft.UI.Xaml.Controls.BackdropMaterial.SetApplyToRootOrPageBackground(sender as Control, true);

                    TitleBar = ApplicationView.GetForCurrentView().TitleBar;
                    TitleBar.ButtonBackgroundColor         = Colors.Transparent;
                    TitleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
                    Window.Current.SetTitleBar(TitleBarDragArea);
                }
                await CoreApplication.MainView.DispatcherQueue.EnqueueAsync(() => AppSettings.UpdateThemeElements.Execute(null));
            }
            else
            {
                Microsoft.UI.Xaml.Controls.BackdropMaterial.SetApplyToRootOrPageBackground(sender as Control, true);
                propertiesDialog         = DependencyObjectHelpers.FindParent <ContentDialog>(this);
                propertiesDialog.Closed += PropertiesDialog_Closed;
            }
        }
Example #29
0
        private void MasterWebSocket_MessageReceived(object sender, MessageReceivedEventArgs e)
        {
            Dispatcher.Invoke(() =>
            {
                AddLog("Master Said: " + e.Message);;
                // "Flicker" indicators when messages arrive...
                ColorAnimation colorAnimation = new ColorAnimation();
                colorAnimation.From           = Color.FromRgb(0, 255, 0);
                colorAnimation.To             = Color.FromRgb(128, 128, 128);
                colorAnimation.AutoReverse    = true;
                colorAnimation.Duration       = new Duration(TimeSpan.FromMilliseconds(100));
                colorAnimation.FillBehavior   = FillBehavior.Stop;
                MasterConnectionIndicatorRectangle.Fill.BeginAnimation(SolidColorBrush.ColorProperty, colorAnimation);
            });



            // Get Dictionary representation of JSON message object objects with string keys
            var JSONObjMessage = new JavaScriptSerializer().Deserialize <Dictionary <string, object> >(e.Message);

            if (JSONObjMessage.ContainsKey("action"))
            {
                String slaveTriggercommand = "";

                switch (JSONObjMessage["action"])
                {
                case "authenticate":
                {
                    if (JSONObjMessage["authenticated"].ToString() == "1")          // Authenication success!
                    {
                        // Update Master connection indicator to green (connected & authenticated)
                        Dispatcher.Invoke(() =>
                            {
                                MasterConnectionIndicatorRectangle.Fill = new SolidColorBrush(Color.FromRgb(0, 255, 0));
                            });
                    }
                }
                break;

                case "presentationTriggerIndex":
                {
                    // "Master" has triggered a slide. let's send trigger to all slaves
                    String slideIndex       = JSONObjMessage["slideIndex"].ToString();
                    String presentationPath = JSONObjMessage["presentationPath"].ToString();

                    slaveTriggercommand = "{\"action\":\"presentationTriggerIndex\",\"slideIndex\":\"" + slideIndex + "\",\"presentationPath\":\"" + presentationPath + "\"}";
                    SendSlaveCommand(slaveTriggercommand);

                    /* (NO LONGER NEEDED SINCE Pro 7.1.2 !!!!)
                     * // ALERT: to avoid Pro7 hanging/crash we do a workaround:
                     * // Always make sure if we are about to trigger a slide for a NEW presentationPath then send presentationRequest FIRST before presentationTriggerIndex
                     * // We do this by recording the currentPresentationPath and comparing before every triggered slide.
                     * if (CurrentPresentationPath != presentationPath)
                     * {
                     *  SlaveWebSocket.Send("{\"action\": \"presentationRequest\",\"presentationPath\": \"" + presentationPath + "\",\"presentationSlideQuality\": \"0\"}");
                     *
                     *  // wait a bit - hopefully pro7 slave "catches up here" and then send trigger command
                     *  Task.Factory.StartNew(() =>
                     *  {
                     *      System.Threading.Thread.Sleep(500);  //TODO: if we get stuck with this terrible workaround - maybe make this configurable.. (or better still, let's also enumarate the playlist upon connection and just call presenationRequest on *everything* to avoid this delay)
                     *      CurrentPresentationPath = presentationPath;
                     *      SlaveWebSocket.Send(slaveTriggercommand);
                     *  });
                     * }
                     * else
                     * {
                     *  SlaveWebSocket.Send(slaveTriggercommand);
                     * } */
                }
                break;

                case "clearText":
                    if (TimeStampOfLastClearText != null && DateTime.Now.Subtract(TimeStampOfLastClearText).TotalMilliseconds < 300)      //TODO: make this configurable???
                    {
                        slaveTriggercommand = "{\"action\":\"clearText\"}";
                        SendSlaveCommand(slaveTriggercommand);
                    }
                    TimeStampOfLastClearText = DateTime.Now;
                    break;

                case "clearVideo":
                    slaveTriggercommand = "{\"action\":\"clearVideo\"}";
                    SendSlaveCommand(slaveTriggercommand);
                    TimeStampOfLastClearText = DateTime.Now;
                    break;

                case "clearAudio":
                    slaveTriggercommand = "{\"action\":\"clearAudio\"}";
                    SendSlaveCommand(slaveTriggercommand);
                    TimeStampOfLastClearText = DateTime.Now;
                    break;

                case "clearAll":
                    slaveTriggercommand = "{\"action\":\"clearAll\"}";
                    SendSlaveCommand(slaveTriggercommand);
                    TimeStampOfLastClearText = DateTime.Now;
                    break;

                default:
                    break;
                }
            }
        }
Example #30
0
        public static async Task <MessageBoxResult> ShowInContainer(string containerIdentifier, string message, string title = "", MessageBoxButton button = MessageBoxButton.OK, MessageBoxIcon icon = MessageBoxIcon.None)
        {
            MessageBoxResult result         = MessageBoxResult.No;
            bool             isReturnResult = false;

            if (!MessageBoxContainer.Containers.ContainsKey(containerIdentifier))
            {
                return(result);
            }

            MessageBoxContainer container = MessageBoxContainer.Containers[containerIdentifier];

            container.Dispatcher.VerifyAccess();

            MessageBoxCard card = new MessageBoxCard
            {
                Content          = message,
                Title            = title,
                MessageBoxButton = button,
            };

            card.ReturnResult += (a, b) =>
            {
                isReturnResult = true;
                result         = b.Result;
            };

            switch (icon)
            {
            case MessageBoxIcon.None:
                card.IsShowIcon = false;
                break;

            case MessageBoxIcon.Info:
                card.IsShowIcon      = true;
                card.IconType        = IconType.InformationFill;
                card.ThemeColorBrush = infoBrush;
                break;

            case MessageBoxIcon.Success:
                card.IsShowIcon      = true;
                card.IconType        = IconType.CheckboxCircleFill;
                card.ThemeColorBrush = successBrush;
                break;

            case MessageBoxIcon.Warining:
                card.IsShowIcon      = true;
                card.IconType        = IconType.ErrorWarningFill;
                card.ThemeColorBrush = warningBrush;
                break;

            case MessageBoxIcon.Error:
                card.IsShowIcon      = true;
                card.IconType        = IconType.CloseCircleFill;
                card.ThemeColorBrush = errorBrush;
                break;

            case MessageBoxIcon.Question:
                card.IsShowIcon      = true;
                card.IconType        = IconType.QuestionFill;
                card.ThemeColorBrush = questionBrush;
                break;
            }

            container.Visibility = Visibility.Visible;

            // 动画
            Storyboard cardStoryboard = new Storyboard();

            DoubleAnimation opacityAnimation = new DoubleAnimation
            {
                From           = 0,
                To             = 1,
                Duration       = new Duration(TimeSpan.FromMilliseconds(200)),
                EasingFunction = new CubicEase {
                    EasingMode = EasingMode.EaseOut
                }
            };

            Storyboard.SetTargetProperty(opacityAnimation, new PropertyPath(UIElement.OpacityProperty));

            DoubleAnimation transformAnimation = new DoubleAnimation
            {
                From           = 50,
                To             = 0,
                Duration       = new Duration(TimeSpan.FromMilliseconds(200)),
                EasingFunction = new CubicEase {
                    EasingMode = EasingMode.EaseOut
                }
            };

            Storyboard.SetTargetProperty(transformAnimation, new PropertyPath("(UIElement.RenderTransform).(TranslateTransform.Y)"));

            cardStoryboard.Children.Add(opacityAnimation);
            cardStoryboard.Children.Add(transformAnimation);

            // 背景动画
            ColorAnimation backgroundAnimation = new ColorAnimation
            {
                From           = Colors.Transparent,
                To             = containerBackgroun,
                Duration       = new Duration(TimeSpan.FromMilliseconds(150)),
                EasingFunction = new CubicEase {
                    EasingMode = EasingMode.EaseOut
                }
            };

            backgroundAnimation.Completed += (sender, e) =>
            {
                container.Child = card;
                card.BeginStoryboard(cardStoryboard);
                card.Focus();
            };

            container.Background.BeginAnimation(SolidColorBrush.ColorProperty, backgroundAnimation);

            await Task.Run(() => { while (!isReturnResult)
                                   {
                                       Thread.Sleep(10);
                                   }
                           });

            return(result);
        }
Example #31
0
        private static void OnRenderPressedChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
        {
            ImageButtonChrome buttonChrome = (ImageButtonChrome)o;

            if (!buttonChrome.Animates)
            {
                buttonChrome._localResources = null;
                buttonChrome.InvalidateVisual();
                return;
            }
            if ((bool)e.NewValue)
            {
                if (buttonChrome._localResources == null)
                {
                    buttonChrome._localResources = new ImageButtonChrome.LocalResources();
                    buttonChrome.InvalidateVisual();
                }
                Duration        duration  = new Duration(TimeSpan.FromSeconds(0.1));
                DoubleAnimation animation = new DoubleAnimation(1.0, duration);
                buttonChrome.BackgroundOverlay.BeginAnimation(Brush.OpacityProperty, animation);
                buttonChrome.BorderOverlayPen.Brush.BeginAnimation(Brush.OpacityProperty, animation);
                buttonChrome.LeftDropShadowBrush.BeginAnimation(Brush.OpacityProperty, animation);
                buttonChrome.TopDropShadowBrush.BeginAnimation(Brush.OpacityProperty, animation);
                animation = new DoubleAnimation(0.0, duration);
                buttonChrome.InnerBorderPen.Brush.BeginAnimation(Brush.OpacityProperty, animation);
                ColorAnimation         animation2    = new ColorAnimation(Color.FromRgb(194, 228, 246), duration);
                GradientStopCollection gradientStops = ((LinearGradientBrush)buttonChrome.BackgroundOverlay).GradientStops;
                gradientStops[0].BeginAnimation(GradientStop.ColorProperty, animation2);
                gradientStops[1].BeginAnimation(GradientStop.ColorProperty, animation2);
                animation2 = new ColorAnimation(Color.FromRgb(171, 218, 243), duration);
                gradientStops[2].BeginAnimation(GradientStop.ColorProperty, animation2);
                animation2 = new ColorAnimation(Color.FromRgb(144, 203, 235), duration);
                gradientStops[3].BeginAnimation(GradientStop.ColorProperty, animation2);
                animation2 = new ColorAnimation(Color.FromRgb(44, 98, 139), duration);
                buttonChrome.BorderOverlayPen.Brush.BeginAnimation(SolidColorBrush.ColorProperty, animation2);
                return;
            }
            if (buttonChrome._localResources == null)
            {
                buttonChrome.InvalidateVisual();
                return;
            }
            bool            renderMouseOver = buttonChrome.RenderMouseOver;
            Duration        duration2       = new Duration(TimeSpan.FromSeconds(0.1));
            DoubleAnimation doubleAnimation = new DoubleAnimation
            {
                Duration = duration2
            };

            buttonChrome.LeftDropShadowBrush.BeginAnimation(Brush.OpacityProperty, doubleAnimation);
            buttonChrome.TopDropShadowBrush.BeginAnimation(Brush.OpacityProperty, doubleAnimation);
            buttonChrome.InnerBorderPen.Brush.BeginAnimation(Brush.OpacityProperty, doubleAnimation);
            if (!renderMouseOver)
            {
                buttonChrome.BorderOverlayPen.Brush.BeginAnimation(Brush.OpacityProperty, doubleAnimation);
                buttonChrome.BackgroundOverlay.BeginAnimation(Brush.OpacityProperty, doubleAnimation);
            }
            ColorAnimation colorAnimation = new ColorAnimation
            {
                Duration = duration2
            };

            buttonChrome.BorderOverlayPen.Brush.BeginAnimation(SolidColorBrush.ColorProperty, colorAnimation);
            GradientStopCollection gradientStops2 = ((LinearGradientBrush)buttonChrome.BackgroundOverlay).GradientStops;

            gradientStops2[0].BeginAnimation(GradientStop.ColorProperty, colorAnimation);
            gradientStops2[1].BeginAnimation(GradientStop.ColorProperty, colorAnimation);
            gradientStops2[2].BeginAnimation(GradientStop.ColorProperty, colorAnimation);
            gradientStops2[3].BeginAnimation(GradientStop.ColorProperty, colorAnimation);
        }
Example #32
0
        private void SetupDataAnimations()
        {
            if (this.AnimationsSetup || this.Client.ClientData == null) return;

            var client = this.Client;
            var data = client.ClientData;

            this.heightString = $"Height: {data.Height}";
            this.shoeString = $"Shoe size: {data.ShoeSize}";

            this.overlayAnimation = new ColorAnimation(Color.White, client.Color, TimeSpan.FromSeconds(1.5));

            float alpha = 0.7f;

            this.nameOpacityAnimation = new FloatAnimation(0.0f, alpha, TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(2));
            this.namePositionAnimation = new Vector2Animation(new Vector2(0, -30), new Vector2(50, -30), TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(2));
            this.nameStringAnimation = new StringAnimation("", data.Name, TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(2));

            this.surnameOpacityAnimation = new FloatAnimation(0.0f, alpha, TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(3));
            this.surnamePositionAnimation = new Vector2Animation(new Vector2(0, -5), new Vector2(50, -5), TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(3));
            this.surnameStringAnimation = new StringAnimation("", data.Surname, TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(3));

            this.emailOpacityAnimation = new FloatAnimation(0.0f, alpha, TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(4));
            this.emailPositionAnimation = new Vector2Animation(new Vector2(0, 20), new Vector2(50, 20), TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(4));
            this.emailStringAnimation = new StringAnimation("", data.Email, TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(4));

            this.heightOpacityAnimation = new FloatAnimation(0.0f, alpha, TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(5));
            this.heightPositionAnimation = new Vector2Animation(new Vector2(-40, 0), new Vector2(-40, 120), TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(5));
            this.heightStringAnimation = new StringAnimation("", heightString, TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(5));

            this.shoeSizeOpacityAnimation = new FloatAnimation(0.0f, alpha, TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(6));
            this.shoeSizePositionAnimation = new Vector2Animation(new Vector2(-40, 100), new Vector2(-40, 150), TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(6));
            this.shoeSizeStringAnimation = new StringAnimation("", shoeString, TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(6));
        }