示例#1
0
        public MainPage()
        {
            InitializeComponent();

            Compositor = Window.Current.Compositor;

            //Set Background color.
            GradientBrush            = Compositor.CreateLinearGradientBrush();
            GradientBrush.StartPoint = new Vector2(0.5f, 0);
            GradientBrush.EndPoint   = new Vector2(0.5f, 1);

            TopGradientStop    = Compositor.CreateColorGradientStop(0, Color.FromArgb(255, 0, 0, 0));
            BottomGradientStop = Compositor.CreateColorGradientStop(0.352f, Color.FromArgb(255, 51, 27, 59));
            GradientBrush.ColorStops.Add(BottomGradientStop);
            GradientBrush.ColorStops.Add(TopGradientStop);
            BackgroundVisual       = Compositor.CreateSpriteVisual();
            BackgroundVisual.Brush = GradientBrush;
            ElementCompositionPreview.SetElementChildVisual(Gradient, BackgroundVisual);

            BuldRef         = Bulb;
            BuldEffectRef   = BuldLight;
            ScreenEffectRef = ScreenEffect;

            BaseUri = base.BaseUri;

            Gradient.SizeChanged += (s, e) =>
            {
                if (e.NewSize == e.PreviousSize)
                {
                    return;
                }
                BackgroundVisual.Size     = e.NewSize.ToVector2();
                GradientBrush.CenterPoint = BackgroundVisual.Size / 2;
            };
        }
示例#2
0
        XElement FromCompositionLinearGradientBrush(CompositionLinearGradientBrush obj)
        {
            return(new XElement(GetCompositionObjectName(obj), GetContents()));

            IEnumerable <XObject> GetContents()
            {
                foreach (var item in GetCompositionObjectContents(obj))
                {
                    yield return(item);
                }
            }
        }
示例#3
0
        public Gradients() : base()
        {
            InitializeComponent();

            _compositor = Window.Current.Compositor;

            _gradientBrush            = _compositor.CreateLinearGradientBrush();
            _gradientBrush.StartPoint = Vector2.Zero;
            _gradientBrush.EndPoint   = new Vector2(1.0f);

            _relaxGradientStop        = _compositor.CreateColorGradientStop();
            _relaxGradientStop.Offset = 0.5f;
            _relaxGradientStop.Color  = Blue;
            _focusGradientStop        = _compositor.CreateColorGradientStop();
            _focusGradientStop.Offset = 0.5f;
            _focusGradientStop.Color  = Red;
            _gradientBrush.ColorStops.Add(_relaxGradientStop);
            _gradientBrush.ColorStops.Add(_focusGradientStop);
            _backgroundVisual       = _compositor.CreateSpriteVisual();
            _backgroundVisual.Brush = _gradientBrush;
            ElementCompositionPreview.SetElementChildVisual(Gradient, _backgroundVisual);



            Loaded += async(s, e) =>
            {
                await Task.Delay(2000);

                UpdateGradients();
                MiddleText.Visibility = Visibility.Collapsed;
                await Task.Delay(2000);

                UpdateText();
            };

            Gradient.SizeChanged += (s, e) =>
            {
                if (e.NewSize == e.PreviousSize)
                {
                    return;
                }

                _backgroundVisual.Size     = e.NewSize.ToVector2();
                _gradientBrush.CenterPoint = _backgroundVisual.Size / 2;
            };

            ViewModel.IsInPomodoroChanged += (s, e) =>
            {
                UpdateGradients();
                UpdateText();
            };
        }
