MfcSettingDialogView.xaml.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 MfcSettingDialogView : UserControl
  13. {
  14. public MfcSettingDialogView()
  15. {
  16. InitializeComponent();
  17. this.Loaded += MfcSettingDialogView_Loaded;
  18. }
  19. private void MfcSettingDialogView_Loaded(object sender, RoutedEventArgs e)
  20. {
  21. }
  22. private void InputTextBox_TextChanged(object sender, TextChangedEventArgs e)
  23. {
  24. double input;
  25. if (!double.TryParse(inputBox.Text, out input))
  26. (this.DataContext as MfcSettingDialogViewModel).IsEnableOk = false;
  27. else if (input < 0 || input > (this.DataContext as MfcSettingDialogViewModel).DeviceData.Scale)
  28. (this.DataContext as MfcSettingDialogViewModel).IsEnableOk = false;
  29. else
  30. (this.DataContext as MfcSettingDialogViewModel).IsEnableOk = true;
  31. inputBox.Foreground = (this.DataContext as MfcSettingDialogViewModel).IsEnableOk ?
  32. System.Windows.Media.Brushes.Black : System.Windows.Media.Brushes.Red;
  33. }
  34. private void OnEnterKeyIsHit(object sender, KeyEventArgs e)
  35. {
  36. try
  37. {
  38. if (!(this.DataContext as MfcSettingDialogViewModel).IsEnableOk) return;
  39. if (e.Key == Key.Return)
  40. {
  41. (this.DataContext as MfcSettingDialogViewModel).OK();
  42. }
  43. }
  44. catch (Exception ex)
  45. {
  46. LOG.Error(ex.Message);
  47. }
  48. }
  49. }
  50. }