using System; using Avalonia.Platform; namespace Avalonia.Media { /// /// Represents the geometry of a rectangle. /// public class RectangleGeometry : Geometry { /// /// Defines the property. /// public static readonly StyledProperty RectProperty = AvaloniaProperty.Register(nameof(Rect)); static RectangleGeometry() { AffectsGeometry(RectProperty); } /// /// Initializes a new instance of the class. /// public RectangleGeometry() { } /// /// Initializes a new instance of the class. /// /// The rectangle bounds. public RectangleGeometry(Rect rect) { Rect = rect; } /// /// Gets or sets the bounds of the rectangle. /// public Rect Rect { get => GetValue(RectProperty); set => SetValue(RectProperty, value); } /// public override Geometry Clone() => new RectangleGeometry(Rect); protected override IGeometryImpl? CreateDefiningGeometry() { var factory = AvaloniaLocator.Current.GetRequiredService(); return factory.CreateRectangleGeometry(Rect); } } }