示例#4
0
        protected override CompositionBrush CreateBrush()
        {
            _compositor = Window.Current.Compositor;

            _foregroundBrush            = _compositor.CreateLinearGradientBrush();
            _foregroundBrush.StartPoint = Vector2.Zero;
            _foregroundBrush.EndPoint   = new Vector2(1.0f);

            _bottomRightGradientStop        = _compositor.CreateColorGradientStop();
            _bottomRightGradientStop.Offset = 0.5f;
            _bottomRightGradientStop.Color  = Green;
            _topLeftradientStop             = _compositor.CreateColorGradientStop();
            _topLeftradientStop.Offset      = 0.5f;
            _topLeftradientStop.Color       = Blue;
            _foregroundBrush.ColorStops.Add(_bottomRightGradientStop);
            _foregroundBrush.ColorStops.Add(_topLeftradientStop);


            _backgroundBrush            = _compositor.CreateLinearGradientBrush();
            _backgroundBrush.StartPoint = new Vector2(1.0f, 0);
            _backgroundBrush.EndPoint   = new Vector2(0, 1.0f);

            _topRightGradientStop          = _compositor.CreateColorGradientStop();
            _topRightGradientStop.Offset   = 0.25f;
            _topRightGradientStop.Color    = Black;
            _bottomLeftGradientStop        = _compositor.CreateColorGradientStop();
            _bottomLeftGradientStop.Offset = 1.0f;
            _bottomLeftGradientStop.Color  = Black;
            _backgroundBrush.ColorStops.Add(_topRightGradientStop);
            _backgroundBrush.ColorStops.Add(_bottomLeftGradientStop);

            var graphicsEffect = new BlendEffect()
            {
                Mode       = BlendEffectMode.Screen,
                Foreground = new CompositionEffectSourceParameter("Main"),
                Background = new CompositionEffectSourceParameter("Tint"),
            };

            var effectFactory = _compositor.CreateEffectFactory(graphicsEffect);

            _brush = effectFactory.CreateBrush();
            _brush.SetSourceParameter("Main", _foregroundBrush);
            _brush.SetSourceParameter("Tint", _backgroundBrush);
            return(_brush);
        }
示例#5
0
        private void CreateMainElipse()
        {
            CompositionRoundedRectangleGeometry roundedRectangle = compositor.CreateRoundedRectangleGeometry();

            roundedRectangle.Size         = new Vector2(150, 50);
            roundedRectangle.CornerRadius = new Vector2(25, 25);
            CompositionSpriteShape compositionSpriteShape = compositor.CreateSpriteShape(roundedRectangle);

            linearGradientBrush            = compositor.CreateLinearGradientBrush();
            linearGradientBrush.StartPoint = new Vector2(0, 1);
            linearGradientBrush.EndPoint   = new Vector2(0f, 1);
            linearGradientBrush.ColorStops.Insert(0, compositor.CreateColorGradientStop(0f, backgroundColor));
            linearGradientBrush.ColorStops.Insert(1, compositor.CreateColorGradientStop(0.5f, waveColor));
            linearGradientBrush.ColorStops.Insert(2, compositor.CreateColorGradientStop(1f, backgroundColor));

            compositionSpriteShape.FillBrush = linearGradientBrush;
            shapeVisualElipse      = compositor.CreateShapeVisual();
            shapeVisualElipse.Size = new Vector2(150, 50);
            shapeVisualElipse.Shapes.Add(compositionSpriteShape);
        }
