Browse Source

扫码调整。

master
yibo 7 years ago
parent
commit
1b42ce0768
1 changed files with 7 additions and 5 deletions
  1. +7
    -5
      WinFormControl/UScanPanel.cs

+ 7
- 5
WinFormControl/UScanPanel.cs View File

@ -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)


Loading…
Cancel
Save