csharpc-sharpdotnetxamlavaloniauicross-platformcross-platform-xamlavaloniaguimulti-platformuser-interfacedotnetcore
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.6 KiB
57 lines
1.6 KiB
using System;
|
|
using Avalonia.Platform;
|
|
|
|
namespace Avalonia.Media
|
|
{
|
|
/// <summary>
|
|
/// Represents the geometry of a rectangle.
|
|
/// </summary>
|
|
public class RectangleGeometry : Geometry
|
|
{
|
|
/// <summary>
|
|
/// Defines the <see cref="Rect"/> property.
|
|
/// </summary>
|
|
public static readonly StyledProperty<Rect> RectProperty =
|
|
AvaloniaProperty.Register<RectangleGeometry, Rect>(nameof(Rect));
|
|
|
|
static RectangleGeometry()
|
|
{
|
|
AffectsGeometry(RectProperty);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="RectangleGeometry"/> class.
|
|
/// </summary>
|
|
public RectangleGeometry()
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="RectangleGeometry"/> class.
|
|
/// </summary>
|
|
/// <param name="rect">The rectangle bounds.</param>
|
|
public RectangleGeometry(Rect rect)
|
|
{
|
|
Rect = rect;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets the bounds of the rectangle.
|
|
/// </summary>
|
|
public Rect Rect
|
|
{
|
|
get => GetValue(RectProperty);
|
|
set => SetValue(RectProperty, value);
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public override Geometry Clone() => new RectangleGeometry(Rect);
|
|
|
|
private protected sealed override IGeometryImpl? CreateDefiningGeometry()
|
|
{
|
|
var factory = AvaloniaLocator.Current.GetRequiredService<IPlatformRenderInterface>();
|
|
|
|
return factory.CreateRectangleGeometry(Rect);
|
|
}
|
|
}
|
|
}
|
|
|