public OutlinePanel() : base()
 {
     this.DefaultStyleKey = typeof(OutlinePanel);
     _compositor          = ElementCompositionPreview.GetElementVisual(this).Compositor;
     _maskBrush           = _compositor.CreateMaskBrush();
     Visual.Brush         = _maskBrush;
     _maskBrushSource     = _compositor.CreateColorBrush(Color);
 }
Beispiel #2
0
        CompositionColorBrush GetCompositionColorBrush(CompositionColorBrush obj)
        {
            if (GetExisting(obj, out CompositionColorBrush result))
            {
                return(result);
            }

            result = CacheAndInitializeCompositionObject(obj, _c.CreateColorBrush(obj.Color));
            StartAnimationsAndFreeze(obj, result);
            return(result);
        }
        private void SetupScrollbars()
        {
            this.fullLogs.Add("SetupScrollbars");

            hScrollIndicatorVisual = ElementCompositionPreview.GetElementVisual(hScrollIndicator);
            vScrollIndicatorVisual = ElementCompositionPreview.GetElementVisual(vScrollIndicator);
            hScrollBarVisual       = ElementCompositionPreview.GetElementVisual(hScrollBar);
            vScrollBarVisual       = ElementCompositionPreview.GetElementVisual(vScrollBar);

            hScrollIndicatorSpriteVisual = hScrollIndicatorVisual.Compositor.CreateSpriteVisual();
            vScrollIndicatorSpriteVisual = vScrollIndicatorVisual.Compositor.CreateSpriteVisual();

            CompositionColorBrush brush = hScrollIndicatorVisual.Compositor.CreateColorBrush(Colors.Red);

            hScrollIndicatorSpriteVisual.Brush = brush;
            vScrollIndicatorSpriteVisual.Brush = brush;

            ElementCompositionPreview.SetElementChildVisual(hScrollIndicator, hScrollIndicatorSpriteVisual);
            ElementCompositionPreview.SetElementChildVisual(vScrollIndicator, vScrollIndicatorSpriteVisual);

            UpdateScrollbars();

            hIndicatorWidthExpression = hScrollIndicatorVisual.Compositor.CreateExpressionAnimation(
                "Vector2(Max(20.0f, Min(hScrollBarVisual.Size.X , seas.Viewport.X * hScrollBarVisual.Size.X / Max(0.0001f, seas.Extent.X * seas.ZoomFactor))), 30.0f)");
            vIndicatorHeightExpression = vScrollIndicatorVisual.Compositor.CreateExpressionAnimation(
                "Vector2(30.0f, Max(20.0f, Min(vScrollBarVisual.Size.Y, seas.Viewport.Y * vScrollBarVisual.Size.Y / Max(0.0001f, seas.Extent.Y * seas.ZoomFactor))))");
            hIndicatorWidthExpression.SetReferenceParameter("seas", scrollPresenter.ExpressionAnimationSources);
            vIndicatorHeightExpression.SetReferenceParameter("seas", scrollPresenter.ExpressionAnimationSources);
            hIndicatorWidthExpression.SetReferenceParameter("hScrollBarVisual", hScrollBarVisual);
            vIndicatorHeightExpression.SetReferenceParameter("vScrollBarVisual", vScrollBarVisual);
            hIndicatorOffsetExpression = hScrollIndicatorVisual.Compositor.CreateExpressionAnimation(
                "Vector3(" +
                "Max(0.0f, Min(hScrollBarVisual.Size.X - hScrollIndicatorSpriteVisual.Size.X, " +
                "seas.Offset.X * (hScrollBarVisual.Size.X - hScrollIndicatorSpriteVisual.Size.X) / Max(1.0f, (seas.Extent.X * seas.ZoomFactor - seas.Viewport.X))))," +
                "0.0f," +
                "0.0f)");
            vIndicatorOffsetExpression = vScrollIndicatorVisual.Compositor.CreateExpressionAnimation(
                "Vector3(" +
                "0.0f," +
                "Max(0.0f, Min(vScrollBarVisual.Size.Y - vScrollIndicatorSpriteVisual.Size.Y, " +
                "seas.Offset.Y * (vScrollBarVisual.Size.Y - vScrollIndicatorSpriteVisual.Size.Y) / Max(1.0f, (seas.Extent.Y * seas.ZoomFactor - seas.Viewport.Y))))," +
                "0.0f)");
            hIndicatorOffsetExpression.SetReferenceParameter("seas", scrollPresenter.ExpressionAnimationSources);
            vIndicatorOffsetExpression.SetReferenceParameter("seas", scrollPresenter.ExpressionAnimationSources);
            hIndicatorOffsetExpression.SetReferenceParameter("hScrollBarVisual", hScrollBarVisual);
            vIndicatorOffsetExpression.SetReferenceParameter("vScrollBarVisual", vScrollBarVisual);
            hIndicatorOffsetExpression.SetReferenceParameter("hScrollIndicatorSpriteVisual", hScrollIndicatorSpriteVisual);
            vIndicatorOffsetExpression.SetReferenceParameter("vScrollIndicatorSpriteVisual", vScrollIndicatorSpriteVisual);

            hScrollIndicatorSpriteVisual.StartAnimation("Size", hIndicatorWidthExpression);
            vScrollIndicatorSpriteVisual.StartAnimation("Size", vIndicatorHeightExpression);
            hScrollIndicatorVisual.StartAnimation("Offset", hIndicatorOffsetExpression);
            vScrollIndicatorVisual.StartAnimation("Offset", vIndicatorOffsetExpression);
        }
            // Traversal order: 53
            // Layer (Shape): Radial
            // Transforms: Radial
            // Ellipse Path / ShapeGroup: Ellipse A
            // Color bound to theme property value: Foreground
            CompositionColorBrush ThemeColor_Foreground_1()
            {
                var result      = _themeColor_Foreground_1 = _c.CreateColorBrush();
                var propertySet = result.Properties;

                propertySet.InsertScalar("Opacity0", 1);
                _reusableExpressionAnimation.ClearAllParameters();
                _reusableExpressionAnimation.Expression = "ColorRGB(_theme.Foreground.W * my.Opacity0,_theme.Foreground.X,_theme.Foreground.Y,_theme.Foreground.Z)";
                _reusableExpressionAnimation.SetReferenceParameter("my", propertySet);
                _reusableExpressionAnimation.SetReferenceParameter("_theme", _themeProperties);
                result.StartAnimation("Color", _reusableExpressionAnimation);
                StartProgressBoundAnimation(propertySet, "Opacity0", Opacity0ScalarAnimation_1_to_0(), _rootProgress);
                return(result);
            }
