2023-02-03 18:23:53 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
2023-02-10 18:49:02 +08:00
|
|
|
|
using AIStudio.Wpf.DiagramDesigner.Geometrys;
|
2023-02-03 18:23:53 +08:00
|
|
|
|
|
|
|
|
|
|
namespace AIStudio.Wpf.DiagramDesigner
|
|
|
|
|
|
{
|
|
|
|
|
|
public class DiagramViewModelHelper
|
|
|
|
|
|
{
|
|
|
|
|
|
public static DesignerItemViewModelBase GetConnectorDataItem(IEnumerable<SelectableDesignerItemViewModelBase> items, Guid conectorDataItemId, Type connectorDataItemType)
|
|
|
|
|
|
{
|
|
|
|
|
|
DesignerItemViewModelBase dataItem = items.OfType<DesignerItemViewModelBase>().Single(x => x.Id == conectorDataItemId);
|
|
|
|
|
|
return dataItem;
|
|
|
|
|
|
}
|
2023-02-10 18:49:02 +08:00
|
|
|
|
|
|
|
|
|
|
public static RectangleBase GetBoundingRectangle(IEnumerable<DesignerItemViewModelBase> items)
|
|
|
|
|
|
{
|
|
|
|
|
|
double x1 = Double.MaxValue;
|
|
|
|
|
|
double y1 = Double.MaxValue;
|
|
|
|
|
|
double x2 = Double.MinValue;
|
|
|
|
|
|
double y2 = Double.MinValue;
|
|
|
|
|
|
|
|
|
|
|
|
foreach (DesignerItemViewModelBase item in items)
|
|
|
|
|
|
{
|
|
|
|
|
|
x1 = Math.Min(item.Left, x1);
|
|
|
|
|
|
y1 = Math.Min(item.Top, y1);
|
|
|
|
|
|
|
2023-06-11 23:58:22 +08:00
|
|
|
|
x2 = Math.Max(item.Left + item.GetItemWidth(), x2);
|
|
|
|
|
|
y2 = Math.Max(item.Top + item.GetItemHeight(), y2);
|
2023-02-10 18:49:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return new RectangleBase(new PointBase(x1, y1), new PointBase(x2, y2));
|
|
|
|
|
|
}
|
2023-03-19 23:26:14 +08:00
|
|
|
|
|
|
|
|
|
|
public static RectangleBase GetBoundingRectangle(DesignerItemViewModelBase item)
|
|
|
|
|
|
{
|
|
|
|
|
|
return GetBoundingRectangle(new DesignerItemViewModelBase[] { item });
|
|
|
|
|
|
}
|
2023-02-03 18:23:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|