mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-24 10:26:35 +08:00
block
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
<dd:LineDashConverter x:Key="LineDashConverter"/>
|
<dd:LineDashConverter x:Key="LineDashConverter"/>
|
||||||
<dd:DoubleToThickness x:Key="DoubleToThickness"/>
|
<dd:DoubleToThickness x:Key="DoubleToThickness"/>
|
||||||
<dd:InvertBoolConverter x:Key="InvertBoolConverter"/>
|
<dd:InvertBoolConverter x:Key="InvertBoolConverter"/>
|
||||||
|
<dd:NotNullOrEmptyToBoolConverter x:Key="NotNullOrEmptyToBoolConverter"/>
|
||||||
|
|
||||||
<DataTemplate DataType="{x:Type dd:DefaultDesignerItemViewModel}">
|
<DataTemplate DataType="{x:Type dd:DefaultDesignerItemViewModel}">
|
||||||
<Grid IsHitTestVisible="False">
|
<Grid IsHitTestVisible="False">
|
||||||
|
|||||||
@@ -12,14 +12,16 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
{
|
{
|
||||||
public class BlockItemsContainerInfo : SelectableViewModelBase
|
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.Parent = dataItem;
|
||||||
|
this.OnlyOneChild = onlyOneChild;
|
||||||
|
this.ChildFlag = childFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockItemsContainerInfo(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
public BlockItemsContainerInfo(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
||||||
@@ -65,6 +67,17 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
}
|
}
|
||||||
|
|
||||||
#region 属性
|
#region 属性
|
||||||
|
public bool OnlyOneChild
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
} = true;
|
||||||
|
|
||||||
|
public List<string> ChildFlag
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
} = new List<string>();
|
||||||
|
|
||||||
|
|
||||||
private double _itemWidth = double.NaN;
|
private double _itemWidth = double.NaN;
|
||||||
public double ItemWidth
|
public double ItemWidth
|
||||||
{
|
{
|
||||||
@@ -147,7 +160,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<BlockItemsContainerInfo> ChildrenContain
|
public List<BlockItemsContainerInfo> ChildrenContainer
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -155,7 +168,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int ContainLevel
|
public int ContainerLevel
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -165,7 +178,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
}
|
}
|
||||||
else
|
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)
|
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
|
#endregion
|
||||||
|
|
||||||
public double GetItemWidth()
|
public double GetItemWidth()
|
||||||
@@ -237,7 +250,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
|
|
||||||
public List<BlockItemsContainerInfo> GetAllContain(ObservableCollection<BlockDesignerItemViewModel> children, bool self)
|
public List<BlockItemsContainerInfo> GetAllContain(ObservableCollection<BlockDesignerItemViewModel> children, bool self)
|
||||||
{
|
{
|
||||||
List <BlockItemsContainerInfo> itemsContainers= new List <BlockItemsContainerInfo>();
|
List<BlockItemsContainerInfo> itemsContainers = new List<BlockItemsContainerInfo>();
|
||||||
if (self)
|
if (self)
|
||||||
{
|
{
|
||||||
itemsContainers.Add(this);
|
itemsContainers.Add(this);
|
||||||
|
|||||||
@@ -3221,7 +3221,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
{
|
{
|
||||||
if (port.GetBounds().IntersectsWith(blockDesignerItemViewModel.GetBounds())) //如果两个位置相交
|
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)
|
if (innerport != null)
|
||||||
{
|
{
|
||||||
innerport.DataItem.ShowConnectors = true;
|
innerport.DataItem.ShowConnectors = true;
|
||||||
@@ -3356,7 +3356,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
{
|
{
|
||||||
if (port.GetBounds().IntersectsWith(blockDesignerItemTempLink.GetBounds())) //如果两个位置相交
|
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)
|
if (innerport != null)
|
||||||
{
|
{
|
||||||
innerport.DataItem.ShowConnectors = true;
|
innerport.DataItem.ShowConnectors = true;
|
||||||
@@ -3446,7 +3446,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
var container = FindNearContainerToAttachTo(item);
|
var container = FindNearContainerToAttachTo(item);
|
||||||
if (container != null)
|
if (container != null)
|
||||||
{
|
{
|
||||||
(container.DataItem as BlockDesignerItemViewModel).AddChild(item.Items.FirstOrDefault(), container);//待完善
|
container.DataItem.AddChild(item.Items.FirstOrDefault(), container);//待完善
|
||||||
container.BeAttachTo = false;
|
container.BeAttachTo = false;
|
||||||
container.DisableAttachTo = false;
|
container.DisableAttachTo = false;
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -1,68 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using AIStudio.Wpf.DiagramDesigner.Models;
|
|
||||||
|
|
||||||
namespace AIStudio.Wpf.DiagramDesigner
|
|
||||||
{
|
|
||||||
public class BlockContainDesignerItemViewModel : BlockDesignerItemViewModel
|
|
||||||
{
|
|
||||||
public BlockContainDesignerItemViewModel()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockContainDesignerItemViewModel(IDiagramViewModel root) : base(root)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockContainDesignerItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockContainDesignerItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void InitNew()
|
|
||||||
{
|
|
||||||
base.InitNew();
|
|
||||||
|
|
||||||
Containers.Add(new BlockItemsContainerInfo(this.Root, this));
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void AddChild(BlockDesignerItemViewModel child, BlockItemsContainerInfo container)
|
|
||||||
{
|
|
||||||
if (container == null)
|
|
||||||
{
|
|
||||||
container = FirstContainer;
|
|
||||||
}
|
|
||||||
var oldchildren = container.Children.FirstOrDefault();
|
|
||||||
if (oldchildren != null)
|
|
||||||
{
|
|
||||||
this.RemoveChild(oldchildren, container);
|
|
||||||
}
|
|
||||||
|
|
||||||
Root.Items.Remove(child);
|
|
||||||
container.AddChild(child);
|
|
||||||
|
|
||||||
base.AddChild(child, container);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void RemoveChild(BlockDesignerItemViewModel child, BlockItemsContainerInfo container)
|
|
||||||
{
|
|
||||||
if (container == null)
|
|
||||||
{
|
|
||||||
container = FirstContainer;
|
|
||||||
}
|
|
||||||
Root.Items.Add(child);
|
|
||||||
container.RemoveChild(child);
|
|
||||||
|
|
||||||
this.RemoveFromSelection();
|
|
||||||
child.AddToSelection(true, false);
|
|
||||||
|
|
||||||
base.RemoveChild(child, container);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using AIStudio.Wpf.DiagramDesigner.Models;
|
|
||||||
|
|
||||||
namespace AIStudio.Wpf.DiagramDesigner
|
|
||||||
{
|
|
||||||
public class BlockContainListDesignerItemViewModel : BlockDesignerItemViewModel
|
|
||||||
{
|
|
||||||
public BlockContainListDesignerItemViewModel()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockContainListDesignerItemViewModel(IDiagramViewModel root) : base(root)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockContainListDesignerItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockContainListDesignerItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void InitNew()
|
|
||||||
{
|
|
||||||
base.InitNew();
|
|
||||||
|
|
||||||
Containers.Add(new BlockItemsContainerInfo(this.Root, this));
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void AddChild(BlockDesignerItemViewModel child, BlockItemsContainerInfo container)
|
|
||||||
{
|
|
||||||
if (container == null)
|
|
||||||
{
|
|
||||||
container = FirstContainer;
|
|
||||||
}
|
|
||||||
Root.Items.Remove(child);
|
|
||||||
container.Children.Add(child);
|
|
||||||
|
|
||||||
base.AddChild(child, container);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void RemoveChild(BlockDesignerItemViewModel child, BlockItemsContainerInfo container)
|
|
||||||
{
|
|
||||||
if (container == null)
|
|
||||||
{
|
|
||||||
container = FirstContainer;
|
|
||||||
}
|
|
||||||
Root.Items.Add(child);
|
|
||||||
container.Children.Remove(child);
|
|
||||||
|
|
||||||
base.RemoveChild(child, container);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Collections.ObjectModel;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using AIStudio.Wpf.DiagramDesigner.Geometrys;
|
|
||||||
|
|
||||||
namespace AIStudio.Wpf.DiagramDesigner
|
|
||||||
{
|
|
||||||
public class BlockDesignerItemTempLink
|
|
||||||
{
|
|
||||||
public List<BlockDesignerItemViewModel> Items
|
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
} = new List<BlockDesignerItemViewModel>();
|
|
||||||
|
|
||||||
public RectangleBase GetBounds(bool includePorts = false)
|
|
||||||
{
|
|
||||||
return Items.FirstOrDefault().GetBounds();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<FullyCreatedConnectorInfo> Connectors
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
List<FullyCreatedConnectorInfo> connectors = new List<FullyCreatedConnectorInfo>();
|
|
||||||
if (Items.FirstOrDefault().TopConnector != null)
|
|
||||||
{
|
|
||||||
connectors.Add(Items.FirstOrDefault().TopConnector);
|
|
||||||
}
|
|
||||||
if (Items.FirstOrDefault().LeftConnector != null)
|
|
||||||
{
|
|
||||||
connectors.Add(Items.FirstOrDefault().LeftConnector);
|
|
||||||
}
|
|
||||||
if (Items.LastOrDefault().BottomConnector != null)
|
|
||||||
{
|
|
||||||
connectors.Add(Items.LastOrDefault().BottomConnector);
|
|
||||||
}
|
|
||||||
if (Items.LastOrDefault().RightConnector != null)
|
|
||||||
{
|
|
||||||
connectors.Add(Items.LastOrDefault().RightConnector);
|
|
||||||
}
|
|
||||||
return connectors;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<BlockDesignerItemTempLink> Build(List<BlockDesignerItemViewModel> blocks)
|
|
||||||
{
|
|
||||||
List<BlockDesignerItemTempLink> links = new List<BlockDesignerItemTempLink>();
|
|
||||||
foreach (var block in blocks.OrderBy(p => p.BlockLevel).ToList())
|
|
||||||
{
|
|
||||||
bool success = false;
|
|
||||||
foreach (var link in links)
|
|
||||||
{
|
|
||||||
if (link.Items.LastOrDefault() == block.Prev)
|
|
||||||
{
|
|
||||||
link.Items.Add(block);
|
|
||||||
success = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (success == false)
|
|
||||||
{
|
|
||||||
BlockDesignerItemTempLink link = new BlockDesignerItemTempLink();
|
|
||||||
link.Items.Add(block);
|
|
||||||
links.Add(link);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return links;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,6 +4,7 @@ using System.Collections.ObjectModel;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using AIStudio.Wpf.DiagramDesigner.Geometrys;
|
||||||
using AIStudio.Wpf.DiagramDesigner.Models;
|
using AIStudio.Wpf.DiagramDesigner.Models;
|
||||||
using static System.Net.Mime.MediaTypeNames;
|
using static System.Net.Mime.MediaTypeNames;
|
||||||
|
|
||||||
@@ -108,6 +109,22 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
|
|
||||||
public virtual void AddChild(BlockDesignerItemViewModel child, BlockItemsContainerInfo container)
|
public virtual void AddChild(BlockDesignerItemViewModel child, BlockItemsContainerInfo container)
|
||||||
{
|
{
|
||||||
|
if (container == null)
|
||||||
|
{
|
||||||
|
container = FirstContainer;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (container.OnlyOneChild)
|
||||||
|
{
|
||||||
|
var oldchildren = container.Children.FirstOrDefault();
|
||||||
|
if (oldchildren != null)
|
||||||
|
{
|
||||||
|
this.RemoveChild(oldchildren, container);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Root.Items.Remove(child);
|
||||||
|
container.AddChild(child);
|
||||||
|
|
||||||
child.RemoveFromSelection();
|
child.RemoveFromSelection();
|
||||||
this.GetRootContainItem.AddToSelection(true, true);
|
this.GetRootContainItem.AddToSelection(true, true);
|
||||||
|
|
||||||
@@ -119,8 +136,14 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
|
|
||||||
public virtual void RemoveChild(BlockDesignerItemViewModel child, BlockItemsContainerInfo container)
|
public virtual void RemoveChild(BlockDesignerItemViewModel child, BlockItemsContainerInfo container)
|
||||||
{
|
{
|
||||||
this.RemoveFromSelection();
|
if (container == null)
|
||||||
|
{
|
||||||
|
container = FirstContainer;
|
||||||
|
}
|
||||||
|
Root.Items.Add(child);
|
||||||
|
container.RemoveChild(child);
|
||||||
|
|
||||||
|
this.RemoveFromSelection();
|
||||||
child.AddToSelection(true, true);
|
child.AddToSelection(true, true);
|
||||||
|
|
||||||
System.Windows.Application.Current?.Dispatcher.BeginInvoke(new Action(async () => {
|
System.Windows.Application.Current?.Dispatcher.BeginInvoke(new Action(async () => {
|
||||||
@@ -129,6 +152,11 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string Flag
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
|
||||||
public int BlockLevel
|
public int BlockLevel
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -157,11 +185,6 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
get; set;
|
get; set;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanContainTo
|
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
} = true;
|
|
||||||
|
|
||||||
public BlockItemsContainerInfo ParentContainer
|
public BlockItemsContainerInfo ParentContainer
|
||||||
{
|
{
|
||||||
get; set;
|
get; set;
|
||||||
@@ -242,4 +265,124 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region 扩展
|
||||||
|
public class BlockContainDesignerItemViewModel : BlockDesignerItemViewModel
|
||||||
|
{
|
||||||
|
public BlockContainDesignerItemViewModel()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockContainDesignerItemViewModel(IDiagramViewModel root) : base(root)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockContainDesignerItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockContainDesignerItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void InitNew()
|
||||||
|
{
|
||||||
|
base.InitNew();
|
||||||
|
|
||||||
|
Containers.Add(new BlockItemsContainerInfo(this.Root, this, true, null));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BlockContainListDesignerItemViewModel : BlockDesignerItemViewModel
|
||||||
|
{
|
||||||
|
public BlockContainListDesignerItemViewModel()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockContainListDesignerItemViewModel(IDiagramViewModel root) : base(root)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockContainListDesignerItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockContainListDesignerItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void InitNew()
|
||||||
|
{
|
||||||
|
base.InitNew();
|
||||||
|
|
||||||
|
Containers.Add(new BlockItemsContainerInfo(this.Root, this, false, null));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 帮助
|
||||||
|
public class BlockDesignerItemTempLink
|
||||||
|
{
|
||||||
|
public List<BlockDesignerItemViewModel> Items
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
} = new List<BlockDesignerItemViewModel>();
|
||||||
|
|
||||||
|
public RectangleBase GetBounds()
|
||||||
|
{
|
||||||
|
return Items.FirstOrDefault().GetBounds();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<FullyCreatedConnectorInfo> Connectors
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
List<FullyCreatedConnectorInfo> connectors = new List<FullyCreatedConnectorInfo>();
|
||||||
|
if (Items.FirstOrDefault().TopConnector != null)
|
||||||
|
{
|
||||||
|
connectors.Add(Items.FirstOrDefault().TopConnector);
|
||||||
|
}
|
||||||
|
if (Items.FirstOrDefault().LeftConnector != null)
|
||||||
|
{
|
||||||
|
connectors.Add(Items.FirstOrDefault().LeftConnector);
|
||||||
|
}
|
||||||
|
if (Items.LastOrDefault().BottomConnector != null)
|
||||||
|
{
|
||||||
|
connectors.Add(Items.LastOrDefault().BottomConnector);
|
||||||
|
}
|
||||||
|
if (Items.LastOrDefault().RightConnector != null)
|
||||||
|
{
|
||||||
|
connectors.Add(Items.LastOrDefault().RightConnector);
|
||||||
|
}
|
||||||
|
return connectors;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<BlockDesignerItemTempLink> Build(List<BlockDesignerItemViewModel> blocks)
|
||||||
|
{
|
||||||
|
List<BlockDesignerItemTempLink> links = new List<BlockDesignerItemTempLink>();
|
||||||
|
foreach (var block in blocks.OrderBy(p => p.BlockLevel).ToList())
|
||||||
|
{
|
||||||
|
bool success = false;
|
||||||
|
foreach (var link in links)
|
||||||
|
{
|
||||||
|
if (link.Items.LastOrDefault() == block.Prev)
|
||||||
|
{
|
||||||
|
link.Items.Add(block);
|
||||||
|
success = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (success == false)
|
||||||
|
{
|
||||||
|
BlockDesignerItemTempLink link = new BlockDesignerItemTempLink();
|
||||||
|
link.Items.Add(block);
|
||||||
|
links.Add(link);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return links;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user