void Click_S5() { s5.GestureRecognizers.Add(new TapGestureRecognizer() { Command = new Command(() => { ISimpleAudioPlayer Tone; Tone = CrossSimpleAudioPlayer.CreateSimpleAudioPlayer(); Stream Tonee = GetType().Assembly.GetManifestResourceStream("gTuner.sounds.30 A#3.mp3"); Tone.Load(Tonee); Tone.Play(); }) }); }
/// <summary> /// Will change menus and texts /// Do NOT invoke any methods from inside ChangeStatus() /// </summary> /// <param name="a"></param> private void ChangeStatus(eStatus a) { if (m_BCreader != null) { m_BCreader.ScannerEnable = false; } CurrentStatus = a; txtBoxID.Enabled = false; switch (a) { case eStatus.Offline: txtStatus.Text = "Offline, please connect"; txtStatus.BackColor = Color.Red; mnuConnectReader.Enabled = true; mnuDisconnectReader.Enabled = false; mnuEnableLogging.Enabled = true; mnuRestart.Enabled = false; LowBeep.Play(); break; case eStatus.ReadBarcode: txtStatus.Text = "Waiting for Barcode"; txtStatus.BackColor = Color.LightGreen; break; case eStatus.ReadTag: txtStatus.Text = "Waiting for single Tag"; txtStatus.BackColor = Color.LightCyan; mnuRestart.Enabled = true; HighBeep2.Play(); break; case eStatus.WriteTag: txtStatus.Text = "Writing single Tag"; txtStatus.BackColor = Color.Green; mnuRestart.Enabled = true; if (m_bBoxIDEnabled) { txtBoxID.Enabled = true; } else { txtBoxID.Enabled = false; } HighBeep2.Play(); break; case eStatus.WriteTagError: txtStatus.Text = "Tag write error. Retrying"; txtStatus.BackColor = Color.Red; LowBeepLow.Play(); mnuRestart.Enabled = true; break; case eStatus.TooManyTags: txtStatus.Text = "Please look for a single Tag"; txtStatus.BackColor = Color.Red; LowBeepLow.Play(); mnuRestart.Enabled = true; break; case eStatus.BarCodeErr: txtStatus.Text = "Barcode does not meet Spec!"; txtStatus.BackColor = Color.Red; //the following will be done inside CenterTrigger event //if (m_BCreader!=null) // m_BCreader.ScannerEnable = true; LowBeepLow.Play(); break; case eStatus.InvalidTag: txtStatus.Text = "TagData does not meet Spec!"; txtStatus.BackColor = Color.Red; LowBeepLow.Play(); break; default: txtStatus.Text = "Unknown Status"; txtStatus.BackColor = Color.LightPink; mnuRestart.Enabled = true; break; /* Offline, * ReadTag, * ReadBarcode, * WriteTag, * TooManyTags, * BarCodeSizeErr, * WriteTagError */ } txtStatus.Refresh(); Application.DoEvents(); }
private bool ExecuteCMD(string tCMD) { string tMsg = null; Add2List("Sending->" + tCMD); try { if (m_Reader.IsConnected) { tMsg = m_Reader.Execute(tCMD); } else { ChangeStatus(eStatus.Offline); Add2List("Reader disconnected, please Connect"); return(false); } } catch (BasicReaderException eBRI) { Add2List("BasicReaderException: " + eBRI.ToString()); //MessageBox.Show("BasicReaderException: IDL ERR occured for CMD: " + tCMD + "\r\n" + eBRI.ToString()); ChangeStatus(eStatus.Offline); return(false); } //"H112233445566778899001122 HE2001040\r\nOK>" Add2List("--->" + tMsg); //Show TAG ID if (sCurrentCMD.Equals("READ TAGID")) { sbyte[] aFieldSeparator = { (sbyte)' ' }; sbyte[] aRespBuf = tools.StrToSByteArray(tMsg); Tag[] tags = BRIParser.GetTags(aRespBuf, aFieldSeparator); if (tags == null) { return(false); } if (tags.GetLength(0) == 1) { //only one tag should be visible //save the last 22Bits as Box ID if (VWGTLTAG.IsValidTag(tags[0].ToString()) == false) { DialogResult ant = MessageBox.Show("Tag does not meet specs. Overwrite?", "VW tag demo", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (ant == DialogResult.Yes) { UInt32 uBox = vwTag.BoxID; vwTag = new VWGTLTAG(); vwTag.BoxID = uBox; } else { ChangeStatus(eStatus.InvalidTag); return(false); } } else { vwTag = new VWGTLTAG(tags[0].ToString()); //create a new tag with the tag data read } //read the box id from the tag iCurrentBoxID = vwTag.BoxID; txtBoxID.Text = iCurrentBoxID.ToString(); //fill txtbox with data from tag txtTagDataStr.Text = vwTag.sFilter + " " + vwTag.iSupplierID.ToString() + " " + vwTag.iItemNumber.ToString(); System.Diagnostics.Debug.WriteLine("READ TAGID tag data: " + vwTag.ToString()); //tagKey is the same as tag data //System.Diagnostics.Debug.WriteLine("READ TAGID: tags[0].tagkey: " + tools.Hex2Asc(sByteArrayToString(tags[0].TagKey))); //store TAGID sHexCurrentTagID = tags[0].TagFields.FieldArray[0].DataString.Substring(1); ChangeStatus(eStatus.WriteTag); } else { //only one tag should be visible ChangeStatus(eStatus.TooManyTags); } //read tag data (aka EPCID) if (tMsg.StartsWith("H")) { string s; s = tMsg.Substring(1, tMsg.IndexOf(" ") - 1); txtTagData.Text = s; s = tMsg.Substring(s.Length + 1); s = tools.CopyToR(s); s = s.Substring(s.IndexOf("H") + 1); txtTagID.Text = s; } } if (sCurrentCMD.Equals("ATTRIB TAGTYPE=EPCC1G2") == true) { if (tMsg.IndexOf("OK") >= 0) { return(true); } else { return(false); } } if (tMsg.IndexOf("ERR") >= 0 && sCurrentCMD.Equals("ATTRIB SCHEDOPT=1") == false) { //MessageBox.Show("Warning, BRI ERR occured for: " + tCMD + "\r\n" + tMsg); Add2List("Warning, BRI ERR occured for: " + tCMD + "\r\n" + tMsg); return(false); } if (sCurrentCMD.StartsWith("W ")) { if (tMsg.IndexOf("ERR") >= 0 && CurrentStatus == eStatus.WriteTag) { ChangeStatus(eStatus.WriteTagError); return(false); } if (tMsg.IndexOf("WROK") >= 0 && (CurrentStatus == eStatus.WriteTagError) || (CurrentStatus == eStatus.WriteTag)) { HighBeep.Play(); ChangeStatus(eStatus.ReadBarcode); if (tMsg.StartsWith("H"))//"H303033353032393035343135 HE2001040 WROK\r\nOK>" { string s; s = tMsg.Substring(1, tMsg.IndexOf(" ") - 1); txtTagData.Text = s; System.Diagnostics.Debug.WriteLine("WROK: tag data string: " + s); s = tMsg.Substring(s.Length + 1); s = tools.CopyToR(s); s = s.Substring(s.IndexOf("H") + 1); //"E2001040 WROK" txtTagID.Text = s.Substring(1, s.IndexOf(" ") - 1); System.Diagnostics.Debug.WriteLine(s); } } } return(true); }