Esempio n. 1
0
        public void SetBorderBrush(RadialGradientPaint radialGradientPaint)
        {
            _strokeColor = null;
            _stroke      = radialGradientPaint;

            SetNeedsDisplay();
        }
Esempio n. 2
0
 public void SetBackground(Paint?paint)
 {
     if (paint is SolidPaint solidPaint)
     {
         SetBackground(solidPaint);
     }
     else if (paint is LinearGradientPaint linearGradientPaint)
     {
         SetBackground(linearGradientPaint);
     }
     else if (paint is RadialGradientPaint radialGradientPaint)
     {
         SetBackground(radialGradientPaint);
     }
     else if (paint is ImagePaint imagePaint)
     {
         SetBackground(imagePaint);
     }
     else if (paint is PatternPaint patternPaint)
     {
         SetBackground(patternPaint);
     }
     else
     {
         SetDefaultBackgroundColor();
     }
 }
 public DrawTextBlobCanvasCommand(TextBlob textBlob, float x, float y, Paint paint)
 {
     TextBlob = textBlob;
     X        = x;
     Y        = y;
     Paint    = paint;
 }
Esempio n. 4
0
        public void SetBorderBrush(LinearGradientPaint linearGradientPaint)
        {
            _strokeColor = null;
            _stroke      = linearGradientPaint;

            SetNeedsDisplay();
        }
Esempio n. 5
0
        public void SetBackground(RadialGradientPaint radialGradientPaint)
        {
            _backgroundColor = null;
            _background      = radialGradientPaint;

            SetNeedsDisplay();
        }
Esempio n. 6
0
        public void SetBorderBrush(Paint?paint)
        {
            if (paint is SolidPaint solidPaint)
            {
                SetBorderBrush(solidPaint);
            }

            if (paint is LinearGradientPaint linearGradientPaint)
            {
                SetBorderBrush(linearGradientPaint);
            }

            if (paint is RadialGradientPaint radialGradientPaint)
            {
                SetBorderBrush(radialGradientPaint);
            }

            if (paint is ImagePaint imagePaint)
            {
                SetBorderBrush(imagePaint);
            }

            if (paint is PatternPaint patternPaint)
            {
                SetBorderBrush(patternPaint);
            }
        }
Esempio n. 7
0
        public void SetBackground(LinearGradientPaint linearGradientPaint)
        {
            _backgroundColor = null;
            _background      = linearGradientPaint;

            SetNeedsDisplay();
        }
 public DrawTextCanvasCommand(string text, float x, float y, Paint paint)
 {
     Text  = text;
     X     = x;
     Y     = y;
     Paint = paint;
 }
Esempio n. 9
0
 public DrawImageCanvasCommand(Image image, Rect source, Rect dest, Paint?paint = null)
 {
     Image  = image;
     Source = source;
     Dest   = dest;
     Paint  = paint;
 }
Esempio n. 10
0
 public DrawTextOnPathCanvasCommand(string text, Path path, float hOffset, float vOffset, Paint paint)
 {
     Text    = text;
     Path    = path;
     HOffset = hOffset;
     VOffset = vOffset;
     Paint   = paint;
 }
Esempio n. 11
0
 void UpdateDrawableCanvas(Paint?paint)
 {
     if (_drawableCanvas.IsValueCreated || paint is not null)
     {
         ((MauiDrawable)_drawableCanvas.Value.Drawable).Background = paint;
         _drawableCanvas.Value.Invalidate();
     }
 }
Esempio n. 12
0
        public static void UpdateStroke(this Path borderPath, Paint?borderBrush)
        {
            if (borderPath == null)
            {
                return;
            }

            borderPath.Stroke = borderBrush?.ToPlatform();
        }
Esempio n. 13
0
        public void UpdateBackground(Paint?background)
        {
            if (_borderPath == null)
            {
                return;
            }

            _borderPath.UpdateBackground(background);
        }
