using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Primitives; using Avalonia.Media; namespace Ursa.Controls.Shapes; public class PureCircle: Control { public static readonly StyledProperty BackgroundProperty = TemplatedControl.BackgroundProperty.AddOwner(); public IBrush? Background { get => GetValue(BackgroundProperty); set => SetValue(BackgroundProperty, value); } public static readonly StyledProperty DiameterProperty = AvaloniaProperty.Register( nameof(Diameter)); public double Diameter { get => GetValue(DiameterProperty); set => SetValue(DiameterProperty, value); } static PureCircle() { FocusableProperty.OverrideDefaultValue(false); AffectsMeasure(DiameterProperty); AffectsRender(DiameterProperty, BackgroundProperty); } protected override Size MeasureOverride(Size availableSize) { return new Size(Diameter, Diameter); } public override void Render(DrawingContext context) { double value = Diameter / 2; context.DrawEllipse(Background, null, new(value, value), value, value); } }