mirror of
https://gitee.com/wang-yin1/wpf-visual-process-framework
synced 2026-03-03 00:00:56 +08:00
添加项目文件。
This commit is contained in:
119
ImageCapture/FolderImageNode.xaml
Normal file
119
ImageCapture/FolderImageNode.xaml
Normal file
@@ -0,0 +1,119 @@
|
||||
<b:NodeBase x:Class="ImageCapture.FolderImageNode"
|
||||
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:ImageCapture"
|
||||
xmlns:b="clr-namespace:VisionFrame.Base;assembly=VisionFrame.Base"
|
||||
xmlns:c="clr-namespace:VisionFrame.Base.Converter;assembly=VisionFrame.Base"
|
||||
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="图像加载(F)" 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
ImageCapture/FolderImageNode.xaml.cs
Normal file
29
ImageCapture/FolderImageNode.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 ImageCapture
|
||||
{
|
||||
/// <summary>
|
||||
/// FolderImageNode.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class FolderImageNode : NodeBase
|
||||
{
|
||||
public FolderImageNode()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
80
ImageCapture/FolderImageNodeModel.cs
Normal file
80
ImageCapture/FolderImageNodeModel.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VisionFrame.Base;
|
||||
|
||||
namespace ImageCapture
|
||||
{
|
||||
/// <summary>
|
||||
/// 通信目录进行图像加载
|
||||
/// </summary>
|
||||
public class FolderImageNodeModel : NodeModelBase
|
||||
{
|
||||
public FolderImageNodeModel()
|
||||
{
|
||||
this.NodeName = "图像加载(F)";
|
||||
|
||||
this.Arguments.Add(new VisionFrame.Base.Models.NodeArgModel
|
||||
{
|
||||
ArgName = "图像目录",
|
||||
ArgType = "String",
|
||||
Direction = "输入",
|
||||
ValueMode = 2
|
||||
});
|
||||
this.Arguments.Add(new VisionFrame.Base.Models.NodeArgModel
|
||||
{
|
||||
ArgName = "图像Handle",
|
||||
ArgType = "IntPtr",
|
||||
Direction = "输出"
|
||||
});
|
||||
this.Arguments.Add(new VisionFrame.Base.Models.NodeArgModel
|
||||
{
|
||||
ArgName = "测试",
|
||||
ArgType = "IntPtr",
|
||||
Direction = "输出",
|
||||
ValueMode = 1
|
||||
});
|
||||
}
|
||||
int index = 0;
|
||||
public override void Execute(IFlowContext flowContext)
|
||||
{
|
||||
// 对接输入参数
|
||||
if (this.Arguments[0].ArgValue == null)
|
||||
throw new Exception("图像目录参数未配置");
|
||||
if (this.Arguments[1].ArgValue == null)
|
||||
throw new Exception("图像Handle参数未配置");
|
||||
|
||||
string folder = this.Arguments[0].ArgValue.ToString();
|
||||
|
||||
if (!Directory.Exists(folder))
|
||||
throw new Exception("图像目录未找到");
|
||||
|
||||
string[] files = Directory.GetFiles(folder, "*.bmp");
|
||||
if (files.Length == 0)
|
||||
throw new Exception("未发现图像文件");
|
||||
|
||||
IntPtr handle = new Bitmap(files[index]).GetHbitmap();
|
||||
|
||||
|
||||
// 对接输入参数 --- FlowTab中的参数名称
|
||||
//this.Arguments[1].ArgValue
|
||||
|
||||
var am = flowContext.ArgumentList
|
||||
.FirstOrDefault(a => a.ArgName == this.Arguments[1].ArgValue.ToString());
|
||||
|
||||
if (am.ArgType != this.Arguments[1].ArgType)
|
||||
throw new Exception("参数配置异常!类型不匹配");
|
||||
|
||||
am.Value = handle;
|
||||
|
||||
index++;
|
||||
if (index >= files.Length)
|
||||
index = 0;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
100
ImageCapture/HalconImageNode.xaml
Normal file
100
ImageCapture/HalconImageNode.xaml
Normal file
@@ -0,0 +1,100 @@
|
||||
<b:NodeBase x:Class="ImageCapture.HalconImageNode"
|
||||
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:ImageCapture"
|
||||
xmlns:b="clr-namespace:VisionFrame.Base;assembly=VisionFrame.Base"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="34" d:DesignWidth="140">
|
||||
<UserControl.Resources>
|
||||
<BooleanToVisibilityConverter x:Key="b2v"/>
|
||||
</UserControl.Resources>
|
||||
<Grid x: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="LawnGreen"/>
|
||||
</Border>
|
||||
|
||||
<TextBlock Text="图像采集(H)" Grid.Column="1"
|
||||
VerticalAlignment="Center" Margin="5,0"
|
||||
Foreground="#555"/>
|
||||
<TextBlock Text="0ms" 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}"/>
|
||||
</Grid>
|
||||
</b:NodeBase>
|
||||
30
ImageCapture/HalconImageNode.xaml.cs
Normal file
30
ImageCapture/HalconImageNode.xaml.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
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 ImageCapture
|
||||
{
|
||||
/// <summary>
|
||||
/// HalconImageNode.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class HalconImageNode : NodeBase
|
||||
{
|
||||
public HalconImageNode()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
17
ImageCapture/HalconImageNodeModel.cs
Normal file
17
ImageCapture/HalconImageNodeModel.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VisionFrame.Base;
|
||||
|
||||
namespace ImageCapture
|
||||
{
|
||||
public class HalconImageNodeModel : NodeModelBase
|
||||
{
|
||||
public override void Execute(IFlowContext flowContext)
|
||||
{
|
||||
base.Execute(flowContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
22
ImageCapture/ImageCapture.csproj
Normal file
22
ImageCapture/ImageCapture.csproj
Normal file
@@ -0,0 +1,22 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWPF>true</UseWPF>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="copy $(TargetPath) $(SolutionDir)VisionFrame\bin\Debug\net9.0-windows\Activities\$(TargetFileName) /y" />
|
||||
</Target>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.Drawing.Common" Version="9.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\VisionFrame.Base\VisionFrame.Base.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user