示例#6
0
        private static CompositionGradientBrush CreateCompositionGradientBrush(GradientBrush gradientBrush, Compositor compositor)
        {
            CompositionGradientBrush compositionBrush;

            if (gradientBrush is LinearGradientBrush linearGradient)
            {
                CompositionLinearGradientBrush compositionLinearGradientBrush = compositor.CreateLinearGradientBrush();
                compositionLinearGradientBrush.StartPoint = linearGradient.StartPoint.ToVector2();
                compositionLinearGradientBrush.EndPoint   = linearGradient.EndPoint.ToVector2();

                compositionBrush = compositionLinearGradientBrush;
            }
            else
            {
                return(null);
            }

            compositionBrush.RelativeTransformMatrix = gradientBrush.RelativeTransform?.MatrixCore ?? Matrix3x2.Identity;
            compositionBrush.ExtendMode  = ConvertGradientExtendMode(gradientBrush.SpreadMethod);
            compositionBrush.MappingMode = ConvertBrushMappingMode(gradientBrush.MappingMode);
            ConvertGradientColorStops(compositor, compositionBrush, gradientBrush.GradientStops, gradientBrush.Opacity);

            return(compositionBrush);
        }
        protected override void OnConnected()
        {
            var compositor = Window.Current.Compositor;

            // Assign the gradient brush to the CompositionBrush.
            _gradientBrush   = compositor.CreateLinearGradientBrush();
            CompositionBrush = _gradientBrush;

            // Initially, we set the end point to be (0,0) 'cause we want to animate it at start.
            // If you don't want this behavior, simply set it to a different value within (1,1).
            _gradientBrush.EndPoint = Vector2.Zero;

            // Create gradient initial colors.
            var gradientStop1 = compositor.CreateColorGradientStop();

            gradientStop1.Offset = 0.0f;
            gradientStop1.Color  = GradientStop1StartColor;
            var gradientStop2 = compositor.CreateColorGradientStop();

            gradientStop2.Offset = 1.0f;
            gradientStop2.Color  = GradientStop2StartColor;
            _gradientBrush.ColorStops.Add(gradientStop1);
            _gradientBrush.ColorStops.Add(gradientStop2);

            Window.Current.SizeChanged += OnWindowSizeChanged;

            // There are 3 animations going on here:
            //
            // First, we kick off an EndPoint offset animation to smoothly transition a
            // solid background to a gradient.
            //
            // Once it's finished, we then kick off TWO other animations simultaneously.
            // These TWO animations include a set of gradient stop color animations and
            // a rotation animation that rotates the gradient brush.

            var linearEase = compositor.CreateLinearEasingFunction();
            var batch      = compositor.CreateScopedBatch(CompositionBatchTypes.Animation);

            batch.Completed += (s, e) =>
            {
                StartGradientColorAnimations();
                StartGradientRotationAnimation();
            };
            var endPointOffsetAnimation = compositor.CreateVector2KeyFrameAnimation();

            endPointOffsetAnimation.Duration = TimeSpan.FromSeconds(3);
            endPointOffsetAnimation.InsertKeyFrame(1.0f, Vector2.One);
            _gradientBrush.StartAnimation(nameof(_gradientBrush.EndPoint), endPointOffsetAnimation);
            batch.End();

            void StartGradientColorAnimations()
            {
                var color1Animation = compositor.CreateColorKeyFrameAnimation();

                color1Animation.Duration          = TimeSpan.FromSeconds(10);
                color1Animation.IterationBehavior = AnimationIterationBehavior.Forever;
                color1Animation.Direction         = AnimationDirection.Alternate;
                color1Animation.InsertKeyFrame(0.0f, GradientStop1StartColor, linearEase);
                color1Animation.InsertKeyFrame(0.5f, Color.FromArgb(255, 65, 88, 208), linearEase);
                color1Animation.InsertKeyFrame(1.0f, Color.FromArgb(255, 43, 210, 255), linearEase);
                gradientStop1.StartAnimation(nameof(gradientStop1.Color), color1Animation);

                var color2Animation = compositor.CreateColorKeyFrameAnimation();

                color2Animation.Duration          = TimeSpan.FromSeconds(10);
                color2Animation.IterationBehavior = AnimationIterationBehavior.Forever;
                color2Animation.Direction         = AnimationDirection.Alternate;
                color2Animation.InsertKeyFrame(0.0f, GradientStop2StartColor, linearEase);
                color1Animation.InsertKeyFrame(0.5f, Color.FromArgb(255, 200, 80, 192), linearEase);
                color2Animation.InsertKeyFrame(1.0f, Color.FromArgb(255, 43, 255, 136), linearEase);
                gradientStop2.StartAnimation(nameof(gradientStop2.Color), color2Animation);
            }

            void StartGradientRotationAnimation()
            {
                var rotationAnimation = compositor.CreateScalarKeyFrameAnimation();

                rotationAnimation.Duration          = TimeSpan.FromSeconds(15);
                rotationAnimation.IterationBehavior = AnimationIterationBehavior.Forever;
                rotationAnimation.InsertKeyFrame(1.0f, 360.0f, linearEase);
                _gradientBrush.StartAnimation(nameof(_gradientBrush.RotationAngleInDegrees), rotationAnimation);
            }
        }