Beispiel #5
0
        public SplitTo5View()
        {
            this.InitializeComponent();
            _compositor = Window.Current.Compositor;

            _colorBursh = _compositor.CreateColorBrush(Colors.Black);
            var backgroundVisual = _compositor.CreateSpriteVisual();

            backgroundVisual.Brush = _colorBursh;
            ElementCompositionPreview.SetElementChildVisual(RootBackground, backgroundVisual);

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

                backgroundVisual.Size = e.NewSize.ToVector2();
            };

            ViewModel.IsInPomodoroChanged += (s, e) =>
            {
                UpdateBackground();
                UpdateOffset();
            };

            Loaded += (s, e) =>
            {
                UpdateBackground();
                UpdateOffset();
            };

            _contentAeraVisual = ElementCompositionPreview.GetElementVisual(ContentAera);

            _workVisuals = new List <Visual>();
            _workVisuals.Add(ElementCompositionPreview.GetElementVisual(WorkSection1));
            _workVisuals.Add(ElementCompositionPreview.GetElementVisual(WorkSection2));
            _workVisuals.Add(ElementCompositionPreview.GetElementVisual(WorkSection3));
            _workVisuals.Add(ElementCompositionPreview.GetElementVisual(WorkSection4));
            _workVisuals.Add(ElementCompositionPreview.GetElementVisual(WorkSection5));

            _breakVisuals = new List <Visual>();
            _breakVisuals.Add(ElementCompositionPreview.GetElementVisual(BreakSection5));
            _breakVisuals.Add(ElementCompositionPreview.GetElementVisual(BreakSection4));
            _breakVisuals.Add(ElementCompositionPreview.GetElementVisual(BreakSection3));
            _breakVisuals.Add(ElementCompositionPreview.GetElementVisual(BreakSection2));
            _breakVisuals.Add(ElementCompositionPreview.GetElementVisual(BreakSection1));
        }
        protected override void OnConnected()
        {
            if (CompositionBrush == null)
            {
                IsConnected    = true;
                canvasDevice   = CanvasDevice.GetSharedDevice();
                graphicsDevice = CanvasComposition.CreateCompositionGraphicsDevice(Compositor, canvasDevice);
                surface1       = graphicsDevice.CreateDrawingSurface(
                    new Windows.Foundation.Size(100, 100),
                    Windows.Graphics.DirectX.DirectXPixelFormat.B8G8R8A8UIntNormalized,
                    Windows.Graphics.DirectX.DirectXAlphaMode.Premultiplied);
                surface2 = graphicsDevice.CreateDrawingSurface(
                    new Windows.Foundation.Size(100, 100),
                    Windows.Graphics.DirectX.DirectXPixelFormat.B8G8R8A8UIntNormalized,
                    Windows.Graphics.DirectX.DirectXAlphaMode.Premultiplied);
                surfaceBrush1         = Compositor.CreateSurfaceBrush(surface1);
                surfaceBrush2         = Compositor.CreateSurfaceBrush(surface2);
                surfaceBrush1.Stretch = CompositionStretch.Fill;
                surfaceBrush2.Stretch = CompositionStretch.Fill;

                colorBrush1 = Compositor.CreateColorBrush();
                colorBrush2 = Compositor.CreateColorBrush();

                Source1Animation = Compositor.CreateScalarKeyFrameAnimation();
                Source1Animation.InsertKeyFrame(0f, 1f);
                Source1Animation.InsertKeyFrame(1f, 0f);
                Source1Animation.Duration = Duration;

                Source2Animation = Compositor.CreateScalarKeyFrameAnimation();
                Source2Animation.InsertKeyFrame(0f, 0f);
                Source2Animation.InsertKeyFrame(1f, 1f);
                Source2Animation.Duration = Duration;

                var effect = new ArithmeticCompositeEffect()
                {
                    Name           = "effect",
                    Source1        = new CompositionEffectSourceParameter("source1"),
                    Source2        = new CompositionEffectSourceParameter("source2"),
                    Source1Amount  = 1f,
                    Source2Amount  = 0f,
                    MultiplyAmount = 0,
                };
                CompositionBrush = Compositor.CreateEffectFactory(effect, new[] { "effect.Source1Amount", "effect.Source2Amount" }).CreateBrush();
            }
        }
