using BPASmartClient.Helper; using FryPot_DosingSystem.Model; using FryPot_DosingSystem.ViewModel; 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 FryPot_DosingSystem.View { /// /// FlowProcessView.xaml 的交互逻辑 /// public partial class FlowProcessView : Window { public FlowProcessView() { InitializeComponent(); this.br.MouseLeftButtonDown += (o, e) => { if (e.LeftButton == MouseButtonState.Pressed) this.DragMove(); }; ActionManage.GetInstance.CancelRegister("CloseFlowProcessView"); ActionManage.GetInstance.Register(new Action(() => { this.Close(); }), "CloseFlowProcessView"); } private void Label_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { Label txt = sender as Label; if (txt != null) { StackPanel oldSp = FindFirstVisualChild(itemcontrols, "stk"); if (oldSp != null) oldSp.Background = new SolidColorBrush(Color.FromRgb(38, 76, 115)); StackPanel sp = VisualTreeHelper.GetParent(txt) as StackPanel; sp.Background = new SolidColorBrush(Color.FromRgb(8, 20, 36)); ActionManage.GetInstance.Send("CurrentItemId", txt.Content); } } public StackPanel FindFirstVisualChild(DependencyObject obj, string childName) { for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++) { DependencyObject child = VisualTreeHelper.GetChild(obj, i); if (child != null && child is StackPanel && child.GetValue(NameProperty).ToString() == childName) { if (child is StackPanel stack && stack.Background?.ToString() == "#FF081424") return stack; } else { StackPanel SP = FindFirstVisualChild(child, childName); if (SP != null) { return SP; } } } return null; } private void Button_Click(object sender, RoutedEventArgs e) { NewFryPotMaterial win = new NewFryPotMaterial(); win.Show(); } public string TextLimit(string str) { if (Regex.IsMatch(str, @"^\d+$"))//非负整数 非零正整数^\+?[1-9][0-9]*$ { return str; } else { return string.Empty; } } /// /// 文本输入做限定 /// /// /// private void TextBox_TextChanged(object sender, TextChangedEventArgs e) { if (sender is TextBox txt) { txt.Text = TextLimit(txt.Text); } } private void TextBox_TextChanged_1(object sender, TextChangedEventArgs e) { if (sender is TextBox txt) { txt.Text = TextLimit(txt.Text); } } private void TextBox_TextChanged_2(object sender, TextChangedEventArgs e) { if (sender is TextBox txt) { txt.Text = TextLimit(txt.Text); } } private void TextBox_TextChanged_3(object sender, TextChangedEventArgs e) { if (sender is TextBox txt) { txt.Text = TextLimit(txt.Text); } } private void TextBox_TextChanged_4(object sender, TextChangedEventArgs e) { if (sender is TextBox txt) { txt.Text = TextLimit(txt.Text); } } private void TextBox_TextChanged_5(object sender, TextChangedEventArgs e) { if (sender is TextBox txt) { txt.Text = TextLimit(txt.Text); } } private void TextBox_TextChanged_6(object sender, TextChangedEventArgs e) { if (sender is TextBox txt) { txt.Text = TextLimit(txt.Text); } } private void TextBox_TextChanged_7(object sender, TextChangedEventArgs e) { if (sender is TextBox txt) { txt.Text = TextLimit(txt.Text); } } private void TextBox_TextChanged_8(object sender, TextChangedEventArgs e) { if (sender is TextBox txt) { txt.Text = TextLimit(txt.Text); } } private void TextBox_TextChanged_10(object sender, TextChangedEventArgs e) { if (sender is TextBox txtbox) { if (Regex.IsMatch(txtbox.Text, @"^[0-9]+(.[1-9]{0,1})?$"))//验证整数或1位小数 { txtbox.Text = txtbox.Text.Trim(); } else { // MessageBox.Show("原料重量非法输入", "警告", MessageBoxButton.OKCancel, MessageBoxImage.Warning); txtbox.Text = string.Empty; } } } //private void ComboBox_KeyUp(object sender, KeyEventArgs e) //{ // var res = sender as ComboBox; // Json.Read(); // if (res.Text != null && res.Text != String.Empty) // { // var datas = Json.Data.Names.Where(s => s.Contains(res.Text.Trim())); // // var datas = Json.Data.Names.ToList().FindAll(s => s.Contains(res.Text.Trim())); // if (datas.Count() > 0) // { // res.ItemsSource = datas; // res.IsDropDownOpen = true; // } // else // { // res.IsDropDownOpen = false; // } // } //} //private void ComboBox_LostFocus(object sender, RoutedEventArgs e) //{ // var res = sender as ComboBox; // if (res.Text != null && res.Text != String.Empty) // { // if (!Json.Data.Names.Contains(res.Text.Trim()))//判断是否存在原料 // { // //FlowProcessNames.GetInstance.Names.Add(res.Text.Trim()); // //Json.Data = FlowProcessNames.GetInstance; // Json.Data.Names.Add(res.Text.Trim()); // Json.Save(); // } // } //} } }