Class Geometry
Defines a geometric shape.
[TypeConverter(typeof(GeometryTypeConverter))]
public abstract class Geometry : AvaloniaObject, INotifyPropertyChanged
- Inheritance
-
Geometry
- Implements
- Derived
- Inherited Members
- Extension Methods
Fields
TransformProperty
Defines the Transform property.
public static readonly StyledProperty<Transform?> TransformProperty
Field Value
Properties
Bounds
Gets the geometry's bounding rectangle.
public Rect Bounds { get; }
Property Value
ContourLength
Gets the geometry's total length as if all its contours are placed in a straight line.
public double ContourLength { get; }
Property Value
Transform
Gets or sets a transform to apply to the geometry.
public Transform? Transform { get; set; }
Property Value
Methods
AffectsGeometry(params AvaloniaProperty[])
Marks a property as affecting the geometry's Avalonia.Media.Geometry.PlatformImpl.
protected static void AffectsGeometry(params AvaloniaProperty[] properties)
Parameters
properties
AvaloniaProperty[]The properties.
Remarks
After a call to this method in a control's static constructor, any change to the property will cause InvalidateGeometry() to be called on the element.
Clone()
Clones the geometry.
public abstract Geometry Clone()
Returns
- Geometry
A cloned geometry.
Combine(Geometry, RectangleGeometry, GeometryCombineMode, Transform?)
Combines the two geometries using the specified GeometryCombineMode and applies the specified transform to the resulting geometry.
public static Geometry Combine(Geometry geometry1, RectangleGeometry geometry2, GeometryCombineMode combineMode, Transform? transform = null)
Parameters
geometry1
GeometryThe first geometry to combine.
geometry2
RectangleGeometryThe second geometry to combine.
combineMode
GeometryCombineModeOne of the enumeration values that specifies how the geometries are combined.
transform
TransformA transformation to apply to the combined geometry, or
null
.
Returns
FillContains(Point)
Indicates whether the geometry's fill contains the specified point.
public bool FillContains(Point point)
Parameters
point
PointThe point.
Returns
- bool
true
if the geometry contains the point; otherwise,false
.
GetRenderBounds(IPen)
Gets the geometry's bounding rectangle with the specified pen.
public Rect GetRenderBounds(IPen pen)
Parameters
pen
IPenThe stroke thickness.
Returns
- Rect
The bounding rectangle.
GetWidenedGeometry(IPen)
Gets a Geometry that is the shape defined by the stroke on the Geometry produced by the specified Pen.
public Geometry GetWidenedGeometry(IPen pen)
Parameters
pen
IPenThe pen to use.
Returns
- Geometry
The outlined geometry.
InvalidateGeometry()
Invalidates the platform implementation of the geometry.
protected void InvalidateGeometry()
Parse(string)
Creates a Geometry from a string.
public static Geometry Parse(string s)
Parameters
s
stringThe string.
Returns
StrokeContains(IPen, Point)
Indicates whether the geometry's stroke contains the specified point.
public bool StrokeContains(IPen pen, Point point)
Parameters
Returns
- bool
true
if the geometry contains the point; otherwise,false
.
TryGetPointAndTangentAtDistance(double, out Point, out Point)
Attempts to get the corresponding point and tangent from the specified distance along the contour of the geometry.
public bool TryGetPointAndTangentAtDistance(double distance, out Point point, out Point tangent)
Parameters
distance
doubleThe contour distance to get from.
point
PointThe point in the specified distance.
tangent
PointThe tangent in the specified distance.
Returns
- bool
If there's valid point and tangent at the specified distance.
TryGetPointAtDistance(double, out Point)
Attempts to get the corresponding point at the specified distance
public bool TryGetPointAtDistance(double distance, out Point point)
Parameters
Returns
- bool
If there's valid point at the specified distance.
TryGetSegment(double, double, bool, out Geometry?)
Attempts to get the corresponding path segment given by the two distances specified. Imagine it like snipping a part of the current geometry.
public bool TryGetSegment(double startDistance, double stopDistance, bool startOnBeginFigure, out Geometry? segmentGeometry)
Parameters
startDistance
doubleThe contour distance to start snipping from.
stopDistance
doubleThe contour distance to stop snipping to.
startOnBeginFigure
boolIf ture, the resulting snipped path will start with a BeginFigure call.
segmentGeometry
GeometryThe resulting snipped path.
Returns
- bool
If the snipping operation is successful.
Events
Changed
Raised when the geometry changes.
public event EventHandler? Changed