FetchingForm.cs 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Threading.Tasks;
  4. using System.Windows.Forms;
  5. using System.Reflection;
  6. using System.Runtime.InteropServices;
  7. using Message;
  8. using Sunny.UI;
  9. using tool;
  10. using System.Threading;
  11. using chutian_parking_terminal.process_manage;
  12. namespace chutian_parking_terminal
  13. {
  14. public partial class FetchingForm : Form
  15. {
  16. AutoResizeForm m_auto_resize_form = new AutoResizeForm();
  17. //定义该接口后会自动打开扫描
  18. private int start = -1;//记录ScannerTextBox的光标位置
  19. public bool m_is_return;
  20. public FetchingForm()
  21. {
  22. InitializeComponent();
  23. }
  24. private void returnBtn_Click(object sender, EventArgs e)
  25. {
  26. m_is_return = true;
  27. this.Close();
  28. }
  29. private void FetchingForm_Load(object sender, EventArgs e)
  30. {
  31. //m_auto_resize_form.controllInitializeSize(this);
  32. ScannerTextBox.LostFocus += new EventHandler(ScannerTextBox_LostFocus);
  33. this.label6.Text = "智象泊车终端" + (int.Parse(json_file_operation.Instance.read_json_string("ternimalNumber"))+1).ToString() + "号机";
  34. this.label7.Text = this.label7.Text + (int.Parse(json_file_operation.Instance.read_json_string("ternimalNumber")) + 1);
  35. this.timeLab.Text = System.DateTime.Now.ToString("yyyy-MM-dd");
  36. this.timeLab.Visible = true;
  37. }
  38. private void FetchingForm_FormClosing(object sender, FormClosingEventArgs e)
  39. {
  40. }
  41. /// <summary>
  42. /// 取消button按钮的焦点黑色边框
  43. /// </summary>
  44. /// <param name="需要取消黑色焦点边框的button"></param>
  45. private void SetButton(Button button)
  46. {
  47. MethodInfo methodinfo = button.GetType().GetMethod("SetStyle", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod);
  48. methodinfo.Invoke(button, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod, null, new object[] { ControlStyles.Selectable, false }, Application.CurrentCulture);
  49. }
  50. private void FetchingForm_Activated(object sender, EventArgs e)
  51. {
  52. ScannerTextBox.Focus();
  53. }
  54. private void ScannerTextBox_TextChanged(object sender, EventArgs e)
  55. {
  56. string str = ScannerTextBox.Text;
  57. }
  58. void ScannerTextBox_LostFocus(object sender, EventArgs e)
  59. {
  60. //记录textBox光标位置
  61. start = ScannerTextBox.SelectionStart;
  62. }
  63. /// <summary>
  64. /// 置为已提交车牌信息
  65. /// </summary>
  66. /// <param name="sender"></param>
  67. /// <param name="e"></param>
  68. private void OKBtn_Click(object sender, EventArgs e)
  69. {
  70. Process_manage.Instance.set_exit_task_license(ScannerTextBox.Text);
  71. m_is_return = false;
  72. this.Close();
  73. }
  74. /// <summary>
  75. /// 清空所有下拉框数据
  76. /// </summary>
  77. /// <param name="sender"></param>
  78. /// <param name="e"></param>
  79. private void clearBtn_Click(object sender, EventArgs e)
  80. {
  81. if (start > 0)
  82. {
  83. //删除光标前一位
  84. ScannerTextBox.Text = ScannerTextBox.Text.Remove(start - 1, 1);
  85. //光标行前移一位
  86. ScannerTextBox.Select(start - 1, 0);
  87. //textBox获取焦点
  88. ScannerTextBox.Select();
  89. }
  90. else if (start == 0)
  91. {
  92. ScannerTextBox.SelectionStart = 0;
  93. ScannerTextBox.Select(ScannerTextBox.Text.Length, 0);
  94. ScannerTextBox.Select();
  95. }
  96. }
  97. private void chinese_button_Click(object sender, EventArgs e)
  98. {
  99. this.panelscannerBox.Controls.Remove(this.english_panel);
  100. this.panelscannerBox.Controls.Add(this.chinese_panel);
  101. }
  102. private void return_button_Click(object sender, EventArgs e)
  103. {
  104. this.panelscannerBox.Controls.Remove(this.chinese_panel);
  105. this.panelscannerBox.Controls.Add(this.english_panel);
  106. }
  107. private static bool flag = true;
  108. private static object obj = new object();
  109. public void updateScannerText(string initString, ref UIComboBox uiComboBox)
  110. {
  111. lock (obj)
  112. {
  113. if (flag)
  114. {
  115. if (uiComboBox.Text != initString)
  116. {
  117. flag = false;
  118. this.ScannerTextBox.Text = this.ScannerTextBox.Text + uiComboBox.Text;
  119. }
  120. }
  121. else
  122. {
  123. flag = true;
  124. uiComboBox.SelectedIndex = 0;
  125. //uiComboBox.Text = initString;
  126. }
  127. }
  128. }
  129. private void uiComboBox11_SelectedIndexChanged(object sender, EventArgs e)
  130. {
  131. updateScannerText(" 01", ref uiComboBox11);
  132. }
  133. private void uiComboBox12_SelectedIndexChanged(object sender, EventArgs e)
  134. {
  135. updateScannerText(" 2ABC", ref uiComboBox12);
  136. }
  137. private void uiComboBox13_SelectedIndexChanged(object sender, EventArgs e)
  138. {
  139. updateScannerText(" 3DEF", ref uiComboBox13);
  140. }
  141. private void uiComboBox14_SelectedIndexChanged(object sender, EventArgs e)
  142. {
  143. updateScannerText(" 4GH", ref uiComboBox14);
  144. }
  145. private void uiComboBox15_SelectedIndexChanged(object sender, EventArgs e)
  146. {
  147. updateScannerText(" 5JKL", ref uiComboBox15);
  148. }
  149. private void uiComboBox16_SelectedIndexChanged(object sender, EventArgs e)
  150. {
  151. updateScannerText(" 6MN", ref uiComboBox16);
  152. }
  153. private void uiComboBox17_SelectedIndexChanged(object sender, EventArgs e)
  154. {
  155. updateScannerText("7PQRS", ref uiComboBox17);
  156. }
  157. private void uiComboBox18_SelectedIndexChanged(object sender, EventArgs e)
  158. {
  159. updateScannerText(" 8TUV", ref uiComboBox18);
  160. }
  161. private void uiComboBox19_SelectedIndexChanged(object sender, EventArgs e)
  162. {
  163. updateScannerText("9WXYZ", ref uiComboBox19);
  164. }
  165. private void uiComboBox21_SelectedIndexChanged(object sender, EventArgs e)
  166. {
  167. updateScannerText(" 鄂湘渝", ref uiComboBox21);
  168. }
  169. private void uiComboBox22_SelectedIndexChanged(object sender, EventArgs e)
  170. {
  171. updateScannerText(" 陕豫皖", ref uiComboBox22);
  172. }
  173. private void uiComboBox23_SelectedIndexChanged(object sender, EventArgs e)
  174. {
  175. updateScannerText(" 赣贵川", ref uiComboBox23);
  176. }
  177. private void uiComboBox24_SelectedIndexChanged(object sender, EventArgs e)
  178. {
  179. updateScannerText(" 桂粤闽", ref uiComboBox24);
  180. }
  181. private void uiComboBox25_SelectedIndexChanged(object sender, EventArgs e)
  182. {
  183. updateScannerText(" 浙沪苏", ref uiComboBox25);
  184. }
  185. private void uiComboBox26_SelectedIndexChanged(object sender, EventArgs e)
  186. {
  187. updateScannerText(" 鲁冀晋", ref uiComboBox26);
  188. }
  189. private void uiComboBox27_SelectedIndexChanged(object sender, EventArgs e)
  190. {
  191. updateScannerText(" 云宁甘", ref uiComboBox27);
  192. }
  193. private void uiComboBox28_SelectedIndexChanged(object sender, EventArgs e)
  194. {
  195. updateScannerText(" 藏新青", ref uiComboBox28);
  196. }
  197. private void uiComboBox29_SelectedIndexChanged(object sender, EventArgs e)
  198. {
  199. updateScannerText(" 蒙京津", ref uiComboBox29);
  200. }
  201. private void uiComboBox210_SelectedIndexChanged(object sender, EventArgs e)
  202. {
  203. updateScannerText(" 辽吉黑", ref uiComboBox210);
  204. }
  205. private void uiComboBox211_SelectedIndexChanged(object sender, EventArgs e)
  206. {
  207. updateScannerText("琼港澳台", ref uiComboBox211);
  208. }
  209. private void determine_button_Click(object sender, EventArgs e)
  210. {
  211. string t_license = uiComboBox1.Text +
  212. uiComboBox2.Text +
  213. uiComboBox3.Text +
  214. uiComboBox4.Text +
  215. uiComboBox5.Text +
  216. uiComboBox6.Text +
  217. uiComboBox7.Text +
  218. uiComboBox8.Text;
  219. this.ScannerTextBox.Text = t_license;
  220. }
  221. private void ScannerTextBox_KeyUp(object sender, KeyEventArgs e)
  222. {
  223. if (e.KeyCode == Keys.Control || e.KeyCode == Keys.Enter)
  224. {
  225. this.ScannerTextBox.Text = this.ScannerTextBox.Text.Replace("\r\n", "");
  226. this.OKBtn_Click(sender,e);
  227. }
  228. }
  229. private void FetchingForm_SizeChanged(object sender, EventArgs e)
  230. {
  231. m_auto_resize_form.controlAutoSize(this);
  232. }
  233. }
  234. }