Beispiel #1
0
        /// <summary>
        /// Adds a <see cref="CompositionBrush"/> instance on top of the target <see cref="FrameworkElement"/>
        /// </summary>
        /// <param name="brush">The <see cref="CompositionBrush"/> instance to display</param>
        /// <param name="target">The target <see cref="FrameworkElement"/> that will host the effect</param>
        public static void AttachToElement(this CompositionBrush brush, FrameworkElement target)
        {
            // Add the brush to a sprite and attach it to the target element
            SpriteVisual sprite = Window.Current.Compositor.CreateSpriteVisual();

            sprite.Brush = brush;
            sprite.Size  = new Vector2((float)target.ActualWidth, (float)target.ActualHeight);
            ElementCompositionPreview.SetElementChildVisual(target, sprite);
        }
Beispiel #2
0
 partial void OnBrushChangedPartial(CompositionBrush brush)
 {
     if (brush is CompositionColorBrush b)
     {
         NativeLayer.BackgroundColor = b.Color;
     }
     else
     {
         this.Log().Error($"The brush type {brush?.GetType()} is not supported for sprite visuals.");
     }
 }
Beispiel #3
0
 partial void OnBrushChangedPartial(CompositionBrush brush)
 {
     if (brush is CompositionColorBrush b)
     {
         _paint.Color = new SKColor(b.Color.R, b.Color.G, b.Color.B, b.Color.A);
     }
     else
     {
         this.Log().Error($"The brush type {brush?.GetType()} is not supported for sprite visuals.");
     }
 }
Beispiel #4
0
 partial void OnBrushChangedPartial(CompositionBrush brush);