AITMicrowaveSettingDialogView.xaml.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System;
  2. using System.Windows;
  3. using System.Windows.Controls;
  4. using System.Windows.Input;
  5. using Aitex.Core.Common.DeviceData;
  6. using Aitex.Core.RT.Log;
  7. namespace MECF.Framework.UI.Client.Ctrlib.UnitControls
  8. {
  9. /// <summary>
  10. /// InputFileNameDialogView.xaml 的交互逻辑
  11. /// </summary>
  12. public partial class AITMicrowaveSettingDialogView : UserControl
  13. {
  14. public AITMicrowaveSettingDialogView()
  15. {
  16. InitializeComponent();
  17. }
  18. private void InputTextBox_TextChanged(object sender, TextChangedEventArgs e)
  19. {
  20. double input;
  21. if (!double.TryParse(inputBox.Text, out input))
  22. (this.DataContext as AITMicrowaveSettingDialogViewModel).IsEnableOk = false;
  23. else if (input < 0 || input > (this.DataContext as AITMicrowaveSettingDialogViewModel).DeviceData.ScalePower)
  24. (this.DataContext as AITMicrowaveSettingDialogViewModel).IsEnableOk = false;
  25. else
  26. (this.DataContext as AITMicrowaveSettingDialogViewModel).IsEnableOk = true;
  27. inputBox.Foreground = (this.DataContext as AITMicrowaveSettingDialogViewModel).IsEnableOk ?
  28. System.Windows.Media.Brushes.Black : System.Windows.Media.Brushes.Red;
  29. }
  30. private void OnEnterKeyIsHit(object sender, KeyEventArgs e)
  31. {
  32. try
  33. {
  34. if (!(this.DataContext as AITMicrowaveSettingDialogViewModel).IsEnableOk) return;
  35. if (e.Key == Key.Return)
  36. {
  37. (this.DataContext as AITMicrowaveSettingDialogViewModel).SetPower();
  38. }
  39. }
  40. catch (Exception ex)
  41. {
  42. LOG.Error(ex.Message);
  43. }
  44. }
  45. }
  46. }