From 1b42ce0768e7e7813e07998b97642ff0e16a1abd Mon Sep 17 00:00:00 2001 From: yibo <361071264@qq.com> Date: Wed, 9 May 2018 16:08:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=AB=E7=A0=81=E8=B0=83=E6=95=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WinFormControl/UScanPanel.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/WinFormControl/UScanPanel.cs b/WinFormControl/UScanPanel.cs index 4b4480c..69cec1b 100644 --- a/WinFormControl/UScanPanel.cs +++ b/WinFormControl/UScanPanel.cs @@ -45,6 +45,7 @@ namespace WinFormControl } bool reading = false; + string _scarText = string.Empty; private void ParentForm_KeyPress(object sender, KeyPressEventArgs e) { if (!reading) @@ -55,24 +56,25 @@ namespace WinFormControl } if (!textBox1.Focused) - { textBox1.Focus(); - textBox1.Text = e.KeyChar.ToString(); - textBox1.Select(textBox1.TextLength, 0); - } if (e.KeyChar == (char)Keys.Enter) { e.Handled = true; - var code = ParseCode(textBox1.Text); + var code = ParseCode(_scarText); textBox1.Text = code; textBox1.Select(textBox1.TextLength, 0); + _scarText = string.Empty; reading = false; if (AfterScan != null) AfterScan(); } else + { reading = true; + e.Handled = true; + _scarText += e.KeyChar.ToString(); + } } static string ParseCode(string url)