123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286 |
- using System;
- using System.Collections.Generic;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Reflection;
- using System.Runtime.InteropServices;
- using Message;
- using Sunny.UI;
- using tool;
- using chutian_parking_terminal.motion_executer;
- using System.Threading;
- namespace chutian_parking_terminal
- {
- public partial class FetchingForm : Form
- {
- //定义该接口后会自动打开扫描
- private ScannerServer scan;
- private int start = -1;//记录ScannerTextBox的光标位置
- private string license = "";
- public bool m_is_return;
- private Thread m_scan_thread;
- private bool m_scan_condition;
- public FetchingForm()
- {
- InitializeComponent();
- scan = new ScannerServer();
- m_scan_thread = new Thread(get_scan_license_thread);
- m_scan_thread.Start();
- m_scan_condition = true;
- }
- private void returnBtn_Click(object sender, EventArgs e)
- {
- m_is_return = true;
- this.Close();
- m_scan_condition = false;
- m_scan_thread.Abort();
- }
-
- private void FetchingForm_Load(object sender, EventArgs e)
- {
- ScannerTextBox.LostFocus += new EventHandler(ScannerTextBox_LostFocus);
- this.label6.Text = "智象泊车终端" + json_file_operation.Instance.read_json_string("ternimalNumber") + "号机";
- this.label7.Text = this.label7.Text + json_file_operation.Instance.read_json_string("ternimalNumber");
- }
- private void get_scan_license_thread()
- {
- while (m_scan_condition)
- {
- if (scan.GetInfo(out license))
- {
- if (license != "")
- {
- ScannerTextBox.Text = license;
- }
- }
- }
-
- }
- private void FetchingForm_FormClosing(object sender, FormClosingEventArgs e)
- {
- scan.Close();
- m_scan_condition = false;
- m_scan_thread.Abort();
- }
- /// <summary>
- /// 取消button按钮的焦点黑色边框
- /// </summary>
- /// <param name="需要取消黑色焦点边框的button"></param>
- private void SetButton(Button button)
- {
- MethodInfo methodinfo = button.GetType().GetMethod("SetStyle", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod);
- methodinfo.Invoke(button, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod, null, new object[] { ControlStyles.Selectable, false }, Application.CurrentCulture);
- }
- private void FetchingForm_Activated(object sender, EventArgs e)
- {
- ScannerTextBox.Focus();
- }
- private void ScannerTextBox_TextChanged(object sender, EventArgs e)
- {
- string str = ScannerTextBox.Text;
- }
- void ScannerTextBox_LostFocus(object sender, EventArgs e)
- {
- //记录textBox光标位置
- start = ScannerTextBox.SelectionStart;
- }
- /// <summary>
- /// 置为已提交车牌信息
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void OKBtn_Click(object sender, EventArgs e)
- {
- Exit_execute.Instance.set_pickup_license(ScannerTextBox.Text);
- m_is_return = false;
- this.Close();
- m_scan_condition = false;
- m_scan_thread.Abort();
- }
- /// <summary>
- /// 清空所有下拉框数据
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void clearBtn_Click(object sender, EventArgs e)
- {
- if (start > 0)
- {
- //删除光标前一位
- ScannerTextBox.Text = ScannerTextBox.Text.Remove(start - 1, 1);
- //光标行前移一位
- ScannerTextBox.Select(start - 1, 0);
- //textBox获取焦点
- ScannerTextBox.Select();
- }
- else if (start == 0)
- {
- ScannerTextBox.SelectionStart = 0;
- ScannerTextBox.Select(ScannerTextBox.Text.Length, 0);
- ScannerTextBox.Select();
- }
- }
- private void chinese_button_Click(object sender, EventArgs e)
- {
- this.panelscannerBox.Controls.Remove(this.english_panel);
- this.panelscannerBox.Controls.Add(this.chinese_panel);
- }
- private void return_button_Click(object sender, EventArgs e)
- {
- this.panelscannerBox.Controls.Remove(this.chinese_panel);
- this.panelscannerBox.Controls.Add(this.english_panel);
- }
- private static bool flag = true;
- private static object obj = new object();
- public void updateScannerText(string initString, ref UIComboBox uiComboBox)
- {
- lock (obj)
- {
- if (flag)
- {
- if (uiComboBox.Text != initString)
- {
- flag = false;
- this.ScannerTextBox.Text = this.ScannerTextBox.Text + uiComboBox.Text;
- }
- }
- else
- {
- flag = true;
- uiComboBox.SelectedIndex = 0;
- //uiComboBox.Text = initString;
- }
- }
- }
- private void uiComboBox11_SelectedIndexChanged(object sender, EventArgs e)
- {
- updateScannerText(" 01", ref uiComboBox11);
- }
- private void uiComboBox12_SelectedIndexChanged(object sender, EventArgs e)
- {
- updateScannerText(" 2ABC", ref uiComboBox12);
- }
- private void uiComboBox13_SelectedIndexChanged(object sender, EventArgs e)
- {
- updateScannerText(" 3DEF", ref uiComboBox13);
- }
- private void uiComboBox14_SelectedIndexChanged(object sender, EventArgs e)
- {
- updateScannerText(" 4GH", ref uiComboBox14);
- }
- private void uiComboBox15_SelectedIndexChanged(object sender, EventArgs e)
- {
- updateScannerText(" 5JKL", ref uiComboBox15);
- }
- private void uiComboBox16_SelectedIndexChanged(object sender, EventArgs e)
- {
- updateScannerText(" 6MN", ref uiComboBox16);
- }
- private void uiComboBox17_SelectedIndexChanged(object sender, EventArgs e)
- {
- updateScannerText("7PQRS", ref uiComboBox17);
- }
- private void uiComboBox18_SelectedIndexChanged(object sender, EventArgs e)
- {
- updateScannerText(" 8TUV", ref uiComboBox18);
- }
- private void uiComboBox19_SelectedIndexChanged(object sender, EventArgs e)
- {
- updateScannerText("9WXYZ", ref uiComboBox19);
- }
- private void uiComboBox21_SelectedIndexChanged(object sender, EventArgs e)
- {
- updateScannerText(" 鄂湘渝", ref uiComboBox21);
- }
- private void uiComboBox22_SelectedIndexChanged(object sender, EventArgs e)
- {
- updateScannerText(" 陕豫皖", ref uiComboBox22);
- }
- private void uiComboBox23_SelectedIndexChanged(object sender, EventArgs e)
- {
- updateScannerText(" 赣贵川", ref uiComboBox23);
- }
- private void uiComboBox24_SelectedIndexChanged(object sender, EventArgs e)
- {
- updateScannerText(" 桂粤闽", ref uiComboBox24);
- }
- private void uiComboBox25_SelectedIndexChanged(object sender, EventArgs e)
- {
- updateScannerText(" 浙沪苏", ref uiComboBox25);
- }
- private void uiComboBox26_SelectedIndexChanged(object sender, EventArgs e)
- {
- updateScannerText(" 鲁冀晋", ref uiComboBox26);
- }
- private void uiComboBox27_SelectedIndexChanged(object sender, EventArgs e)
- {
- updateScannerText(" 云宁甘", ref uiComboBox27);
- }
- private void uiComboBox28_SelectedIndexChanged(object sender, EventArgs e)
- {
- updateScannerText(" 藏新青", ref uiComboBox28);
- }
- private void uiComboBox29_SelectedIndexChanged(object sender, EventArgs e)
- {
- updateScannerText(" 蒙京津", ref uiComboBox29);
- }
- private void uiComboBox210_SelectedIndexChanged(object sender, EventArgs e)
- {
- updateScannerText(" 辽吉黑", ref uiComboBox210);
- }
- private void uiComboBox211_SelectedIndexChanged(object sender, EventArgs e)
- {
- updateScannerText("琼港澳台", ref uiComboBox211);
- }
- private void determine_button_Click(object sender, EventArgs e)
- {
- string t_license = uiComboBox1.Text +
- uiComboBox2.Text +
- uiComboBox3.Text +
- uiComboBox4.Text +
- uiComboBox5.Text +
- uiComboBox6.Text +
- uiComboBox7.Text +
- uiComboBox8.Text;
- this.ScannerTextBox.Text = t_license;
- }
- }
- }
|