RecipeNameDialog.xaml.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using Aitex.Core.UI.View.Common;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Text.RegularExpressions;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. using System.Windows.Documents;
  11. using System.Windows.Input;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. using System.Windows.Shapes;
  15. namespace Aitex.Sorter.UI.Views
  16. {
  17. /// <summary>
  18. /// RecipeNameDialog.xaml 的交互逻辑
  19. /// </summary>
  20. public partial class RecipeNameDialog : Window, IBaseView
  21. {
  22. public RecipeNameDialog(string name = null)
  23. {
  24. InitializeComponent();
  25. tbInput.Text = name;
  26. btnOk.IsEnabled = name != null;
  27. }
  28. private void tbInput_TextChanged(object sender, TextChangedEventArgs e)
  29. {
  30. btnOk.IsEnabled = IsValidFileName(tbInput.Text);
  31. }
  32. private void btnOk_Click(object sender, RoutedEventArgs e)
  33. {
  34. DialogResult = true;
  35. }
  36. private void btnCancel_Click(object sender, RoutedEventArgs e)
  37. {
  38. DialogResult = false;
  39. }
  40. public string RecipeName
  41. {
  42. get
  43. {
  44. return tbInput.Text.Trim();
  45. }
  46. }
  47. bool IsValidFileName(string strIn)
  48. {
  49. return !string.IsNullOrWhiteSpace(strIn);
  50. }
  51. }
  52. }