mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-08 10:16:36 +08:00
zz
This commit is contained in:
@@ -119,23 +119,6 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
}
|
||||
|
||||
//public PointBase Position
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// var offset = GetOffSetFunc?.Invoke() ?? new Point(0, 0);
|
||||
// return new PointBase(DataItem.Left + offset.X, DataItem.Top + offset.Y);
|
||||
// }
|
||||
//}
|
||||
|
||||
//public PointBase MiddlePosition
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// return new PointBase(Position.X + GetItemWidth() / 2, Position.Y + GetItemHeight() / 2);
|
||||
// }
|
||||
//}
|
||||
|
||||
public RectangleBase GetBounds()
|
||||
{
|
||||
var offset = GetOffSetFunc?.Invoke() ?? new Point(0, 0);
|
||||
@@ -156,6 +139,28 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
get; set;
|
||||
} = new ObservableCollection<BlockDesignerItemViewModel>();
|
||||
|
||||
public List<ItemsContainerInfo> ChildrenContain
|
||||
{
|
||||
get
|
||||
{
|
||||
return Children?.SelectMany(p => p.Contains)?.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public int ContainLevel
|
||||
{
|
||||
get
|
||||
{
|
||||
if (DataItem.ParentContain == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return DataItem.ParentContain.ContainLevel + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Func<Point> _getOffSetFunc;
|
||||
public Func<Point> GetOffSetFunc
|
||||
@@ -209,5 +214,37 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
return double.IsNaN(ItemHeight) ? ActualItemHeight : ItemHeight;
|
||||
}
|
||||
|
||||
public void AddChild(BlockDesignerItemViewModel child)
|
||||
{
|
||||
child.ParentContain = this;
|
||||
Children.Add(child);
|
||||
}
|
||||
|
||||
public void RemoveChild(BlockDesignerItemViewModel child)
|
||||
{
|
||||
child.ParentContain = null;
|
||||
Children.Remove(child);
|
||||
}
|
||||
|
||||
public List<ItemsContainerInfo> GetAllContain(ObservableCollection<BlockDesignerItemViewModel> children)
|
||||
{
|
||||
List <ItemsContainerInfo> itemsContainers= new List <ItemsContainerInfo>();
|
||||
if (children != null)
|
||||
{
|
||||
foreach (var item in children)
|
||||
{
|
||||
if (item.Contains != null)
|
||||
{
|
||||
itemsContainers.AddRange(item.Contains);
|
||||
foreach (var contain in item.Contains)
|
||||
{
|
||||
itemsContainers.AddRange(contain.GetAllContain(contain.Children));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return itemsContainers;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3160,6 +3160,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
if (port.GetBounds().IntersectsWith(blockDesignerItemViewModel.GetBounds())) //如果两个位置相交
|
||||
{
|
||||
|
||||
port.DataItem.ShowConnectors = true;
|
||||
if (port.CanAttachTo(blockDesignerItemViewModel) == true)
|
||||
{
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
|
||||
Root.Items.Remove(child);
|
||||
FirstContain.Children.Add(child);
|
||||
FirstContain.AddChild(child);
|
||||
|
||||
base.AddChild(child);
|
||||
}
|
||||
@@ -49,7 +49,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
public override void RemoveChild(BlockDesignerItemViewModel child)
|
||||
{
|
||||
Root.Items.Add(child);
|
||||
FirstContain.Children.Remove(child);
|
||||
FirstContain.RemoveChild(child);
|
||||
|
||||
this.RemoveFromSelection();
|
||||
child.AddToSelection(true, false);
|
||||
|
||||
@@ -41,6 +41,11 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
get; set;
|
||||
}
|
||||
|
||||
public ItemsContainerInfo ParentContain
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public void AddNext(BlockDesignerItemViewModel next)
|
||||
{
|
||||
if (this.Next == next)
|
||||
|
||||
Reference in New Issue
Block a user