添加block快,不需要连接线,直接吸附。

This commit is contained in:
艾竹
2023-05-21 22:06:59 +08:00
parent 2fd8321363
commit fde899cfa9
30 changed files with 680 additions and 338 deletions

View File

@@ -0,0 +1,68 @@
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 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()
{
AddConnector(new BlockConnectorInfo(this.Root, this, ConnectorOrientation.Top));
AddConnector(new BlockConnectorInfo(this.Root, this, ConnectorOrientation.Bottom));
}
public BlockDesignerItemViewModel Next
{
get;set;
}
public void AddNext(BlockDesignerItemViewModel next)
{
next.Left = this.Left;
next.Top = this.Top + this.ItemHeight;
next.ParentId = this.Id;
next.Parent = this;
this.Next = next;
if (next.Next != null)
{
next.AddNext(next.Next);
}
}
public override void AddToSelection(bool selected, bool clearother)
{
if (clearother)
{
foreach (SelectableDesignerItemViewModelBase item in Root.SelectedItems.ToList())
{
if (item != this)
{
item.RemoveFromSelection();
}
}
}
IsSelected = selected;
}
}
}