using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; 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 DyeingComputer.Windows { /// /// ViewStep.xaml 的交互逻辑 /// public partial class ViewStep : Window { public ViewStep() { InitializeComponent(); Form1_Load(); } private void Tb_KeyPress(object sender, TextCompositionEventArgs e)//输入事件 { //Regex re = new Regex("[^0-9.-]+"); Regex re = new Regex(@"^[0-9]+(.[0-9]{1,3})?$");// 非零的正整数 e.Handled = !re.IsMatch(e.Text); } string[] a = {"001","007","008","013","017", "020", "022", "031", "035", "036", "039", "040", "041", "049", "050", "051", "054", "055", "056","065","066","067","090","091","092","093","094" }; private void Form1_Load() { this.boxID.Items.Add(Properties.Resources.TemperatureControl); this.boxID.Items.Add(Properties.Resources.AddWater + "(" + Properties.Resources.WaterLevel + ")"); this.boxID.Items.Add(Properties.Resources.AddWater + "(" + Properties.Resources.Flowmeter + ")"); this.boxID.Items.Add(Properties.Resources.Washing + "(" + Properties.Resources.WaterLevel + ")"); this.boxID.Items.Add(Properties.Resources.Washing + "(" + Properties.Resources.Cooling + ")"); this.boxID.Items.Add(Properties.Resources.Drainage); } private void TextBox_TextChanged(object sender, TextChangedEventArgs e) { int l = boxNAME.Text.Length; string text = boxNAME.Text.ToString(); if (l == 3) { boxID.SelectedIndex = Array.IndexOf(a, text); } } private void boxID_SelectionChanged(object sender, SelectionChangedEventArgs e) { } } }