添加项目文件。

This commit is contained in:
wang-yin1
2025-07-14 21:08:46 +08:00
parent f4133fc5e9
commit 6deb8d089f
58 changed files with 5593 additions and 0 deletions

View 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>
<ItemGroup>
<PackageReference Include="System.Drawing.Common" Version="9.0.0" />
</ItemGroup>
<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>

View File

@@ -0,0 +1,117 @@
<b:NodeBase x:Class="ImageProcess.ImageShowNode"
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:ImageProcess"
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 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="图像显示" 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="&#xe660;"
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="&#xe7db;"
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>

View File

@@ -0,0 +1,48 @@
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 ImageProcess
{
/// <summary>
/// ImageShowNode.xaml 的交互逻辑
/// </summary>
public partial class ImageShowNode : NodeBase
{
public ImageShowNode()
{
InitializeComponent();
}
//public ICommand AnchorDownCommand { get; set; }
//public ICommand AnchorUpCommand { get; set; }
private void Ellipse_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
this.AnchorDownCommand?.Execute(
(this.DataContext as NodeModelBase).NodeId + ";" + (sender as Ellipse).Tag.ToString()
);
e.Handled = true;
}
private void Ellipse_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
this.AnchorUpCommand?.Execute(
(this.DataContext as NodeModelBase).NodeId + ";" + (sender as Ellipse).Tag.ToString()
);
e.Handled = true;
}
}
}

View File

@@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VisionFrame.Base;
namespace ImageProcess
{
public class ImageShowNodeModel : NodeModelBase
{
public ImageShowNodeModel()
{
this.NodeName = "图像显示";
this.Arguments.Add(new VisionFrame.Base.Models.NodeArgModel
{
ArgName = "图像Handle",
ArgType = "IntPtr",
Direction = "输入",
ValueMode = 0
});
this.Arguments.Add(new VisionFrame.Base.Models.NodeArgModel
{
ArgName = "图像宽",
ArgType = "Int",
Direction = "输出",
ValueMode = 0
});
this.Arguments.Add(new VisionFrame.Base.Models.NodeArgModel
{
ArgName = "图像高",
ArgType = "Int",
Direction = "输出",
ValueMode = 0
});
}
public override void Execute(IFlowContext flowContext)
{
if (this.Arguments[0].ArgValue == null)
throw new Exception("图像Handle参数未配置");
var am = flowContext.ArgumentList
.FirstOrDefault(a => a.ArgName == this.Arguments[0].ArgValue.ToString());
if (am.ArgType != this.Arguments[0].ArgType)
throw new Exception("参数配置异常!类型不匹配");
if (IntPtr.TryParse(am.Value.ToString(), out IntPtr img_handler))
{
//
//Bitmap bitmap = Bitmap.FromHbitmap(img_handler);
//bitmap.Width
//bitmap.Height
flowContext.ShowImage(img_handler);
}
else
throw new Exception("图像Handle数据无效");
}
}
}