示例#8
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            _compositor = ElementCompositionPreview.GetElementVisual(this).Compositor;

            // Update Rectangle widths to match text width
            Rectangle1.Width = TextBlock1.ActualWidth;
            Rectangle2.Width = TextBlock2.ActualWidth;
            Rectangle3.Width = TextBlock3.ActualWidth;
            Rectangle4.Width = TextBlock4.ActualWidth;

            // Create the four visuals that will be used to hold the LinearGradient brush
            _vis1 = _compositor.CreateSpriteVisual();
            _vis2 = _compositor.CreateSpriteVisual();
            _vis3 = _compositor.CreateSpriteVisual();
            _vis4 = _compositor.CreateSpriteVisual();

            // Create the linearGradient brush and set the first set of colors to the gradientStops of the Brush
            _linearGradientBrush  = _compositor.CreateLinearGradientBrush();
            _gradientStop1        = _compositor.CreateColorGradientStop();
            _gradientStop1.Offset = 0;
            _gradientStop1.Color  = warmColor1;
            _gradientStop2        = _compositor.CreateColorGradientStop();
            _gradientStop2.Offset = 1;
            _gradientStop2.Color  = warmColor2;
            _linearGradientBrush.ColorStops.Add(_gradientStop1);
            _linearGradientBrush.ColorStops.Add(_gradientStop2);

            // Paint visuals with brushes and set their locations
            _vis1.Brush = _linearGradientBrush;
            _vis1.Scale = new Vector3(0, 1, 0);
            _vis1.Size  = new Vector2((float)Rectangle1.ActualWidth, (float)Rectangle1.ActualHeight);

            _vis2.Brush = _linearGradientBrush;
            _vis2.Scale = new Vector3(0, 1, 0);
            _vis2.Size  = new Vector2((float)Rectangle2.ActualWidth, (float)Rectangle2.ActualHeight);

            _vis3.Brush = _linearGradientBrush;
            _vis3.Scale = new Vector3(0, 1, 0);
            _vis3.Size  = new Vector2((float)Rectangle3.ActualWidth, (float)Rectangle3.ActualHeight);

            _vis4.Brush = _linearGradientBrush;
            _vis4.Scale = new Vector3(0, 1, 0);
            _vis4.Size  = new Vector2((float)Rectangle4.ActualWidth, (float)Rectangle4.ActualHeight);

            // Parent visuals to XAML rectangles
            ElementCompositionPreview.SetElementChildVisual(Rectangle1, _vis1);
            ElementCompositionPreview.SetElementChildVisual(Rectangle2, _vis2);
            ElementCompositionPreview.SetElementChildVisual(Rectangle3, _vis3);
            ElementCompositionPreview.SetElementChildVisual(Rectangle4, _vis4);

            //create the scale & offset animation

            Vector3KeyFrameAnimation offsetAnim_r1 = _compositor.CreateVector3KeyFrameAnimation();

            offsetAnim_r1.InsertKeyFrame(1, new Vector3((float)Rectangle1.ActualWidth, (float)Rectangle1.ActualHeight, 0));
            offsetAnim_r1.Duration = TimeSpan.FromSeconds(6);

            // Instantiate animation
            //TODO update to animate gradient stops instaed of scale
            _scaleAnim = _compositor.CreateVector3KeyFrameAnimation();
            _scaleAnim.InsertKeyFrame(0, new Vector3(0, 1, 0));
            _scaleAnim.InsertKeyFrame(.5f, new Vector3(1, 1, 0));
            _scaleAnim.InsertKeyFrame(1, new Vector3(0, 1, 0));
            _scaleAnim.Duration = TimeSpan.FromSeconds(2);

            // animation of color stops
            _colorAnimGradientStop1 = _compositor.CreateColorKeyFrameAnimation();
            _colorAnimGradientStop1.InsertKeyFrame(.5f, Colors.Honeydew);
            _colorAnimGradientStop1.Duration = TimeSpan.FromSeconds(4);

            _colorAnimGradientStop2 = _compositor.CreateColorKeyFrameAnimation();
            _colorAnimGradientStop2.InsertKeyFrame(.5f, Colors.DeepPink);
            _colorAnimGradientStop2.Duration = TimeSpan.FromSeconds(4);

            _offsetAnim          = _compositor.CreateScalarKeyFrameAnimation();
            _offsetAnim.Duration = TimeSpan.FromSeconds(1);

            // when the buttons of text are pressed, the brush will change colors. Below is the set up for animation
            _changeb1stop1 = _compositor.CreateColorKeyFrameAnimation();
            _changeb1stop1.InsertKeyFrame(.5f, Colors.LightSkyBlue);
            _changeb1stop1.Duration = TimeSpan.FromSeconds(2);

            _changeb1stop2 = _compositor.CreateColorKeyFrameAnimation();
            _changeb1stop2.InsertKeyFrame(.5f, Colors.Teal);
            _changeb1stop2.Duration = TimeSpan.FromSeconds(2);
        }
        public MainPage()
        {
            InitializeComponent();

            var compositor = Window.Current.Compositor;

            _gradientBrush1            = compositor.CreateLinearGradientBrush();
            _gradientBrush1.StartPoint = new Vector2(1.0f);
            _gradientBrush1.EndPoint   = Vector2.Zero;

            var gradientStop1 = compositor.CreateColorGradientStop();

            gradientStop1.Offset = 0.5f;
            gradientStop1.Color  = GradientStop1StartColor;
            var gradientStop2 = compositor.CreateColorGradientStop();

            gradientStop2.Offset = 0.5f;
            gradientStop2.Color  = GradientStop2StartColor;
            _gradientBrush1.ColorStops.Add(gradientStop1);
            _gradientBrush1.ColorStops.Add(gradientStop2);

            _gradientBrush2            = compositor.CreateLinearGradientBrush();
            _gradientBrush2.StartPoint = new Vector2(1.0f, 0);
            _gradientBrush2.EndPoint   = new Vector2(0, 1.0f);

            var gradientStop3 = compositor.CreateColorGradientStop();

            gradientStop3.Offset = 0.25f;
            gradientStop3.Color  = GradientStop4StartColor;
            var gradientStop4 = compositor.CreateColorGradientStop();

            gradientStop4.Offset = 1.0f;
            gradientStop4.Color  = GradientStop4StartColor;
            _gradientBrush2.ColorStops.Add(gradientStop3);
            _gradientBrush2.ColorStops.Add(gradientStop4);

            var graphicsEffect = new BlendEffect()
            {
                Mode       = BlendEffectMode.Screen,
                Foreground = new CompositionEffectSourceParameter("Main"),
                Background = new CompositionEffectSourceParameter("Tint"),
            };

            var effectFactory = compositor.CreateEffectFactory(graphicsEffect);
            var brush         = effectFactory.CreateBrush();

            brush.SetSourceParameter("Main", _gradientBrush1);
            brush.SetSourceParameter("Tint", _gradientBrush2);

            _backgroundVisual       = compositor.CreateSpriteVisual();
            _backgroundVisual.Brush = brush;
            ElementCompositionPreview.SetElementChildVisual(Gradient, _backgroundVisual);



            var gradientStop1OffsetAnimation = compositor.CreateScalarKeyFrameAnimation();

            gradientStop1OffsetAnimation.Duration  = TimeSpan.FromSeconds(1);
            gradientStop1OffsetAnimation.DelayTime = TimeSpan.FromSeconds(2);
            gradientStop1OffsetAnimation.InsertKeyFrame(1.0f, 0.25f);
            gradientStop1.StartAnimation(nameof(gradientStop1.Offset), gradientStop1OffsetAnimation);

            var gradientStop2OffsetAnimation = compositor.CreateScalarKeyFrameAnimation();

            gradientStop2OffsetAnimation.Duration  = TimeSpan.FromSeconds(1);
            gradientStop2OffsetAnimation.DelayTime = TimeSpan.FromSeconds(2);
            gradientStop2OffsetAnimation.InsertKeyFrame(1.0f, 1.0f);
            gradientStop2.StartAnimation(nameof(gradientStop1.Offset), gradientStop2OffsetAnimation);

            var gradientStop3Animation = compositor.CreateColorKeyFrameAnimation();

            gradientStop3Animation.Duration  = TimeSpan.FromSeconds(2);
            gradientStop3Animation.DelayTime = TimeSpan.FromSeconds(2);
            gradientStop3Animation.Direction = AnimationDirection.Alternate;
            gradientStop3Animation.InsertKeyFrame(1.0f, GradientStop3StartColor);
            gradientStop3.StartAnimation(nameof(gradientStop1.Color), gradientStop3Animation);

            Loaded += async(s, e) =>
            {
                await Task.Yield();

                LeftText.Visibility   = Visibility.Collapsed;
                RightText.Visibility  = Visibility.Collapsed;
                MiddleText.Visibility = Visibility.Visible;
            };

            Gradient.SizeChanged += (s, e) =>
            {
                if (e.NewSize == e.PreviousSize)
                {
                    return;
                }

                _backgroundVisual.Size      = e.NewSize.ToVector2();
                _gradientBrush1.CenterPoint = _backgroundVisual.Size / 2;
                _gradientBrush2.CenterPoint = _backgroundVisual.Size / 2;
            };
        }
