SelectLabelWindow.xaml.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System;
  2. using System.IO;
  3. using System.Windows;
  4. namespace AIPractice.LabellerServer.WPF
  5. {
  6. /// <summary>
  7. /// Interaction logic for SelectLabelWindow.xaml
  8. /// </summary>
  9. public partial class SelectLabelWindow : Window
  10. {
  11. public string SelectedLabel { get; private set; }
  12. public SelectLabelWindow()
  13. {
  14. InitializeComponent();
  15. SelectedLabel = null;
  16. var labelFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Database","SpecialLabels");
  17. if (Directory.Exists(labelFolder))
  18. {
  19. var labels = Directory.GetFiles(labelFolder, "*.lb", SearchOption.TopDirectoryOnly);
  20. foreach (var label in labels)
  21. {
  22. var fileName = Path.GetFileName(label);
  23. LabelList.Items.Add(fileName);
  24. }
  25. }
  26. }
  27. private void OnOkClick(object sender, RoutedEventArgs e)
  28. {
  29. if (LabelList.SelectedIndex != -1)
  30. {
  31. SelectedLabel = LabelList.SelectedItem.ToString();
  32. Close();
  33. }
  34. else
  35. {
  36. MessageBox.Show("请选择一个标签", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
  37. }
  38. }
  39. private void OnCloseClick(object sender, RoutedEventArgs e)
  40. {
  41. Close();
  42. }
  43. }
  44. }