终端一体化运控平台
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 

250 Zeilen
7.9 KiB

  1. using BPASmartClient.Helper;
  2. using FryPot_DosingSystem.Model;
  3. using FryPot_DosingSystem.ViewModel;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Text.RegularExpressions;
  9. using System.Threading.Tasks;
  10. using System.Windows;
  11. using System.Windows.Controls;
  12. using System.Windows.Data;
  13. using System.Windows.Documents;
  14. using System.Windows.Input;
  15. using System.Windows.Media;
  16. using System.Windows.Media.Imaging;
  17. using System.Windows.Shapes;
  18. namespace FryPot_DosingSystem.View
  19. {
  20. /// <summary>
  21. /// FlowProcessView.xaml 的交互逻辑
  22. /// </summary>
  23. public partial class FlowProcessView : Window
  24. {
  25. public FlowProcessView()
  26. {
  27. InitializeComponent();
  28. this.br.MouseLeftButtonDown += (o, e) => { if (e.LeftButton == MouseButtonState.Pressed) this.DragMove(); };
  29. ActionManage.GetInstance.CancelRegister("CloseFlowProcessView");
  30. ActionManage.GetInstance.Register(new Action(() =>
  31. {
  32. this.Close();
  33. }), "CloseFlowProcessView");
  34. }
  35. private void Label_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  36. {
  37. Label txt = sender as Label;
  38. if (txt != null)
  39. {
  40. StackPanel oldSp = FindFirstVisualChild(itemcontrols, "stk");
  41. if (oldSp != null)
  42. oldSp.Background = new SolidColorBrush(Color.FromRgb(38, 76, 115));
  43. StackPanel sp = VisualTreeHelper.GetParent(txt) as StackPanel;
  44. sp.Background = new SolidColorBrush(Color.FromRgb(8, 20, 36));
  45. ActionManage.GetInstance.Send("CurrentItemId", txt.Content);
  46. }
  47. }
  48. public StackPanel FindFirstVisualChild(DependencyObject obj, string childName)
  49. {
  50. for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)
  51. {
  52. DependencyObject child = VisualTreeHelper.GetChild(obj, i);
  53. if (child != null && child is StackPanel && child.GetValue(NameProperty).ToString() == childName)
  54. {
  55. if (child is StackPanel stack && stack.Background?.ToString() == "#FF081424")
  56. return stack;
  57. }
  58. else
  59. {
  60. StackPanel SP = FindFirstVisualChild(child, childName);
  61. if (SP != null)
  62. {
  63. return SP;
  64. }
  65. }
  66. }
  67. return null;
  68. }
  69. private void Button_Click(object sender, RoutedEventArgs e)
  70. {
  71. NewFryPotMaterial win = new NewFryPotMaterial();
  72. win.Show();
  73. }
  74. public string TextLimit(string str)
  75. {
  76. if (Regex.IsMatch(str, @"^\d+$"))//非负整数 非零正整数^\+?[1-9][0-9]*$
  77. {
  78. return str;
  79. }
  80. else
  81. {
  82. return string.Empty;
  83. }
  84. }
  85. /// <summary>
  86. /// 文本输入做限定
  87. /// </summary>
  88. /// <param name="sender"></param>
  89. /// <param name="e"></param>
  90. private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
  91. {
  92. if (sender is TextBox txt)
  93. {
  94. txt.Text = TextLimit(txt.Text);
  95. }
  96. }
  97. private void TextBox_TextChanged_1(object sender, TextChangedEventArgs e)
  98. {
  99. if (sender is TextBox txtbox)
  100. {
  101. if (Regex.IsMatch(txtbox.Text, @"^[0-9]+(.[0-9]{0,1})?$"))//验证整数或1位小数
  102. {
  103. txtbox.Text = txtbox.Text.Trim();
  104. }
  105. else
  106. {
  107. // MessageBox.Show("原料重量非法输入", "警告", MessageBoxButton.OKCancel, MessageBoxImage.Warning);
  108. txtbox.Text = string.Empty;
  109. }
  110. }
  111. }
  112. private void TextBox_TextChanged_2(object sender, TextChangedEventArgs e)
  113. {
  114. if (sender is TextBox txt)
  115. {
  116. txt.Text = TextLimit(txt.Text);
  117. }
  118. }
  119. private void TextBox_TextChanged_3(object sender, TextChangedEventArgs e)
  120. {
  121. if (sender is TextBox txt)
  122. {
  123. txt.Text = TextLimit(txt.Text);
  124. }
  125. }
  126. private void TextBox_TextChanged_4(object sender, TextChangedEventArgs e)
  127. {
  128. if (sender is TextBox txt)
  129. {
  130. txt.Text = TextLimit(txt.Text);
  131. }
  132. }
  133. private void TextBox_TextChanged_5(object sender, TextChangedEventArgs e)
  134. {
  135. if (sender is TextBox txt)
  136. {
  137. txt.Text = TextLimit(txt.Text);
  138. }
  139. }
  140. private void TextBox_TextChanged_6(object sender, TextChangedEventArgs e)
  141. {
  142. if (sender is TextBox txt)
  143. {
  144. txt.Text = TextLimit(txt.Text);
  145. }
  146. }
  147. private void TextBox_TextChanged_7(object sender, TextChangedEventArgs e)
  148. {
  149. if (sender is TextBox txt)
  150. {
  151. txt.Text = TextLimit(txt.Text);
  152. }
  153. }
  154. private void TextBox_TextChanged_8(object sender, TextChangedEventArgs e)
  155. {
  156. if (sender is TextBox txtbox)
  157. {
  158. if (Regex.IsMatch(txtbox.Text, @"^[0-9]+(.[0-9]{0,1})?$"))//验证整数或1位小数
  159. {
  160. txtbox.Text = txtbox.Text.Trim();
  161. }
  162. else
  163. {
  164. // MessageBox.Show("原料重量非法输入", "警告", MessageBoxButton.OKCancel, MessageBoxImage.Warning);
  165. txtbox.Text = string.Empty;
  166. }
  167. }
  168. }
  169. private void TextBox_TextChanged_10(object sender, TextChangedEventArgs e)
  170. {
  171. if (sender is TextBox txtbox)
  172. {
  173. if (Regex.IsMatch(txtbox.Text, @"^[0-9]+(.[1-9]{0,1})?$"))//验证整数或1位小数
  174. {
  175. txtbox.Text = txtbox.Text.Trim();
  176. }
  177. else
  178. {
  179. // MessageBox.Show("原料重量非法输入", "警告", MessageBoxButton.OKCancel, MessageBoxImage.Warning);
  180. txtbox.Text = string.Empty;
  181. }
  182. }
  183. }
  184. //private void ComboBox_KeyUp(object sender, KeyEventArgs e)
  185. //{
  186. // var res = sender as ComboBox;
  187. // Json<FlowProcessNames>.Read();
  188. // if (res.Text != null && res.Text != String.Empty)
  189. // {
  190. // var datas = Json<FlowProcessNames>.Data.Names.Where(s => s.Contains(res.Text.Trim()));
  191. // // var datas = Json<MaterialNames>.Data.Names.ToList().FindAll(s => s.Contains(res.Text.Trim()));
  192. // if (datas.Count() > 0)
  193. // {
  194. // res.ItemsSource = datas;
  195. // res.IsDropDownOpen = true;
  196. // }
  197. // else
  198. // {
  199. // res.IsDropDownOpen = false;
  200. // }
  201. // }
  202. //}
  203. //private void ComboBox_LostFocus(object sender, RoutedEventArgs e)
  204. //{
  205. // var res = sender as ComboBox;
  206. // if (res.Text != null && res.Text != String.Empty)
  207. // {
  208. // if (!Json<FlowProcessNames>.Data.Names.Contains(res.Text.Trim()))//判断是否存在原料
  209. // {
  210. // //FlowProcessNames.GetInstance.Names.Add(res.Text.Trim());
  211. // //Json<FlowProcessNames>.Data = FlowProcessNames.GetInstance;
  212. // Json<FlowProcessNames>.Data.Names.Add(res.Text.Trim());
  213. // Json<FlowProcessNames>.Save();
  214. // }
  215. // }
  216. //}
  217. }
  218. }