mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-28 04:03:23 +08:00
sfc实现中
This commit is contained in:
@@ -123,6 +123,7 @@
|
||||
<ProjectReference Include="..\AIStudio.Wpf.BaseDiagram\AIStudio.Wpf.BaseDiagram.csproj" />
|
||||
<ProjectReference Include="..\AIStudio.Wpf.Flowchart\AIStudio.Wpf.Flowchart.csproj" />
|
||||
<ProjectReference Include="..\AIStudio.Wpf.Logical\AIStudio.Wpf.Logical.csproj" />
|
||||
<ProjectReference Include="..\AIStudio.Wpf.SFC\AIStudio.Wpf.SFC.csproj" />
|
||||
<ProjectReference Include="..\Util.DiagramDesigner\Util.DiagramDesigner.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
<ResourceDictionary Source="/AIStudio.Wpf.ADiagram;component/Themes/Generic.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.Flowchart;component/ViewModels/FlowNode.xaml"/>
|
||||
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.Logical;component/ViewModels/LogicalGateItemViewModel.xaml"/>
|
||||
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.SFC;component/ViewModels/SFCNode.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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<ToolBoxData>(mediaToolBoxItems) });
|
||||
|
||||
List<ToolBoxData> sfcToolBoxItems = new List<ToolBoxData>();
|
||||
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<ToolBoxData>(sfcToolBoxItems) });
|
||||
|
||||
LoadMyItems();
|
||||
LoadSvgItems();
|
||||
}
|
||||
@@ -243,7 +255,7 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
|
||||
DiagramItem diagramItem = new DiagramItem();
|
||||
diagramItem.AddItems(new List<DesignerItemViewModelBase> { designer });
|
||||
diagramDocument.DiagramItems.Add(diagramItem);
|
||||
string newname = NewNameHelper.GetNewName(MyToolBoxCategory.ToolBoxItems.OfType<DesignerItemToolBoxData>().Select(p => Path.GetFileNameWithoutExtension(p.FileName)),"");
|
||||
string newname = NewNameHelper.GetNewName(MyToolBoxCategory.ToolBoxItems.OfType<DesignerItemToolBoxData>().Select(p => Path.GetFileNameWithoutExtension(p.FileName)), "");
|
||||
var filename = $"{_custom}\\{newname}.json";
|
||||
File.WriteAllText(filename, JsonConvert.SerializeObject(diagramDocument));
|
||||
|
||||
|
||||
@@ -177,7 +177,23 @@
|
||||
</Trigger>
|
||||
</DataTemplate.Triggers>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate DataType="{x:Type model:SFCToolBoxData}">
|
||||
<Grid Width="{Binding Width}" Height="{Binding Height}">
|
||||
<Rectangle Name="Border"
|
||||
StrokeThickness="1"
|
||||
StrokeDashArray="2"
|
||||
Fill="Transparent"
|
||||
SnapsToDevicePixels="true"/>
|
||||
<Grid ToolTip="{Binding Text}">
|
||||
<ContentControl Style="{StaticResource CustomSFCNodeStyle}" Margin="2"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<DataTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="true">
|
||||
<Setter TargetName="Border" Property="Stroke" Value="Gray"/>
|
||||
</Trigger>
|
||||
</DataTemplate.Triggers>
|
||||
</DataTemplate>
|
||||
<DataTemplate DataType="{x:Type viewmodels:ToolBoxCategory}">
|
||||
<Grid Visibility="{Binding IsChecked,Converter={StaticResource boolToVisibilityConverter}}">
|
||||
<Expander Header="{Binding Header}"
|
||||
|
||||
Reference in New Issue
Block a user