mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-05 16:56:34 +08:00
sfc界面处理完成,还差顺序逻辑控制过程
This commit is contained in:
@@ -9,10 +9,52 @@ namespace AIStudio.Wpf.SFC.ViewModels
|
||||
{
|
||||
public SFCActionNode() : base(SFCNodeKinds.Action)
|
||||
{
|
||||
FontViewModel.FontSize = 10;
|
||||
ItemWidth = 60;
|
||||
ItemHeight = 48;
|
||||
|
||||
ExecuteAddLeftInput(null);
|
||||
}
|
||||
|
||||
public SFCActionNode(IDiagramViewModel parent, DesignerItemBase designer) : base(parent, designer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private string _expression;
|
||||
public string Expression
|
||||
{
|
||||
get
|
||||
{
|
||||
return _expression;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _expression, value);
|
||||
}
|
||||
}
|
||||
|
||||
private LinkPoint _linkPoint;
|
||||
public LinkPoint LinkPoint
|
||||
{
|
||||
get
|
||||
{
|
||||
return _linkPoint;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _linkPoint, value);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void ExecuteEditCommand(object parameter)
|
||||
{
|
||||
SFCActionNodeData data = new SFCActionNodeData(LinkPoint, Expression);
|
||||
if (visualiserService.ShowDialog(data) == true)
|
||||
{
|
||||
this.LinkPoint = data.LinkPoint;
|
||||
this.Expression = data.Expression;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
53
AIStudio.Wpf.SFC/ViewModels/SFCActionNodeData.cs
Normal file
53
AIStudio.Wpf.SFC/ViewModels/SFCActionNodeData.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using AIStudio.Wpf.BaseDiagram.Commands;
|
||||
using AIStudio.Wpf.BaseDiagram.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows.Input;
|
||||
using Util.DiagramDesigner;
|
||||
|
||||
namespace AIStudio.Wpf.SFC.ViewModels
|
||||
{
|
||||
/// <summary>
|
||||
/// This is passed to the PopupWindow.xaml window, where a DataTemplate is used to provide the
|
||||
/// ContentControl with the look for this data. This class is also used to allow
|
||||
/// the popup to be cancelled without applying any changes to the calling ViewModel
|
||||
/// whos data will be updated if the PopupWindow.xaml window is closed successfully
|
||||
/// </summary>
|
||||
public class SFCActionNodeData : TitleBindableBase
|
||||
{
|
||||
public SFCActionNodeData(LinkPoint linkPoint, string expression)
|
||||
{
|
||||
Title = "输出动作";
|
||||
|
||||
LinkPoint = linkPoint;
|
||||
Expression = expression;
|
||||
}
|
||||
|
||||
private string _expression;
|
||||
public string Expression
|
||||
{
|
||||
get
|
||||
{
|
||||
return _expression;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _expression, value);
|
||||
}
|
||||
}
|
||||
|
||||
private LinkPoint _linkPoint;
|
||||
public LinkPoint LinkPoint
|
||||
{
|
||||
get
|
||||
{
|
||||
return _linkPoint;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _linkPoint, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,10 +9,37 @@ namespace AIStudio.Wpf.SFC.ViewModels
|
||||
{
|
||||
public SFCCOBeginNode() : base(SFCNodeKinds.COBegin)
|
||||
{
|
||||
ItemWidth = 280;
|
||||
ItemHeight = 10;
|
||||
|
||||
ExecuteAddTopInput(null);
|
||||
ExecuteAddBottomOutput(null);
|
||||
ExecuteAddBottomOutput(null);
|
||||
}
|
||||
|
||||
public SFCCOBeginNode(IDiagramViewModel parent, DesignerItemBase designer) : base(parent, designer)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ExecuteAddTopInput(object parameter)
|
||||
{
|
||||
FullyCreatedConnectorInfo connector = new FullyCreatedConnectorInfo(this, ConnectorOrientation.Top, true);
|
||||
connector.YRatio = 0;
|
||||
connector.XRatio = (40 + Input.Count * 200) / ItemWidth;
|
||||
Input.Add(Input.Count, connector);
|
||||
|
||||
AddConnector(connector);
|
||||
}
|
||||
|
||||
public override void ExecuteAddBottomOutput(object parameter)
|
||||
{
|
||||
FullyCreatedConnectorInfo connector = new FullyCreatedConnectorInfo(this, ConnectorOrientation.Bottom, true);
|
||||
connector.YRatio = 1;
|
||||
connector.XRatio = (40 + Output.Count * 200) / ItemWidth;
|
||||
Output.Add(Output.Count, connector);
|
||||
|
||||
|
||||
AddConnector(connector);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,10 +9,38 @@ namespace AIStudio.Wpf.SFC.ViewModels
|
||||
{
|
||||
public SFCCOEndNode() : base(SFCNodeKinds.COEnd)
|
||||
{
|
||||
ItemWidth = 280;
|
||||
ItemHeight = 10;
|
||||
|
||||
ExecuteAddBottomOutput(null);
|
||||
ExecuteAddTopInput(null);
|
||||
ExecuteAddTopInput(null);
|
||||
}
|
||||
|
||||
public SFCCOEndNode(IDiagramViewModel parent, DesignerItemBase designer) : base(parent, designer)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ExecuteAddTopInput(object parameter)
|
||||
{
|
||||
FullyCreatedConnectorInfo connector = new FullyCreatedConnectorInfo(this, ConnectorOrientation.Top, true);
|
||||
connector.YRatio = 0;
|
||||
connector.XRatio = (40 + Input.Count * 200) / ItemWidth;
|
||||
Input.Add(Input.Count, connector);
|
||||
|
||||
AddConnector(connector);
|
||||
}
|
||||
|
||||
public override void ExecuteAddBottomOutput(object parameter)
|
||||
{
|
||||
FullyCreatedConnectorInfo connector = new FullyCreatedConnectorInfo(this, ConnectorOrientation.Bottom, true);
|
||||
connector.YRatio = 1;
|
||||
connector.XRatio = (40 + Output.Count * 200) / ItemWidth;
|
||||
Output.Add(Output.Count, connector);
|
||||
|
||||
|
||||
AddConnector(connector);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Media;
|
||||
using Util.DiagramDesigner;
|
||||
|
||||
namespace AIStudio.Wpf.SFC.ViewModels
|
||||
@@ -9,10 +12,83 @@ namespace AIStudio.Wpf.SFC.ViewModels
|
||||
{
|
||||
public SFCConditionNode() : base(SFCNodeKinds.Condition)
|
||||
{
|
||||
ColorViewModel.LineColor.Color = Colors.Black;
|
||||
ItemWidth = 30;
|
||||
ItemHeight = 30;
|
||||
|
||||
ExecuteAddTopInput(null);
|
||||
ExecuteAddBottomOutput(null);
|
||||
}
|
||||
|
||||
public SFCConditionNode(IDiagramViewModel parent, DesignerItemBase designer) : base(parent, designer)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
base.Init();
|
||||
}
|
||||
|
||||
private bool _showText;
|
||||
public override bool ShowText
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _showText, value);
|
||||
}
|
||||
}
|
||||
|
||||
private string _expression;
|
||||
public string Expression
|
||||
{
|
||||
get
|
||||
{
|
||||
return _expression;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _expression, value);
|
||||
}
|
||||
}
|
||||
|
||||
private string _para;
|
||||
public string Para
|
||||
{
|
||||
get
|
||||
{
|
||||
return _para;
|
||||
}
|
||||
set
|
||||
{
|
||||
_para = value;
|
||||
}
|
||||
}
|
||||
|
||||
private ObservableCollection<LinkPoint> _linkPoint = new ObservableCollection<LinkPoint>();
|
||||
public ObservableCollection<LinkPoint> LinkPoint
|
||||
{
|
||||
get
|
||||
{
|
||||
return _linkPoint;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _linkPoint, value);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void ExecuteEditCommand(object parameter)
|
||||
{
|
||||
SFCConditionNodeData data = new SFCConditionNodeData(LinkPoint, Expression);
|
||||
if (visualiserService.ShowDialog(data) == true)
|
||||
{
|
||||
this.LinkPoint = new ObservableCollection<LinkPoint>(data.LinkPoint.Select(p => SFCService.LinkPoint.FirstOrDefault(q => q.Name == p.Name)));
|
||||
this.Expression = data.Expression;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
82
AIStudio.Wpf.SFC/ViewModels/SFCConditionNodeData.cs
Normal file
82
AIStudio.Wpf.SFC/ViewModels/SFCConditionNodeData.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using AIStudio.Wpf.BaseDiagram.Commands;
|
||||
using AIStudio.Wpf.BaseDiagram.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows.Input;
|
||||
using Util.DiagramDesigner;
|
||||
|
||||
namespace AIStudio.Wpf.SFC.ViewModels
|
||||
{
|
||||
/// <summary>
|
||||
/// This is passed to the PopupWindow.xaml window, where a DataTemplate is used to provide the
|
||||
/// ContentControl with the look for this data. This class is also used to allow
|
||||
/// the popup to be cancelled without applying any changes to the calling ViewModel
|
||||
/// whos data will be updated if the PopupWindow.xaml window is closed successfully
|
||||
/// </summary>
|
||||
public class SFCConditionNodeData : TitleBindableBase
|
||||
{
|
||||
public SFCConditionNodeData(IEnumerable<LinkPoint> linkPoint, string expression)
|
||||
{
|
||||
Title = "转移条件";
|
||||
LinkPoint = new ObservableCollection<LinkPoint>(linkPoint);
|
||||
Expression = expression;
|
||||
}
|
||||
|
||||
private string _expression;
|
||||
public string Expression
|
||||
{
|
||||
get
|
||||
{
|
||||
return _expression;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _expression, value);
|
||||
}
|
||||
}
|
||||
|
||||
private ObservableCollection<LinkPoint> _linkPoint;
|
||||
public ObservableCollection<LinkPoint> LinkPoint
|
||||
{
|
||||
get
|
||||
{
|
||||
return _linkPoint;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _linkPoint, value);
|
||||
}
|
||||
}
|
||||
|
||||
private ICommand _addCommand;
|
||||
public ICommand AddCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._addCommand ?? (this._addCommand = new DelegateCommand<object>(para => this.AddExecuted(para)));
|
||||
}
|
||||
}
|
||||
|
||||
private ICommand _deleteCommand;
|
||||
public ICommand DeleteCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._deleteCommand ?? (this._deleteCommand = new DelegateCommand<object>(para => this.DeleteExecuted(para)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void AddExecuted(object para)
|
||||
{
|
||||
LinkPoint.Add(new SFC.LinkPoint());
|
||||
}
|
||||
|
||||
private void DeleteExecuted(object para)
|
||||
{
|
||||
LinkPoint.Remove(para as SFC.LinkPoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Text;
|
||||
using System.Windows.Media;
|
||||
using Util.DiagramDesigner;
|
||||
|
||||
namespace AIStudio.Wpf.SFC.ViewModels
|
||||
@@ -14,10 +15,10 @@ namespace AIStudio.Wpf.SFC.ViewModels
|
||||
|
||||
public SFCNode(SFCNodeKinds kind) : base()
|
||||
{
|
||||
ColorViewModel.FillColor.Color = Colors.Blue;
|
||||
Kind = kind;
|
||||
ItemWidth = 80;
|
||||
ItemHeight = 40;
|
||||
|
||||
ItemHeight = 40;
|
||||
}
|
||||
|
||||
public SFCNode(IDiagramViewModel parent, DesignerItemBase designer) : base(parent, designer)
|
||||
@@ -27,14 +28,16 @@ namespace AIStudio.Wpf.SFC.ViewModels
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
base.Init();
|
||||
|
||||
IsRatioConnector = true;
|
||||
ShowRotate = false;
|
||||
ShowArrow = false;
|
||||
ShowText = true;
|
||||
IsReadOnlyText = true;
|
||||
|
||||
base.Init();
|
||||
|
||||
visualiserService = ApplicationServicesProvider.Instance.Provider.VisualizerService;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void LoadDesignerItemViewModel(IDiagramViewModel parent, SelectableDesignerItemBase designerbase)
|
||||
{
|
||||
@@ -42,7 +45,95 @@ namespace AIStudio.Wpf.SFC.ViewModels
|
||||
|
||||
}
|
||||
|
||||
protected override void InitConnector()
|
||||
{
|
||||
ClearConnectors();
|
||||
}
|
||||
|
||||
public Dictionary<int, FullyCreatedConnectorInfo> Input { get; set; } = new Dictionary<int, FullyCreatedConnectorInfo>();
|
||||
public Dictionary<int, FullyCreatedConnectorInfo> Output { get; set; } = new Dictionary<int, FullyCreatedConnectorInfo>();
|
||||
public Dictionary<int, FullyCreatedConnectorInfo> Action { get; set; } = new Dictionary<int, FullyCreatedConnectorInfo>();
|
||||
|
||||
public virtual void ExecuteAddLeftInput(object parameter)
|
||||
{
|
||||
FullyCreatedConnectorInfo connector = new FullyCreatedConnectorInfo(this, ConnectorOrientation.Left, true);
|
||||
connector.XRatio = 0;
|
||||
Input.Add(Input.Count, connector);
|
||||
for (int i = 0; i < Input.Values.Count; i++)
|
||||
{
|
||||
Input[i].YRatio = (i + 1.0) / (Input.Values.Count + 1.0);
|
||||
}
|
||||
AddConnector(connector);
|
||||
}
|
||||
|
||||
public virtual void ExecuteAddTopInput(object parameter)
|
||||
{
|
||||
FullyCreatedConnectorInfo connector = new FullyCreatedConnectorInfo(this, ConnectorOrientation.Top, true);
|
||||
connector.YRatio = 0;
|
||||
Input.Add(Input.Count, connector);
|
||||
for (int i = 0; i < Input.Values.Count; i++)
|
||||
{
|
||||
Input[i].XRatio = (i + 1.0) / (Input.Values.Count + 1.0);
|
||||
if (Output.ContainsKey(i))
|
||||
{
|
||||
Output[i].XRatio = Input[i].XRatio;
|
||||
}
|
||||
}
|
||||
AddConnector(connector);
|
||||
}
|
||||
|
||||
public virtual void ExecuteAddRightOutput(object parameter)
|
||||
{
|
||||
FullyCreatedConnectorInfo connector = new FullyCreatedConnectorInfo(this, ConnectorOrientation.Right, true);
|
||||
connector.XRatio = 1;
|
||||
Output.Add(Output.Count, connector);
|
||||
for (int i = 0; i < Output.Values.Count; i++)
|
||||
{
|
||||
Output[i].YRatio = (i + 1.0) / (Output.Values.Count + 1.0);
|
||||
}
|
||||
AddConnector(connector);
|
||||
}
|
||||
|
||||
public virtual void ExecuteAddBottomOutput(object parameter)
|
||||
{
|
||||
FullyCreatedConnectorInfo connector = new FullyCreatedConnectorInfo(this, ConnectorOrientation.Bottom, true);
|
||||
connector.YRatio = 1;
|
||||
Output.Add(Output.Count, connector);
|
||||
for (int i = 0; i < Output.Values.Count; i++)
|
||||
{
|
||||
Output[i].XRatio = (i + 1.0) / (Output.Values.Count + 1.0);
|
||||
if (Input.ContainsKey(i))
|
||||
{
|
||||
Input[i].XRatio = Output[i].XRatio;
|
||||
}
|
||||
}
|
||||
|
||||
AddConnector(connector);
|
||||
}
|
||||
|
||||
public virtual void ExecuteAddActionOutput(object parameter)
|
||||
{
|
||||
FullyCreatedConnectorInfo connector = new FullyCreatedConnectorInfo(this, ConnectorOrientation.Right, true);
|
||||
connector.XRatio = 1;
|
||||
Action.Add(Action.Count, connector);
|
||||
Action[Action.Count - 1].YRatio = 0.5;
|
||||
AddConnector(connector);
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public SFCNodeKinds Kind { get; set; }
|
||||
|
||||
private double _value;
|
||||
public double Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _value, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,15 @@
|
||||
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:local="clr-namespace:AIStudio.Wpf.SFC"
|
||||
xmlns:converter="clr-namespace:AIStudio.Wpf.BaseDiagram.Converters;assembly=AIStudio.Wpf.BaseDiagram">
|
||||
|
||||
<s:ColorBrushConverter x:Key="ColorBrushConverter"/>
|
||||
<converter:HalfConverter x:Key="HalfConverter"/>
|
||||
<converter:IntToBoolConverter x:Key="IntToBoolConverter"/>
|
||||
|
||||
<ControlTemplate x:Key="StartStyle" TargetType="{x:Type ContentControl}">
|
||||
<Grid>
|
||||
<Grid IsHitTestVisible="False">
|
||||
<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>
|
||||
@@ -19,37 +22,38 @@
|
||||
</ControlTemplate>
|
||||
|
||||
<ControlTemplate x:Key="NodeStyle" TargetType="{x:Type ContentControl}">
|
||||
<Grid>
|
||||
<Grid IsHitTestVisible="False">
|
||||
<Border BorderThickness="4" BorderBrush="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}" Background="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}">
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</ControlTemplate>
|
||||
|
||||
<ControlTemplate x:Key="ConditionStyle" TargetType="{x:Type ContentControl}">
|
||||
<Grid>
|
||||
<Grid IsHitTestVisible="False">
|
||||
<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>
|
||||
<TextBlock Text="{Binding Text}" RenderTransformOrigin="1,0.5" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="2">
|
||||
<TextBlock.RenderTransform>
|
||||
<TranslateTransform X="{Binding ItemWidth}"/>
|
||||
</TextBlock.RenderTransform>
|
||||
</TextBlock>
|
||||
</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 IsHitTestVisible="False">
|
||||
<Ellipse StrokeThickness="1" Stroke="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}" Fill="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}" />
|
||||
</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 IsHitTestVisible="False">
|
||||
<Border BorderThickness="0,2,0,2" BorderBrush="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}" Background="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}">
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
@@ -58,8 +62,8 @@
|
||||
</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 IsHitTestVisible="False">
|
||||
<Border BorderThickness="0,2,0,2" BorderBrush="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}" Background="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}">
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
@@ -67,6 +71,105 @@
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
<ControlTemplate x:Key="TankStyle" TargetType="{x:Type ContentControl}">
|
||||
<Grid IsHitTestVisible="False">
|
||||
<Rectangle RadiusX="5" RadiusY="5" StrokeThickness="1" Stroke="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}" Fill="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}" />
|
||||
<ProgressBar Orientation="Vertical" Foreground="Green" Background="Red" Value="{Binding LinkPoint.Value,FallbackValue=50}" Width="5" HorizontalAlignment="Right" Margin="5" Maximum="100" Minimum="0"/>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
<Style TargetType="{x:Type ToggleButton}" x:Key="SolenoidToggleButtonStyle">
|
||||
<Setter Property="Background" Value="Red"/>
|
||||
<Setter Property="SnapsToDevicePixels" Value="True" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ToggleButton}">
|
||||
<Grid x:Name="Grid" Margin="{TemplateBinding Padding}">
|
||||
<Path x:Name="path1" Data="M192 128l128 128-128 128z" Fill="Red" Stroke="Black" Stretch="Fill" Width="{Binding Path=ActualWidth, RelativeSource={RelativeSource Mode=TemplatedParent}, Converter={StaticResource HalfConverter}}" HorizontalAlignment="Left"/>
|
||||
<Path x:Name="path2" Data="M450 600L650 800V400z" Fill="Red" Stroke="Black" Stretch="Fill" Width="{Binding Path=ActualWidth, RelativeSource={RelativeSource Mode=TemplatedParent}, Converter={StaticResource HalfConverter}}" HorizontalAlignment="Right"/>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Foreground" Value="{DynamicResource GrayBrush8}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter Property="Foreground" Value="{DynamicResource Fluent.Ribbon.Brushes.HighlightBrush}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsChecked" Value="True">
|
||||
<Setter Property="Fill" TargetName="path1" Value="Green" />
|
||||
<Setter Property="Fill" TargetName="path2" Value="Green" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter Property="Opacity" Value="0.6" TargetName="Grid"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="{x:Type ToggleButton}" x:Key="StartToggleButtonStyle">
|
||||
<Setter Property="Background" Value="Red"/>
|
||||
<Setter Property="SnapsToDevicePixels" Value="True" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ToggleButton}">
|
||||
<Grid x:Name="Grid" Margin="{TemplateBinding Padding}" Background="{TemplateBinding Background}">
|
||||
<TextBlock x:Name="txt" Text="开始" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Foreground" Value="{DynamicResource GrayBrush8}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter Property="Foreground" Value="{DynamicResource Fluent.Ribbon.Brushes.HighlightBrush}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsChecked" Value="True">
|
||||
<Setter Property="Background" TargetName="Grid" Value="Green" />
|
||||
<Setter Property="Text" TargetName="txt" Value="停止" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter Property="Opacity" Value="0.6" TargetName="Grid"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<ControlTemplate x:Key="SolenoidStyle" TargetType="{x:Type ContentControl}">
|
||||
<Grid Margin="0,5">
|
||||
<ToggleButton Style="{StaticResource SolenoidToggleButtonStyle}" IsChecked="{Binding DOLinkPoint.Value, Converter={StaticResource IntToBoolConverter}}"/>
|
||||
<TextBlock Text="{Binding Text}" RenderTransformOrigin="0.5,1" TextWrapping="Wrap" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="2">
|
||||
<TextBlock.RenderTransform>
|
||||
<TranslateTransform Y="16"/>
|
||||
</TextBlock.RenderTransform>
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
<ControlTemplate x:Key="StartBtnStyle" TargetType="{x:Type ContentControl}">
|
||||
<Grid Margin="0,5">
|
||||
<ToggleButton Style="{StaticResource StartToggleButtonStyle}" IsChecked="{Binding LinkPoint.Value, Converter={StaticResource IntToBoolConverter}}"/>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
<ControlTemplate x:Key="ListStyle" TargetType="{x:Type ContentControl}">
|
||||
<Grid Margin="2">
|
||||
<ItemsControl ItemsSource="{x:Static local:SFCService.LinkPoint}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal" Margin="2">
|
||||
<TextBlock Text="{Binding Name}" Width="45" VerticalAlignment="Center" />
|
||||
<TextBlock Text="{Binding Despcription}" Width="60" VerticalAlignment="Center" />
|
||||
<TextBox Text="{Binding Value,Mode=TwoWay}" Width="50" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
<Style x:Key="CustomSFCNodeStyle" TargetType="{x:Type ContentControl}">
|
||||
<Setter Property="Template" Value="{StaticResource StartStyle}" />
|
||||
<Style.Triggers>
|
||||
@@ -88,12 +191,140 @@
|
||||
<DataTrigger Binding="{Binding Kind}" Value="COEnd">
|
||||
<Setter Property="Template" Value="{StaticResource COEndStyle}" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Kind}" Value="Simulate_Tank">
|
||||
<Setter Property="Template" Value="{StaticResource TankStyle}" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Kind}" Value="Simulate_Solenoid">
|
||||
<Setter Property="Template" Value="{StaticResource SolenoidStyle}" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Kind}" Value="Simulate_Start">
|
||||
<Setter Property="Template" Value="{StaticResource StartBtnStyle}" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Kind}" Value="Simulate_List">
|
||||
<Setter Property="Template" Value="{StaticResource ListStyle}" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<DataTemplate DataType="{x:Type viewmodel:SFCNode}">
|
||||
<Grid IsHitTestVisible="False">
|
||||
<Grid>
|
||||
<ContentControl Style="{StaticResource CustomSFCNodeStyle}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate DataType="{x:Type viewmodel:SFCConditionNodeData}">
|
||||
<Grid Background="{DynamicResource Fluent.Ribbon.Brushes.AccentBaseColorBrush}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Grid.Column="0"
|
||||
Content="条件"
|
||||
Margin="5" />
|
||||
<TextBox Grid.Column="1"
|
||||
Text="{Binding Expression}" VerticalAlignment="Center"
|
||||
Margin="2"
|
||||
FontSize="12"/>
|
||||
<StackPanel Grid.Column="0" Grid.Row="1" Orientation="Horizontal" VerticalAlignment="Top">
|
||||
<Label
|
||||
Content="绑定"
|
||||
Margin="5,5,0,5" />
|
||||
<Button Command="{Binding AddCommand}" Width="16" Height="16">
|
||||
<Path Stretch="Fill" Fill="Black" Data="M938.666667 426.666667h-341.333334V85.333333c0-46.933333-38.4-85.333333-85.333333-85.333333s-85.333333 38.4-85.333333 85.333333v341.333334H85.333333c-46.933333 0-85.333333 38.4-85.333333 85.333333s38.4 85.333333 85.333333 85.333333h341.333334v341.333334c0 46.933333 38.4 85.333333 85.333333 85.333333s85.333333-38.4 85.333333-85.333333v-341.333334h341.333334c46.933333 0 85.333333-38.4 85.333333-85.333333s-38.4-85.333333-85.333333-85.333333z"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Vertical" Grid.Column="1" Grid.Row="1" Margin="2">
|
||||
<ItemsControl
|
||||
ItemsSource="{Binding LinkPoint}" AlternationCount="{Binding LinkPoint.Count}" Background="{DynamicResource Fluent.Ribbon.Brushes.AccentBaseColorBrush}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<DockPanel Margin="2">
|
||||
<Button DockPanel.Dock="Right" Command="{Binding DataContext.DeleteCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ItemsControl}}}" CommandParameter="{Binding .}" Width="16" Height="16">
|
||||
<Path Stretch="Fill" Fill="Black" Data="M512 620.544l253.3376 253.3376a76.6976 76.6976 0 1 0 108.544-108.544L620.6464 512l253.2352-253.3376a76.6976 76.6976 0 1 0-108.544-108.544L512 403.3536 258.6624 150.1184a76.6976 76.6976 0 1 0-108.544 108.544L403.3536 512 150.1184 765.3376a76.6976 76.6976 0 1 0 108.544 108.544L512 620.6464z"/>
|
||||
</Button>
|
||||
<ComboBox SelectedValue="{Binding Name}" ItemsSource="{x:Static local:SFCService.LinkPoint}" VerticalAlignment="Center" SelectedValuePath="Name" DisplayMemberPath="Name" FontSize="12"/>
|
||||
</DockPanel>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate DataType="{x:Type viewmodel:SFCActionNodeData}">
|
||||
<Grid Background="{DynamicResource Fluent.Ribbon.Brushes.AccentBaseColorBrush}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Grid.Column="0"
|
||||
Content="结果"
|
||||
Margin="5" />
|
||||
<TextBox Grid.Column="1"
|
||||
Text="{Binding Expression}" VerticalAlignment="Center"
|
||||
Margin="2"
|
||||
FontSize="12"/>
|
||||
<Label Grid.Column="0" Grid.Row="1"
|
||||
Content="测点"
|
||||
Margin="5" />
|
||||
<ComboBox Grid.Column="1" Grid.Row="1"
|
||||
SelectedItem="{Binding LinkPoint}" ItemsSource="{x:Static local:SFCService.LinkPoint}" VerticalAlignment="Center" DisplayMemberPath="Name"
|
||||
Margin="5"
|
||||
FontSize="12"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate DataType="{x:Type viewmodel:Simulate_SolenoidViewModelData}">
|
||||
<Grid Background="{DynamicResource Fluent.Ribbon.Brushes.AccentBaseColorBrush}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Grid.Column="0"
|
||||
Content="输入"
|
||||
Margin="5" />
|
||||
<ComboBox Grid.Column="1" Grid.Row="0"
|
||||
SelectedItem="{Binding DILinkPoint}" ItemsSource="{x:Static local:SFCService.LinkPoint}" VerticalAlignment="Center" DisplayMemberPath="Name"
|
||||
Margin="5"
|
||||
FontSize="12"/>
|
||||
<Label Grid.Column="0"
|
||||
Grid.Row="1"
|
||||
Content="反馈"
|
||||
Margin="5" />
|
||||
<ComboBox Grid.Column="1" Grid.Row="1"
|
||||
SelectedItem="{Binding DOLinkPoint}" ItemsSource="{x:Static local:SFCService.LinkPoint}" VerticalAlignment="Center" DisplayMemberPath="Name"
|
||||
Margin="5"
|
||||
FontSize="12"/>
|
||||
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate DataType="{x:Type viewmodel:Simulate_TankViewModelData}">
|
||||
<Grid Background="{DynamicResource Fluent.Ribbon.Brushes.AccentBaseColorBrush}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Grid.Column="0"
|
||||
Content="液位"
|
||||
Margin="5" />
|
||||
<ComboBox Grid.Column="1" Grid.Row="0"
|
||||
SelectedItem="{Binding LinkPoint}" ItemsSource="{x:Static local:SFCService.LinkPoint}" VerticalAlignment="Center" DisplayMemberPath="Name"
|
||||
Margin="5"
|
||||
FontSize="12"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
</ResourceDictionary>
|
||||
@@ -9,10 +9,14 @@ namespace AIStudio.Wpf.SFC.ViewModels
|
||||
{
|
||||
public SFCNodeNode() : base(SFCNodeKinds.Node)
|
||||
{
|
||||
ExecuteAddTopInput(null);
|
||||
ExecuteAddBottomOutput(null);
|
||||
ExecuteAddActionOutput(null);
|
||||
}
|
||||
|
||||
public SFCNodeNode(IDiagramViewModel parent, DesignerItemBase designer) : base(parent, designer)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ namespace AIStudio.Wpf.SFC.ViewModels
|
||||
{
|
||||
public SFCStartNode() : base(SFCNodeKinds.Start)
|
||||
{
|
||||
ExecuteAddTopInput(null);
|
||||
ExecuteAddBottomOutput(null);
|
||||
}
|
||||
|
||||
public SFCStartNode(IDiagramViewModel parent, DesignerItemBase designer) : base(parent, designer)
|
||||
|
||||
22
AIStudio.Wpf.SFC/ViewModels/Simulate_ListViewModel.cs
Normal file
22
AIStudio.Wpf.SFC/ViewModels/Simulate_ListViewModel.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Text;
|
||||
using Util.DiagramDesigner;
|
||||
|
||||
namespace AIStudio.Wpf.SFC.ViewModels
|
||||
{
|
||||
public class Simulate_ListViewModel : SFCNode
|
||||
{
|
||||
public Simulate_ListViewModel() : base(SFCNodeKinds.Simulate_List)
|
||||
{
|
||||
ItemWidth = 170;
|
||||
ItemHeight = 260;
|
||||
}
|
||||
|
||||
public Simulate_ListViewModel(IDiagramViewModel parent, DesignerItemBase designer) : base(parent, designer)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
80
AIStudio.Wpf.SFC/ViewModels/Simulate_SolenoidViewModel.cs
Normal file
80
AIStudio.Wpf.SFC/ViewModels/Simulate_SolenoidViewModel.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Text;
|
||||
using Util.DiagramDesigner;
|
||||
|
||||
namespace AIStudio.Wpf.SFC.ViewModels
|
||||
{
|
||||
public class Simulate_SolenoidViewModel : SFCNode
|
||||
{
|
||||
public Simulate_SolenoidViewModel() : base(SFCNodeKinds.Simulate_Solenoid)
|
||||
{
|
||||
ItemWidth = 32;
|
||||
ItemHeight = 32;
|
||||
|
||||
ExecuteAddLeftInput(null);
|
||||
ExecuteAddRightOutput(null);
|
||||
}
|
||||
|
||||
public Simulate_SolenoidViewModel(IDiagramViewModel parent, DesignerItemBase designer) : base(parent, designer)
|
||||
{
|
||||
}
|
||||
|
||||
private bool _showText;
|
||||
public override bool ShowText
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _showText, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 输入
|
||||
/// </summary>
|
||||
private LinkPoint _dILinkPoint;
|
||||
public LinkPoint DILinkPoint
|
||||
{
|
||||
get
|
||||
{
|
||||
return _dILinkPoint;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _dILinkPoint, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 反馈
|
||||
/// </summary>
|
||||
private LinkPoint _dOLinkPoint;
|
||||
public LinkPoint DOLinkPoint
|
||||
{
|
||||
get
|
||||
{
|
||||
return _dOLinkPoint;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _dOLinkPoint, value);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void ExecuteEditCommand(object parameter)
|
||||
{
|
||||
Simulate_SolenoidViewModelData data = new Simulate_SolenoidViewModelData(DILinkPoint, DOLinkPoint);
|
||||
if (visualiserService.ShowDialog(data) == true)
|
||||
{
|
||||
this.DILinkPoint = data.DILinkPoint;
|
||||
this.DOLinkPoint = data.DOLinkPoint;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
using AIStudio.Wpf.BaseDiagram.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Util.DiagramDesigner;
|
||||
|
||||
namespace AIStudio.Wpf.SFC.ViewModels
|
||||
{
|
||||
public class Simulate_SolenoidViewModelData : TitleBindableBase
|
||||
{
|
||||
public Simulate_SolenoidViewModelData(LinkPoint dILinkPoint, LinkPoint dOLinkPoint)
|
||||
{
|
||||
Title = "阀门";
|
||||
DILinkPoint = dILinkPoint;
|
||||
DOLinkPoint = dOLinkPoint;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 输入
|
||||
/// </summary>
|
||||
private LinkPoint _dILinkPoint;
|
||||
public LinkPoint DILinkPoint
|
||||
{
|
||||
get
|
||||
{
|
||||
return _dILinkPoint;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _dILinkPoint, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 反馈
|
||||
/// </summary>
|
||||
private LinkPoint _dOLinkPoint;
|
||||
public LinkPoint DOLinkPoint
|
||||
{
|
||||
get
|
||||
{
|
||||
return _dOLinkPoint;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _dOLinkPoint, value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
37
AIStudio.Wpf.SFC/ViewModels/Simulate_StartViewModel.cs
Normal file
37
AIStudio.Wpf.SFC/ViewModels/Simulate_StartViewModel.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Util.DiagramDesigner;
|
||||
|
||||
namespace AIStudio.Wpf.SFC.ViewModels
|
||||
{
|
||||
public class Simulate_StartViewModel : SFCNode
|
||||
{
|
||||
public Simulate_StartViewModel() : base(SFCNodeKinds.Simulate_Start)
|
||||
{
|
||||
ItemWidth = 32;
|
||||
ItemHeight = 32;
|
||||
|
||||
ExecuteAddLeftInput(null);
|
||||
ExecuteAddRightOutput(null);
|
||||
}
|
||||
|
||||
public Simulate_StartViewModel(IDiagramViewModel parent, DesignerItemBase designer) : base(parent, designer)
|
||||
{
|
||||
}
|
||||
|
||||
private LinkPoint linkPoint;
|
||||
public LinkPoint LinkPoint
|
||||
{
|
||||
get
|
||||
{
|
||||
return linkPoint;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref linkPoint, value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
72
AIStudio.Wpf.SFC/ViewModels/Simulate_TankViewModel.cs
Normal file
72
AIStudio.Wpf.SFC/ViewModels/Simulate_TankViewModel.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Util.DiagramDesigner;
|
||||
|
||||
namespace AIStudio.Wpf.SFC.ViewModels
|
||||
{
|
||||
public class Simulate_TankViewModel : SFCNode
|
||||
{
|
||||
public Simulate_TankViewModel() : base(SFCNodeKinds.Simulate_Tank)
|
||||
{
|
||||
ItemWidth = 50;
|
||||
ItemHeight = 120;
|
||||
|
||||
ExecuteAddLeftInput(null);
|
||||
ExecuteAddLeftInput(null);
|
||||
ExecuteAddRightOutput(null);
|
||||
ExecuteAddRightOutput(null);
|
||||
}
|
||||
|
||||
public Simulate_TankViewModel(IDiagramViewModel parent, DesignerItemBase designer) : base(parent, designer)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ExecuteAddLeftInput(object parameter)
|
||||
{
|
||||
FullyCreatedConnectorInfo connector = new FullyCreatedConnectorInfo(this, ConnectorOrientation.Left, true);
|
||||
connector.XRatio = 0;
|
||||
connector.YRatio = (30 + Input.Count * 60) / ItemHeight;
|
||||
Input.Add(Input.Count, connector);
|
||||
|
||||
AddConnector(connector);
|
||||
}
|
||||
|
||||
public override void ExecuteAddRightOutput(object parameter)
|
||||
{
|
||||
FullyCreatedConnectorInfo connector = new FullyCreatedConnectorInfo(this, ConnectorOrientation.Right, true);
|
||||
connector.XRatio = 1;
|
||||
connector.YRatio = (30 + Output.Count * 60) / ItemHeight;
|
||||
Output.Add(Output.Count, connector);
|
||||
|
||||
|
||||
AddConnector(connector);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 液位
|
||||
/// </summary>
|
||||
private LinkPoint linkPoint;
|
||||
public LinkPoint LinkPoint
|
||||
{
|
||||
get
|
||||
{
|
||||
return linkPoint;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref linkPoint, value);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void ExecuteEditCommand(object parameter)
|
||||
{
|
||||
Simulate_TankViewModelData data = new Simulate_TankViewModelData(LinkPoint);
|
||||
if (visualiserService.ShowDialog(data) == true)
|
||||
{
|
||||
this.LinkPoint = data.LinkPoint;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
34
AIStudio.Wpf.SFC/ViewModels/Simulate_TankViewModelData.cs
Normal file
34
AIStudio.Wpf.SFC/ViewModels/Simulate_TankViewModelData.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using AIStudio.Wpf.BaseDiagram.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Util.DiagramDesigner;
|
||||
|
||||
namespace AIStudio.Wpf.SFC.ViewModels
|
||||
{
|
||||
public class Simulate_TankViewModelData : TitleBindableBase
|
||||
{
|
||||
public Simulate_TankViewModelData(LinkPoint linkPoint)
|
||||
{
|
||||
Title = "容器";
|
||||
LinkPoint = linkPoint;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 液位
|
||||
/// </summary>
|
||||
private LinkPoint linkPoint;
|
||||
public LinkPoint LinkPoint
|
||||
{
|
||||
get
|
||||
{
|
||||
return linkPoint;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref linkPoint, value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user