This commit is contained in:
kwai
2023-06-14 19:41:29 +08:00
parent 0f7a5b0308
commit 207523eb16
5 changed files with 63 additions and 20 deletions

View File

@@ -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;
}
}
}