Beispiel #7
0
        public Layer(Compositor compositor, int identifier, Vector3 offset, Vector2 size,
                     ContainerVisual parent, CompositionColorBrush layerColor)
        {
            _compositor     = compositor;
            LayerColor      = layerColor;
            FocusedVisuals  = new List <Visual>();
            ElevatedVisuals = new List <Visual>();

            SpriteVisual x = _compositor.CreateSpriteVisual();

            x.Size     = new Vector2(size.X, size.Y);
            x.Offset   = Offset = offset;
            Identifier = identifier;
            x.Comment  = Identifier.ToString();

            _backingVisual = x;
            parent.Children.InsertAtTop(x);
        }
Beispiel #8
0
        XElement FromCompositionColorBrush(CompositionColorBrush obj)
        {
            return(new XElement(GetCompositionObjectName(obj), GetContents()));

            IEnumerable <XObject> GetContents()
            {
                foreach (var item in GetCompositionObjectContents(obj))
                {
                    yield return(item);
                }

                var color = obj.Color;

                yield return(new XAttribute("Color", $"#{ToHex(color.A)}{ToHex(color.R)}{ToHex(color.G)}{ToHex(color.B)}"));

                string ToHex(byte value) => value.ToString("X2");
            }
        }
Beispiel #9
0
        // Poll for up to 1 sec for underlyig WUC brush to become a CompositionColorBrush using the FallbackColor.
        // This is needed because fallback <-> acrylic changes (and color changes in the fallback brush, if it is in use)
        // are delayed until transition animations are completed.
        // Since XCBB.CompositionBrush is not a DependencyProperty, we can't get a property change notification.
        private async Task PollForFallbackBrush()
        {
            await Task.Run(async() =>
            {
                for (int i = 0; i < 5; i++)
                {
                    bool hasFallbackBrush = false;
                    RunOnUIThread.Execute(() =>
                    {
                        CompositionColorBrush polledBrushAsColorBrush = _acrylicTestApi.CompositionBrush as CompositionColorBrush;
                        hasFallbackBrush = polledBrushAsColorBrush != null && polledBrushAsColorBrush.Color.Equals(_acrylicBrush.FallbackColor);
                    });
                    if (hasFallbackBrush)
                    {
                        break;
                    }

                    await Task.Delay(200);
                }
            });
        }
Beispiel #10
0
        public SpringTextView()
        {
            this.InitializeComponent();
            _compositor = Window.Current.Compositor;
            _colorBursh = _compositor.CreateColorBrush(Colors.Black);
            var backgroundVisual = _compositor.CreateSpriteVisual();

            backgroundVisual.Brush = _colorBursh;
            ElementCompositionPreview.SetElementChildVisual(RootBackground, backgroundVisual);

            _focusVisual = ElementCompositionPreview.GetElementVisual(FocusElement);
            _relaxVisual = ElementCompositionPreview.GetElementVisual(RelaxElement);

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

                backgroundVisual.Size = e.NewSize.ToVector2();
            };

            ContentArea.SizeChanged += (s, e) =>
            {
                UpdateOffset();
            };

            ViewModel.IsInPomodoroChanged += (s, e) =>
            {
                UpdateBackground();
                UpdateOffset();
            };

            Loaded += (s, e) =>
            {
                UpdateBackground();
                UpdateOffset();
            };
        }
