使用PointBase代替Point

This commit is contained in:
艾竹
2023-01-08 09:22:37 +08:00
parent 8fc69bc96d
commit 5d7717cc2b
65 changed files with 4317 additions and 403 deletions

View File

@@ -7,6 +7,7 @@ using System.Windows;
using System.Linq;
using System.Reactive.Linq;
using AIStudio.Wpf.DiagramDesigner.Models;
using AIStudio.Wpf.DiagramDesigner.Geometry;
namespace AIStudio.Wpf.DiagramDesigner
{
@@ -85,6 +86,10 @@ namespace AIStudio.Wpf.DiagramDesigner
get { return (connectors != null && connectors.Count >= 4) ? connectors[3] : null; }
}
public ShapeDefiner ShapeDefiner
{
get;
}
private string _icon;
[CanDo]
@@ -133,16 +138,16 @@ namespace AIStudio.Wpf.DiagramDesigner
}
[CanDo]
public Point ItemWidthHeight
public SizeBase Size
{
get
{
return new Point(ItemWidth, ItemHeight);
return new SizeBase(ItemWidth, ItemHeight);
}
set
{
ItemWidth = value.X;
ItemHeight = value.Y;
ItemWidth = value.Width;
ItemHeight = value.Height;
}
}
@@ -211,14 +216,22 @@ namespace AIStudio.Wpf.DiagramDesigner
{
SetProperty(ref _top, value);
}
}
}
[CanDo]
public Point TopLeft
public PointBase Position
{
get
{
return new Point(Left, Top);
return new PointBase(Left, Top);
}
}
[CanDo]
public PointBase TopLeft
{
get
{
return new PointBase(Left, Top);
}
set
{
@@ -386,17 +399,37 @@ namespace AIStudio.Wpf.DiagramDesigner
public void RaiseTopLeft()
{
this.RaisePropertyChanged(nameof(TopLeft), new Point(GetOldValue<double>(nameof(Left)), GetOldValue<double>(nameof(Top))), TopLeft);
this.RaisePropertyChanged(nameof(TopLeft), new PointBase(GetOldValue<double>(nameof(Left)), GetOldValue<double>(nameof(Top))), TopLeft);
}
public void RaiseItemWidthHeight()
{
this.RaisePropertyChanged(nameof(ItemWidthHeight), new Point(GetOldValue<double>(nameof(ItemWidth)), GetOldValue<double>(nameof(ItemHeight))), ItemWidthHeight);
this.RaisePropertyChanged(nameof(Size), new SizeBase(GetOldValue<double>(nameof(ItemWidth)), GetOldValue<double>(nameof(ItemHeight))), Size);
}
public void RaiseAngle()
{
this.RaisePropertyChanged(nameof(Angle), GetOldValue<double>(nameof(Angle)), Angle);
}
public RectangleBase GetBounds(bool includePorts = false)
{
if (!includePorts)
return new RectangleBase(Left, Top, ItemWidth, ItemHeight);
var leftPort = LeftConnector;
var topPort = TopConnector;
var rightPort = RightConnector;
var bottomPort = BottomConnector;
var left = leftPort == null ? Left: Math.Min(Left, leftPort.Position.X);
var top = topPort == null ? Top : Math.Min(Left, topPort.Position.Y);
var right = rightPort == null ? Left + ItemWidth :
Math.Max(rightPort.Position.X + rightPort.ConnectorWidth, Left + ItemWidth);
var bottom = bottomPort == null ? Top + ItemHeight :
Math.Max(bottomPort.Position.Y + bottomPort.ConnectorHeight, Top + ItemHeight);
return new RectangleBase(left, top, right, bottom);
}
}
}