123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- using MeterVision.Config;
- using Ookii.Dialogs.Wpf;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.ComponentModel;
- using System.IO;
- 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.Shapes;
- namespace MeterVision.Dlg
- {
- /// <summary>
- /// EditConfigDlg.xaml 的交互逻辑
- /// </summary>
- public partial class EditConfigDlg : Window, INotifyPropertyChanged
- {
- public event PropertyChangedEventHandler PropertyChanged;
- protected void OnPropertyChanged(string propertyName)
- {
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
- }
- public ObservableCollection<string> AiDlls { get; set; }
- public ObservableCollection<string> Onnxs { get; set; }
- public CfginiItem mConfigItem { get; set; }
- public EditConfigDlg()
- {
- InitializeComponent();
- mConfigItem = CfginiItem.GetConfigItem();
- FindFreeAIDllFiles();
- FindOnnxFiles();
- this.DataContext = this;
- }
- private void FindFreeAIDllFiles()
- {
- // 获取当前应用程序的 EXE 文件路径
- string exeDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
- // 使用通配符查询符合条件的 DLL 文件
- string[] files = Directory.GetFiles(exeDirectory, "*freeAI*.dll");
- if (AiDlls == null)
- {
- AiDlls = new ObservableCollection<string>();
- }
- else
- {
- AiDlls.Clear();
- }
- // 输出找到的所有文件
- foreach (var file in files)
- {
- //Console.WriteLine(file);
- // 获取文件名(包含扩展名)
- string fileNameWithExtension = Path.GetFileName(file);
- // 获取文件名(不包含扩展名)
- string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(file);
- AiDlls.Add(fileNameWithExtension);
- }
- }
- private void FindOnnxFiles()
- {
- // 获取当前应用程序的 EXE 文件路径
- string exeDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
- // 使用通配符查询符合条件的 DLL 文件
- string[] files = Directory.GetFiles(exeDirectory, "*.onnx");
- if (Onnxs == null)
- {
- Onnxs = new ObservableCollection<string>();
- }
- else
- {
- Onnxs.Clear();
- }
- // 输出找到的所有文件
- foreach (var file in files)
- {
- //Console.WriteLine(file);
- // 获取文件名(包含扩展名)
- string fileNameWithExtension = Path.GetFileName(file);
- // 获取文件名(不包含扩展名)
- string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(file);
- Onnxs.Add(fileNameWithExtension);
- }
- }
- private void BtnClose_Click(object sender, RoutedEventArgs e)
- {
- this.Close();
- }
- private void BtnDstImgPath_Click(object sender, RoutedEventArgs e)
- {
- var dialog = new VistaFolderBrowserDialog();
- //dialog.Description = "请选择目标图像输出文件夹";
- dialog.Description = "请选择识别数据输出文件夹";
- dialog.UseDescriptionForTitle = true; // 使用 Description 作为窗口标题
- // 显示对话框并检查用户是否点击了“确定”
- if (dialog.ShowDialog() == true)
- {
- // 获取用户选择的文件夹路径
- string selectedFolderPath = dialog.SelectedPath;
- mConfigItem.Output = selectedFolderPath;
- }
- }
- //---------------------------
- }
- }
|