mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-04 16:16:34 +08:00
sfc实现中
This commit is contained in:
18
AIStudio.Wpf.SFC/ViewModels/SFCActionNode.cs
Normal file
18
AIStudio.Wpf.SFC/ViewModels/SFCActionNode.cs
Normal file
@@ -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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
18
AIStudio.Wpf.SFC/ViewModels/SFCCOBeginNode.cs
Normal file
18
AIStudio.Wpf.SFC/ViewModels/SFCCOBeginNode.cs
Normal file
@@ -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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
18
AIStudio.Wpf.SFC/ViewModels/SFCCOEndNode.cs
Normal file
18
AIStudio.Wpf.SFC/ViewModels/SFCCOEndNode.cs
Normal file
@@ -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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
18
AIStudio.Wpf.SFC/ViewModels/SFCConditionNode.cs
Normal file
18
AIStudio.Wpf.SFC/ViewModels/SFCConditionNode.cs
Normal file
@@ -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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
48
AIStudio.Wpf.SFC/ViewModels/SFCNode.cs
Normal file
48
AIStudio.Wpf.SFC/ViewModels/SFCNode.cs
Normal file
@@ -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; }
|
||||
}
|
||||
}
|
||||
99
AIStudio.Wpf.SFC/ViewModels/SFCNode.xaml
Normal file
99
AIStudio.Wpf.SFC/ViewModels/SFCNode.xaml
Normal file
@@ -0,0 +1,99 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:s="clr-namespace:Util.DiagramDesigner;assembly=Util.DiagramDesigner"
|
||||
xmlns:viewmodel="clr-namespace:AIStudio.Wpf.SFC.ViewModels"
|
||||
xmlns:converter="clr-namespace:AIStudio.Wpf.BaseDiagram.Converters;assembly=AIStudio.Wpf.BaseDiagram">
|
||||
|
||||
<s:ColorBrushConverter x:Key="ColorBrushConverter"/>
|
||||
|
||||
<ControlTemplate x:Key="StartStyle" TargetType="{x:Type ContentControl}">
|
||||
<Grid>
|
||||
<Border BorderThickness="1" BorderBrush="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}">
|
||||
<Border BorderThickness="1" Margin="3" BorderBrush="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}" Background="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}">
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
</Border>
|
||||
</Border>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
<ControlTemplate x:Key="NodeStyle" TargetType="{x:Type ContentControl}">
|
||||
<Grid>
|
||||
<Border BorderThickness="4" BorderBrush="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}" Background="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}">
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
<ControlTemplate x:Key="ConditionStyle" TargetType="{x:Type ContentControl}">
|
||||
<Grid>
|
||||
<Border BorderThickness="1" HorizontalAlignment="Center" BorderBrush="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}">
|
||||
</Border>
|
||||
<Border BorderThickness="1" VerticalAlignment="Center" BorderBrush="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}">
|
||||
</Border>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
<ControlTemplate x:Key="ActionStyle" TargetType="{x:Type ContentControl}">
|
||||
<Grid>
|
||||
<Border BorderThickness="1" BorderBrush="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}" Background="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}">
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
<ControlTemplate x:Key="COBeginStyle" TargetType="{x:Type ContentControl}">
|
||||
<Grid>
|
||||
<Border BorderThickness="0,1,0,1" BorderBrush="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}" Background="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}">
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
<ControlTemplate x:Key="COEndStyle" TargetType="{x:Type ContentControl}">
|
||||
<Grid>
|
||||
<Border BorderThickness="0,1,0,1" BorderBrush="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}" Background="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}">
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
<Style x:Key="CustomSFCNodeStyle" TargetType="{x:Type ContentControl}">
|
||||
<Setter Property="Template" Value="{StaticResource StartStyle}" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding Kind}" Value="Start">
|
||||
<Setter Property="Template" Value="{StaticResource StartStyle}" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Kind}" Value="Node">
|
||||
<Setter Property="Template" Value="{StaticResource NodeStyle}" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Kind}" Value="Condition">
|
||||
<Setter Property="Template" Value="{StaticResource ConditionStyle}" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Kind}" Value="Action">
|
||||
<Setter Property="Template" Value="{StaticResource ActionStyle}" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Kind}" Value="COBegin">
|
||||
<Setter Property="Template" Value="{StaticResource COBeginStyle}" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Kind}" Value="COEnd">
|
||||
<Setter Property="Template" Value="{StaticResource COEndStyle}" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<DataTemplate DataType="{x:Type viewmodel:SFCNode}">
|
||||
<Grid IsHitTestVisible="False">
|
||||
<ContentControl Style="{StaticResource CustomSFCNodeStyle}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ResourceDictionary>
|
||||
18
AIStudio.Wpf.SFC/ViewModels/SFCNodeNode.cs
Normal file
18
AIStudio.Wpf.SFC/ViewModels/SFCNodeNode.cs
Normal file
@@ -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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
18
AIStudio.Wpf.SFC/ViewModels/SFCStartNode.cs
Normal file
18
AIStudio.Wpf.SFC/ViewModels/SFCStartNode.cs
Normal file
@@ -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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user