diff --git a/AIStudio.Wpf.DiagramDesigner/AIStudio.Wpf.DiagramDesigner.csproj b/AIStudio.Wpf.DiagramDesigner/AIStudio.Wpf.DiagramDesigner.csproj
index d5a44c1..76dacc3 100644
--- a/AIStudio.Wpf.DiagramDesigner/AIStudio.Wpf.DiagramDesigner.csproj
+++ b/AIStudio.Wpf.DiagramDesigner/AIStudio.Wpf.DiagramDesigner.csproj
@@ -8,7 +8,7 @@
A.png
- 1.0.9
+ 1.1.0
一个Wpf的Diagram控件基础库
diff --git a/AIStudio.Wpf.DiagramDesigner/Controls/PopupWindow.xaml.cs b/AIStudio.Wpf.DiagramDesigner/Controls/PopupWindow.xaml.cs
index dacbe28..90e8789 100644
--- a/AIStudio.Wpf.DiagramDesigner/Controls/PopupWindow.xaml.cs
+++ b/AIStudio.Wpf.DiagramDesigner/Controls/PopupWindow.xaml.cs
@@ -29,5 +29,14 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
this.DialogResult = true;
this.Close();
}
+
+ protected override void OnClosed(EventArgs e)
+ {
+ base.OnClosed(e);
+ if (this.DataContext is IDisposable disposable)
+ {
+ disposable.Dispose();
+ }
+ }
}
}
diff --git a/AIStudio.Wpf.DiagramDesigner/ViewModels/DefaultViewModel/LogicalGateItemViewModelBase.cs b/AIStudio.Wpf.DiagramDesigner/ViewModels/DefaultViewModel/LogicalGateItemViewModelBase.cs
index 6805b5f..7b75373 100644
--- a/AIStudio.Wpf.DiagramDesigner/ViewModels/DefaultViewModel/LogicalGateItemViewModelBase.cs
+++ b/AIStudio.Wpf.DiagramDesigner/ViewModels/DefaultViewModel/LogicalGateItemViewModelBase.cs
@@ -21,6 +21,15 @@ namespace AIStudio.Wpf.DiagramDesigner
get; private set;
}
+ public virtual bool EnableAddInput
+ {
+ get;
+ } = false;
+
+ public virtual bool EnableAddOutput
+ {
+ get;
+ } = false;
public LogicalGateItemViewModelBase(LogicalType logicalType) : this(null, logicalType)
{
@@ -29,71 +38,17 @@ namespace AIStudio.Wpf.DiagramDesigner
public LogicalGateItemViewModelBase(IDiagramViewModel root, LogicalType logicalType) : base(root)
{
- this.LogicalType = logicalType;
-
- if (this.LogicalType == LogicalType.Input)
- {
- ClearConnectors();
- ExecuteAddOutput(null);
- }
- else if (this.LogicalType == LogicalType.Output)
- {
- ClearConnectors();
- ExecuteAddInput(null);
- }
- else if (this.LogicalType == LogicalType.Constant)
- {
- ClearConnectors();
- ExecuteAddOutput(null);
- }
- else if (this.LogicalType == LogicalType.Time)
- {
- ClearConnectors();
- ExecuteAddOutput(null);
- }
- else if (this.LogicalType == LogicalType.None)
- {
- ClearConnectors();
- ExecuteAddOutput(null);
- }
- else if (this.LogicalType == LogicalType.NOT)
- {
- ClearConnectors();
- ExecuteAddInput(null);
- ExecuteAddOutput(null);
- }
- else if (this.LogicalType == LogicalType.SEL)
- {
- ClearConnectors();
- ExecuteAddInput(null, 0);
- ExecuteAddInput(null, 1);
- ExecuteAddInput(null, 2);
- ExecuteAddOutput(null, 0);
- }
- else if (this.LogicalType >= LogicalType.ABS && this.LogicalType <= LogicalType.EXPT)
- {
- ClearConnectors();
- ExecuteAddInput(null);
- ExecuteAddOutput(null);
- }
- else
- {
- ClearConnectors();
- ExecuteAddInput(null);
- ExecuteAddInput(null);
- ExecuteAddOutput(null);
- }
- BuildMenuOptions();
+ this.LogicalType = logicalType;
}
public LogicalGateItemViewModelBase(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
{
- BuildMenuOptions();
+
}
public LogicalGateItemViewModelBase(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
{
- BuildMenuOptions();
+
}
public override SelectableItemBase GetSerializableObject()
@@ -107,6 +62,7 @@ namespace AIStudio.Wpf.DiagramDesigner
ShowArrow = false;
AddInputCommand = new SimpleCommand(Command_Enable, para => ExecuteAddInput(para));
AddOutputCommand = new SimpleCommand(Command_Enable, para => ExecuteAddOutput(para));
+ BuildMenuOptions();
base.Init(root, initNew);
}
@@ -118,21 +74,8 @@ namespace AIStudio.Wpf.DiagramDesigner
private void BuildMenuOptions()
{
- bool enAddInput = false;
- bool enAddOutput = false;
- if (LogicalType >= LogicalType.ADD && LogicalType <= LogicalType.AVE)
- {
- enAddInput = true;
- enAddOutput = false;
- }
- else
- {
- enAddInput = false;
- enAddOutput = false;
- }
-
menuOptions = new ObservableCollection();
- if (enAddInput == true)
+ if (EnableAddInput == true)
{
CinchMenuItem menuItem = new CinchMenuItem();
menuItem.Text = "添加输入";
@@ -140,7 +83,7 @@ namespace AIStudio.Wpf.DiagramDesigner
menuItem.CommandParameter = menuItem;
menuOptions.Add(menuItem);
}
- if (enAddOutput == true)
+ if (EnableAddOutput == true)
{
CinchMenuItem menuItem = new CinchMenuItem();
menuItem.Text = "添加输出";
diff --git a/Extensions/AIStudio.Wpf.Logical/ViewModels/LogicalGateItemViewModel.cs b/Extensions/AIStudio.Wpf.Logical/ViewModels/LogicalGateItemViewModel.cs
index 028e24d..6bd56bc 100644
--- a/Extensions/AIStudio.Wpf.Logical/ViewModels/LogicalGateItemViewModel.cs
+++ b/Extensions/AIStudio.Wpf.Logical/ViewModels/LogicalGateItemViewModel.cs
@@ -13,12 +13,12 @@ namespace AIStudio.Wpf.Logical.ViewModels
protected IUIVisualizerService visualiserService;
public LogicalGateItemViewModel(LogicalType logicalType) : this(null, logicalType)
{
-
+
}
public LogicalGateItemViewModel(IDiagramViewModel root, LogicalType logicalType) : base(root, logicalType)
{
-
+
}
public LogicalGateItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
@@ -98,8 +98,28 @@ namespace AIStudio.Wpf.Logical.ViewModels
public AddGateItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
{
+ }
+
+ protected override void InitNew()
+ {
+ base.InitNew();
+
+ ClearConnectors();
+ ExecuteAddInput(null);
+ ExecuteAddInput(null);
+ ExecuteAddOutput(null);
}
+ public override bool EnableAddInput
+ {
+ get;
+ } = true;
+
+ public override bool EnableAddOutput
+ {
+ get;
+ } = false;
+
public override void CalculateOutput()
{
foreach (var output in Output)
@@ -129,6 +149,16 @@ namespace AIStudio.Wpf.Logical.ViewModels
}
+ protected override void InitNew()
+ {
+ base.InitNew();
+
+ ClearConnectors();
+ ExecuteAddInput(null);
+ ExecuteAddInput(null);
+ ExecuteAddOutput(null);
+ }
+
public override void CalculateOutput()
{
foreach (var output in Output)
@@ -160,6 +190,26 @@ namespace AIStudio.Wpf.Logical.ViewModels
}
+ protected override void InitNew()
+ {
+ base.InitNew();
+
+ ClearConnectors();
+ ExecuteAddInput(null);
+ ExecuteAddInput(null);
+ ExecuteAddOutput(null);
+ }
+
+ public override bool EnableAddInput
+ {
+ get;
+ } = true;
+
+ public override bool EnableAddOutput
+ {
+ get;
+ } = false;
+
public override void CalculateOutput()
{
foreach (var output in Output)
@@ -199,6 +249,26 @@ namespace AIStudio.Wpf.Logical.ViewModels
}
+ protected override void InitNew()
+ {
+ base.InitNew();
+
+ ClearConnectors();
+ ExecuteAddInput(null);
+ ExecuteAddInput(null);
+ ExecuteAddOutput(null);
+ }
+
+ public override bool EnableAddInput
+ {
+ get;
+ } = true;
+
+ public override bool EnableAddOutput
+ {
+ get;
+ } = false;
+
public override void CalculateOutput()
{
foreach (var output in Output)
@@ -235,6 +305,26 @@ namespace AIStudio.Wpf.Logical.ViewModels
}
+ protected override void InitNew()
+ {
+ base.InitNew();
+
+ ClearConnectors();
+ ExecuteAddInput(null);
+ ExecuteAddInput(null);
+ ExecuteAddOutput(null);
+ }
+
+ public override bool EnableAddInput
+ {
+ get;
+ } = true;
+
+ public override bool EnableAddOutput
+ {
+ get;
+ } = false;
+
public override void CalculateOutput()
{
foreach (var output in Output)
@@ -266,6 +356,16 @@ namespace AIStudio.Wpf.Logical.ViewModels
}
+ protected override void InitNew()
+ {
+ base.InitNew();
+
+ ClearConnectors();
+ ExecuteAddInput(null);
+ ExecuteAddInput(null);
+ ExecuteAddOutput(null);
+ }
+
public override void CalculateOutput()
{
foreach (var output in Output)
@@ -297,6 +397,16 @@ namespace AIStudio.Wpf.Logical.ViewModels
}
+ protected override void InitNew()
+ {
+ base.InitNew();
+
+ ClearConnectors();
+ ExecuteAddInput(null);
+ ExecuteAddInput(null);
+ ExecuteAddOutput(null);
+ }
+
public override void CalculateOutput()
{
foreach (var output in Output)
@@ -328,6 +438,16 @@ namespace AIStudio.Wpf.Logical.ViewModels
}
+ protected override void InitNew()
+ {
+ base.InitNew();
+
+ ClearConnectors();
+ ExecuteAddInput(null);
+ ExecuteAddInput(null);
+ ExecuteAddOutput(null);
+ }
+
public override void CalculateOutput()
{
foreach (var output in Output)
@@ -359,6 +479,16 @@ namespace AIStudio.Wpf.Logical.ViewModels
}
+ protected override void InitNew()
+ {
+ base.InitNew();
+
+ ClearConnectors();
+ ExecuteAddInput(null);
+ ExecuteAddInput(null);
+ ExecuteAddOutput(null);
+ }
+
public override void CalculateOutput()
{
foreach (var output in Output)
@@ -390,6 +520,15 @@ namespace AIStudio.Wpf.Logical.ViewModels
}
+ protected override void InitNew()
+ {
+ base.InitNew();
+
+ ClearConnectors();
+ ExecuteAddInput(null);
+ ExecuteAddOutput(null);
+ }
+
public override void CalculateOutput()
{
foreach (var output in Output)
@@ -430,6 +569,16 @@ namespace AIStudio.Wpf.Logical.ViewModels
}
+ protected override void InitNew()
+ {
+ base.InitNew();
+
+ ClearConnectors();
+ ExecuteAddInput(null);
+ ExecuteAddInput(null);
+ ExecuteAddOutput(null);
+ }
+
public override void CalculateOutput()
{
foreach (var output in Output)
@@ -461,6 +610,16 @@ namespace AIStudio.Wpf.Logical.ViewModels
}
+ protected override void InitNew()
+ {
+ base.InitNew();
+
+ ClearConnectors();
+ ExecuteAddInput(null);
+ ExecuteAddInput(null);
+ ExecuteAddOutput(null);
+ }
+
public override void CalculateOutput()
{
foreach (var output in Output)
@@ -492,6 +651,16 @@ namespace AIStudio.Wpf.Logical.ViewModels
}
+ protected override void InitNew()
+ {
+ base.InitNew();
+
+ ClearConnectors();
+ ExecuteAddInput(null);
+ ExecuteAddInput(null);
+ ExecuteAddOutput(null);
+ }
+
public override void CalculateOutput()
{
foreach (var output in Output)
@@ -523,6 +692,16 @@ namespace AIStudio.Wpf.Logical.ViewModels
}
+ protected override void InitNew()
+ {
+ base.InitNew();
+
+ ClearConnectors();
+ ExecuteAddInput(null);
+ ExecuteAddInput(null);
+ ExecuteAddOutput(null);
+ }
+
public override void CalculateOutput()
{
foreach (var output in Output)
@@ -554,6 +733,17 @@ namespace AIStudio.Wpf.Logical.ViewModels
}
+ protected override void InitNew()
+ {
+ base.InitNew();
+
+ ClearConnectors();
+ ExecuteAddInput(null, 0);
+ ExecuteAddInput(null, 1);
+ ExecuteAddInput(null, 2);
+ ExecuteAddOutput(null, 0);
+ }
+
public override void CalculateOutput()
{
foreach (var output in Output)
@@ -585,6 +775,16 @@ namespace AIStudio.Wpf.Logical.ViewModels
}
+ protected override void InitNew()
+ {
+ base.InitNew();
+
+ ClearConnectors();
+ ExecuteAddInput(null);
+ ExecuteAddInput(null);
+ ExecuteAddOutput(null);
+ }
+
public override void CalculateOutput()
{
foreach (var output in Output)
@@ -616,6 +816,16 @@ namespace AIStudio.Wpf.Logical.ViewModels
}
+ protected override void InitNew()
+ {
+ base.InitNew();
+
+ ClearConnectors();
+ ExecuteAddInput(null);
+ ExecuteAddInput(null);
+ ExecuteAddOutput(null);
+ }
+
public override void CalculateOutput()
{
foreach (var output in Output)
@@ -647,6 +857,16 @@ namespace AIStudio.Wpf.Logical.ViewModels
}
+ protected override void InitNew()
+ {
+ base.InitNew();
+
+ ClearConnectors();
+ ExecuteAddInput(null);
+ ExecuteAddInput(null);
+ ExecuteAddOutput(null);
+ }
+
public override void CalculateOutput()
{
foreach (var output in Output)
@@ -678,6 +898,16 @@ namespace AIStudio.Wpf.Logical.ViewModels
}
+ protected override void InitNew()
+ {
+ base.InitNew();
+
+ ClearConnectors();
+ ExecuteAddInput(null);
+ ExecuteAddInput(null);
+ ExecuteAddOutput(null);
+ }
+
public override void CalculateOutput()
{
foreach (var output in Output)
@@ -709,6 +939,16 @@ namespace AIStudio.Wpf.Logical.ViewModels
}
+ protected override void InitNew()
+ {
+ base.InitNew();
+
+ ClearConnectors();
+ ExecuteAddInput(null);
+ ExecuteAddInput(null);
+ ExecuteAddOutput(null);
+ }
+
public override void CalculateOutput()
{
foreach (var output in Output)
@@ -739,6 +979,16 @@ namespace AIStudio.Wpf.Logical.ViewModels
}
+ protected override void InitNew()
+ {
+ base.InitNew();
+
+ ClearConnectors();
+ ExecuteAddInput(null);
+ ExecuteAddInput(null);
+ ExecuteAddOutput(null);
+ }
+
public override void CalculateOutput()
{
foreach (var output in Output)
@@ -770,6 +1020,16 @@ namespace AIStudio.Wpf.Logical.ViewModels
}
+ protected override void InitNew()
+ {
+ base.InitNew();
+
+ ClearConnectors();
+ ExecuteAddInput(null);
+ ExecuteAddInput(null);
+ ExecuteAddOutput(null);
+ }
+
public override void CalculateOutput()
{
foreach (var output in Output)
@@ -801,6 +1061,16 @@ namespace AIStudio.Wpf.Logical.ViewModels
}
+ protected override void InitNew()
+ {
+ base.InitNew();
+
+ ClearConnectors();
+ ExecuteAddInput(null);
+ ExecuteAddInput(null);
+ ExecuteAddOutput(null);
+ }
+
public override void CalculateOutput()
{
foreach (var output in Output)
@@ -832,6 +1102,16 @@ namespace AIStudio.Wpf.Logical.ViewModels
}
+ protected override void InitNew()
+ {
+ base.InitNew();
+
+ ClearConnectors();
+ ExecuteAddInput(null);
+ ExecuteAddInput(null);
+ ExecuteAddOutput(null);
+ }
+
public override void CalculateOutput()
{
foreach (var output in Output)
@@ -864,6 +1144,15 @@ namespace AIStudio.Wpf.Logical.ViewModels
}
+ protected override void InitNew()
+ {
+ base.InitNew();
+
+ ClearConnectors();
+ ExecuteAddInput(null);
+ ExecuteAddOutput(null);
+ }
+
public override void CalculateOutput()
{
foreach (var output in Output)
@@ -895,6 +1184,15 @@ namespace AIStudio.Wpf.Logical.ViewModels
}
+ protected override void InitNew()
+ {
+ base.InitNew();
+
+ ClearConnectors();
+ ExecuteAddInput(null);
+ ExecuteAddOutput(null);
+ }
+
public override void CalculateOutput()
{
foreach (var output in Output)
@@ -926,6 +1224,15 @@ namespace AIStudio.Wpf.Logical.ViewModels
}
+ protected override void InitNew()
+ {
+ base.InitNew();
+
+ ClearConnectors();
+ ExecuteAddInput(null);
+ ExecuteAddOutput(null);
+ }
+
public override void CalculateOutput()
{
foreach (var output in Output)
@@ -957,6 +1264,15 @@ namespace AIStudio.Wpf.Logical.ViewModels
}
+ protected override void InitNew()
+ {
+ base.InitNew();
+
+ ClearConnectors();
+ ExecuteAddInput(null);
+ ExecuteAddOutput(null);
+ }
+
public override void CalculateOutput()
{
foreach (var output in Output)
@@ -988,6 +1304,15 @@ namespace AIStudio.Wpf.Logical.ViewModels
}
+ protected override void InitNew()
+ {
+ base.InitNew();
+
+ ClearConnectors();
+ ExecuteAddInput(null);
+ ExecuteAddOutput(null);
+ }
+
public override void CalculateOutput()
{
foreach (var output in Output)
@@ -1019,6 +1344,15 @@ namespace AIStudio.Wpf.Logical.ViewModels
}
+ protected override void InitNew()
+ {
+ base.InitNew();
+
+ ClearConnectors();
+ ExecuteAddInput(null);
+ ExecuteAddOutput(null);
+ }
+
public override void CalculateOutput()
{
foreach (var output in Output)
@@ -1050,6 +1384,15 @@ namespace AIStudio.Wpf.Logical.ViewModels
}
+ protected override void InitNew()
+ {
+ base.InitNew();
+
+ ClearConnectors();
+ ExecuteAddInput(null);
+ ExecuteAddOutput(null);
+ }
+
public override void CalculateOutput()
{
foreach (var output in Output)
@@ -1081,6 +1424,15 @@ namespace AIStudio.Wpf.Logical.ViewModels
}
+ protected override void InitNew()
+ {
+ base.InitNew();
+
+ ClearConnectors();
+ ExecuteAddInput(null);
+ ExecuteAddOutput(null);
+ }
+
public override void CalculateOutput()
{
foreach (var output in Output)
@@ -1112,6 +1464,15 @@ namespace AIStudio.Wpf.Logical.ViewModels
}
+ protected override void InitNew()
+ {
+ base.InitNew();
+
+ ClearConnectors();
+ ExecuteAddInput(null);
+ ExecuteAddOutput(null);
+ }
+
public override void CalculateOutput()
{
foreach (var output in Output)
@@ -1143,6 +1504,15 @@ namespace AIStudio.Wpf.Logical.ViewModels
}
+ protected override void InitNew()
+ {
+ base.InitNew();
+
+ ClearConnectors();
+ ExecuteAddInput(null);
+ ExecuteAddOutput(null);
+ }
+
public override void CalculateOutput()
{
foreach (var output in Output)
@@ -1174,6 +1544,15 @@ namespace AIStudio.Wpf.Logical.ViewModels
}
+ protected override void InitNew()
+ {
+ base.InitNew();
+
+ ClearConnectors();
+ ExecuteAddInput(null);
+ ExecuteAddOutput(null);
+ }
+
public override void CalculateOutput()
{
foreach (var output in Output)
@@ -1205,6 +1584,15 @@ namespace AIStudio.Wpf.Logical.ViewModels
}
+ protected override void InitNew()
+ {
+ base.InitNew();
+
+ ClearConnectors();
+ ExecuteAddInput(null);
+ ExecuteAddOutput(null);
+ }
+
public override void CalculateOutput()
{
foreach (var output in Output)
@@ -1237,9 +1625,17 @@ namespace AIStudio.Wpf.Logical.ViewModels
}
+ protected override void InitNew()
+ {
+ base.InitNew();
+
+ ClearConnectors();
+ ExecuteAddOutput(null);
+ }
+
public override void GetInput()
{
- //无输入
+ //无输入
}
public override void CalculateOutput()
@@ -1305,6 +1701,14 @@ namespace AIStudio.Wpf.Logical.ViewModels
}
}
+ protected override void InitNew()
+ {
+ base.InitNew();
+
+ ClearConnectors();
+ ExecuteAddOutput(null);
+ }
+
public override void GetInput()
{
//无输入
@@ -1387,15 +1791,23 @@ namespace AIStudio.Wpf.Logical.ViewModels
}
}
+ protected override void InitNew()
+ {
+ base.InitNew();
+
+ ClearConnectors();
+ ExecuteAddInput(null);
+ }
+
public override void CalculateOutput()
{
var first = Input.Values.FirstOrDefault();
Value = first.ConnectorValue;
LinkPoint.Value = first.ConnectorValue;
foreach (var output in Output)
- {
+ {
output.Value.ConnectorValue = first.ConnectorValue;
- output.Value.ValueType = first.ValueType;
+ output.Value.ValueType = first.ValueType;
}
base.CalculateOutput();
}
@@ -1417,7 +1829,7 @@ namespace AIStudio.Wpf.Logical.ViewModels
public TimerDesignerItemViewModel() : this(null)
{
-
+
}
public TimerDesignerItemViewModel(IDiagramViewModel root) : base(root, LogicalType.Time)
@@ -1451,6 +1863,9 @@ namespace AIStudio.Wpf.Logical.ViewModels
protected override void InitNew()
{
base.InitNew();
+
+ ClearConnectors();
+ ExecuteAddOutput(null);
}
protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase)