FetchingForm.cs 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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. namespace chutian_parking_terminal
  12. {
  13. public partial class FetchingForm : Form
  14. {
  15. AutoResizeForm m_auto_resize_form = new AutoResizeForm();
  16. //定义该接口后会自动打开扫描
  17. private int start = -1;//记录ScannerTextBox的光标位置
  18. public bool m_is_return;
  19. public string m_license;
  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. m_is_return = false;
  71. this.Close();
  72. }
  73. /// <summary>
  74. /// 清空所有下拉框数据
  75. /// </summary>
  76. /// <param name="sender"></param>
  77. /// <param name="e"></param>
  78. private void clearBtn_Click(object sender, EventArgs e)
  79. {
  80. if (start > 0)
  81. {
  82. //删除光标前一位
  83. ScannerTextBox.Text = ScannerTextBox.Text.Remove(start - 1, 1);
  84. //光标行前移一位
  85. ScannerTextBox.Select(start - 1, 0);
  86. //textBox获取焦点
  87. ScannerTextBox.Select();
  88. }
  89. else if (start == 0)
  90. {
  91. ScannerTextBox.SelectionStart = 0;
  92. ScannerTextBox.Select(ScannerTextBox.Text.Length, 0);
  93. ScannerTextBox.Select();
  94. }
  95. }
  96. private void chinese_button_Click(object sender, EventArgs e)
  97. {
  98. this.panelscannerBox.Controls.Remove(this.english_panel);
  99. this.panelscannerBox.Controls.Add(this.chinese_panel);
  100. }
  101. private void return_button_Click(object sender, EventArgs e)
  102. {
  103. this.panelscannerBox.Controls.Remove(this.chinese_panel);
  104. this.panelscannerBox.Controls.Add(this.english_panel);
  105. }
  106. private static bool flag = true;
  107. private static object obj = new object();
  108. public void updateScannerText(string initString, ref UIComboBox uiComboBox)
  109. {
  110. lock (obj)
  111. {
  112. if (flag)
  113. {
  114. if (uiComboBox.Text != initString)
  115. {
  116. flag = false;
  117. this.ScannerTextBox.Text = this.ScannerTextBox.Text + uiComboBox.Text;
  118. }
  119. }
  120. else
  121. {
  122. flag = true;
  123. uiComboBox.SelectedIndex = 0;
  124. //uiComboBox.Text = initString;
  125. }
  126. }
  127. }
  128. private void uiComboBox11_SelectedIndexChanged(object sender, EventArgs e)
  129. {
  130. updateScannerText(" 01", ref uiComboBox11);
  131. }
  132. private void uiComboBox12_SelectedIndexChanged(object sender, EventArgs e)
  133. {
  134. updateScannerText(" 2ABC", ref uiComboBox12);
  135. }
  136. private void uiComboBox13_SelectedIndexChanged(object sender, EventArgs e)
  137. {
  138. updateScannerText(" 3DEF", ref uiComboBox13);
  139. }
  140. private void uiComboBox14_SelectedIndexChanged(object sender, EventArgs e)
  141. {
  142. updateScannerText(" 4GH", ref uiComboBox14);
  143. }
  144. private void uiComboBox15_SelectedIndexChanged(object sender, EventArgs e)
  145. {
  146. updateScannerText(" 5JKL", ref uiComboBox15);
  147. }
  148. private void uiComboBox16_SelectedIndexChanged(object sender, EventArgs e)
  149. {
  150. updateScannerText(" 6MN", ref uiComboBox16);
  151. }
  152. private void uiComboBox17_SelectedIndexChanged(object sender, EventArgs e)
  153. {
  154. updateScannerText("7PQRS", ref uiComboBox17);
  155. }
  156. private void uiComboBox18_SelectedIndexChanged(object sender, EventArgs e)
  157. {
  158. updateScannerText(" 8TUV", ref uiComboBox18);
  159. }
  160. private void uiComboBox19_SelectedIndexChanged(object sender, EventArgs e)
  161. {
  162. updateScannerText("9WXYZ", ref uiComboBox19);
  163. }
  164. private void uiComboBox21_SelectedIndexChanged(object sender, EventArgs e)
  165. {
  166. updateScannerText(" 鄂湘渝", ref uiComboBox21);
  167. }
  168. private void uiComboBox22_SelectedIndexChanged(object sender, EventArgs e)
  169. {
  170. updateScannerText(" 陕豫皖", ref uiComboBox22);
  171. }
  172. private void uiComboBox23_SelectedIndexChanged(object sender, EventArgs e)
  173. {
  174. updateScannerText(" 赣贵川", ref uiComboBox23);
  175. }
  176. private void uiComboBox24_SelectedIndexChanged(object sender, EventArgs e)
  177. {
  178. updateScannerText(" 桂粤闽", ref uiComboBox24);
  179. }
  180. private void uiComboBox25_SelectedIndexChanged(object sender, EventArgs e)
  181. {
  182. updateScannerText(" 浙沪苏", ref uiComboBox25);
  183. }
  184. private void uiComboBox26_SelectedIndexChanged(object sender, EventArgs e)
  185. {
  186. updateScannerText(" 鲁冀晋", ref uiComboBox26);
  187. }
  188. private void uiComboBox27_SelectedIndexChanged(object sender, EventArgs e)
  189. {
  190. updateScannerText(" 云宁甘", ref uiComboBox27);
  191. }
  192. private void uiComboBox28_SelectedIndexChanged(object sender, EventArgs e)
  193. {
  194. updateScannerText(" 藏新青", ref uiComboBox28);
  195. }
  196. private void uiComboBox29_SelectedIndexChanged(object sender, EventArgs e)
  197. {
  198. updateScannerText(" 蒙京津", ref uiComboBox29);
  199. }
  200. private void uiComboBox210_SelectedIndexChanged(object sender, EventArgs e)
  201. {
  202. updateScannerText(" 辽吉黑", ref uiComboBox210);
  203. }
  204. private void uiComboBox211_SelectedIndexChanged(object sender, EventArgs e)
  205. {
  206. updateScannerText("琼港澳台", ref uiComboBox211);
  207. }
  208. private void determine_button_Click(object sender, EventArgs e)
  209. {
  210. string t_license = uiComboBox1.Text +
  211. uiComboBox2.Text +
  212. uiComboBox3.Text +
  213. uiComboBox4.Text +
  214. uiComboBox5.Text +
  215. uiComboBox6.Text +
  216. uiComboBox7.Text +
  217. uiComboBox8.Text;
  218. this.ScannerTextBox.Text = t_license;
  219. }
  220. private void ScannerTextBox_KeyUp(object sender, KeyEventArgs e)
  221. {
  222. if (e.KeyCode == Keys.Control || e.KeyCode == Keys.Enter)
  223. {
  224. m_license = ScannerTextBox.Text;
  225. if (ScannerTextBox.Text.Length == 16 || ScannerTextBox.Text.Length == 17)
  226. {
  227. this.ScannerTextBox.Text = this.ScannerTextBox.Text.Substring(0, this.ScannerTextBox.Text.Length - 9);
  228. }
  229. this.ScannerTextBox.Text = this.ScannerTextBox.Text.Replace("\r\n", "");
  230. this.OKBtn_Click(sender,e);
  231. }
  232. }
  233. private void FetchingForm_SizeChanged(object sender, EventArgs e)
  234. {
  235. m_auto_resize_form.controlAutoSize(this);
  236. }
  237. }
  238. }