DlgSaveImagePath.xaml.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using MV485.helper;
  2. using Ookii.Dialogs.Wpf;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.IO;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows;
  10. using System.Windows.Controls;
  11. using System.Windows.Data;
  12. using System.Windows.Documents;
  13. using System.Windows.Input;
  14. using System.Windows.Media;
  15. using System.Windows.Media.Imaging;
  16. namespace MV485.Dlg
  17. {
  18. /// <summary>
  19. /// DlgSaveImagePath.xaml 的交互逻辑
  20. /// </summary>
  21. public partial class DlgSaveImagePath : Window
  22. {
  23. //默认的图像保存路径
  24. public static string DefaultImagePath =
  25. Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "wm_image");
  26. //private string _selectedSavePath = "";
  27. public DlgSaveImagePath()
  28. {
  29. InitializeComponent();
  30. //获取图像保存路径
  31. string savePath = ConfigManager.Instance.GetConfigValue(ConfigKey.SaveImagePath, DefaultImagePath);
  32. txtImagePath.Text = savePath;
  33. }
  34. private void BtnBrowser_Click(object sender, RoutedEventArgs e)
  35. {
  36. var dialog = new VistaFolderBrowserDialog();
  37. //dialog.Description = "请选择目标图像输出文件夹";
  38. dialog.Description = "请选择数据监听时图像数据的保存文件夹";
  39. dialog.UseDescriptionForTitle = true; // 使用 Description 作为窗口标题
  40. // 显示对话框并检查用户是否点击了“确定”
  41. if (dialog.ShowDialog() == true)
  42. {
  43. // 获取用户选择的文件夹路径
  44. string selectedFolderPath = dialog.SelectedPath;
  45. //mConfigItem.Output = selectedFolderPath;
  46. //_selectedSavePath = selectedFolderPath;
  47. txtImagePath.Text = selectedFolderPath;
  48. }
  49. }
  50. private void BtnOK_Click(object sender, RoutedEventArgs e)
  51. {
  52. if(string.IsNullOrEmpty(txtImagePath.Text))
  53. {
  54. MessageBox.Show("文件夹不能为空", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
  55. return;
  56. }
  57. ConfigManager.Instance.UpdateConfig(ConfigKey.SaveImagePath, txtImagePath.Text.Trim());
  58. DialogResult = true;
  59. this.Close();
  60. }
  61. private void BtnClose_Click(object sender, RoutedEventArgs e)
  62. {
  63. this.Close();
  64. }
  65. //-------------------------------------------------------
  66. }
  67. }