mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-03 00:00:57 +08:00
29 lines
1.0 KiB
C#
29 lines
1.0 KiB
C#
using AIStudio.Wpf.DiagramDesigner.Models;
|
|
|
|
namespace AIStudio.Wpf.DiagramDesigner.Geometrys
|
|
{
|
|
public delegate IShape ShapeDefiner(DesignerItemViewModelBase node);
|
|
|
|
public static class Shapes
|
|
{
|
|
public static IShape Rectangle(DesignerItemViewModelBase node) => new RectangleBase(node.Position, node.Size);
|
|
|
|
public static IShape Circle(DesignerItemViewModelBase node)
|
|
{
|
|
var halfWidth = node.Size.Width / 2;
|
|
var centerX = node.Position.X + halfWidth;
|
|
var centerY = node.Position.Y + node.Size.Height / 2;
|
|
return new EllipseBase(centerX, centerY, halfWidth, halfWidth);
|
|
}
|
|
|
|
public static IShape Ellipse(DesignerItemViewModelBase node)
|
|
{
|
|
var halfWidth = node.Size.Width / 2;
|
|
var halfHeight = node.Size.Height / 2;
|
|
var centerX = node.Position.X + halfWidth;
|
|
var centerY = node.Position.Y + halfHeight;
|
|
return new EllipseBase(centerX, centerY, halfWidth, halfHeight);
|
|
}
|
|
}
|
|
}
|