mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-03 00:00:57 +08:00
block
This commit is contained in:
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Media;
|
||||
using AIStudio.Wpf.DiagramDesigner.Geometrys;
|
||||
using AIStudio.Wpf.DiagramDesigner.Models;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
@@ -52,6 +53,29 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
}
|
||||
|
||||
public override PointBase Position
|
||||
{
|
||||
get
|
||||
{
|
||||
if (DataItem?.ParentContainer == null)
|
||||
{
|
||||
return PointHelper.GetPointForConnector(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
return PointHelper.GetPointForConnector(this);//Todo
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override PointBase MiddlePosition
|
||||
{
|
||||
get
|
||||
{
|
||||
return PointHelper.GetPointForConnector(this, true);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CanAttachTo(ConnectorInfoBase port)
|
||||
{
|
||||
if (port is BlockConnectorInfo blockConnectorInfo)
|
||||
|
||||
@@ -137,14 +137,28 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
var offset = GetOffSetFunc?.Invoke() ?? new Point(0, 0);
|
||||
|
||||
var containBound = new RectangleBase(DataItem.Left + offset.X, DataItem.Top + offset.Y, GetItemWidth(), GetItemHeight());
|
||||
//foreach(var child in Children)
|
||||
//{
|
||||
// var bound = new RectangleBase(DataItem.Left + offset.X, DataItem.Top + offset.Y, child.GetItemWidth(), child.GetItemHeight());
|
||||
//}
|
||||
|
||||
return containBound;
|
||||
}
|
||||
|
||||
public List<RectangleBase> GetChildrenBounds()
|
||||
{
|
||||
List<RectangleBase> bounds = new List<RectangleBase>();
|
||||
var offset = GetOffSetFunc?.Invoke() ?? new Point(0, 0);
|
||||
|
||||
var containBound = new RectangleBase(DataItem.Left + offset.X, DataItem.Top + offset.Y, GetItemWidth(), GetItemHeight());
|
||||
double height = 0;
|
||||
foreach (var child in Children)
|
||||
{
|
||||
var bound = new RectangleBase(DataItem.Left + offset.X, DataItem.Top + offset.Y + height, child.GetItemWidth(), child.GetItemHeight());
|
||||
bounds.Add(bound);
|
||||
|
||||
height += child.GetItemHeight();
|
||||
}
|
||||
|
||||
return bounds;
|
||||
}
|
||||
|
||||
public BlockDesignerItemViewModel DataItem
|
||||
{
|
||||
get
|
||||
|
||||
@@ -126,13 +126,15 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
innerport.DataItem.ShowConnectors = true;
|
||||
if (innerport.CanAttachTo(blockDesignerItemTempLink.Items.FirstOrDefault()) == true)
|
||||
{
|
||||
if (innerport.OnlyOneChild)
|
||||
if (innerport.OnlyOneChild || innerport.Children.Count == 0)
|
||||
{
|
||||
innerport.BeAttachTo = true;
|
||||
return innerport;
|
||||
}
|
||||
else
|
||||
{
|
||||
var childrenbounds = container.GetChildrenBounds();
|
||||
|
||||
innerport.BeAttachTo = true;
|
||||
return innerport;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user