CustomValueWindow.xaml.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Shapes;
  14. namespace NEIntelligentControl2.Windows
  15. {
  16. /// <summary>
  17. /// 自定义挂牌内容输入窗口
  18. /// </summary>
  19. public partial class CustomValueWindow : Window
  20. {
  21. public string Value { get; set; }
  22. private string _Title = "[检修]";
  23. public CustomValueWindow()
  24. {
  25. InitializeComponent();
  26. }
  27. public static string ShowWindow()
  28. {
  29. CustomValueWindow cvw = new CustomValueWindow();
  30. cvw.Owner = Application.Current.MainWindow;
  31. var b = cvw.ShowDialog();
  32. if (b == true)
  33. {
  34. return cvw.Value;
  35. }
  36. return null;
  37. }
  38. private void Button_Click(object sender, RoutedEventArgs e)
  39. {
  40. switch (((Control)sender).Tag)
  41. {
  42. case "cancel":// 取消
  43. this.DialogResult = false;
  44. break;
  45. case "ok":// 确定
  46. this.Value = _Title + _TBMain.Text?.Trim();
  47. this.DialogResult = true;
  48. break;
  49. default:return;
  50. }
  51. }
  52. private void Window_Loaded(object sender, RoutedEventArgs e)
  53. {
  54. _TBMain.Focus();
  55. }
  56. private void RadioButton_Click(object sender, RoutedEventArgs e)
  57. {
  58. _Title = ((RadioButton)(sender)).Tag as string;
  59. }
  60. }
  61. }