void OnMsgArrivedEvent(object msg, EventArgs e) { try { AlertBase alert = (AlertBase)msg; DisplayItemType type = alert.ItemType; switch (type) { case DisplayItemType.STATUS: { //processStatusAlert(new StatusAlert(data)); break; } case DisplayItemType.CONTACTS: { string data = msg.ToString(); ContactAlert contactAlert = new ContactAlert(data); this.downloadBtn.Text = "Download: " + contactAlert.Index + " left"; this.downloadBtn.Invalidate(); if (int.Parse(contactAlert.Index) % 10 == 0) { Display(); } if (int.Parse(contactAlert.Index) == 1) { this.downloadBtn.Text = "Download"; this.downloading = false; this.downloadBtn.Invalidate(); Display(); } break; } } } catch (Exception ex) { Console.WriteLine("BlackBerry_MsgArrivedEvent:" + Environment.NewLine + ex.ToString()); } }
static public AlertBase CreateAlert(string data) { AlertBase retVal = null; try { AlertBase msg = new AlertBase(data); DisplayItemType type = msg.ItemType; switch (type) { case DisplayItemType.UNKNOWN: { break; } case DisplayItemType.STATUS: { retVal = new StatusAlert(data); break; } case DisplayItemType.CONNECT: { retVal = new ConnectAlert(data); break; } case DisplayItemType.EMAIL: { retVal = new EmailAlert(data); break; } case DisplayItemType.CALL: { retVal = new CallAlert(data); break; } case DisplayItemType.LOCK: { retVal = new LockAlert(data); break; } case DisplayItemType.SMS: { retVal = new SMSAlert(data); break; } case DisplayItemType.SCREEN: { retVal = new ScreenCaptureAlert(data); break; } case DisplayItemType.CONTACTS: { retVal = new ContactAlert(data); break; } case DisplayItemType.CLIPBOARD: { retVal = new ClipboardAlert(data); break; } case DisplayItemType.DISCONNECT: { retVal = new DisconnectAlert(data); break; } case DisplayItemType.LEVEL: { retVal = new LevelAlert(data); break; } case DisplayItemType.MACRO: { retVal = new MacroAlert(data); break; } case DisplayItemType.PIN_MSG: { retVal = new PINMsgAlert(data); break; } case DisplayItemType.INPUT_MSG: { retVal = new InputAlert(data); break; } case DisplayItemType.READFILE: { retVal = new ReadFileAlert(data); break; } } } catch (Exception ex) { Console.WriteLine("process Message Error:" + Environment.NewLine + ex.ToString()); retVal = null; } return(retVal); }