2023-05-21 22:06:59 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
2023-06-11 23:58:22 +08:00
|
|
|
|
using System.Collections.ObjectModel;
|
2023-05-21 22:06:59 +08:00
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
2023-06-18 16:21:18 +08:00
|
|
|
|
using AIStudio.Wpf.DiagramDesigner.Geometrys;
|
2023-05-21 22:06:59 +08:00
|
|
|
|
using AIStudio.Wpf.DiagramDesigner.Models;
|
2023-06-13 19:06:51 +08:00
|
|
|
|
using static System.Net.Mime.MediaTypeNames;
|
2023-05-21 22:06:59 +08:00
|
|
|
|
|
|
|
|
|
|
namespace AIStudio.Wpf.DiagramDesigner
|
|
|
|
|
|
{
|
|
|
|
|
|
public class BlockDesignerItemViewModel : DesignerItemViewModelBase
|
|
|
|
|
|
{
|
|
|
|
|
|
public BlockDesignerItemViewModel()
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public BlockDesignerItemViewModel(IDiagramViewModel root) : base(root)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public BlockDesignerItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public BlockDesignerItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
2023-06-11 23:58:22 +08:00
|
|
|
|
ItemWidth = double.NaN;
|
|
|
|
|
|
ItemHeight = double.NaN;
|
2023-05-21 22:06:59 +08:00
|
|
|
|
AddConnector(new BlockConnectorInfo(this.Root, this, ConnectorOrientation.Top));
|
|
|
|
|
|
AddConnector(new BlockConnectorInfo(this.Root, this, ConnectorOrientation.Bottom));
|
2023-06-11 23:58:22 +08:00
|
|
|
|
IsReadOnlyText = true;
|
2023-05-21 22:06:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-07-01 21:38:23 +08:00
|
|
|
|
public void AddNext(BlockDesignerItemViewModel next, bool first = true)
|
2023-05-21 22:06:59 +08:00
|
|
|
|
{
|
2023-06-13 19:06:51 +08:00
|
|
|
|
if (this.Next == next)
|
|
|
|
|
|
{
|
|
|
|
|
|
AlignNext(next);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2023-07-01 21:38:23 +08:00
|
|
|
|
|
|
|
|
|
|
if (next.Prev != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
next.Prev.RemoveNext();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var oldnext = RemoveNext();
|
2023-06-13 19:06:51 +08:00
|
|
|
|
|
2023-05-21 22:06:59 +08:00
|
|
|
|
next.Left = this.Left;
|
2023-06-11 23:58:22 +08:00
|
|
|
|
next.Top = this.Top + this.GetItemHeight();
|
2023-05-21 22:06:59 +08:00
|
|
|
|
next.ParentId = this.Id;
|
2023-07-01 21:38:23 +08:00
|
|
|
|
next.Prev = this;
|
2023-05-21 22:06:59 +08:00
|
|
|
|
this.Next = next;
|
2023-06-13 19:06:51 +08:00
|
|
|
|
if (next.Next != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
next.AlignNext(next.Next);
|
|
|
|
|
|
}
|
2023-07-01 21:38:23 +08:00
|
|
|
|
if (oldnext != null && first == true)
|
2023-06-17 23:55:54 +08:00
|
|
|
|
{
|
|
|
|
|
|
System.Windows.Application.Current?.Dispatcher.BeginInvoke(new Action(async () => {
|
|
|
|
|
|
await Task.Delay(10);
|
2023-07-01 21:38:23 +08:00
|
|
|
|
GetLast().AddNext(oldnext, false);
|
2023-06-17 23:55:54 +08:00
|
|
|
|
}));
|
2023-06-18 16:21:18 +08:00
|
|
|
|
|
2023-06-17 23:55:54 +08:00
|
|
|
|
}
|
2023-06-13 19:06:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void AlignNext(BlockDesignerItemViewModel next)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (next != null && this.Next == next)
|
|
|
|
|
|
{
|
|
|
|
|
|
next.Left = this.Left;
|
|
|
|
|
|
next.Top = this.Top + this.GetItemHeight();
|
|
|
|
|
|
if (next.Next != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
next.AlignNext(next.Next);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-06-11 23:58:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-07-01 21:38:23 +08:00
|
|
|
|
public BlockDesignerItemViewModel RemoveNext()
|
2023-06-11 23:58:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
var next = this.Next;
|
|
|
|
|
|
if (next != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
next.ParentId = new Guid();
|
2023-07-01 21:38:23 +08:00
|
|
|
|
next.Prev = null;
|
2023-06-11 23:58:22 +08:00
|
|
|
|
this.Next = null;
|
2023-07-01 21:38:23 +08:00
|
|
|
|
return next;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return null;
|
2023-06-11 23:58:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-05-21 22:06:59 +08:00
|
|
|
|
public override void AddToSelection(bool selected, bool clearother)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (clearother)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (SelectableDesignerItemViewModelBase item in Root.SelectedItems.ToList())
|
|
|
|
|
|
{
|
|
|
|
|
|
if (item != this)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.RemoveFromSelection();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
IsSelected = selected;
|
|
|
|
|
|
}
|
2023-06-11 23:58:22 +08:00
|
|
|
|
|
2023-06-27 22:57:08 +08:00
|
|
|
|
public virtual void InsertChild(BlockDesignerItemViewModel child, BlockItemsContainerInfo container, int index)
|
2023-06-11 23:58:22 +08:00
|
|
|
|
{
|
2023-06-18 16:21:18 +08:00
|
|
|
|
if (container == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
container = FirstContainer;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (container.OnlyOneChild)
|
|
|
|
|
|
{
|
|
|
|
|
|
var oldchildren = container.Children.FirstOrDefault();
|
|
|
|
|
|
if (oldchildren != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.RemoveChild(oldchildren, container);
|
|
|
|
|
|
}
|
2023-07-02 11:23:00 +08:00
|
|
|
|
Root.Items.Remove(child);
|
|
|
|
|
|
if (child.Prev != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
child.Prev.RemoveNext();
|
|
|
|
|
|
}
|
|
|
|
|
|
if (child.Next != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
child.RemoveNext();
|
|
|
|
|
|
}
|
|
|
|
|
|
container.InsertChild(child, index);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
var list = child.GetNexts(true);
|
|
|
|
|
|
list.Reverse();
|
|
|
|
|
|
list.ForEach(p => {
|
|
|
|
|
|
Root.Items.Remove(p);
|
|
|
|
|
|
if (p.Prev != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
p.Prev.RemoveNext();
|
|
|
|
|
|
}
|
|
|
|
|
|
if (p.Next != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
p.RemoveNext();
|
|
|
|
|
|
}
|
|
|
|
|
|
container.InsertChild(p, index);
|
|
|
|
|
|
});
|
2023-06-18 16:21:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-06-11 23:58:22 +08:00
|
|
|
|
child.RemoveFromSelection();
|
2023-06-17 09:31:15 +08:00
|
|
|
|
this.GetRootContainItem.AddToSelection(true, true);
|
2023-06-13 19:06:51 +08:00
|
|
|
|
|
2023-06-13 22:51:34 +08:00
|
|
|
|
System.Windows.Application.Current?.Dispatcher.BeginInvoke(new Action(async () => {
|
2023-06-13 22:51:59 +08:00
|
|
|
|
await Task.Delay(10);
|
2023-06-13 22:51:34 +08:00
|
|
|
|
AlignNext(this.Next);
|
2023-06-18 16:21:18 +08:00
|
|
|
|
}));
|
2023-06-11 23:58:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-06-17 23:55:54 +08:00
|
|
|
|
public virtual void RemoveChild(BlockDesignerItemViewModel child, BlockItemsContainerInfo container)
|
2023-06-11 23:58:22 +08:00
|
|
|
|
{
|
2023-06-18 16:21:18 +08:00
|
|
|
|
if (container == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
container = FirstContainer;
|
|
|
|
|
|
}
|
|
|
|
|
|
Root.Items.Add(child);
|
|
|
|
|
|
container.RemoveChild(child);
|
2023-06-15 22:44:12 +08:00
|
|
|
|
|
2023-06-18 16:21:18 +08:00
|
|
|
|
this.RemoveFromSelection();
|
2023-06-15 22:44:12 +08:00
|
|
|
|
child.AddToSelection(true, true);
|
2023-06-13 19:06:51 +08:00
|
|
|
|
|
2023-06-13 22:51:34 +08:00
|
|
|
|
System.Windows.Application.Current?.Dispatcher.BeginInvoke(new Action(async () => {
|
2023-06-13 22:51:59 +08:00
|
|
|
|
await Task.Delay(10);
|
2023-06-13 22:51:34 +08:00
|
|
|
|
AlignNext(this.Next);
|
|
|
|
|
|
}));
|
2023-06-11 23:58:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-06-18 16:21:18 +08:00
|
|
|
|
public string Flag
|
|
|
|
|
|
{
|
|
|
|
|
|
get; set;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-06-17 23:55:54 +08:00
|
|
|
|
public int BlockLevel
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
if (Prev == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return Prev.BlockLevel + 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-06-17 09:31:15 +08:00
|
|
|
|
public BlockDesignerItemViewModel Prev
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return Parent as BlockDesignerItemViewModel;
|
|
|
|
|
|
}
|
2023-07-01 21:38:23 +08:00
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (Parent != value)
|
|
|
|
|
|
{
|
|
|
|
|
|
Parent = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-06-17 09:31:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public BlockDesignerItemViewModel Next
|
|
|
|
|
|
{
|
|
|
|
|
|
get; set;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-06-17 23:55:54 +08:00
|
|
|
|
public BlockItemsContainerInfo ParentContainer
|
2023-06-17 09:31:15 +08:00
|
|
|
|
{
|
|
|
|
|
|
get; set;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-06-17 23:55:54 +08:00
|
|
|
|
public ObservableCollection<BlockItemsContainerInfo> Containers
|
2023-06-11 23:58:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
get; set;
|
2023-06-16 19:03:15 +08:00
|
|
|
|
} = new ObservableCollection<BlockItemsContainerInfo>();
|
2023-06-11 23:58:22 +08:00
|
|
|
|
|
2023-06-17 23:55:54 +08:00
|
|
|
|
public BlockItemsContainerInfo FirstContainer
|
2023-06-11 23:58:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2023-06-17 23:55:54 +08:00
|
|
|
|
return Containers?.FirstOrDefault();
|
2023-06-11 23:58:22 +08:00
|
|
|
|
}
|
2023-06-17 09:31:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-06-17 23:55:54 +08:00
|
|
|
|
public BlockItemsContainerInfo SecondContainer
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return Containers?.Skip(1)?.FirstOrDefault();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public BlockItemsContainerInfo ThirdContainer
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return Containers?.Skip(2)?.FirstOrDefault();
|
|
|
|
|
|
}
|
2023-06-18 16:21:18 +08:00
|
|
|
|
}
|
2023-06-17 23:55:54 +08:00
|
|
|
|
|
2023-06-17 09:31:15 +08:00
|
|
|
|
public BlockDesignerItemViewModel GetFirst()
|
|
|
|
|
|
{
|
2023-07-02 11:23:00 +08:00
|
|
|
|
var parent = this.Prev;
|
|
|
|
|
|
while (parent?.Prev != null)
|
2023-06-17 09:31:15 +08:00
|
|
|
|
{
|
2023-07-02 11:23:00 +08:00
|
|
|
|
parent = parent.Prev;
|
2023-06-17 09:31:15 +08:00
|
|
|
|
}
|
2023-07-02 11:23:00 +08:00
|
|
|
|
|
2023-06-17 09:31:15 +08:00
|
|
|
|
return parent;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public BlockDesignerItemViewModel GetLast()
|
|
|
|
|
|
{
|
|
|
|
|
|
var next = this;
|
2023-07-02 11:23:00 +08:00
|
|
|
|
while (next.Next != null)
|
2023-06-17 09:31:15 +08:00
|
|
|
|
{
|
2023-07-02 11:23:00 +08:00
|
|
|
|
next = next.Next;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return next;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<BlockDesignerItemViewModel> GetNexts(bool self)
|
|
|
|
|
|
{
|
|
|
|
|
|
List<BlockDesignerItemViewModel> blockDesignerItemViewModels = new List<BlockDesignerItemViewModel>();
|
|
|
|
|
|
if (self)
|
|
|
|
|
|
{
|
|
|
|
|
|
blockDesignerItemViewModels.Add(this);
|
|
|
|
|
|
}
|
|
|
|
|
|
var next = this;
|
|
|
|
|
|
while (next != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
next = next.Next;
|
|
|
|
|
|
if (next != null)
|
2023-06-17 09:31:15 +08:00
|
|
|
|
{
|
2023-07-02 11:23:00 +08:00
|
|
|
|
blockDesignerItemViewModels.Add(next);
|
2023-06-17 09:31:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-07-02 11:23:00 +08:00
|
|
|
|
|
|
|
|
|
|
return blockDesignerItemViewModels;
|
2023-06-17 09:31:15 +08:00
|
|
|
|
}
|
2023-06-15 22:44:12 +08:00
|
|
|
|
|
2023-06-18 18:43:48 +08:00
|
|
|
|
public void AddContainer(BlockItemsContainerInfo container)
|
2023-06-15 22:44:12 +08:00
|
|
|
|
{
|
2023-06-18 18:43:48 +08:00
|
|
|
|
Containers.Add(container);
|
|
|
|
|
|
RaisePropertyChanged(nameof(FirstContainer));
|
|
|
|
|
|
RaisePropertyChanged(nameof(SecondContainer));
|
|
|
|
|
|
RaisePropertyChanged(nameof(ThirdContainer));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void RemoveContainer(BlockItemsContainerInfo container)
|
|
|
|
|
|
{
|
|
|
|
|
|
Containers.Remove(container);
|
|
|
|
|
|
RaisePropertyChanged(nameof(FirstContainer));
|
|
|
|
|
|
RaisePropertyChanged(nameof(SecondContainer));
|
|
|
|
|
|
RaisePropertyChanged(nameof(ThirdContainer));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void ClearContainers()
|
|
|
|
|
|
{
|
|
|
|
|
|
Containers.Clear();
|
|
|
|
|
|
RaisePropertyChanged(nameof(FirstContainer));
|
|
|
|
|
|
RaisePropertyChanged(nameof(SecondContainer));
|
|
|
|
|
|
RaisePropertyChanged(nameof(ThirdContainer));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<BlockItemsContainerInfo> GetAllContainers()
|
|
|
|
|
|
{
|
|
|
|
|
|
return Containers.SelectMany(p => p.GetAllContainers(p.Children, true)).ToList();
|
2023-06-15 22:44:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-06-17 09:31:15 +08:00
|
|
|
|
public BlockDesignerItemViewModel GetRootContainItem
|
2023-06-15 22:44:12 +08:00
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2023-06-17 23:55:54 +08:00
|
|
|
|
if (ParentContainer == null)
|
2023-06-15 22:44:12 +08:00
|
|
|
|
{
|
|
|
|
|
|
return this;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2023-06-17 23:55:54 +08:00
|
|
|
|
return ParentContainer.DataItem.GetRootContainItem;
|
2023-06-15 22:44:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-06-11 23:58:22 +08:00
|
|
|
|
}
|
2023-05-21 22:06:59 +08:00
|
|
|
|
}
|
2023-06-18 16:21:18 +08:00
|
|
|
|
|
|
|
|
|
|
#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())
|
2023-07-02 11:23:00 +08:00
|
|
|
|
{
|
2023-06-18 16:21:18 +08:00
|
|
|
|
bool success = false;
|
|
|
|
|
|
foreach (var link in links)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (link.Items.LastOrDefault() == block.Prev)
|
2023-07-02 11:23:00 +08:00
|
|
|
|
{
|
2023-06-18 16:21:18 +08:00
|
|
|
|
link.Items.Add(block);
|
|
|
|
|
|
success = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (success == false)
|
|
|
|
|
|
{
|
|
|
|
|
|
BlockDesignerItemTempLink link = new BlockDesignerItemTempLink();
|
|
|
|
|
|
link.Items.Add(block);
|
|
|
|
|
|
links.Add(link);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return links;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
2023-05-21 22:06:59 +08:00
|
|
|
|
}
|