public static byte GetBarcodeDataIsdcRs() { byte[] data = new byte[m_IsdcRsApi.iInputOutputBufferSize]; UInt32[] pnBytesReturned = new UInt32[1]; byte status; Int32 wBarCodeSize; string msg = ""; status = m_IsdcRsApi.GetBarcodeDataIsdcRs(data, m_IsdcRsApi.iInputOutputBufferSize, pnBytesReturned); wBarCodeSize = (Int32)(data[1] | (data[0] << 8)); if (status == 0) { // refresh barcode data display string s_tmp = ""; bool bIdentifier = false; for (int wCount = 2; wCount < wBarCodeSize + 2; wCount++) { if ((wCount == 2) && (data[wCount] == ']')) { bIdentifier = true; } if ((wCount == (wBarCodeSize)) && (data[wCount] == 0x0D)) { data[wCount] = 0x00; } if ((wCount == (wBarCodeSize + 1)) && (data[wCount] == 0x0A)) { data[wCount] = 0x00; } s_tmp += Convert.ToChar(data[wCount]); } msg = s_tmp; if ((bIdentifier) && (BarcodeIdentifierCode == 0)) { msg = s_tmp.Remove(0, 3); } if (IsDebugMode) { Trace.WriteLine("Get Intermec Packet Data"); } PublicFunction.OutputKeyboardMessage(msg);// Winmate brian modify on 2018/04/18 } return(status); }
public static DialogResult ShowDialogMessageBox(string text, string title, MessageBoxButtons buttons = MessageBoxButtons.OK, MessageBoxIcon icon = MessageBoxIcon.Error) { PublicFunction.CloseSpecificProcess("Attention"); if (newMessageBox == null) { newMessageBox = new DialogMessageBox(); } newMessageBox.textBoxMessage.Text = text; newMessageBox.Text = title; if (buttons.Equals(MessageBoxButtons.OK)) { newMessageBox.buttonOK.Visible = true; } else if (buttons.Equals(MessageBoxButtons.YesNo)) { newMessageBox.buttonYes.Visible = true; newMessageBox.buttonNo.Visible = true; } newMessageBox.ShowDialog(); MessageBoxResult = newMessageBox.labelResult.Text; newMessageBox = null; // newMessageBox.Dispose(); // if (IsDebugMode) Trace.WriteLine("DialogMessage : " + MessageBoxResult + "\t" + (newMessageBox) == null); switch (MessageBoxResult) { case "OK": return(DialogResult.OK); case "Yes": return(DialogResult.Yes); case "No": return(DialogResult.No); default: return(DialogResult.OK); } }
private void mSerialPort_DataReceived(Object sender, SerialDataReceivedEventArgs e) { if ((sender as SerialPort).BytesToRead > 0) { buffer = new byte[mSerialPort.ReadBufferSize]; count = mSerialPort.Read(buffer, 0, mSerialPort.ReadBufferSize - 1); char[] tmp = new char[count]; for (int i = 0; i < count; i++) { tmp[i] = (char)buffer[i]; if (buffer[0] == 0x8F) { DeviceResponse = 0x8F; } else if (buffer[0] == 0x15) { DeviceResponse = 0x15; } else if (buffer[1] == CMD_ACK) { DeviceResponse = CMD_ACK; } } message = new String(tmp, 0, count); if (DeviceResponse == CMD_ACK)// SE4500DL { if (buffer[1] == CMD_ACK) { se4500dlVersion = "SE4500DL"; // Trace.WriteLine("CMD_ACK"); } else if ((buffer[1] != CMD_ACK) && (buffer[1] != CMD_NAK)) { msg2 += message; } } else { msg2 += message; } // if (IsDebugMode) Trace.WriteLine("SerialPort DataReceived : " + message + " , Count : " + count); } if (!firstScan && msg2.Contains("OK")) { isSupportBarCode = true; firstScan = true; msg2 = ""; type = 3; } else if (!firstScan && (DeviceResponse == 0x15)) { isSupportBarCode = true; firstScan = true; msg2 = ""; type = 1; } else if (!firstScan && (DeviceResponse == 0x8F)) { isSupportBarCode = true; firstScan = true; msg2 = ""; type = 2; } else if (!firstScan && (DeviceResponse == CMD_ACK)) { isSupportBarCode = true; firstScan = true; msg2 = ""; type = 5; } if (isSupportBarCode) { if ((type == 0) || (type == 3)) // Opticon { if ((int)buffer[count - 1] == 0x0D) // ASCII control unint 0x0D=CR (enter) { if (IsDebugMode) { Trace.WriteLine("Get MDI3100 Data"); } PublicFunction.OutputKeyboardMessage(msg2);// Winmate brian modify on 2018/04/18 msg2 = ""; } } else if (type == 1)// BS523 { if (IsDebugMode) { Trace.WriteLine("Get BS523 Data"); } if ((msg2.Length == 1) && ((msg2[0] == 0x06) || (msg2[0] == 0x15))) { msg2 = ""; } else { if (msg2.Length != 0) { PublicFunction.OutputKeyboardMessage(msg2);// Winmate brian modify on 2018/04/18 } } msg2 = ""; } else if (type == 2)// Opticon M3 (1D) { if ((int)buffer[count - 1] == 0x0A) { if (IsDebugMode) { Trace.WriteLine("Get M3 Data"); } PublicFunction.OutputKeyboardMessage(msg2);// Winmate brian modify on 2018/04/18 msg2 = ""; } } } }