添加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;
}
}
}

View File

@@ -49,7 +49,7 @@ namespace AIStudio.Wpf.DiagramDesigner
//propertyChangedSubscription = WhenPropertyChanged.Where(o => o.ToString() == "Left" || o.ToString() == "Top" || o.ToString() == "ItemWidth" || o.ToString() == "ItemHeight").Subscribe(ChangeImageElement);
//connectorsChangedSubscription = WhenConnectorsChanged.Subscribe(OnConnectorsChanged);
AddItemCommand = new SimpleCommand(Command_Enable, ExecuteAddItemCommand);
AddCommand = new SimpleCommand(Command_Enable, ExecuteAddItemCommand);
ImageSwitchCommand = new SimpleCommand(Command_Enable, ExecuteImageSwitchCommand);
BuildMenuOptions();
}
@@ -82,7 +82,7 @@ namespace AIStudio.Wpf.DiagramDesigner
}
}
public ICommand AddItemCommand
public ICommand AddCommand
{
get; private set;
}
@@ -143,7 +143,7 @@ namespace AIStudio.Wpf.DiagramDesigner
// }
// }
// }
// else if (args.Action == NotifyCollectionChangedAction.Remove)
// else if (args.Action == NotifyCollectionChangedAction.Delete)
// {
// if (args.OldItems.Count > 0)
// {

View File

@@ -72,7 +72,9 @@ namespace AIStudio.Wpf.DiagramDesigner
protected override void InitNew()
{
base.InitNew();
ExecuteAddInput(null);
ExecuteAddInput(null);
ExecuteAddOutput(null);
}
private void BuildMenuOptions()
@@ -182,7 +184,7 @@ namespace AIStudio.Wpf.DiagramDesigner
public override void ClearConnectors()
{
connectors.Clear();
Connectors.Clear();
Input.Clear();
Output.Clear();
}

View File

@@ -63,7 +63,7 @@ namespace AIStudio.Wpf.DiagramDesigner
protected override void ClearText()
{
Root.RemoveItemCommand.Execute(this);
Root.DeleteCommand.Execute(this);
}
}
}