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.
44 lines
1.4 KiB
44 lines
1.4 KiB
// Copyright (c) The Perspex Project. All rights reserved.
|
|
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|
|
|
using Perspex.Platform;
|
|
|
|
namespace Perspex.Media
|
|
{
|
|
/// <summary>
|
|
/// Represents the geometry of a line.
|
|
/// </summary>
|
|
public class LineGeometry : Geometry
|
|
{
|
|
private Point _startPoint;
|
|
private Point _endPoint;
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="LineGeometry"/> class.
|
|
/// </summary>
|
|
/// <param name="startPoint">The start point.</param>
|
|
/// <param name="endPoint">The end point.</param>
|
|
public LineGeometry(Point startPoint, Point endPoint)
|
|
{
|
|
_startPoint = startPoint;
|
|
_endPoint = endPoint;
|
|
IPlatformRenderInterface factory = PerspexLocator.Current.GetService<IPlatformRenderInterface>();
|
|
IStreamGeometryImpl impl = factory.CreateStreamGeometry();
|
|
|
|
using (IStreamGeometryContextImpl context = impl.Open())
|
|
{
|
|
context.BeginFigure(_startPoint, false);
|
|
context.LineTo(_endPoint);
|
|
context.EndFigure(false);
|
|
}
|
|
|
|
PlatformImpl = impl;
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public override Geometry Clone()
|
|
{
|
|
return new LineGeometry(_startPoint, _endPoint);
|
|
}
|
|
}
|
|
}
|
|
|