终端一体化运控平台
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

230 lines
7.1 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 txt)
  100. {
  101. txt.Text = TextLimit(txt.Text);
  102. }
  103. }
  104. private void TextBox_TextChanged_2(object sender, TextChangedEventArgs e)
  105. {
  106. if (sender is TextBox txt)
  107. {
  108. txt.Text = TextLimit(txt.Text);
  109. }
  110. }
  111. private void TextBox_TextChanged_3(object sender, TextChangedEventArgs e)
  112. {
  113. if (sender is TextBox txt)
  114. {
  115. txt.Text = TextLimit(txt.Text);
  116. }
  117. }
  118. private void TextBox_TextChanged_4(object sender, TextChangedEventArgs e)
  119. {
  120. if (sender is TextBox txt)
  121. {
  122. txt.Text = TextLimit(txt.Text);
  123. }
  124. }
  125. private void TextBox_TextChanged_5(object sender, TextChangedEventArgs e)
  126. {
  127. if (sender is TextBox txt)
  128. {
  129. txt.Text = TextLimit(txt.Text);
  130. }
  131. }
  132. private void TextBox_TextChanged_6(object sender, TextChangedEventArgs e)
  133. {
  134. if (sender is TextBox txt)
  135. {
  136. txt.Text = TextLimit(txt.Text);
  137. }
  138. }
  139. private void TextBox_TextChanged_7(object sender, TextChangedEventArgs e)
  140. {
  141. if (sender is TextBox txt)
  142. {
  143. txt.Text = TextLimit(txt.Text);
  144. }
  145. }
  146. private void TextBox_TextChanged_8(object sender, TextChangedEventArgs e)
  147. {
  148. if (sender is TextBox txt)
  149. {
  150. txt.Text = TextLimit(txt.Text);
  151. }
  152. }
  153. private void TextBox_TextChanged_10(object sender, TextChangedEventArgs e)
  154. {
  155. if (sender is TextBox txtbox)
  156. {
  157. if (Regex.IsMatch(txtbox.Text, @"^[0-9]+(.[1-9]{0,1})?$"))//验证整数或1位小数
  158. {
  159. txtbox.Text = txtbox.Text.Trim();
  160. }
  161. else
  162. {
  163. // MessageBox.Show("原料重量非法输入", "警告", MessageBoxButton.OKCancel, MessageBoxImage.Warning);
  164. txtbox.Text = string.Empty;
  165. }
  166. }
  167. }
  168. //private void ComboBox_KeyUp(object sender, KeyEventArgs e)
  169. //{
  170. // var res = sender as ComboBox;
  171. // Json<FlowProcessNames>.Read();
  172. // if (res.Text != null && res.Text != String.Empty)
  173. // {
  174. // var datas = Json<FlowProcessNames>.Data.Names.Where(s => s.Contains(res.Text.Trim()));
  175. // // var datas = Json<MaterialNames>.Data.Names.ToList().FindAll(s => s.Contains(res.Text.Trim()));
  176. // if (datas.Count() > 0)
  177. // {
  178. // res.ItemsSource = datas;
  179. // res.IsDropDownOpen = true;
  180. // }
  181. // else
  182. // {
  183. // res.IsDropDownOpen = false;
  184. // }
  185. // }
  186. //}
  187. //private void ComboBox_LostFocus(object sender, RoutedEventArgs e)
  188. //{
  189. // var res = sender as ComboBox;
  190. // if (res.Text != null && res.Text != String.Empty)
  191. // {
  192. // if (!Json<FlowProcessNames>.Data.Names.Contains(res.Text.Trim()))//判断是否存在原料
  193. // {
  194. // //FlowProcessNames.GetInstance.Names.Add(res.Text.Trim());
  195. // //Json<FlowProcessNames>.Data = FlowProcessNames.GetInstance;
  196. // Json<FlowProcessNames>.Data.Names.Add(res.Text.Trim());
  197. // Json<FlowProcessNames>.Save();
  198. // }
  199. // }
  200. //}
  201. }
  202. }