mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-05-01 13:39:28 +08:00
sfc界面处理完成,还差顺序逻辑控制过程
This commit is contained in:
@@ -56,12 +56,13 @@ namespace AIStudio.Wpf.ADiagram.Models
|
||||
public class SFCToolBoxData : ToolBoxData
|
||||
{
|
||||
public SFCNodeKinds Kind { get; set; }
|
||||
public SFCToolBoxData(SFCNodeKinds kind, Type type, double width = 32, double height = 32) : base(kind.GetDescription(), null, type, width, height)
|
||||
public SFCToolBoxData(SFCNodeKinds kind, Type type, double width = 32, double height = 32) : base(null, null, type, width, height)
|
||||
{
|
||||
Kind = kind;
|
||||
ColorViewModel.LineColor.Color = Colors.Black;
|
||||
}
|
||||
ColorViewModel.FillColor.Color = Colors.Blue;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class DesignerItemToolBoxData : ToolBoxData
|
||||
|
||||
@@ -772,7 +772,7 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public void CenterExecuted(object para)
|
||||
public void CenterMoveExecuted(object para)
|
||||
{
|
||||
foreach (var item in DiagramViewModel.SelectedItems.OfType<DesignerItemViewModelBase>())
|
||||
{
|
||||
@@ -781,6 +781,38 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public void LeftMoveExecuted(object para)
|
||||
{
|
||||
foreach (var item in DiagramViewModel.SelectedItems.OfType<DesignerItemViewModelBase>())
|
||||
{
|
||||
item.Left -= 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
public void RightMoveExecuted(object para)
|
||||
{
|
||||
foreach (var item in DiagramViewModel.SelectedItems.OfType<DesignerItemViewModelBase>())
|
||||
{
|
||||
item.Left += 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpMoveExecuted(object para)
|
||||
{
|
||||
foreach (var item in DiagramViewModel.SelectedItems.OfType<DesignerItemViewModelBase>())
|
||||
{
|
||||
item.Top -= 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
public void DownMoveExecuted(object para)
|
||||
{
|
||||
foreach (var item in DiagramViewModel.SelectedItems.OfType<DesignerItemViewModelBase>())
|
||||
{
|
||||
item.Top += 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
public void SameWidthExecuted(object para)
|
||||
{
|
||||
if (para is DesignerItemViewModelBase designerItem)
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace AIStudio.Wpf.Flowchart
|
||||
|
||||
DiagramViewModel.ClearSelectedItems();
|
||||
|
||||
FlowchartService.InitOAData(DiagramViewModel.Items.OfType<FlowNode>().ToList(), DiagramViewModel.Items.OfType<ConnectorViewModel>().ToList());
|
||||
FlowchartService.InitData(DiagramViewModel.Items.OfType<FlowNode>().ToList(), DiagramViewModel.Items.OfType<ConnectorViewModel>().ToList());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -461,7 +461,7 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._centerCommand ?? (this._centerCommand = new DelegateCommand<object>(para => this.CenterExecuted(para)));
|
||||
return this._centerCommand ?? (this._centerCommand = new DelegateCommand<object>(para => this.CenterMoveExecuted(para)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -706,8 +706,9 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
|
||||
}
|
||||
|
||||
|
||||
private void KeyExecuted(string para)
|
||||
public bool KeyExecuted(string para)
|
||||
{
|
||||
bool executed = true;
|
||||
switch (para)
|
||||
{
|
||||
case "Control+A": SelectedAllExecuted(); break;
|
||||
@@ -719,8 +720,15 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
|
||||
case "Control+S": SaveExecuted(); break;
|
||||
case "Control+Z": UnDoExecuted(); break;
|
||||
case "Control+Y": ReDoExecuted(); break;
|
||||
case "None+Delete": DeleteExecuted(); break;
|
||||
case "Delete": DeleteExecuted(); break;
|
||||
case "Left": LeftMoveExecuted(); break;
|
||||
case "Right": RightMoveExecuted(); break;
|
||||
case "Up": UpMoveExecuted(); break;
|
||||
case "Down": DownMoveExecuted(); break;
|
||||
default: executed = false; break;
|
||||
}
|
||||
|
||||
return executed;
|
||||
}
|
||||
|
||||
private void UnDoExecuted()
|
||||
@@ -889,6 +897,10 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
|
||||
{
|
||||
DiagramsViewModel = new LogicalViewModel(NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", (DiagramType)Enum.Parse(typeof(DiagramType), type));
|
||||
}
|
||||
else if (type == DiagramType.SFC.ToString())
|
||||
{
|
||||
DiagramsViewModel = new SFCViewModel(NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", (DiagramType)Enum.Parse(typeof(DiagramType), type));
|
||||
}
|
||||
else
|
||||
{
|
||||
DiagramsViewModel = new DiagramsViewModel(NewNameHelper.GetNewName(DiagramsViewModels.Select(p => p.Title), "新建-"), "*", (DiagramType)Enum.Parse(typeof(DiagramType), type));
|
||||
@@ -993,11 +1005,39 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void CenterExecuted(object para)
|
||||
private void CenterMoveExecuted(object para)
|
||||
{
|
||||
if (DiagramsViewModel == null) return;
|
||||
|
||||
DiagramsViewModel.CenterExecuted(para);
|
||||
DiagramsViewModel.CenterMoveExecuted(para);
|
||||
}
|
||||
|
||||
private void LeftMoveExecuted(object para = null)
|
||||
{
|
||||
if (DiagramsViewModel == null) return;
|
||||
|
||||
DiagramsViewModel.LeftMoveExecuted(para);
|
||||
}
|
||||
|
||||
private void RightMoveExecuted(object para = null)
|
||||
{
|
||||
if (DiagramsViewModel == null) return;
|
||||
|
||||
DiagramsViewModel.RightMoveExecuted(para);
|
||||
}
|
||||
|
||||
private void UpMoveExecuted(object para = null)
|
||||
{
|
||||
if (DiagramsViewModel == null) return;
|
||||
|
||||
DiagramsViewModel.UpMoveExecuted(para);
|
||||
}
|
||||
|
||||
private void DownMoveExecuted(object para = null)
|
||||
{
|
||||
if (DiagramsViewModel == null) return;
|
||||
|
||||
DiagramsViewModel.DownMoveExecuted(para);
|
||||
}
|
||||
|
||||
private void SameWidthExecuted(object para)
|
||||
|
||||
247
AIStudio.Wpf.ADiagram/ViewModels/SFCViewModel.cs
Normal file
247
AIStudio.Wpf.ADiagram/ViewModels/SFCViewModel.cs
Normal file
@@ -0,0 +1,247 @@
|
||||
using AIStudio.Wpf.ADiagram.ViewModels;
|
||||
using AIStudio.Wpf.Flowchart.ViewModels;
|
||||
using AIStudio.Wpf.SFC;
|
||||
using AIStudio.Wpf.SFC.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using Util.DiagramDesigner;
|
||||
|
||||
namespace AIStudio.Wpf.Flowchart
|
||||
{
|
||||
public class SFCViewModel : DiagramsViewModel
|
||||
{
|
||||
public SFCViewModel(string title, string status, DiagramType diagramType) : base(title, status, diagramType)
|
||||
{
|
||||
|
||||
}
|
||||
public SFCViewModel(string filename) : base(filename)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void InitDiagramViewModel()
|
||||
{
|
||||
base.InitDiagramViewModel();
|
||||
|
||||
DiagramViewModel.ShowGrid = true;
|
||||
DiagramViewModel.GridCellSize = new Size(100, 60);
|
||||
DiagramViewModel.CellHorizontalAlignment = CellHorizontalAlignment.Center;
|
||||
DiagramViewModel.CellVerticalAlignment = CellVerticalAlignment.Center;
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
base.Init();
|
||||
|
||||
SFCStartNode start = new SFCStartNode() { Left = 0, Top = 60, Text = "S0" };
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(start);
|
||||
|
||||
SFCConditionNode condition1 = new SFCConditionNode() { Left = 0, Top = 120, Text = "X0" };
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(condition1);
|
||||
|
||||
SFCNodeNode step1 = new SFCNodeNode() { Left = 0, Top = 180, Text = "S1" };
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(step1);
|
||||
|
||||
SFCActionNode action11 = new SFCActionNode() { Left = 100, Top = 180, Text = "SET_V1" };
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(action11);
|
||||
|
||||
SFCActionNode action12 = new SFCActionNode() { Left = 200, Top = 180, Text = "SET_V2" };
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(action12);
|
||||
|
||||
SFCActionNode action13 = new SFCActionNode() { Left = 300, Top = 180, Text = "SET_V3" };
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(action13);
|
||||
|
||||
SFCActionNode action14 = new SFCActionNode() { Left = 400, Top = 180, Text = "RES_V4" };
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(action14);
|
||||
|
||||
SFCConditionNode condition2 = new SFCConditionNode() { Left = 0, Top = 240, Text = "X1" };
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(condition2);
|
||||
|
||||
SFCNodeNode step2 = new SFCNodeNode() { Left = 0, Top = 300, Text = "S2" };
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(step2);
|
||||
|
||||
SFCActionNode action2 = new SFCActionNode() { Left = 100, Top = 300, Text = "SET_V4" };
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(action2);
|
||||
|
||||
SFCConditionNode condition3 = new SFCConditionNode() { Left = 0, Top = 360, Text = "X2" };
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(condition3);
|
||||
|
||||
SFCNodeNode step3 = new SFCNodeNode() { Left = 0, Top = 420, Text = "S3" };
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(step3);
|
||||
|
||||
SFCActionNode action3 = new SFCActionNode() { Left = 100, Top = 420, Text = "RES_V1" };
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(action3);
|
||||
|
||||
SFCConditionNode condition4 = new SFCConditionNode() { Left = 0, Top = 480, Text = "X4" };
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(condition4);
|
||||
|
||||
SFCCOBeginNode cobegin = new SFCCOBeginNode() { Left = 38, Top = 540, Text = "" };
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(cobegin);
|
||||
|
||||
SFCNodeNode step4 = new SFCNodeNode() { Left = 0, Top = 600, Text = "S4" };
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(step4);
|
||||
|
||||
SFCActionNode action4 = new SFCActionNode() { Left = 100, Top = 600, Text = "RES_V2" };
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(action4);
|
||||
|
||||
SFCNodeNode step5 = new SFCNodeNode() { Left = 200, Top = 600, Text = "S5" };
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(step5);
|
||||
|
||||
SFCActionNode action5 = new SFCActionNode() { Left = 300, Top = 600, Text = "RES_V3" };
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(action5);
|
||||
|
||||
SFCCOEndNode coend = new SFCCOEndNode() { Left = 38, Top = 660, Text = "" };
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(coend);
|
||||
|
||||
ConnectorViewModel connector1 = new ConnectorViewModel(start.Output[0], condition1.Input[0]);
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector1);
|
||||
|
||||
ConnectorViewModel connector2 = new ConnectorViewModel(condition1.Output[0], step1.Input[0]);
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector2);
|
||||
|
||||
ConnectorViewModel connector31 = new ConnectorViewModel(step1.Action[0], action11.Input[0]);
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector31);
|
||||
|
||||
ConnectorViewModel connector32 = new ConnectorViewModel(step1.Action[0], action12.Input[0]);
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector32);
|
||||
|
||||
ConnectorViewModel connector33 = new ConnectorViewModel(step1.Action[0], action13.Input[0]);
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector33);
|
||||
|
||||
ConnectorViewModel connector34 = new ConnectorViewModel(step1.Action[0], action14.Input[0]);
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector34);
|
||||
|
||||
ConnectorViewModel connector4 = new ConnectorViewModel(step1.Output[0], condition2.Input[0]);
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector4);
|
||||
|
||||
ConnectorViewModel connector5 = new ConnectorViewModel(condition2.Output[0], step2.Input[0]);
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector5);
|
||||
|
||||
ConnectorViewModel connector6 = new ConnectorViewModel(step2.Action[0], action2.Input[0]);
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector6);
|
||||
|
||||
ConnectorViewModel connector7 = new ConnectorViewModel(step2.Output[0], condition3.Input[0]);
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector7);
|
||||
|
||||
ConnectorViewModel connector8 = new ConnectorViewModel(condition3.Output[0], step3.Input[0]);
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector8);
|
||||
|
||||
ConnectorViewModel connector9 = new ConnectorViewModel(step3.Action[0], action3.Input[0]);
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector9);
|
||||
|
||||
ConnectorViewModel connector10 = new ConnectorViewModel(step3.Output[0], condition4.Input[0]);
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector10);
|
||||
|
||||
ConnectorViewModel connector11 = new ConnectorViewModel(condition4.Output[0], cobegin.Input[0]);
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector11);
|
||||
|
||||
ConnectorViewModel connector12 = new ConnectorViewModel(cobegin.Output[0], step4.Input[0]);
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector12);
|
||||
|
||||
ConnectorViewModel connector13 = new ConnectorViewModel(step4.Action[0], action4.Input[0]);
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector13);
|
||||
|
||||
ConnectorViewModel connector14 = new ConnectorViewModel(cobegin.Output[1], step5.Input[0]);
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector14);
|
||||
|
||||
ConnectorViewModel connector15 = new ConnectorViewModel(step5.Action[0], action5.Input[0]);
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector15);
|
||||
|
||||
ConnectorViewModel connector16 = new ConnectorViewModel(step4.Output[0], coend.Input[0]);
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector16);
|
||||
|
||||
ConnectorViewModel connector17 = new ConnectorViewModel(step5.Output[0], coend.Input[1]);
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector17);
|
||||
|
||||
ConnectorViewModel connector18 = new ConnectorViewModel(coend.Output[0], start.Input[0]);
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(connector18);
|
||||
|
||||
#region 模拟部分
|
||||
TextDesignerItemViewModel despcription = new TextDesignerItemViewModel()
|
||||
{
|
||||
Left = 230,
|
||||
Top = 270,
|
||||
ItemWidth = 300,
|
||||
ItemHeight = 120,
|
||||
Text = @"模拟一个容器的高低液位控制方法
|
||||
1.按下启动按钮, 程序启动
|
||||
2.当液位低于20%的时候, V1,V2,V3打开, V4关闭
|
||||
3.当液位高于50%的时候, V4打开
|
||||
4.当液位高于70%的时侯, V1关闭
|
||||
5.当液位高于80%的时候, V2,V3并行关闭"
|
||||
};
|
||||
despcription.FontViewModel.HorizontalAlignment = HorizontalAlignment.Left;
|
||||
despcription.FontViewModel.VerticalAlignment = VerticalAlignment.Top;
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(despcription);
|
||||
|
||||
Simulate_ListViewModel list = new Simulate_ListViewModel()
|
||||
{
|
||||
Left = 410,
|
||||
Top = 390,
|
||||
};
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(list);
|
||||
|
||||
Simulate_StartViewModel btnstart = new Simulate_StartViewModel() { Left = 0, Top = 0, LinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "S0"), };
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(btnstart);
|
||||
|
||||
Simulate_TankViewModel tank1 = new Simulate_TankViewModel() { Left = 100, Top = 43, ItemWidth = 48, ItemHeight = 60, Text = "T1", LinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "T1") };
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(tank1);
|
||||
|
||||
Simulate_SolenoidViewModel k1 = new Simulate_SolenoidViewModel() { Left = 200, Top = 0, Text = "K1", DILinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K1_DI"), DOLinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K1_DO") };
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(k1);
|
||||
|
||||
Simulate_SolenoidViewModel k2 = new Simulate_SolenoidViewModel() { Left = 200, Top = 60, Text = "K2", DILinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K2_DI"), DOLinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K2_DO") };
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(k2);
|
||||
|
||||
Simulate_SolenoidViewModel k3 = new Simulate_SolenoidViewModel() { Left = 200, Top = 120, Text = "K3", DILinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K3_DI"), DOLinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K3_DO") };
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(k3);
|
||||
|
||||
Simulate_TankViewModel tank2 = new Simulate_TankViewModel() { Left = 300, Top = 28, Text = "T2", LinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "T2") };
|
||||
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(tank2);
|
||||
|
||||
Simulate_SolenoidViewModel k4 = new Simulate_SolenoidViewModel() { Left = 400, Top = 60, Text = "K4", DILinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K4_DI"), DOLinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "K4_DO") };
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(k4);
|
||||
|
||||
Simulate_TankViewModel tank3 = new Simulate_TankViewModel() { Left = 500, Top = 103, ItemWidth = 48, ItemHeight = 60, Text = "T3", LinkPoint = SFCService.LinkPoint.FirstOrDefault(p => p.Name == "T3") };
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(tank3);
|
||||
|
||||
ConnectorViewModel conn1 = new ConnectorViewModel(tank1.Output[0], k1.Input[0]);
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(conn1);
|
||||
|
||||
ConnectorViewModel conn2 = new ConnectorViewModel(tank1.Output[0], k2.Input[0]);
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(conn2);
|
||||
|
||||
ConnectorViewModel conn3 = new ConnectorViewModel(tank1.Output[0], k3.Input[0]);
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(conn3);
|
||||
|
||||
ConnectorViewModel conn4 = new ConnectorViewModel(k1.Output[0], tank2.Input[0]);
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(conn4);
|
||||
|
||||
ConnectorViewModel conn5 = new ConnectorViewModel(k2.Output[0], tank2.Input[0]);
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(conn5);
|
||||
|
||||
ConnectorViewModel conn6 = new ConnectorViewModel(k3.Output[0], tank2.Input[0]);
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(conn6);
|
||||
|
||||
ConnectorViewModel conn7 = new ConnectorViewModel(tank2.Output[1], k4.Input[0]);
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(conn7);
|
||||
|
||||
ConnectorViewModel conn8 = new ConnectorViewModel(k4.Output[0], tank3.Input[0]);
|
||||
DiagramViewModel.DirectAddItemCommand.Execute(conn8);
|
||||
#endregion
|
||||
|
||||
DiagramViewModel.ClearSelectedItems();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ using Util.DiagramDesigner;
|
||||
using Util.DiagramDesigner.Helpers;
|
||||
using AIStudio.Wpf.SFC;
|
||||
using AIStudio.Wpf.SFC.ViewModels;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace AIStudio.Wpf.ADiagram.ViewModels
|
||||
{
|
||||
@@ -186,7 +187,9 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
|
||||
sfcToolBoxItems.Add(new SFCToolBoxData(SFCNodeKinds.Action, typeof(SFCActionNode), 32, 28));
|
||||
sfcToolBoxItems.Add(new SFCToolBoxData(SFCNodeKinds.COBegin, typeof(SFCCOBeginNode), 32, 10));
|
||||
sfcToolBoxItems.Add(new SFCToolBoxData(SFCNodeKinds.COEnd, typeof(SFCCOEndNode), 32, 10));
|
||||
|
||||
sfcToolBoxItems.Add(new SFCToolBoxData(SFCNodeKinds.Simulate_Tank, typeof(Simulate_TankViewModel), 32, 32));
|
||||
sfcToolBoxItems.Add(new SFCToolBoxData(SFCNodeKinds.Simulate_Solenoid, typeof(Simulate_SolenoidViewModel)));
|
||||
sfcToolBoxItems.Add(new SFCToolBoxData(SFCNodeKinds.Simulate_Start, typeof(Simulate_StartViewModel)));
|
||||
ToolBoxCategory.Add(new ToolBoxCategory() { Header = "SFC顺序控制图", ToolBoxItems = new ObservableCollection<ToolBoxData>(sfcToolBoxItems) });
|
||||
|
||||
LoadMyItems();
|
||||
|
||||
@@ -91,6 +91,9 @@
|
||||
<Button Margin="5" ToolTip="逻辑图" Command="{Binding NewCommand}" CommandParameter="Logical" Width="80" Height="80" Foreground="{DynamicResource BlackBrush}" Background="{DynamicResource WhiteBrush}" BorderBrush="{DynamicResource BlackBrush}">
|
||||
<Path Stretch="Fill" Margin="20" Fill="{DynamicResource GrayBrush2}" Data="M 23.6584,49.0333L 23.5634,46.9483L 22.5134,47.9133C 22.1467,48.2067 21.7434,48.4608 21.3034,48.6758C 20.8634,48.8908 20.3851,49.0575 19.8684,49.1758C 19.3517,49.2942 18.7851,49.3533 18.1684,49.3533C 17.3517,49.3533 16.6351,49.2317 16.0184,48.9883C 15.4017,48.745 14.8842,48.4067 14.4659,47.9733C 14.0476,47.54 13.7309,47.0167 13.5159,46.4033C 13.3009,45.79 13.1934,45.115 13.1934,44.3783C 13.1934,43.615 13.3526,42.9108 13.6709,42.2658C 13.9892,41.6208 14.4759,41.0667 15.1309,40.6033C 15.7859,40.14 16.6026,39.7758 17.5809,39.5108C 18.5592,39.2458 19.7067,39.1133 21.0234,39.1133L 23.1134,39.1133L 23.1134,38.1833C 23.1134,37.7867 23.0559,37.4283 22.9409,37.1083C 22.8259,36.7883 22.6409,36.5167 22.3859,36.2933C 22.1309,36.07 21.8001,35.8975 21.3934,35.7758C 20.9867,35.6542 20.4867,35.5933 19.8934,35.5933C 18.9567,35.5933 18.0326,35.7058 17.1209,35.9308C 16.2092,36.1558 15.3267,36.47 14.4734,36.8733L 14.4734,33.6733C 15.2367,33.3967 16.1167,33.1675 17.1134,32.9858C 18.1101,32.8042 19.1451,32.7133 20.2184,32.7133C 21.3984,32.7133 22.4117,32.8258 23.2584,33.0508C 24.1051,33.2758 24.8017,33.6142 25.3484,34.0658C 25.8951,34.5175 26.2992,35.0808 26.5609,35.7558C 26.8226,36.4308 26.9534,37.22 26.9534,38.1233L 26.9534,49.0333L 23.6584,49.0333 Z M 23.1134,41.9934L 20.8284,41.9934C 20.1984,41.9934 19.6634,42.0575 19.2234,42.1859C 18.7834,42.3142 18.4259,42.4909 18.1509,42.7159C 17.8759,42.9409 17.6742,43.2009 17.5459,43.4959C 17.4176,43.7909 17.3534,44.1033 17.3534,44.4333C 17.3534,45.0967 17.5576,45.6025 17.9659,45.9509C 18.3742,46.2992 18.9317,46.4734 19.6384,46.4734C 20.1584,46.4734 20.6992,46.275 21.2609,45.8783C 21.8226,45.4817 22.4401,44.915 23.1134,44.1784L 23.1134,41.9934 Z M 40.0334,49.0333L 40.0334,38.5584C 40.0334,36.795 39.3751,35.9134 38.0584,35.9134C 37.4017,35.9134 36.7734,36.1775 36.1734,36.7059C 35.5734,37.2342 34.9401,37.9517 34.2734,38.8583L 34.2734,49.0333L 30.4334,49.0334L 30.4334,33.0334L 33.7584,33.0334L 33.8534,35.3934L 34.8734,34.2859C 35.2267,33.9542 35.6092,33.6717 36.0209,33.4384C 36.4326,33.205 36.8759,33.0259 37.3509,32.9009C 37.8259,32.7759 38.3584,32.7134 38.9484,32.7134C 39.7717,32.7134 40.4901,32.8467 41.1034,33.1134C 41.7167,33.38 42.2292,33.7575 42.6409,34.2459C 43.0526,34.7342 43.3609,35.3217 43.5659,36.0084C 43.7709,36.695 43.8734,37.4617 43.8734,38.3084L 43.8734,49.0333L 40.0334,49.0333 Z M 57.6534,49.0333L 57.5584,46.6883L 56.5159,47.7808C 56.1576,48.1092 55.7734,48.3892 55.3634,48.6208C 54.9534,48.8525 54.5142,49.0325 54.0459,49.1609C 53.5776,49.2892 53.0601,49.3533 52.4934,49.3533C 51.5467,49.3533 50.7051,49.1642 49.9684,48.7859C 49.2317,48.4075 48.6134,47.87 48.1134,47.1733C 47.6134,46.4767 47.2317,45.6292 46.9684,44.6309C 46.7051,43.6325 46.5734,42.52 46.5734,41.2933C 46.5734,39.8233 46.7809,38.5508 47.1959,37.4758C 47.6109,36.4008 48.1867,35.5092 48.9234,34.8008C 49.6601,34.0925 50.5342,33.5675 51.5459,33.2259C 52.5576,32.8842 53.6567,32.7134 54.8434,32.7134L 56.0509,32.7909L 57.1334,32.9934L 57.1334,26.9534L 60.9734,26.9534L 60.9734,49.0333L 57.6534,49.0333 Z M 50.7334,41.0983C 50.7334,42.0017 50.7926,42.7725 50.9109,43.4108C 51.0292,44.0492 51.2051,44.5717 51.4384,44.9783C 51.6717,45.385 51.9584,45.6825 52.2984,45.8708C 52.6384,46.0592 53.0251,46.1534 53.4584,46.1534C 54.1017,46.1534 54.7126,45.885 55.2909,45.3484C 55.8692,44.8117 56.4834,44.0767 57.1334,43.1433L 57.1334,35.9933L 56.0259,35.7059L 54.6984,35.5933C 54.0917,35.5933 53.5451,35.7225 53.0584,35.9809C 52.5717,36.2392 52.1559,36.6042 51.8109,37.0758C 51.4659,37.5475 51.2001,38.1242 51.0134,38.8059C 50.8267,39.4875 50.7334,40.2517 50.7334,41.0983 Z M 36,60L 36,63L 33,63L 33,67L 36,67L 36,70L 40,70L 40,67L 43,67L 43,63L 40,63L 40,60L 36,60 Z M 38,73C 25.6744,73 14.8369,66.6288 8.60116,57L 67.3988,57C 61.1631,66.6288 50.3256,73 38,73 Z " ></Path>
|
||||
</Button>
|
||||
<Button Margin="5" ToolTip="顺序控制图" Command="{Binding NewCommand}" CommandParameter="SFC" Width="80" Height="80" Foreground="{DynamicResource BlackBrush}" Background="{DynamicResource WhiteBrush}" BorderBrush="{DynamicResource BlackBrush}">
|
||||
<Path Stretch="Fill" Margin="20" Fill="{DynamicResource GrayBrush2}" Data="M10.984 13.836a.5.5 0 0 1-.353-.146l-.745-.743a.5.5 0 1 1 .706-.708l.392.391 1.181-1.18a.5.5 0 0 1 .708.707l-1.535 1.533a.504.504 0 0 1-.354.146zm9.353-.147l1.534-1.532a.5.5 0 0 0-.707-.707l-1.181 1.18-.392-.391a.5.5 0 1 0-.706.708l.746.743a.497.497 0 0 0 .706-.001zM4.527 7.452l2.557-1.585A1 1 0 0 0 7.09 4.17L4.533 2.56A1 1 0 0 0 3 3.406v3.196a1.001 1.001 0 0 0 1.527.85zm2.03-2.436L4 6.602V3.406l2.557 1.61zM24 12.5c0 1.93-1.57 3.5-3.5 3.5a3.503 3.503 0 0 1-3.46-3h-2.08a3.503 3.503 0 0 1-3.46 3 3.502 3.502 0 0 1-3.46-3h-.558c-.972 0-1.85-.399-2.482-1.042V17c0 1.654 1.346 3 3 3h.04c.244-1.693 1.7-3 3.46-3 1.93 0 3.5 1.57 3.5 3.5S13.43 24 11.5 24a3.502 3.502 0 0 1-3.46-3H8c-2.206 0-4-1.794-4-4V9.899A5.008 5.008 0 0 1 0 5c0-2.757 2.243-5 5-5s5 2.243 5 5a5.005 5.005 0 0 1-4.952 4.998A2.482 2.482 0 0 0 7.482 12h.558c.244-1.693 1.7-3 3.46-3a3.502 3.502 0 0 1 3.46 3h2.08a3.503 3.503 0 0 1 3.46-3c1.93 0 3.5 1.57 3.5 3.5zm-15 8c0 1.378 1.122 2.5 2.5 2.5s2.5-1.122 2.5-2.5-1.122-2.5-2.5-2.5S9 19.122 9 20.5zM5 9c2.206 0 4-1.794 4-4S7.206 1 5 1 1 2.794 1 5s1.794 4 4 4zm9 3.5c0-1.378-1.122-2.5-2.5-2.5S9 11.122 9 12.5s1.122 2.5 2.5 2.5 2.5-1.122 2.5-2.5zm9 0c0-1.378-1.122-2.5-2.5-2.5S18 11.122 18 12.5s1.122 2.5 2.5 2.5 2.5-1.122 2.5-2.5zm-13 8a.5.5 0 1 0 1 0 .5.5 0 0 0-1 0zm2 0a.5.5 0 1 0 1 0 .5.5 0 0 0-1 0zm12 0c0 1.93-1.57 3.5-3.5 3.5a3.503 3.503 0 0 1-3.46-3.002c-.007.001-.013.005-.021.005l-.506.017h-.017a.5.5 0 0 1-.016-.999l.506-.017c.018-.002.035.006.052.007A3.503 3.503 0 0 1 20.5 17c1.93 0 3.5 1.57 3.5 3.5zm-1 0c0-1.378-1.122-2.5-2.5-2.5S18 19.122 18 20.5s1.122 2.5 2.5 2.5 2.5-1.122 2.5-2.5z" ></Path>
|
||||
</Button>
|
||||
</WrapPanel>
|
||||
</TabItem>
|
||||
<TabItem Header="待续" />
|
||||
|
||||
@@ -40,10 +40,8 @@ namespace AIStudio.Wpf.ADiagram
|
||||
|
||||
protected override void OnPreviewKeyDown(KeyEventArgs e)
|
||||
{
|
||||
base.OnPreviewKeyDown(e);
|
||||
|
||||
MainWindowViewModel.KeyCommand.Execute(e.KeyboardDevice.Modifiers.ToString() + "+" + e.Key.ToString());
|
||||
}
|
||||
e.Handled = MainWindowViewModel.KeyExecuted(e.KeyboardDevice.Modifiers == ModifierKeys.None ? e.Key.ToString() : e.KeyboardDevice.Modifiers.ToString() + "+" + e.Key.ToString());
|
||||
}
|
||||
|
||||
private void HookEvents()
|
||||
{
|
||||
|
||||
@@ -16,8 +16,10 @@
|
||||
<ResourceDictionary>
|
||||
<conventer:StringPathConverter x:Key="stringPathConverter"/>
|
||||
<conventer:IntVisibilityConverter x:Key="IntVisibilityConverter"/>
|
||||
<dd:EnumDescriptionConverter x:Key="EnumDescriptionConverter"/>
|
||||
<command:CommandReference x:Key="DeleteItemCommandReference" Command="{Binding DeleteItemCommand}"/>
|
||||
|
||||
|
||||
<DataTemplate DataType="{x:Type model:ImageToolBoxData}">
|
||||
<Grid Width="{Binding Width}" Height="{Binding Height}">
|
||||
<Rectangle Name="Border"
|
||||
@@ -165,7 +167,7 @@
|
||||
Fill="Transparent"
|
||||
SnapsToDevicePixels="true"/>
|
||||
<Viewbox Stretch="Fill">
|
||||
<Grid>
|
||||
<Grid IsHitTestVisible="False">
|
||||
<ContentControl Style="{StaticResource CustomFlowNodeStyle}" Margin="2"/>
|
||||
<TextBlock Text="{Binding Text}" Margin="5" Foreground="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}" HorizontalAlignment="Left" />
|
||||
</Grid>
|
||||
@@ -178,14 +180,14 @@
|
||||
</DataTemplate.Triggers>
|
||||
</DataTemplate>
|
||||
<DataTemplate DataType="{x:Type model:SFCToolBoxData}">
|
||||
<Grid Width="{Binding Width}" Height="{Binding Height}">
|
||||
<Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Kind,Converter={StaticResource EnumDescriptionConverter}}">
|
||||
<Rectangle Name="Border"
|
||||
StrokeThickness="1"
|
||||
StrokeDashArray="2"
|
||||
Fill="Transparent"
|
||||
SnapsToDevicePixels="true"/>
|
||||
<Grid ToolTip="{Binding Text}">
|
||||
<ContentControl Style="{StaticResource CustomSFCNodeStyle}" Margin="2"/>
|
||||
<Grid IsHitTestVisible="False">
|
||||
<ContentControl Style="{StaticResource CustomSFCNodeStyle}" Margin="2" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
<DataTemplate.Triggers>
|
||||
|
||||
Reference in New Issue
Block a user