RecipeInfoEditor.xaml.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. int GetPinIndex(string pos)
  34. {
  35. switch(pos)
  36. {
  37. case "Up":
  38. return 0;
  39. case "Down":
  40. return 2;
  41. case "Middle":
  42. return 1;
  43. default:
  44. return -1;
  45. }
  46. }
  47. void RecipeInfoEditor_Loaded(object sender, RoutedEventArgs e)
  48. {
  49. DataContext = RecipeHead;
  50. if (RecipeHead == null)
  51. {
  52. pumpingPinState.SelectedIndex = -1;
  53. ventingPinState.SelectedIndex = -1;
  54. }
  55. else
  56. {
  57. pumpingPinState.SelectedIndex = GetPinIndex(RecipeHead.PumpingPinState);
  58. ventingPinState.SelectedIndex = GetPinIndex(RecipeHead.VentingPinState);
  59. pinDownPressure.Text = RecipeHead.PinDownPressure;
  60. }
  61. }
  62. private void Button_OK_Click(object sender, RoutedEventArgs e)
  63. {
  64. if (RecipeHead != null)
  65. {
  66. RecipeHead.Description = desc.Text;
  67. RecipeHead.BasePressure = basePressure.Text;
  68. RecipeHead.PumpDownLimit = pumpDownLimit.Text;
  69. RecipeHead.PurgeActive = (purgeActive.IsChecked.HasValue && purgeActive.IsChecked.Value) ? "true" : "false";
  70. RecipeHead.NotToPurgeOrVent = (notToPurgeOrVent.IsChecked.HasValue && notToPurgeOrVent.IsChecked.Value) ? "true" : "false";
  71. RecipeHead.SubstrateTemp = substrateTemp.Text;
  72. RecipeHead.PumpingPinState = ((ComboBoxItem)pumpingPinState.SelectedItem).Content.ToString();
  73. RecipeHead.VentingPinState = ((ComboBoxItem)ventingPinState.SelectedItem).Content.ToString();
  74. RecipeHead.PinDownPressure = pinDownPressure.Text;
  75. }
  76. Close();
  77. }
  78. private void Button_Cancel_Click(object sender, RoutedEventArgs e)
  79. {
  80. Close();
  81. }
  82. private void OnPreviewTextInput(object sender, TextCompositionEventArgs e)
  83. {
  84. e.Handled = !IsTextAllowed(e.Text);
  85. }
  86. private static bool IsTextAllowed(string text)
  87. {
  88. Regex regex = new Regex("[^0-9.-]+"); //regex that matches disallowed text
  89. return !regex.IsMatch(text);
  90. }
  91. }
  92. }