diff --git a/AIStudio.Wpf.ADiagram/AIStudio.Wpf.ADiagram.csproj b/AIStudio.Wpf.ADiagram/AIStudio.Wpf.ADiagram.csproj index 4b1bde2..bfffb96 100644 --- a/AIStudio.Wpf.ADiagram/AIStudio.Wpf.ADiagram.csproj +++ b/AIStudio.Wpf.ADiagram/AIStudio.Wpf.ADiagram.csproj @@ -123,6 +123,7 @@ + diff --git a/AIStudio.Wpf.ADiagram/App.xaml b/AIStudio.Wpf.ADiagram/App.xaml index 967845d..fef22ed 100644 --- a/AIStudio.Wpf.ADiagram/App.xaml +++ b/AIStudio.Wpf.ADiagram/App.xaml @@ -11,6 +11,7 @@ + diff --git a/AIStudio.Wpf.ADiagram/Models/PathToolBoxData.cs b/AIStudio.Wpf.ADiagram/Models/PathToolBoxData.cs index 1016c6a..79992fb 100644 --- a/AIStudio.Wpf.ADiagram/Models/PathToolBoxData.cs +++ b/AIStudio.Wpf.ADiagram/Models/PathToolBoxData.cs @@ -1,4 +1,5 @@ using AIStudio.Wpf.Flowchart; +using AIStudio.Wpf.SFC; using System; using System.Windows.Media; using Util.DiagramDesigner; @@ -52,6 +53,17 @@ 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) + { + Kind = kind; + ColorViewModel.LineColor.Color = Colors.Black; + } + + } + public class DesignerItemToolBoxData : ToolBoxData { public string FileName { get; set; } diff --git a/AIStudio.Wpf.ADiagram/ViewModels/ToolBoxViewModel.cs b/AIStudio.Wpf.ADiagram/ViewModels/ToolBoxViewModel.cs index 57477e4..86652f4 100644 --- a/AIStudio.Wpf.ADiagram/ViewModels/ToolBoxViewModel.cs +++ b/AIStudio.Wpf.ADiagram/ViewModels/ToolBoxViewModel.cs @@ -13,6 +13,8 @@ using System.Linq; using System.Windows.Input; using Util.DiagramDesigner; using Util.DiagramDesigner.Helpers; +using AIStudio.Wpf.SFC; +using AIStudio.Wpf.SFC.ViewModels; namespace AIStudio.Wpf.ADiagram.ViewModels { @@ -177,6 +179,16 @@ namespace AIStudio.Wpf.ADiagram.ViewModels mediaToolBoxItems.Add(new MediaToolBoxData("../Images/SVG.png", typeof(SvgDesignerItemViewModel))); ToolBoxCategory.Add(new ToolBoxCategory() { Header = "媒体", ToolBoxItems = new ObservableCollection(mediaToolBoxItems) }); + List sfcToolBoxItems = new List(); + sfcToolBoxItems.Add(new SFCToolBoxData(SFCNodeKinds.Start, typeof(SFCStartNode), 32, 28)); + sfcToolBoxItems.Add(new SFCToolBoxData(SFCNodeKinds.Condition, typeof(SFCConditionNode), 32, 28)); + sfcToolBoxItems.Add(new SFCToolBoxData(SFCNodeKinds.Node, typeof(SFCNodeNode), 32, 28)); + 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)); + + ToolBoxCategory.Add(new ToolBoxCategory() { Header = "SFC顺序控制图", ToolBoxItems = new ObservableCollection(sfcToolBoxItems) }); + LoadMyItems(); LoadSvgItems(); } @@ -243,7 +255,7 @@ namespace AIStudio.Wpf.ADiagram.ViewModels DiagramItem diagramItem = new DiagramItem(); diagramItem.AddItems(new List { designer }); diagramDocument.DiagramItems.Add(diagramItem); - string newname = NewNameHelper.GetNewName(MyToolBoxCategory.ToolBoxItems.OfType().Select(p => Path.GetFileNameWithoutExtension(p.FileName)),""); + string newname = NewNameHelper.GetNewName(MyToolBoxCategory.ToolBoxItems.OfType().Select(p => Path.GetFileNameWithoutExtension(p.FileName)), ""); var filename = $"{_custom}\\{newname}.json"; File.WriteAllText(filename, JsonConvert.SerializeObject(diagramDocument)); diff --git a/AIStudio.Wpf.ADiagram/Views/ToolBoxControl.xaml b/AIStudio.Wpf.ADiagram/Views/ToolBoxControl.xaml index f4596b3..25b0ed1 100644 --- a/AIStudio.Wpf.ADiagram/Views/ToolBoxControl.xaml +++ b/AIStudio.Wpf.ADiagram/Views/ToolBoxControl.xaml @@ -177,7 +177,23 @@ - + + + + + + + + + + + + + + + + netcoreapp3.1 + true + + + + + + + + + + + diff --git a/AIStudio.Wpf.SFC/SFCNodeKinds.cs b/AIStudio.Wpf.SFC/SFCNodeKinds.cs new file mode 100644 index 0000000..2646e14 --- /dev/null +++ b/AIStudio.Wpf.SFC/SFCNodeKinds.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Text; + +namespace AIStudio.Wpf.SFC +{ + public enum SFCNodeKinds + { + [Description("开始")] + Start = 1, + [Description("节点")] + Node = 2, + [Description("转移条件")] + Condition = 3, + [Description("动作")] + Action = 4, + [Description("并行开始")] + COBegin = 5, + [Description("并行结束")] + COEnd = 6, + } +} diff --git a/AIStudio.Wpf.SFC/ViewModels/SFCActionNode.cs b/AIStudio.Wpf.SFC/ViewModels/SFCActionNode.cs new file mode 100644 index 0000000..ff687ea --- /dev/null +++ b/AIStudio.Wpf.SFC/ViewModels/SFCActionNode.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Util.DiagramDesigner; + +namespace AIStudio.Wpf.SFC.ViewModels +{ + public class SFCActionNode : SFCNode + { + public SFCActionNode() : base(SFCNodeKinds.Action) + { + } + + public SFCActionNode(IDiagramViewModel parent, DesignerItemBase designer) : base(parent, designer) + { + } + } +} diff --git a/AIStudio.Wpf.SFC/ViewModels/SFCCOBeginNode.cs b/AIStudio.Wpf.SFC/ViewModels/SFCCOBeginNode.cs new file mode 100644 index 0000000..7c52237 --- /dev/null +++ b/AIStudio.Wpf.SFC/ViewModels/SFCCOBeginNode.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Util.DiagramDesigner; + +namespace AIStudio.Wpf.SFC.ViewModels +{ + public class SFCCOBeginNode : SFCNode + { + public SFCCOBeginNode() : base(SFCNodeKinds.COBegin) + { + } + + public SFCCOBeginNode(IDiagramViewModel parent, DesignerItemBase designer) : base(parent, designer) + { + } + } +} diff --git a/AIStudio.Wpf.SFC/ViewModels/SFCCOEndNode.cs b/AIStudio.Wpf.SFC/ViewModels/SFCCOEndNode.cs new file mode 100644 index 0000000..573b849 --- /dev/null +++ b/AIStudio.Wpf.SFC/ViewModels/SFCCOEndNode.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Util.DiagramDesigner; + +namespace AIStudio.Wpf.SFC.ViewModels +{ + public class SFCCOEndNode : SFCNode + { + public SFCCOEndNode() : base(SFCNodeKinds.COEnd) + { + } + + public SFCCOEndNode(IDiagramViewModel parent, DesignerItemBase designer) : base(parent, designer) + { + } + } +} diff --git a/AIStudio.Wpf.SFC/ViewModels/SFCConditionNode.cs b/AIStudio.Wpf.SFC/ViewModels/SFCConditionNode.cs new file mode 100644 index 0000000..55b914f --- /dev/null +++ b/AIStudio.Wpf.SFC/ViewModels/SFCConditionNode.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Util.DiagramDesigner; + +namespace AIStudio.Wpf.SFC.ViewModels +{ + public class SFCConditionNode : SFCNode + { + public SFCConditionNode() : base(SFCNodeKinds.Condition) + { + } + + public SFCConditionNode(IDiagramViewModel parent, DesignerItemBase designer) : base(parent, designer) + { + } + } +} diff --git a/AIStudio.Wpf.SFC/ViewModels/SFCNode.cs b/AIStudio.Wpf.SFC/ViewModels/SFCNode.cs new file mode 100644 index 0000000..9d0331e --- /dev/null +++ b/AIStudio.Wpf.SFC/ViewModels/SFCNode.cs @@ -0,0 +1,48 @@ +using AIStudio.Wpf.BaseDiagram; +using AIStudio.Wpf.BaseDiagram.Services; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Text; +using Util.DiagramDesigner; + +namespace AIStudio.Wpf.SFC.ViewModels +{ + public class SFCNode : DesignerItemViewModelBase + { + protected IUIVisualizerService visualiserService; + + public SFCNode(SFCNodeKinds kind) : base() + { + Kind = kind; + ItemWidth = 80; + ItemHeight = 40; + + } + + public SFCNode(IDiagramViewModel parent, DesignerItemBase designer) : base(parent, designer) + { + + } + + protected override void Init() + { + base.Init(); + + ShowRotate = false; + ShowText = true; + IsReadOnlyText = true; + + visualiserService = ApplicationServicesProvider.Instance.Provider.VisualizerService; + } + + protected override void LoadDesignerItemViewModel(IDiagramViewModel parent, SelectableDesignerItemBase designerbase) + { + base.LoadDesignerItemViewModel(parent, designerbase); + + } + + [Browsable(false)] + public SFCNodeKinds Kind { get; set; } + } +} diff --git a/AIStudio.Wpf.SFC/ViewModels/SFCNode.xaml b/AIStudio.Wpf.SFC/ViewModels/SFCNode.xaml new file mode 100644 index 0000000..20a3c3b --- /dev/null +++ b/AIStudio.Wpf.SFC/ViewModels/SFCNode.xaml @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/AIStudio.Wpf.SFC/ViewModels/SFCNodeNode.cs b/AIStudio.Wpf.SFC/ViewModels/SFCNodeNode.cs new file mode 100644 index 0000000..2b88146 --- /dev/null +++ b/AIStudio.Wpf.SFC/ViewModels/SFCNodeNode.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Util.DiagramDesigner; + +namespace AIStudio.Wpf.SFC.ViewModels +{ + public class SFCNodeNode : SFCNode + { + public SFCNodeNode() : base(SFCNodeKinds.Node) + { + } + + public SFCNodeNode(IDiagramViewModel parent, DesignerItemBase designer) : base(parent, designer) + { + } + } +} diff --git a/AIStudio.Wpf.SFC/ViewModels/SFCStartNode.cs b/AIStudio.Wpf.SFC/ViewModels/SFCStartNode.cs new file mode 100644 index 0000000..db9f0ba --- /dev/null +++ b/AIStudio.Wpf.SFC/ViewModels/SFCStartNode.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Util.DiagramDesigner; + +namespace AIStudio.Wpf.SFC.ViewModels +{ + public class SFCStartNode : SFCNode + { + public SFCStartNode() : base(SFCNodeKinds.Start) + { + } + + public SFCStartNode(IDiagramViewModel parent, DesignerItemBase designer) : base(parent, designer) + { + } + } +}