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