CreateTestFolderWindow.xaml.cs 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using AIPlatform.Protocol.Entities;
  2. using System;
  3. using System.Windows;
  4. using System.Windows.Controls;
  5. namespace aipdev
  6. {
  7. /// <summary>
  8. /// Interaction logic for CreateTestFolderWindow.xaml
  9. /// </summary>
  10. public partial class CreateTestFolderWindow : Window
  11. {
  12. /// <summary>
  13. /// Gets the new folder name.
  14. /// </summary>
  15. public string NewFolderName { get; private set; }
  16. /// <summary>
  17. /// Gets the new folder description.
  18. /// </summary>
  19. public string NewFolderDescription { get; private set; }
  20. /// <summary>
  21. /// Gets the value that assign the image count from the source folder to the new folder
  22. /// </summary>
  23. public int AssignCount { get; private set; }
  24. /// <summary>
  25. /// Gets the value to indicate whether the folder is shared to other developers.
  26. /// </summary>
  27. public bool IsShared { get; private set; }
  28. /// <summary>
  29. /// Gets the folder's image count which to copy.
  30. /// </summary>
  31. private int SourceFolderImageCount { get; set; }
  32. public CreateTestFolderWindow(ImageFolder folder)
  33. {
  34. InitializeComponent();
  35. TestFolderName.Focus();
  36. SourceFolderImageCount = folder.ImageCount;
  37. }
  38. private void OnTestOkClick(object sender, RoutedEventArgs e)
  39. {
  40. if (string.IsNullOrWhiteSpace(TestFolderName.Text) || string.IsNullOrEmpty(TestFolderName.Text))
  41. {
  42. MessageBox.Show(this, "请填写文件夹名", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
  43. return;
  44. }
  45. if (string.IsNullOrWhiteSpace(TestFolderDesc.Text) || string.IsNullOrEmpty(TestFolderDesc.Text))
  46. {
  47. MessageBox.Show(this, "请填写文件夹描述", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
  48. return;
  49. }
  50. AssignCount = int.Parse(AssignTestImageCount.Text?.Trim() ?? "0");
  51. if (AssignCount == 0)
  52. {
  53. MessageBox.Show(this, "请填写要分配的图片数量", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
  54. return;
  55. }
  56. if (AssignCount > SourceFolderImageCount)
  57. {
  58. MessageBox.Show(this, $"要分配的图片数量超出,最大分配数量是{SourceFolderImageCount},请重新填写。", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
  59. return;
  60. }
  61. NewFolderName = TestFolderName.Text.Trim();
  62. NewFolderDescription = TestFolderDesc.Text.Trim();
  63. //IsShared = IsSharedTestCheckbox.IsChecked == null ? false : IsSharedTestCheckbox.IsChecked.Value;
  64. Close();
  65. }
  66. private void OnTestCancelClick(object sender, RoutedEventArgs e)
  67. {
  68. Close();
  69. }
  70. }
  71. }