RecipeInfoEditor.xaml.cs 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  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 Aitex.UI.RecipeEditor.View
  15. {
  16. /// <summary>
  17. /// Interaction logic for RecipeInfoEditor.xaml
  18. /// </summary>
  19. public partial class RecipeInfoEditor : Window
  20. {
  21. public RecipeHead RecipeHead
  22. {
  23. get;
  24. set;
  25. }
  26. public RecipeInfoEditor()
  27. {
  28. InitializeComponent();
  29. //comboBox_PressureMode.Items.Add("TV");
  30. //comboBox_PressureMode.Items.Add("N2Flow");
  31. Loaded += new RoutedEventHandler(RecipeInfoEditor_Loaded);
  32. }
  33. void RecipeInfoEditor_Loaded(object sender, RoutedEventArgs e)
  34. {
  35. DataContext = RecipeHead;
  36. if (RecipeHead == null)
  37. pumpingPinState.SelectedIndex = -1;
  38. else
  39. pumpingPinState.SelectedIndex = RecipeHead.PumpingPinState == "Up" ? 0 : RecipeHead.PumpingPinState == "Down" ? 1 : -1;
  40. if (RecipeHead == null)
  41. PinStateAfterVent.SelectedIndex = -1;
  42. else
  43. {
  44. PinStateAfterVent.SelectedIndex = RecipeHead.PinStateAfterVent == "Up" ? 0 : RecipeHead.PinStateAfterVent == "Down" ? 1 : -1;
  45. pinDownPressure.Text = RecipeHead.PinDownPressure;
  46. }
  47. }
  48. private void Button_OK_Click(object sender, RoutedEventArgs e)
  49. {
  50. if (RecipeHead != null)
  51. {
  52. RecipeHead.Description = desc.Text;
  53. RecipeHead.BasePressure = basePressure.Text;
  54. RecipeHead.PumpDownLimit = pumpDownLimit.Text;
  55. RecipeHead.PurgeActive = (purgeActive.IsChecked.HasValue && purgeActive.IsChecked.Value) ? "true" : "false";
  56. RecipeHead.SubstrateTemp = substrateTemp.Text;
  57. RecipeHead.PumpingPinState = ((ComboBoxItem)pumpingPinState.SelectedItem).Content.ToString();
  58. RecipeHead.PinStateAfterVent = ((ComboBoxItem)PinStateAfterVent.SelectedItem).Content.ToString();
  59. RecipeHead.PinDownPressure = pinDownPressure.Text;
  60. }
  61. Close();
  62. }
  63. private void Button_Cancel_Click(object sender, RoutedEventArgs e)
  64. {
  65. Close();
  66. }
  67. private void OnPreviewTextInput(object sender, TextCompositionEventArgs e)
  68. {
  69. e.Handled = !IsTextAllowed(e.Text);
  70. }
  71. private static bool IsTextAllowed(string text)
  72. {
  73. Regex regex = new Regex("[^0-9.-]+"); //regex that matches disallowed text
  74. return !regex.IsMatch(text);
  75. }
  76. }
  77. }