mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-13 13:09:28 +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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user