Esempio n. 14
0
        public static void UpdateBackground(this Path borderPath, Paint?background)
        {
            if (borderPath == null)
            {
                return;
            }

            borderPath.Fill = background?.ToPlatform();
        }
Esempio n. 15
0
        public void UpdateBackground(Paint?background)
        {
            if (_borderPath == null)
            {
                return;
            }

            _borderPath.Fill = background?.ToPlatform();
        }
Esempio n. 16
0
        public void SetBorderBrush(SolidPaint solidPaint)
        {
            _strokeColor = solidPaint.Color == null
                                ? UIColor.Clear
                                : solidPaint.Color.ToNative();

            _stroke = null;

            SetNeedsDisplay();
        }
Esempio n. 17
0
		public void SetBackground(SolidPaint solidPaint)
		{
			if (solidPaint.Color == null)
				SetDefaultBackgroundColor();
			else
				_backgroundColor = solidPaint.Color.ToPlatform();

			_background = null;

			SetNeedsDisplay();
		}
Esempio n. 18
0
        public void SetBackground(SolidPaint solidPaint)
        {
            if (solidPaint.Color == null)
            {
                SetDefaultBackgroundColor();
            }
            else
            {
                _backgroundColor = solidPaint.Color.ToNative();
            }

            _background = null;

            SetNeedsDisplay();
        }
Esempio n. 19
0
        public static void UpdateBackground(this UIView platformView, Paint?paint, IButtonStroke?stroke = null)
        {
            // Remove previous background gradient layer if any
            platformView.RemoveBackgroundLayer();

            if (paint.IsNullOrEmpty())
            {
                if (platformView is LayoutView)
                {
                    platformView.BackgroundColor = null;
                }
                else
                {
                    return;
                }
            }


            if (paint is SolidPaint solidPaint)
            {
                Color backgroundColor = solidPaint.Color;

                if (backgroundColor == null)
                {
                    platformView.BackgroundColor = ColorExtensions.BackgroundColor;
                }
                else
                {
                    platformView.BackgroundColor = backgroundColor.ToPlatform();
                }

                return;
            }
            else if (paint is GradientPaint gradientPaint)
            {
                var backgroundLayer = gradientPaint?.ToCALayer(platformView.Bounds);

                if (backgroundLayer != null)
                {
                    backgroundLayer.Name         = BackgroundLayerName;
                    platformView.BackgroundColor = UIColor.Clear;

                    backgroundLayer.UpdateLayerBorder(stroke);

                    platformView.InsertBackgroundLayer(backgroundLayer, 0);
                }
            }
        }
Esempio n. 20
0
        public static Color?ToColor(this Paint?paint)
        {
            if (paint is SolidPaint solidPaint)
            {
                return(solidPaint.Color);
            }

            if (paint is GradientPaint gradientPaint)
            {
                return(gradientPaint.GradientStops?[0]?.Color);
            }

            if (paint is ImagePaint)
            {
                return(null);
            }

            if (paint is PatternPaint)
            {
                return(null);
            }

            return(null);
        }
Esempio n. 21
0
        public static bool IsNullOrEmpty(this Paint?paint)
        {
            if (paint is SolidPaint solidPaint)
            {
                return(solidPaint == null || solidPaint.Color == null);
            }

            if (paint is GradientPaint gradientPaint)
            {
                return(gradientPaint == null || gradientPaint.GradientStops.Length == 0);
            }

            if (paint is ImagePaint imagePaint)
            {
                return(imagePaint == null || imagePaint.Image == null);
            }

            if (paint is PatternPaint patternPaint)
            {
                return(patternPaint == null || patternPaint.Pattern == null);
            }

            return(paint == null);
        }
Esempio n. 22
0
 public static void UpdateBackground(this Panel nativeControl, Paint?paint, UI.Xaml.Media.Brush?defaultBrush = null) =>
 nativeControl.UpdateProperty(Panel.BackgroundProperty, paint.IsNullOrEmpty() ? defaultBrush : paint?.ToNative());
