mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-03 00:00:57 +08:00
block
This commit is contained in:
@@ -12,14 +12,16 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public class BlockItemsContainerInfo : SelectableViewModelBase
|
||||
{
|
||||
public BlockItemsContainerInfo(BlockDesignerItemViewModel dataItem) : this(null, dataItem)
|
||||
public BlockItemsContainerInfo(BlockDesignerItemViewModel dataItem, bool onlyOneChild, List<string> childFlag) : this(null, dataItem, onlyOneChild, childFlag)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public BlockItemsContainerInfo(IDiagramViewModel root, BlockDesignerItemViewModel dataItem) : base(root)
|
||||
public BlockItemsContainerInfo(IDiagramViewModel root, BlockDesignerItemViewModel dataItem, bool onlyOneChild, List<string> childFlag) : base(root)
|
||||
{
|
||||
this.Parent = dataItem;
|
||||
this.OnlyOneChild = onlyOneChild;
|
||||
this.ChildFlag = childFlag;
|
||||
}
|
||||
|
||||
public BlockItemsContainerInfo(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
||||
@@ -65,6 +67,17 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
|
||||
#region 属性
|
||||
public bool OnlyOneChild
|
||||
{
|
||||
get; set;
|
||||
} = true;
|
||||
|
||||
public List<string> ChildFlag
|
||||
{
|
||||
get; set;
|
||||
} = new List<string>();
|
||||
|
||||
|
||||
private double _itemWidth = double.NaN;
|
||||
public double ItemWidth
|
||||
{
|
||||
@@ -147,7 +160,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
}
|
||||
|
||||
public List<BlockItemsContainerInfo> ChildrenContain
|
||||
public List<BlockItemsContainerInfo> ChildrenContainer
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -155,7 +168,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
}
|
||||
|
||||
public int ContainLevel
|
||||
public int ContainerLevel
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -165,7 +178,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
else
|
||||
{
|
||||
return DataItem.ParentContainer.ContainLevel + 1;
|
||||
return DataItem.ParentContainer.ContainerLevel + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -210,7 +223,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
|
||||
public virtual bool CanAttachTo(BlockDesignerItemViewModel item)
|
||||
=> item != null && item != this.DataItem && !item.IsReadOnly && item.CanContainTo;
|
||||
=> item != null && item != this.DataItem && !item.IsReadOnly && (this.ChildFlag == null || this.ChildFlag.Count == 0 || this.ChildFlag.Contains(item.Flag));
|
||||
#endregion
|
||||
|
||||
public double GetItemWidth()
|
||||
@@ -237,7 +250,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
public List<BlockItemsContainerInfo> GetAllContain(ObservableCollection<BlockDesignerItemViewModel> children, bool self)
|
||||
{
|
||||
List <BlockItemsContainerInfo> itemsContainers= new List <BlockItemsContainerInfo>();
|
||||
List<BlockItemsContainerInfo> itemsContainers = new List<BlockItemsContainerInfo>();
|
||||
if (self)
|
||||
{
|
||||
itemsContainers.Add(this);
|
||||
|
||||
@@ -3221,7 +3221,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
if (port.GetBounds().IntersectsWith(blockDesignerItemViewModel.GetBounds())) //如果两个位置相交
|
||||
{
|
||||
var innerport = port.GetAllContain(port.Children, false).Where(p => p.GetBounds().IntersectsWith(blockDesignerItemViewModel.GetBounds())).OrderByDescending(p => p.ContainLevel).FirstOrDefault();
|
||||
var innerport = port.GetAllContain(port.Children, false).Where(p => p.GetBounds().IntersectsWith(blockDesignerItemViewModel.GetBounds())).OrderByDescending(p => p.ContainerLevel).FirstOrDefault();
|
||||
if (innerport != null)
|
||||
{
|
||||
innerport.DataItem.ShowConnectors = true;
|
||||
@@ -3356,7 +3356,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
if (port.GetBounds().IntersectsWith(blockDesignerItemTempLink.GetBounds())) //如果两个位置相交
|
||||
{
|
||||
var innerport = port.GetAllContain(port.Children, false).Where(p => p.GetBounds().IntersectsWith(blockDesignerItemTempLink.GetBounds())).OrderByDescending(p => p.ContainLevel).FirstOrDefault();
|
||||
var innerport = port.GetAllContain(port.Children, false).Where(p => p.GetBounds().IntersectsWith(blockDesignerItemTempLink.GetBounds())).OrderByDescending(p => p.ContainerLevel).FirstOrDefault();
|
||||
if (innerport != null)
|
||||
{
|
||||
innerport.DataItem.ShowConnectors = true;
|
||||
@@ -3446,7 +3446,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
var container = FindNearContainerToAttachTo(item);
|
||||
if (container != null)
|
||||
{
|
||||
(container.DataItem as BlockDesignerItemViewModel).AddChild(item.Items.FirstOrDefault(), container);//待完善
|
||||
container.DataItem.AddChild(item.Items.FirstOrDefault(), container);//待完善
|
||||
container.BeAttachTo = false;
|
||||
container.DisableAttachTo = false;
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user