diff --git a/src/Avalonia.Controls/Shapes/Shape.cs b/src/Avalonia.Controls/Shapes/Shape.cs
index 371b5d92f7..7d1525afc4 100644
--- a/src/Avalonia.Controls/Shapes/Shape.cs
+++ b/src/Avalonia.Controls/Shapes/Shape.cs
@@ -2,38 +2,67 @@ using System;
using Avalonia.Collections;
using Avalonia.Media;
+#nullable enable
+
namespace Avalonia.Controls.Shapes
{
+ ///
+ /// Provides a base class for shape elements, such as , and .
+ ///
public abstract class Shape : Control
{
- public static readonly StyledProperty FillProperty =
- AvaloniaProperty.Register(nameof(Fill));
+ ///
+ /// Defines the property.
+ ///
+ public static readonly StyledProperty FillProperty =
+ AvaloniaProperty.Register(nameof(Fill));
+ ///
+ /// Defines the property.
+ ///
public static readonly StyledProperty StretchProperty =
AvaloniaProperty.Register(nameof(Stretch));
- public static readonly StyledProperty StrokeProperty =
- AvaloniaProperty.Register(nameof(Stroke));
+ ///
+ /// Defines the property.
+ ///
+ public static readonly StyledProperty StrokeProperty =
+ AvaloniaProperty.Register(nameof(Stroke));
- public static readonly StyledProperty> StrokeDashArrayProperty =
- AvaloniaProperty.Register>(nameof(StrokeDashArray));
+ ///
+ /// Defines the property.
+ ///
+ public static readonly StyledProperty?> StrokeDashArrayProperty =
+ AvaloniaProperty.Register?>(nameof(StrokeDashArray));
+ ///
+ /// Defines the property.
+ ///
public static readonly StyledProperty StrokeDashOffsetProperty =
AvaloniaProperty.Register(nameof(StrokeDashOffset));
+ ///
+ /// Defines the property.
+ ///
public static readonly StyledProperty StrokeThicknessProperty =
AvaloniaProperty.Register(nameof(StrokeThickness));
+ ///
+ /// Defines the property.
+ ///
public static readonly StyledProperty StrokeLineCapProperty =
AvaloniaProperty.Register(nameof(StrokeLineCap), PenLineCap.Flat);
+ ///
+ /// Defines the property.
+ ///
public static readonly StyledProperty StrokeJoinProperty =
AvaloniaProperty.Register(nameof(StrokeJoin), PenLineJoin.Miter);
private Matrix _transform = Matrix.Identity;
- private Geometry _definingGeometry;
- private Geometry _renderedGeometry;
- bool _calculateTransformOnArrange = false;
+ private Geometry? _definingGeometry;
+ private Geometry? _renderedGeometry;
+ private bool _calculateTransformOnArrange;
static Shape()
{
@@ -43,7 +72,10 @@ namespace Avalonia.Controls.Shapes
StrokeThicknessProperty, StrokeLineCapProperty, StrokeJoinProperty);
}
- public Geometry DefiningGeometry
+ ///
+ /// Gets a value that represents the of the shape.
+ ///
+ public Geometry? DefiningGeometry
{
get
{
@@ -56,13 +88,10 @@ namespace Avalonia.Controls.Shapes
}
}
- public IBrush Fill
- {
- get { return GetValue(FillProperty); }
- set { SetValue(FillProperty, value); }
- }
-
- public Geometry RenderedGeometry
+ ///
+ /// Gets a value that represents the final rendered of the shape.
+ ///
+ public Geometry? RenderedGeometry
{
get
{
@@ -93,42 +122,72 @@ namespace Avalonia.Controls.Shapes
}
}
+ ///
+ /// Gets or sets the that specifies how the shape's interior is painted.
+ ///
+ public IBrush? Fill
+ {
+ get { return GetValue(FillProperty); }
+ set { SetValue(FillProperty, value); }
+ }
+
+ ///
+ /// Gets or sets a enumeration value that describes how the shape fills its allocated space.
+ ///
public Stretch Stretch
{
get { return GetValue(StretchProperty); }
set { SetValue(StretchProperty, value); }
}
- public IBrush Stroke
+ ///
+ /// Gets or sets the that specifies how the shape's outline is painted.
+ ///
+ public IBrush? Stroke
{
get { return GetValue(StrokeProperty); }
set { SetValue(StrokeProperty, value); }
}
- public AvaloniaList StrokeDashArray
+ ///
+ /// Gets or sets a collection of values that indicate the pattern of dashes and gaps that is used to outline shapes.
+ ///
+ public AvaloniaList? StrokeDashArray
{
get { return GetValue(StrokeDashArrayProperty); }
set { SetValue(StrokeDashArrayProperty, value); }
}
+ ///
+ /// Gets or sets a value that specifies the distance within the dash pattern where a dash begins.
+ ///
public double StrokeDashOffset
{
get { return GetValue(StrokeDashOffsetProperty); }
set { SetValue(StrokeDashOffsetProperty, value); }
}
+ ///
+ /// Gets or sets the width of the shape outline.
+ ///
public double StrokeThickness
{
get { return GetValue(StrokeThicknessProperty); }
set { SetValue(StrokeThicknessProperty, value); }
}
+ ///
+ /// Gets or sets a enumeration value that describes the shape at the ends of a line.
+ ///
public PenLineCap StrokeLineCap
{
get { return GetValue(StrokeLineCapProperty); }
set { SetValue(StrokeLineCapProperty, value); }
}
+ ///
+ /// Gets or sets a enumeration value that specifies the type of join that is used at the vertices of a Shape.
+ ///
public PenLineJoin StrokeJoin
{
get { return GetValue(StrokeJoinProperty); }
@@ -170,12 +229,20 @@ namespace Avalonia.Controls.Shapes
}
}
- protected abstract Geometry CreateDefiningGeometry();
+ ///
+ /// Creates the shape's defining geometry.
+ ///
+ /// Defining of the shape.
+ protected abstract Geometry? CreateDefiningGeometry();
+ ///
+ /// Invalidates the geometry of this shape.
+ ///
protected void InvalidateGeometry()
{
_renderedGeometry = null;
_definingGeometry = null;
+
InvalidateMeasure();
}
@@ -321,8 +388,8 @@ namespace Avalonia.Controls.Shapes
// portion changes.
if (e.Property == BoundsProperty)
{
- var oldBounds = (Rect)e.OldValue;
- var newBounds = (Rect)e.NewValue;
+ var oldBounds = (Rect)e.OldValue!;
+ var newBounds = (Rect)e.NewValue!;
if (oldBounds.Size == newBounds.Size)
{