mirror of
https://gitee.com/wang-yin1/wpf-visual-process-framework
synced 2026-03-02 15:50:51 +08:00
添加项目文件。
This commit is contained in:
119
LogicControl/AddNode.xaml
Normal file
119
LogicControl/AddNode.xaml
Normal file
@@ -0,0 +1,119 @@
|
||||
<b:NodeBase x:Class="LogicControl.AddNode"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:b="clr-namespace:VisionFrame.Base;assembly=VisionFrame.Base"
|
||||
xmlns:c="clr-namespace:VisionFrame.Base.Converter;assembly=VisionFrame.Base"
|
||||
xmlns:local="clr-namespace:LogicControl"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="34" d:DesignWidth="140">
|
||||
<UserControl.Resources>
|
||||
<BooleanToVisibilityConverter x:Key="b2v"/>
|
||||
<c:BoolToBrushConverter x:Key="b2c"/>
|
||||
</UserControl.Resources>
|
||||
<Grid Name="grid">
|
||||
<!--选中状态提醒-->
|
||||
<Rectangle Stroke="#999" StrokeThickness="1"
|
||||
StrokeDashArray="3,5"
|
||||
Visibility="{Binding IsSelected,Converter={StaticResource b2v}}"/>
|
||||
<Border CornerRadius="6" Background="White" Margin="3"
|
||||
Visibility="{Binding IsSelected,Converter={StaticResource b2v}}">
|
||||
<Border.Effect>
|
||||
<DropShadowEffect BlurRadius="10"
|
||||
Color="Gray"
|
||||
ShadowDepth="0"
|
||||
Opacity="0.4"/>
|
||||
</Border.Effect>
|
||||
</Border>
|
||||
|
||||
|
||||
<Border CornerRadius="5" Background="White"
|
||||
Margin="3" BorderBrush="#771f71e5" BorderThickness="1">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="18"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border Background="#771f71e5" CornerRadius="4,0,0,4">
|
||||
<Ellipse Width="8" Height="8" Fill="{Binding IsRunning,Converter={StaticResource b2c}}"/>
|
||||
</Border>
|
||||
|
||||
<TextBlock Text="加法" Grid.Column="1"
|
||||
VerticalAlignment="Center" Margin="5,0"
|
||||
Foreground="#555"/>
|
||||
<TextBlock Text="{Binding Duration,StringFormat=\{0\}ms}" Grid.Column="1" FontSize="9"
|
||||
VerticalAlignment="Center" HorizontalAlignment="Right"
|
||||
Margin="5,0" Foreground="#888"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
|
||||
<Grid Visibility="{Binding ElementName=grid,Path=IsMouseOver,Converter={StaticResource b2v}}">
|
||||
<!--锚点对象-->
|
||||
<!--上-->
|
||||
<Ellipse Width="12" Height="12" Fill="#9FFF"
|
||||
VerticalAlignment="Top"
|
||||
Stroke="#CCC" StrokeThickness="1"
|
||||
Margin="0,-5,0,0"
|
||||
Visibility="{Binding ShowAnchorT,Converter={StaticResource b2v}}"
|
||||
MouseLeftButtonDown="Ellipse_MouseLeftButtonDown"
|
||||
MouseLeftButtonUp="Ellipse_MouseLeftButtonUp"
|
||||
Tag="T"/>
|
||||
<!--下-->
|
||||
<Ellipse Width="12" Height="12" Fill="#9FFF"
|
||||
VerticalAlignment="Bottom"
|
||||
Stroke="#CCC" StrokeThickness="1"
|
||||
Margin="0,0,0,-5"
|
||||
Visibility="{Binding ShowAnchorB,Converter={StaticResource b2v}}"
|
||||
MouseLeftButtonDown="Ellipse_MouseLeftButtonDown"
|
||||
MouseLeftButtonUp="Ellipse_MouseLeftButtonUp"
|
||||
Tag="B"/>
|
||||
<!--左-->
|
||||
<Ellipse Width="12" Height="12" Fill="#9FFF"
|
||||
HorizontalAlignment="Left"
|
||||
Stroke="#CCC" StrokeThickness="1"
|
||||
Margin="-5,0,0,0"
|
||||
Visibility="{Binding ShowAnchorL,Converter={StaticResource b2v}}"
|
||||
MouseLeftButtonDown="Ellipse_MouseLeftButtonDown"
|
||||
MouseLeftButtonUp="Ellipse_MouseLeftButtonUp"
|
||||
Tag="L"/>
|
||||
<!--右-->
|
||||
<Ellipse Width="12" Height="12" Fill="#9FFF"
|
||||
HorizontalAlignment="Right"
|
||||
Stroke="#CCC" StrokeThickness="1"
|
||||
Margin="0,0,-5,0"
|
||||
Visibility="{Binding ShowAnchorR,Converter={StaticResource b2v}}"
|
||||
MouseLeftButtonDown="Ellipse_MouseLeftButtonDown"
|
||||
MouseLeftButtonUp="Ellipse_MouseLeftButtonUp"
|
||||
Tag="R"/>
|
||||
</Grid>
|
||||
<Button Width="16" Height="16"
|
||||
HorizontalAlignment="Right"
|
||||
Content=""
|
||||
Margin="10,0"
|
||||
Background="#9F00"
|
||||
Foreground="#FFF"
|
||||
FontFamily="{DynamicResource Iconfont}"
|
||||
Style="{DynamicResource DeleteElementButtonStyle}"
|
||||
Visibility="{Binding ElementName=grid,
|
||||
Path=IsMouseOver,
|
||||
Converter={StaticResource b2v}}"
|
||||
Command="{Binding DataContext.DeleteElementCommand,RelativeSource={RelativeSource AncestorType=ItemsControl,Mode=FindAncestor}}"
|
||||
CommandParameter="{Binding}"/>
|
||||
<ToggleButton Width="16" Height="16"
|
||||
Tag="8"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="28,0"
|
||||
Content=""
|
||||
Foreground="White"
|
||||
Background="#156FEE"
|
||||
FontFamily="{DynamicResource Iconfont}"
|
||||
Style="{DynamicResource ElementArgsButtonStyle}"
|
||||
Visibility="{Binding ElementName=grid,
|
||||
Path=IsMouseOver,
|
||||
Converter={StaticResource b2v}}"
|
||||
IsChecked="{Binding IsShowProperties}"/>
|
||||
</Grid>
|
||||
</b:NodeBase>
|
||||
29
LogicControl/AddNode.xaml.cs
Normal file
29
LogicControl/AddNode.xaml.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using VisionFrame.Base;
|
||||
|
||||
namespace LogicControl
|
||||
{
|
||||
/// <summary>
|
||||
/// AddNode.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class AddNode : NodeBase
|
||||
{
|
||||
public AddNode()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
75
LogicControl/AddNodeModel.cs
Normal file
75
LogicControl/AddNodeModel.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VisionFrame.Base;
|
||||
|
||||
namespace LogicControl
|
||||
{
|
||||
public class AddNodeModel : NodeModelBase
|
||||
{
|
||||
public AddNodeModel()
|
||||
{
|
||||
this.Arguments.Add(new VisionFrame.Base.Models.NodeArgModel
|
||||
{
|
||||
ArgName = "加数",
|
||||
ArgType = "Any",
|
||||
Direction = "输入"
|
||||
});
|
||||
this.Arguments.Add(new VisionFrame.Base.Models.NodeArgModel
|
||||
{
|
||||
ArgName = "累加值",
|
||||
ArgType = "Any",
|
||||
Direction = "输入",
|
||||
ValueMode = 1
|
||||
});
|
||||
this.Arguments.Add(new VisionFrame.Base.Models.NodeArgModel
|
||||
{
|
||||
ArgName = "结果",
|
||||
ArgType = "Any",
|
||||
Direction = "输出"
|
||||
});
|
||||
}
|
||||
|
||||
public override void Execute(IFlowContext flowContext)
|
||||
{
|
||||
if (this.Arguments[0].ArgValue == null)
|
||||
throw new Exception("参数未配置");
|
||||
if (this.Arguments[1].ArgValue == null)
|
||||
throw new Exception("参数未配置");
|
||||
if (this.Arguments[2].ArgValue == null)
|
||||
throw new Exception("参数未配置");
|
||||
|
||||
|
||||
// 手动输入/下拉选择的差别处理
|
||||
string org_value = this.Arguments[0].ArgValue.ToString();
|
||||
if (this.Arguments[0].ValueMode == 0)
|
||||
{
|
||||
var am = flowContext.ArgumentList
|
||||
.FirstOrDefault(a => a.ArgName == this.Arguments[0].ArgValue.ToString());
|
||||
if (am != null)
|
||||
org_value = (am.Value ?? 0).ToString();
|
||||
}
|
||||
// 累加值
|
||||
string add_value = this.Arguments[1].ArgValue.ToString();
|
||||
if (this.Arguments[1].ValueMode == 0)
|
||||
{
|
||||
var am = flowContext.ArgumentList
|
||||
.FirstOrDefault(a => a.ArgName == this.Arguments[1].ArgValue.ToString());
|
||||
if (am != null)
|
||||
add_value = (am.Value ?? 0).ToString();
|
||||
}
|
||||
|
||||
// 加法结果
|
||||
string compare = org_value + "+" + add_value;
|
||||
object result = new DataTable().Compute(compare, "");
|
||||
|
||||
var rm = flowContext.ArgumentList
|
||||
.FirstOrDefault(a => a.ArgName == this.Arguments[2].ArgValue.ToString());
|
||||
if (rm != null)
|
||||
rm.Value = result;
|
||||
}
|
||||
}
|
||||
}
|
||||
88
LogicControl/DecisionNode.xaml
Normal file
88
LogicControl/DecisionNode.xaml
Normal file
@@ -0,0 +1,88 @@
|
||||
<b:NodeBase x:Class="LogicControl.DecisionNode"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:LogicControl"
|
||||
xmlns:b="clr-namespace:VisionFrame.Base;assembly=VisionFrame.Base"
|
||||
xmlns:c="clr-namespace:VisionFrame.Base.Converter;assembly=VisionFrame.Base"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="50" d:DesignWidth="100">
|
||||
<UserControl.Resources>
|
||||
<BooleanToVisibilityConverter x:Key="b2v"/>
|
||||
<c:BoolToBrushConverter x:Key="b2c"/>
|
||||
</UserControl.Resources>
|
||||
<Grid Name="grid">
|
||||
<!--选中状态提醒-->
|
||||
<Rectangle Stroke="#999" StrokeThickness="1"
|
||||
StrokeDashArray="3,5"
|
||||
Visibility="{Binding IsSelected,Converter={StaticResource b2v}}"/>
|
||||
<Path Data="M619.787898 44.781759l359.427055 359.500183a152.473125 152.473125 0 0 1 0 215.583104L619.787898 979.292101a152.473125 152.473125 0 0 1-215.656232 0L44.704611 619.791918a152.473125 152.473125 0 0 1 0-215.583104L404.204794 44.781759a152.473125 152.473125 0 0 1 215.656233 0z"
|
||||
Fill="#AA1f71e5" Stretch="Fill" Margin="3"
|
||||
Stroke="#1f71e5" StrokeThickness="1"/>
|
||||
<TextBlock Text="判断" VerticalAlignment="Center" HorizontalAlignment="Center"
|
||||
Foreground="#FFF"/>
|
||||
<TextBlock Text="F" FontSize="10" VerticalAlignment="Center" HorizontalAlignment="Left"
|
||||
Margin="15,0" Foreground="#FFF"/>
|
||||
<TextBlock Text="T" FontSize="10" VerticalAlignment="Center" HorizontalAlignment="Right"
|
||||
Margin="15,0" Foreground="#FFF"/>
|
||||
|
||||
|
||||
|
||||
<Grid Visibility="{Binding ElementName=grid,Path=IsMouseOver,Converter={StaticResource b2v}}">
|
||||
<!--锚点对象-->
|
||||
<!--上-->
|
||||
<Ellipse Width="12" Height="12" Fill="#9FFF"
|
||||
VerticalAlignment="Top"
|
||||
Stroke="#CCC" StrokeThickness="1"
|
||||
Margin="0,-5,0,0"
|
||||
Visibility="{Binding ShowAnchorT,Converter={StaticResource b2v}}"
|
||||
MouseLeftButtonUp="Ellipse_MouseLeftButtonUp"
|
||||
Tag="T"/>
|
||||
|
||||
<!--左-->
|
||||
<Ellipse Width="12" Height="12" Fill="#9FFF"
|
||||
HorizontalAlignment="Left"
|
||||
Stroke="#CCC" StrokeThickness="1"
|
||||
Margin="-5,0,0,0"
|
||||
Visibility="{Binding ShowAnchorL,Converter={StaticResource b2v}}"
|
||||
MouseLeftButtonDown="Ellipse_MouseLeftButtonDown"
|
||||
Tag="L;F"/>
|
||||
<!--右-->
|
||||
<Ellipse Width="12" Height="12" Fill="#9FFF"
|
||||
HorizontalAlignment="Right"
|
||||
Stroke="#CCC" StrokeThickness="1"
|
||||
Margin="0,0,-5,0"
|
||||
Visibility="{Binding ShowAnchorR,Converter={StaticResource b2v}}"
|
||||
MouseLeftButtonDown="Ellipse_MouseLeftButtonDown"
|
||||
Tag="R;T"/>
|
||||
</Grid>
|
||||
<Button Width="16" Height="16"
|
||||
HorizontalAlignment="Center" VerticalAlignment="Bottom"
|
||||
Content=""
|
||||
Margin="20,0,0,0"
|
||||
Background="#9F00"
|
||||
Foreground="#FFF"
|
||||
FontFamily="{DynamicResource Iconfont}"
|
||||
Style="{DynamicResource DeleteElementButtonStyle}"
|
||||
Visibility="{Binding ElementName=grid,
|
||||
Path=IsMouseOver,
|
||||
Converter={StaticResource b2v}}"
|
||||
Command="{Binding DataContext.DeleteElementCommand,RelativeSource={RelativeSource AncestorType=ItemsControl,Mode=FindAncestor}}"
|
||||
CommandParameter="{Binding}"/>
|
||||
<ToggleButton Width="16" Height="16"
|
||||
Tag="8"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="Center" VerticalAlignment="Bottom"
|
||||
Margin="0,0,20,0"
|
||||
Content=""
|
||||
Foreground="White"
|
||||
Background="#156FEE"
|
||||
FontFamily="{DynamicResource Iconfont}"
|
||||
Style="{DynamicResource ElementArgsButtonStyle}"
|
||||
Visibility="{Binding ElementName=grid,
|
||||
Path=IsMouseOver,
|
||||
Converter={StaticResource b2v}}"
|
||||
IsChecked="{Binding IsShowProperties}"/>
|
||||
</Grid>
|
||||
</b:NodeBase>
|
||||
29
LogicControl/DecisionNode.xaml.cs
Normal file
29
LogicControl/DecisionNode.xaml.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using VisionFrame.Base;
|
||||
|
||||
namespace LogicControl
|
||||
{
|
||||
/// <summary>
|
||||
/// DecisionNode.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class DecisionNode : NodeBase
|
||||
{
|
||||
public DecisionNode()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
68
LogicControl/DecisionNodeModel.cs
Normal file
68
LogicControl/DecisionNodeModel.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
|
||||
using System.Data;
|
||||
using VisionFrame.Base;
|
||||
|
||||
namespace LogicControl
|
||||
{
|
||||
public class DecisionNodeModel : DecisionNodeModelBase
|
||||
{
|
||||
public DecisionNodeModel()
|
||||
{
|
||||
// 某个变量值 == 什么值 > < >= <= != 关系运算符
|
||||
//
|
||||
this.Arguments.Add(new VisionFrame.Base.Models.NodeArgModel
|
||||
{
|
||||
ArgName = "判断目标",
|
||||
ArgType = "Any",
|
||||
Direction = "输入"
|
||||
});
|
||||
this.Arguments.Add(new VisionFrame.Base.Models.NodeArgModel
|
||||
{
|
||||
ArgName = "判断方式",
|
||||
ArgType = "String",
|
||||
Direction = "输入",
|
||||
ValueMode = 3
|
||||
});
|
||||
this.Arguments.Add(new VisionFrame.Base.Models.NodeArgModel
|
||||
{
|
||||
ArgName = "判断值",
|
||||
ArgType = "Any",
|
||||
Direction = "输入",
|
||||
ValueMode = 1
|
||||
});
|
||||
}
|
||||
public override bool Decision(IFlowContext context)
|
||||
{
|
||||
//int temp = 1;
|
||||
//return new DataTable().Compute("1<=2", "").ToString() == "True";
|
||||
|
||||
if (this.Arguments[0].ArgValue == null)
|
||||
throw new Exception("判断目标参数未配置");
|
||||
if (this.Arguments[1].ArgValue == null)
|
||||
throw new Exception("判断方式参数未配置");
|
||||
if (this.Arguments[2].ArgValue == null)
|
||||
throw new Exception("判断值参数未配置");
|
||||
|
||||
string org_value = "";
|
||||
var am = context.ArgumentList
|
||||
.FirstOrDefault(a => a.ArgName == this.Arguments[0].ArgValue.ToString());
|
||||
if (am != null)
|
||||
org_value = am.Value.ToString();
|
||||
|
||||
string value = this.Arguments[2].ArgValue.ToString();
|
||||
if (this.Arguments[2].ValueMode == 0)
|
||||
{
|
||||
am = context.ArgumentList
|
||||
.FirstOrDefault(a => a.ArgName == this.Arguments[0].ArgValue.ToString());
|
||||
if (am != null)
|
||||
value = am.Value.ToString();
|
||||
}
|
||||
|
||||
string compare = org_value + this.Arguments[1].ArgValue.ToString() + value;
|
||||
// "0x5235443==32432"
|
||||
// "1==2"
|
||||
return new DataTable().Compute(compare, "").ToString() == "True";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
18
LogicControl/LogicControl.csproj
Normal file
18
LogicControl/LogicControl.csproj
Normal file
@@ -0,0 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWPF>true</UseWPF>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\VisionFrame.Base\VisionFrame.Base.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="copy $(TargetPath) $(SolutionDir)VisionFrame\bin\Debug\net9.0-windows\Activities\$(TargetFileName) /y" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user