Beispiel #11
0
        void DrawShape()
        {
            // handle border shape geometry
            using var geo          = _compositor.CreateRoundedRectangleGeometry();
            geo.Size               = _size;
            geo.CornerRadius       = new Vector2(2);
            _shapecolorbrush       = _compositor.CreateColorBrush(Color.FromArgb(30, 0xff, 0xff, 0xff));
            _spriteShape           = _compositor.CreateSpriteShape(geo);
            _spriteShape.FillBrush = _shapecolorbrush;
            _shape.Shapes.Add(_spriteShape);

            // Handle Visibility on composition
            _visible          = _compositor.CreateColorKeyFrameAnimation();
            _visible.Duration = TimeSpan.FromMilliseconds(75);
            _visible.InsertKeyFrame(0f, Color.FromArgb(30, 0xff, 0xff, 0xff));
            _visible.InsertKeyFrame(0.5f, Color.FromArgb(0x40, 0x40, 0x40, 0x40));
            _visible.InsertKeyFrame(1f, Color.FromArgb(0xcc, 0x26, 0x2a, 0x2f));

            _hidden          = _compositor.CreateColorKeyFrameAnimation();
            _hidden.Duration = TimeSpan.FromMilliseconds(75);
            _hidden.InsertKeyFrame(0f, Color.FromArgb(0xcc, 0x26, 0x2a, 0x2f));
            _hidden.InsertKeyFrame(0.5f, Color.FromArgb(0x40, 0x40, 0x40, 0x40));
            _hidden.InsertKeyFrame(1f, Color.FromArgb(30, 0xff, 0xff, 0xff));
        }
Beispiel #12
0
 CompositionColorBrush ColorBrush_Black()
 {
     return(_colorBrush_Black = _c.CreateColorBrush(Color.FromArgb(0xFF, 0x00, 0x00, 0x00)));
 }
Beispiel #13
0
 CompositionColorBrush ColorBrush_AlmostSkyBlue_FF6ABEE2()
 {
     return(_colorBrush_AlmostSkyBlue_FF6ABEE2 = _c.CreateColorBrush(Color.FromArgb(0xFF, 0x6A, 0xBE, 0xE2)));
 }
 CompositionColorBrush ColorBrush_AlmostLightGray_FFCCCCCC()
 {
     return(_colorBrush_AlmostLightGray_FFCCCCCC = _c.CreateColorBrush(Color.FromArgb(0xFF, 0xCC, 0xCC, 0xCC)));
 }
 CompositionColorBrush ColorBrush_AlmostDodgerBlue_FF2F9DFF()
 {
     return(_colorBrush_AlmostDodgerBlue_FF2F9DFF = _c.CreateColorBrush(Color.FromArgb(0xFF, 0x2F, 0x9D, 0xFF)));
 }
Beispiel #16
0
 CompositionColorBrush ColorBrush_AlmostGoldenrod_FFE4950C()
 {
     return(_colorBrush_AlmostGoldenrod_FFE4950C = _c.CreateColorBrush(Color.FromArgb(0xFF, 0xE4, 0x95, 0x0C)));
 }
 /// <summary>
 /// Create an ExpressionNode reference to this CompositionObject.
 /// </summary>
 /// <param name="compObj">The comp object.</param>
 /// <returns>ColorBrushReferenceNode.</returns>
 public static ColorBrushReferenceNode GetReference(this CompositionColorBrush compObj)
 {
     return(new ColorBrushReferenceNode(null, compObj));
 }
