RecipeInfoEditor.xaml.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. }
  37. private void Button_OK_Click(object sender, RoutedEventArgs e)
  38. {
  39. if (RecipeHead != null)
  40. {
  41. RecipeHead.Description = desc.Text;
  42. RecipeHead.BasePressure = basePressure.Text;
  43. RecipeHead.PumpDownLimit = pumpDownLimit.Text;
  44. RecipeHead.PurgeActive = (purgeActive.IsChecked.HasValue && purgeActive.IsChecked.Value) ? "true" : "false";
  45. RecipeHead.ElectrodeTemp = electrodeTemp.Text;
  46. }
  47. Close();
  48. }
  49. private void Button_Cancel_Click(object sender, RoutedEventArgs e)
  50. {
  51. Close();
  52. }
  53. private void OnPreviewTextInput(object sender, TextCompositionEventArgs e)
  54. {
  55. e.Handled = !IsTextAllowed(e.Text);
  56. }
  57. private static bool IsTextAllowed(string text)
  58. {
  59. Regex regex = new Regex("[^0-9.-]+"); //regex that matches disallowed text
  60. return !regex.IsMatch(text);
  61. }
  62. }
  63. }