| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 | using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Text.RegularExpressions;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Imaging;using System.Windows.Shapes;namespace Aitex.UI.RecipeEditor.View{    /// <summary>    /// Interaction logic for RecipeInfoEditor.xaml    /// </summary>    public partial class RecipeInfoEditor : Window    {        public RecipeHead RecipeHead        {            get;            set;        }        public RecipeInfoEditor()        {            InitializeComponent();            //comboBox_PressureMode.Items.Add("TV");            //comboBox_PressureMode.Items.Add("N2Flow");            Loaded += new RoutedEventHandler(RecipeInfoEditor_Loaded);        }        int GetPinIndex(string pos)        {            switch(pos)            {                case "Up":                    return 0;                case "Down":                    return 2;                case "Middle":                    return 1;                default:                    return -1;            }        }        void RecipeInfoEditor_Loaded(object sender, RoutedEventArgs e)        {            DataContext = RecipeHead;            if (RecipeHead == null)            {                pumpingPinState.SelectedIndex = -1;                ventingPinState.SelectedIndex = -1;            }            else            {                pumpingPinState.SelectedIndex = GetPinIndex(RecipeHead.PumpingPinState);                ventingPinState.SelectedIndex = GetPinIndex(RecipeHead.VentingPinState);                pinDownPressure.Text = RecipeHead.PinDownPressure;            }        }        private void Button_OK_Click(object sender, RoutedEventArgs e)        {            if (RecipeHead != null)            {                RecipeHead.Description = desc.Text;                RecipeHead.BasePressure = basePressure.Text;                RecipeHead.PumpDownLimit = pumpDownLimit.Text;                RecipeHead.PurgeActive = (purgeActive.IsChecked.HasValue && purgeActive.IsChecked.Value) ? "true" : "false";                RecipeHead.NotToPurgeOrVent = (notToPurgeOrVent.IsChecked.HasValue && notToPurgeOrVent.IsChecked.Value) ? "true" : "false";                RecipeHead.SubstrateTemp = substrateTemp.Text;                RecipeHead.PumpingPinState = ((ComboBoxItem)pumpingPinState.SelectedItem).Content.ToString();                RecipeHead.VentingPinState = ((ComboBoxItem)ventingPinState.SelectedItem).Content.ToString();                RecipeHead.PinDownPressure = pinDownPressure.Text;            }            Close();        }        private void Button_Cancel_Click(object sender, RoutedEventArgs e)        {            Close();        }        private void OnPreviewTextInput(object sender, TextCompositionEventArgs e)        {            e.Handled = !IsTextAllowed(e.Text);        }        private static bool IsTextAllowed(string text)        {            Regex regex = new Regex("[^0-9.-]+"); //regex that matches disallowed text            return !regex.IsMatch(text);        }    }}
 |