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 System.Threading; namespace chutian_parking_terminal { public partial class FetchingForm : Form { AutoResizeForm m_auto_resize_form = new AutoResizeForm(); //定义该接口后会自动打开扫描 private int start = -1;//记录ScannerTextBox的光标位置 public bool m_is_return; public string m_license; public FetchingForm() { InitializeComponent(); } private void returnBtn_Click(object sender, EventArgs e) { m_is_return = true; this.Close(); } private void FetchingForm_Load(object sender, EventArgs e) { //m_auto_resize_form.controllInitializeSize(this); ScannerTextBox.LostFocus += new EventHandler(ScannerTextBox_LostFocus); this.label6.Text = "智象泊车终端" + (int.Parse(json_file_operation.Instance.read_json_string("ternimalNumber"))+1).ToString() + "号机"; this.label7.Text = this.label7.Text + (int.Parse(json_file_operation.Instance.read_json_string("ternimalNumber")) + 1); this.timeLab.Text = System.DateTime.Now.ToString("yyyy-MM-dd"); this.timeLab.Visible = true; } private void FetchingForm_FormClosing(object sender, FormClosingEventArgs e) { } /// /// 取消button按钮的焦点黑色边框 /// /// 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; } /// /// 置为已提交车牌信息 /// /// /// private void OKBtn_Click(object sender, EventArgs e) { m_is_return = false; this.Close(); } /// /// 清空所有下拉框数据 /// /// /// 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; } private void ScannerTextBox_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Control || e.KeyCode == Keys.Enter) { m_license = ScannerTextBox.Text; if (ScannerTextBox.Text.Length == 16 || ScannerTextBox.Text.Length == 17) { this.ScannerTextBox.Text = this.ScannerTextBox.Text.Substring(0, this.ScannerTextBox.Text.Length - 9); } this.ScannerTextBox.Text = this.ScannerTextBox.Text.Replace("\r\n", ""); this.OKBtn_Click(sender,e); } } private void FetchingForm_SizeChanged(object sender, EventArgs e) { m_auto_resize_form.controlAutoSize(this); } } }