示例#10
0
        public GlowPanel2() : base()
        {
            this.DefaultStyleKey = typeof(GlowPanel2);
            _compositor          = ElementCompositionPreview.GetElementVisual(this).Compositor;
            _maskBrush           = _compositor.CreateMaskBrush();
            Visual.Brush         = _maskBrush;

            _foregroundBrush            = _compositor.CreateLinearGradientBrush();
            _foregroundBrush.StartPoint = Vector2.Zero;
            _foregroundBrush.EndPoint   = new Vector2(1.0f);

            _bottomRightGradientStop        = _compositor.CreateColorGradientStop();
            _bottomRightGradientStop.Offset = 0.5f;
            _bottomRightGradientStop.Color  = Green;
            _topLeftradientStop             = _compositor.CreateColorGradientStop();
            _topLeftradientStop.Offset      = 0.5f;
            _topLeftradientStop.Color       = Blue;
            _foregroundBrush.ColorStops.Add(_bottomRightGradientStop);
            _foregroundBrush.ColorStops.Add(_topLeftradientStop);


            _backgroundBrush            = _compositor.CreateLinearGradientBrush();
            _backgroundBrush.StartPoint = new Vector2(1.0f, 0);
            _backgroundBrush.EndPoint   = new Vector2(0, 1.0f);

            _topRightGradientStop          = _compositor.CreateColorGradientStop();
            _topRightGradientStop.Offset   = 0.25f;
            _topRightGradientStop.Color    = Black;
            _bottomLeftGradientStop        = _compositor.CreateColorGradientStop();
            _bottomLeftGradientStop.Offset = 1.0f;
            _bottomLeftGradientStop.Color  = Black;
            _backgroundBrush.ColorStops.Add(_topRightGradientStop);
            _backgroundBrush.ColorStops.Add(_bottomLeftGradientStop);


            var graphicsEffect = new BlendEffect()
            {
                Mode       = BlendEffectMode.Screen,
                Foreground = new CompositionEffectSourceParameter("Main"),
                Background = new CompositionEffectSourceParameter("Tint"),
            };

            var effectFactory = _compositor.CreateEffectFactory(graphicsEffect);
            var brush         = effectFactory.CreateBrush();

            brush.SetSourceParameter("Main", _foregroundBrush);
            brush.SetSourceParameter("Tint", _backgroundBrush);


            //    GaussianBlurEffect blurEffect = new GaussianBlurEffect()
            //    {
            //        Name = "Blur",
            //        BlurAmount = 1.0f,
            //        BorderMode = EffectBorderMode.Hard,
            //        Source = new CompositionEffectSourceParameter("source");
            //};

            //CompositionEffectFactory blurEffectFactory = _compositor.CreateEffectFactory(blurEffect);
            //CompositionEffectBrush _backdropBrush = blurEffectFactory.CreateBrush();

            //// Create a BackdropBrush and bind it to the EffectSourceParameter source

            //_backdropBrush.SetSourceParameter("source", _compositor.CreateBackdropBrush());

            _maskBrush.Source = brush;


            Loaded += async(s, e) =>
            {
                UpdateGradients();
                await Task.Delay(2000);
            };
        }
        public GradientsWithBlend() : base()
        {
            InitializeComponent();

            _compositor = Window.Current.Compositor;

            _foregroundBrush            = _compositor.CreateLinearGradientBrush();
            _foregroundBrush.StartPoint = Vector2.Zero;
            _foregroundBrush.EndPoint   = new Vector2(1.0f);

            _bottomRightGradientStop        = _compositor.CreateColorGradientStop();
            _bottomRightGradientStop.Offset = 0.5f;
            _bottomRightGradientStop.Color  = Green;
            _topLeftradientStop             = _compositor.CreateColorGradientStop();
            _topLeftradientStop.Offset      = 0.5f;
            _topLeftradientStop.Color       = Blue;
            _foregroundBrush.ColorStops.Add(_bottomRightGradientStop);
            _foregroundBrush.ColorStops.Add(_topLeftradientStop);


            _backgroundBrush            = _compositor.CreateLinearGradientBrush();
            _backgroundBrush.StartPoint = new Vector2(1.0f, 0);
            _backgroundBrush.EndPoint   = new Vector2(0, 1.0f);

            _topRightGradientStop          = _compositor.CreateColorGradientStop();
            _topRightGradientStop.Offset   = 0.25f;
            _topRightGradientStop.Color    = Black;
            _bottomLeftGradientStop        = _compositor.CreateColorGradientStop();
            _bottomLeftGradientStop.Offset = 1.0f;
            _bottomLeftGradientStop.Color  = Black;
            _backgroundBrush.ColorStops.Add(_topRightGradientStop);
            _backgroundBrush.ColorStops.Add(_bottomLeftGradientStop);


            var graphicsEffect = new BlendEffect()
            {
                Mode       = BlendEffectMode.Screen,
                Foreground = new CompositionEffectSourceParameter("Main"),
                Background = new CompositionEffectSourceParameter("Tint"),
            };

            var effectFactory = _compositor.CreateEffectFactory(graphicsEffect);
            var brush         = effectFactory.CreateBrush();

            brush.SetSourceParameter("Main", _foregroundBrush);
            brush.SetSourceParameter("Tint", _backgroundBrush);

            _backgroundVisual       = _compositor.CreateSpriteVisual();
            _backgroundVisual.Brush = brush;


            ElementCompositionPreview.SetElementChildVisual(Gradient, _backgroundVisual);



            //var leftToRightAnimation = _compositor.CreateScalarKeyFrameAnimation();
            //leftToRightAnimation.Duration = TimeSpan.FromSeconds(2);
            //leftToRightAnimation.DelayTime = TimeSpan.FromSeconds(1);
            //leftToRightAnimation.InsertKeyFrame(1.0f, 1.0f);
            //_bottomRightGradientStop.StartAnimation(nameof(_bottomRightGradientStop.Offset), leftToRightAnimation);



            Loaded += async(s, e) =>
            {
                await Task.Delay(2000);

                UpdateGradients();
                MiddleText.Visibility = Visibility.Collapsed;
                await Task.Delay(2000);

                UpdateText();
                ButtonRoot.Visibility = Visibility.Visible;
            };

            Gradient.SizeChanged += (s, e) =>
            {
                if (e.NewSize == e.PreviousSize)
                {
                    return;
                }

                _backgroundVisual.Size       = e.NewSize.ToVector2();
                _foregroundBrush.CenterPoint = _backgroundVisual.Size / 2;
                _backgroundBrush.CenterPoint = _backgroundVisual.Size / 2;
            };

            ViewModel.IsInPomodoroChanged += (s, e) =>
            {
                UpdateGradients();
                UpdateText();
            };
        }
        public ExtendSplash(SplashScreen splashscreen)
        {
            //Splash Related
            splash = splashscreen;
            if (splash != null)
            {
                // Register an event handler to be executed when the splash screen has been dismissed.
                splash.Dismissed += new TypedEventHandler <SplashScreen, Object>(DismissedEventHandler);
            }

            this.InitializeComponent();

            //Animation Backgroud
            var compositor = Window.Current.Compositor;

            //Created default background
            _gradientBrush1            = compositor.CreateLinearGradientBrush();
            _gradientBrush1.StartPoint = new Vector2(1, 1);
            _gradientBrush1.EndPoint   = Vector2.Zero;

            var gradientStop1 = compositor.CreateColorGradientStop();

            gradientStop1.Offset = 0.5f;
            gradientStop1.Color  = GradientStop1StartColor;

            var gradientStop2 = compositor.CreateColorGradientStop();

            gradientStop2.Offset = 0.5f;
            gradientStop2.Color  = GradientStop2StartColor;
            _gradientBrush1.ColorStops.Add(gradientStop1);
            _gradientBrush1.ColorStops.Add(gradientStop2);

            _gradientBrush2            = compositor.CreateLinearGradientBrush();
            _gradientBrush2.StartPoint = new Vector2(1.0f, 0);
            _gradientBrush2.EndPoint   = new Vector2(0, 1.0f);

            var gradientStop3 = compositor.CreateColorGradientStop();

            gradientStop3.Offset = 0.25f;
            gradientStop3.Color  = GradientStop4StartColor;
            var gradientStop4 = compositor.CreateColorGradientStop();

            gradientStop4.Offset = 1.0f;
            gradientStop4.Color  = GradientStop4StartColor;
            _gradientBrush2.ColorStops.Add(gradientStop3);
            _gradientBrush2.ColorStops.Add(gradientStop4);

            var graphicsEffect = new BlendEffect()
            {
                Mode       = BlendEffectMode.Screen,
                Foreground = new CompositionEffectSourceParameter("Main"),
                Background = new CompositionEffectSourceParameter("Tint"),
            };

            var effectFactory = compositor.CreateEffectFactory(graphicsEffect);
            var brush         = effectFactory.CreateBrush();

            brush.SetSourceParameter("Main", _gradientBrush1);
            brush.SetSourceParameter("Tint", _gradientBrush2);

            _backgroundVisual       = compositor.CreateSpriteVisual();
            _backgroundVisual.Brush = brush;
            ElementCompositionPreview.SetElementChildVisual(Gradient, _backgroundVisual);

            var gradientStop1OffsetAnimation = compositor.CreateScalarKeyFrameAnimation();

            gradientStop1OffsetAnimation.Duration  = TimeSpan.FromSeconds(1);
            gradientStop1OffsetAnimation.DelayTime = TimeSpan.FromSeconds(1);
            gradientStop1OffsetAnimation.InsertKeyFrame(1.0f, 0.25f);
            gradientStop1.StartAnimation(nameof(gradientStop1.Offset), gradientStop1OffsetAnimation);

            var gradientStop2OffsetAnimation = compositor.CreateScalarKeyFrameAnimation();

            gradientStop2OffsetAnimation.Duration  = TimeSpan.FromSeconds(1);
            gradientStop2OffsetAnimation.DelayTime = TimeSpan.FromSeconds(1);
            gradientStop2OffsetAnimation.InsertKeyFrame(1.0f, 1.0f);
            gradientStop2.StartAnimation(nameof(gradientStop1.Offset), gradientStop2OffsetAnimation);


            var gradientStop3Animation = compositor.CreateColorKeyFrameAnimation();

            gradientStop3Animation.Duration  = TimeSpan.FromSeconds(1.5);
            gradientStop3Animation.DelayTime = TimeSpan.FromSeconds(2);
            gradientStop3Animation.Direction = Windows.UI.Composition.AnimationDirection.Alternate;
            gradientStop3Animation.InsertKeyFrame(1.0f, GradientStop3StartColor);
            gradientStop3.StartAnimation(nameof(gradientStop1.Color), gradientStop3Animation);

            Loaded += async(s, e) =>
            {
                await Task.Yield();

                MidText.Visibility = Visibility.Collapsed;
            };

            Gradient.SizeChanged += (s, e) =>
            {
                if (e.NewSize == e.PreviousSize)
                {
                    return;
                }

                _backgroundVisual.Size      = e.NewSize.ToVector2();
                _gradientBrush1.CenterPoint = _backgroundVisual.Size / 2;
                _gradientBrush2.CenterPoint = _backgroundVisual.Size / 2;
            };
        }