我開發了一個服裝商店的應用程序以在該應用程序中打印發票我想使用條形碼掃描儀從包含條形碼的物料標籤中自動收集信息並自動填充所有信息我的表格,然後打印發票。 請給出一些建議如何解決這個問題。 我也使用Microsoft.PointOfService庫。在windows應用程序中使用條形碼掃描器C#
0
A
回答
0
通常,條形碼掃描器只是將所有識別的符號作爲標準鍵盤輸入發送。因此,當用戶將注意力集中在應用程序中的文本字段並掃描條形碼時,就像用戶手動輸入條形碼符號並按「Enter」(或任何其他鍵,取決於掃描儀設置)一樣。
1
假設在表單中有一個文本框,當條形碼掃描時,它會在文本框中鍵入條形碼字符。通常,一些掃描儀可以配置爲在掃描結束時添加另一個字符,通常是新行字符。藉此,您可以收聽文本框的KeyPress事件,並處理新行字符。當它被觸發時,那麼你可以檢索表單中的其他細節。
+0
謝謝您的回答 – 2013-02-26 10:28:27
0
我有一個類在我的個人圖書館,以檢測掃描儀的工作原理:
public sealed class ScanReader
{
#region Delegates
public delegate void _DataLoaded(string ScannedData);
#endregion
private readonly double MyMaxMillisecondsBetweenPress;
private readonly List<Regex> MyRegex;
private readonly Timer TimeToNextKeyPress = new Timer();
private string CardBuff = string.Empty;
private bool FirstKeyPress = true;
private DateTime Stamp;
/// <summary>
/// ScanReader constructor
/// </summary>
/// <param name="Press"> Form where KeyPreview = true </param>
/// <param name="Regs"> Regular expressions for filtering scanned data</param>
/// <param name="MaxMillisecondsBetweenPress"> The maximum time between pressing the keys in milliseconds, default = 60 </param>
public ScanReader(Form form, List<Regex> Regs = null, double MaxMillisecondsBetweenPress = 0)
{
MyRegex = Regs ?? null;
MyMaxMillisecondsBetweenPress = MaxMillisecondsBetweenPress == 0 ? 60 : MaxMillisecondsBetweenPress;
form.KeyPress += KeyPressed;
TimeToNextKeyPress.Interval =
Convert.ToInt32(MyMaxMillisecondsBetweenPress + MyMaxMillisecondsBetweenPress*0.2);
TimeToNextKeyPress.Tick += TimeToNextKeyPress_Tick;
}
public event _DataLoaded OnDataLoaded;
private void TimeToNextKeyPress_Tick(object sender, EventArgs e)
{
TimeToNextKeyPress.Stop();
if (MyRegex.Count > 0)
{
foreach (Regex reg in MyRegex)
{
if (reg.IsMatch(CardBuff))
{
OnDataLoaded(CardBuff);
return;
}
}
}
else
OnDataLoaded(CardBuff);
}
private void KeyPressed(object sender, KeyPressEventArgs e)
{
if (FirstKeyPress)
{
Stamp = DateTime.Now;
FirstKeyPress = false;
CardBuff = e.KeyChar.ToString();
}
else
{
if ((DateTime.Now - Stamp).TotalMilliseconds < MyMaxMillisecondsBetweenPress)
{
Stamp = DateTime.Now;
CardBuff += e.KeyChar;
}
else
{
Stamp = DateTime.Now;
CardBuff = e.KeyChar.ToString();
}
}
TimeToNextKeyPress.Stop();
TimeToNextKeyPress.Start();
}
}
如何使用:
var myReader = new ScanReader(this, new List<Regex>
{
new Regex(@"296\d{13,13}"),
new Regex(@"K%.{5,34}"),
new Regex(@"C%.{5,34}"),
new Regex(@"E%.{5,34}"),
});
myReader.OnDataLoaded += FillControls;
相關問題
- 1. C條碼掃描器應用程序#
- 2. 條形碼掃描器zxing和neoreader在我的應用程序
- 3. 在winRT應用程序中使用條碼掃描器
- 4. 在Android應用程序中使用內置的條形碼掃描器
- 5. 運行Windows「條碼掃描器示例」應用程序
- 6. Windows Mobile應用程序條碼掃描與模擬器
- 7. 從.net(C#)windows應用程序中的條碼掃描器中讀取數據!
- 8. 在條形碼掃描儀掃描時用java打印條碼
- 9. 用vb.net掃描條形碼
- 10. 條碼掃描器在自己的Google Glass應用程序中
- 11. 在Java Web應用程序中集成條碼掃描器
- 12. 使用掃描儀的Swing應用程序條形碼閱讀器
- 13. 在android應用程序中設置zxing 2.0條形碼掃描器
- 14. 在Android上使用「Zxing的條形碼掃描儀」應用程序
- 15. 從我的iOS應用程序中使用條形碼掃描儀(如Grabba)
- 16. 如何在c#.net應用程序中使用掃描器
- 17. 使用zbar掃描條形碼圖像?
- 18. 使用QRScanner掃描線性條形碼
- 19. 使用Python進行條形碼掃描
- 20. 條碼掃描器集成在PHP應用程序
- 21. 在Android應用程序中單擊按鈕時調用條形碼掃描儀
- 22. 適用於JSF應用程序,Applet或JWS的條形碼掃描器界面?
- 23. 如何在c#windows應用程序中使用條形碼閱讀器?
- 24. C編程的條碼掃描器#
- 25. 從多個條形碼掃描儀讀取數據到C#應用程序
- 26. 如何將條碼掃描器與android應用程序集成?
- 27. Windows Phone 8.1:使用ZXing.Net從相機掃描條形碼
- 28. 如何在我的應用程序中嵌入條形碼掃描儀?
- 29. 如何將條形碼掃描器集成到玻璃應用程序
- 30. 如何將條形碼掃描器與Web應用程序連接?
@亞歷克斯·基謝廖夫感謝您的答覆.. – 2013-02-26 10:30:07