目录
- 前言
- .net core 8.0
- .net core 8.0新功能,打开文件夹和打开文件
- HSmartWindowControlWPF
- System.Drawing.Common
- 重置拉伸
- 关闭拖拽和缩放
- 文件导出
前言
这里补充一下Halcon导入到WPF的要求
.net core 8.0
Halcon是支持.net core 8.0导入的
.net core 8.0新功能,打开文件夹和打开文件
[RelayCommand]
public void SelectFile()
{MsgHelper.Info("选择文件路径");var dialog = new Microsoft.Win32.OpenFileDialog();dialog.Title = "选择文件路径"; // Default file name// Show open file dialog boxbool? result = dialog.ShowDialog();// Process open file dialog box resultsif (result == true){// Open documentstring filename = dialog.FileName;MsgHelper.Success($"选择文件路径:{filename}");}
}[RelayCommand]
public void SelectFolder()
{MsgHelper.Info("选择文件夹路径");var dialog = new Microsoft.Win32.OpenFolderDialog();dialog.Title = "选择文件夹路径"; // Default file name// Show open file dialog boxbool? result = dialog.ShowDialog();// Process open file dialog box resultsif (result == true){// Open documentstring filename = dialog.FolderName;MsgHelper.Success($"选择文件路径:{filename}");}
}
HSmartWindowControlWPF
System.Drawing.Common
Halcon需要系统绘制DLL,需要nuget库导入
重置拉伸
[RelayCommand]public void ReadImg(){var imageUrl = "D:/workspace/program/Halcon/Images/A.png";MsgHelper.Info($"读取图片,图片路径{imageUrl}");HImage.ReadImage(imageUrl);HSmart.HalconWindow.DispObj(HImage);//图片适应阶段HSmart.SetFullImagePart();}
关闭拖拽和缩放
<!--为了防止拖拽和缩放,这里可以关掉-->
<halcon:HSmartWindowControlWPF Grid.Row="1"x:Name="HSmart"HMoveContent="False"HZoomContent="Off"HDoubleClickToFitContent="False" />
文件导出
- HOperatorSet.WriteImage:图片导出
- HOperatorSet.WriteShapeModel:模板导出