Esempio n. 23
0
 public void DrawImage(Image image, Rect source, Rect dest, Paint?paint = null)
 {
     Commands?.Add(new DrawImageCanvasCommand(image, source, dest, paint));
 }
Esempio n. 24
0
 public static void UpdateBackground(this Border platformControl, Paint?paint, UI.Xaml.Media.Brush?defaultBrush = null) =>
 platformControl.UpdateProperty(Border.BackgroundProperty, paint.IsNullOrEmpty() ? defaultBrush : paint?.ToPlatform());
Esempio n. 25
0
        public static void UpdateTopNavigationViewItemBackgroundSelectedColor(this MauiNavigationView navigationView, Paint?paint)
        {
            var brush = paint?.ToPlatform();

            if (navigationView.TopNavArea != null)
            {
                if (brush is null)
                {
                    navigationView.TopNavArea.Resources.Remove("TopNavigationViewItemBackgroundSelected");
                    navigationView.TopNavArea.Resources.Remove("TopNavigationViewItemBackgroundSelectedPointerOver");
                    navigationView.TopNavArea.Resources.Remove("TopNavigationViewItemBackgroundSelectedPressed");
                }
                else
                {
                    navigationView.TopNavArea.Resources["TopNavigationViewItemBackgroundSelected"]            = brush;
                    navigationView.TopNavArea.Resources["TopNavigationViewItemBackgroundSelectedPointerOver"] = brush;
                    navigationView.TopNavArea.Resources["TopNavigationViewItemBackgroundSelectedPressed"]     = brush;
                }
            }

            if (navigationView.MenuItemsSource is IList <NavigationViewItemViewModel> items)
            {
                foreach (var item in items)
                {
                    item.SelectedBackground = brush;
                }
            }
        }
Esempio n. 26
0
 public static void UpdateTopNavAreaBackground(this MauiNavigationView navigationView, Paint?paint)
 {
     // Background property is set via {ThemeResource NavigationViewTopPaneBackground} in the Control Template
     // AFAICT you can't modify properties set by ThemeResource at runtime so we have to just update this value directly
     if (paint != null)
     {
         navigationView.TopNavArea?.UpdateBackground(paint, null);
     }
     else if (Application.Current.Resources.TryGetValue("NavigationViewTopPaneBackground", out object value) && value is WBrush brush)
     {
         navigationView.TopNavArea?.UpdateBackground(null, brush);
     }
 }
Esempio n. 27
0
        public static void UpdatePaneBackground(this MauiNavigationView navigationView, Paint?paint)
        {
            var rootSplitView = navigationView.RootSplitView;
            var brush         = paint?.ToPlatform();

            if (brush == null)
            {
                object?color = null;
                if (navigationView.IsPaneOpen)
                {
                    color = navigationView.Resources["NavigationViewExpandedPaneBackground"];
                }
                else
                {
                    color = navigationView.Resources["NavigationViewDefaultPaneBackground"];
                }

                if (rootSplitView != null)
                {
                    if (color is WBrush colorBrush)
                    {
                        rootSplitView.PaneBackground = colorBrush;
                    }
                    else if (color is global::Windows.UI.Color uiColor)
                    {
                        rootSplitView.PaneBackground = new WSolidColorBrush(uiColor);
                    }
                }
            }
            else
            {
                if (rootSplitView != null)
                {
                    rootSplitView.PaneBackground = brush;
                }
            }
        }
Esempio n. 28
0
        // TODO: NET7 should this be public?
        internal static void UpdateBackground(this ShapeableImageView platformButton, IImageButton imageButton)
        {
            Paint?paint = imageButton.Background;

            platformButton.Background = paint?.ToDrawable(platformButton.Context);
        }
Esempio n. 29
0
 public SaveLayerCanvasCommand(int count, Paint paint)
 {
     Count = count;
     Paint = paint;
 }
Esempio n. 30
0
 public DrawPathCanvasCommand(Path path, Paint paint)
 {
     Path  = path;
     Paint = paint;
 }