Beispiel #18
0
        public Scrubber()
        {
            this.InitializeComponent();

            // Create the brush used for markers.
            _markerBrush = new SolidColorBrush(GetResourceBrushColor("LottieBasicBrush"));

            // Set our tooltip converter so we are in charge of what is shown on the tooltip.
            _slider.ThumbToolTipValueConverter = new ThumbTooltipConverter(this);

            // Forward the slider change events to any event listeners.
            _slider.ValueChanged += (sender, e) => ValueChanged?.Invoke(this, new ScrubberValueChangedEventArgs(e.OldValue, e.NewValue));

            // Set up the Windows.UI.Composition pieces that will display the parts of the slider.
            // The XAML slider has its parts set to Opacity=0 so they aren't visible and are
            // only used to handle user input.
            var c = Window.Current.Compositor;

            var container = c.CreateContainerVisual();

            // Get the property set. This will be used to animate the trackbar and thumb.
            _properties = container.Properties;

            // Add a property to scale the width of the track and decrease rectangles.
            _properties.InsertScalar("Width", default);

            // Create the brushes and set up expression animations so their colors can
            // be changed by writing to the property set.
            var thumbFillBrush   = CreateBoundColorBrush(_properties, "ThumbFillColor");
            var thumbStrokeBrush = CreateBoundColorBrush(_properties, "ThumbStrokeColor");

            _trackRectangleBrush    = CreateBoundColorBrush(_properties, "TrackColor");
            _decreaseRectangleBrush = CreateBoundColorBrush(_properties, "DecreaseRectangleColor");

            // Create the track rectangle. This is the track that the thumb moves along.
            _trackRectangle       = c.CreateSpriteVisual();
            _trackRectangle.Size  = new Vector2(0, c_trackWidth);
            _trackRectangle.Brush = _trackRectangleBrush;
            container.Children.InsertAtTop(_trackRectangle);

            // Create the decrease rectangle. This is the rectangle that will change in width as the
            // slider position is changed. It shows on the left side of the thumb to indicate how
            // far along the track the position is.
            _decreaseRectangle       = c.CreateSpriteVisual();
            _decreaseRectangle.Size  = new Vector2(0, c_trackWidth);
            _decreaseRectangle.Brush = _decreaseRectangleBrush;
            container.Children.InsertAtTop(_decreaseRectangle);

            // Move the decrease and track rectangles into the track of the slider.
            _trackRectangle.Offset    = new Vector3(9, 15.5F + c_verticalOffset, 0);
            _decreaseRectangle.Offset = new Vector3(9, 15.5F + c_verticalOffset, 0);

            // Create the thumb.
            _thumb = c.CreateShapeVisual();
            var thumbEllipse = c.CreateEllipseGeometry();

            thumbEllipse.Radius = new Vector2(c_thumbRadius);
            thumbEllipse.Center = new Vector2(c_thumbRadius + c_thumbStrokeThickness);

            var thumbShape = c.CreateSpriteShape(thumbEllipse);

            thumbShape.FillBrush       = thumbFillBrush;
            thumbShape.StrokeBrush     = thumbStrokeBrush;
            thumbShape.StrokeThickness = c_thumbStrokeThickness;
            _thumb.Shapes.Add(thumbShape);
            _thumb.Size = new Vector2((c_thumbRadius + c_thumbStrokeThickness) * 2);

            // X value doesn't matter for Offset because it is controlled by an expression animation.
            // The Y value is used to position the thumb vertically so it is centered over the track.
            _thumb.Offset = new Vector3(0, c_thumbRadius + c_verticalOffset - 3.75F, 0);
            container.Children.InsertAtTop(_thumb);

            // Attach our custom-drawn UI as a child visual of the slider.
            ElementCompositionPreview.SetElementChildVisual(_slider, container);

            // Set the initial colors.
            UpdateColors();

            // Intercept keys so we can customize what the keys do.
            ScrubberNavigationKeyHandler.InterceptKeys(this);
        }
Beispiel #19
0
 CompositionColorBrush ColorBrush_Black()
 {
     return(_colorBrush_Black = _c.CreateColorBrush(Color.FromArgb(0xFF, _f.R, _f.G, _f.B)));
 }
 CompositionColorBrush ColorBrush_AlmostCrimson_FFD0021A()
 {
     return(_colorBrush_AlmostCrimson_FFD0021A = _c.CreateColorBrush(Color.FromArgb(0xFF, 0xD0, 0x02, 0x1A)));
 }
Beispiel #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ColorBrushReferenceNode"/> class.
 /// </summary>
 /// <param name="paramName">Name of the parameter.</param>
 /// <param name="brush">The brush.</param>
 internal ColorBrushReferenceNode(string paramName, CompositionColorBrush brush = null)
     : base(paramName, brush)
 {
 }
Beispiel #22
0
 CompositionColorBrush ColorBrush_White()
 {
     return(_colorBrush_White = _c.CreateColorBrush(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF)));
 }
Beispiel #23
0
 CompositionColorBrush ColorBrush_Red()
 {
     //return _colorBrush_Red = _c.CreateColorBrush(Color.FromArgb(0xFF, 0xFF, 0x00, 0x00));
     return(_colorBrush_Red = _c.CreateColorBrush(Color.FromArgb(0xFF, 0x9F, 0x0D, 0x0D)));
 }