/// <summary> /// Each new Result received (through callback in NodeCore), goes /// here, then is processed in an appropriate method, exploiting /// overloading to change behaviour depending on Result subclass. /// </summary> /// <param name="result"></param> public void onNewResult(Communication.Result result) { Type type = result.GetType(); if (type == typeof(Communication.SearchTripResult)) { Communication.SearchTripResult sr = (Communication.SearchTripResult)result; ((ResultTabPage)ResultTabControl.TabPages[sr.OriginalQueryID]).setGridviewDatasource(sr.Trips); connectedStatusLabel.Text = "Connected"; } else if (type == typeof(Communication.InsertOkResult)) { connectedStatusLabel.Text = "Connected - Trip inserted"; } else if (type == typeof(Communication.LoginOkResult)) { SetConnectedView(true); connectDlg.Dispose(); } else if (type == typeof(Communication.RegisterOkResult)) { SetConnectedView(true); registerDlg.Dispose(); } else if (type == typeof(Communication.LoginErrorResult) || type == typeof(Communication.RegisterErrorResult) || type == typeof(Communication.InsertErrorResult)) { MessageBox.Show("Error. Something went wrong, try again."); } }
public void SendCommandsAction(Communication.Result result) { Device.BeginInvokeOnMainThread(() => { DisplayAlert(result.ToString(), null, "OK"); }); this.contentPageComponent.UserInteractionEnabled = true; }
public void GetDeviceStatusAction(Communication.Result result, IPrinterStatus printerStatus) { if (result == Communication.Result.Success) { this.listViewItemCollection.Add(new ListViewItem("Online", printerStatus.Offline, new string[] {"Offline", "Online"}, new Color[] {Color.Red, Color.Blue})); this.listViewItemCollection.Add(new ListViewItem("Cover", printerStatus.CoverOpen, new string[] {"Open", "Closed"}, new Color[] {Color.Red, Color.Blue})); if (printerStatus.ReceiptPaperEmpty) { this.listViewItemCollection.Add(new ListViewItem("Paper", "Empty", Color.Red)); } else if (printerStatus.ReceiptPaperNearEmptyInner || printerStatus.ReceiptPaperNearEmptyOuter) { this.listViewItemCollection.Add(new ListViewItem("Paper", "Near Empty", Color.Orange)); } else { this.listViewItemCollection.Add(new ListViewItem("Paper", "Ready", Color.Blue)); } if (Configuration.CashDrawerOpenActiveHigh) { this.listViewItemCollection.Add(new ListViewItem("Cash Drawer", printerStatus.CompulsionSwitch, new string[] {"Open", "Closed"}, new Color[] {Color.Red, Color.Blue})); } else { this.listViewItemCollection.Add(new ListViewItem("Cash Drawer", ! printerStatus.CompulsionSwitch, new string[] {"Open", "Closed"}, new Color[] {Color.Red, Color.Blue})); } this.listViewItemCollection.Add(new ListViewItem("Head Temperature", printerStatus.OverTemp, new string[] {"High", "Normal"}, new Color[] {Color.Red, Color.Blue})); this.listViewItemCollection.Add(new ListViewItem("Non Recoverable Error", printerStatus.UnrecoverableError, new string[] {"Occurs", "Ready"}, new Color[] {Color.Red, Color.Blue})); this.listViewItemCollection.Add(new ListViewItem("Paper Cutter", printerStatus.CutterError, new string[] {"Error", "Ready"}, new Color[] {Color.Red, Color.Blue})); this.listViewItemCollection.Add(new ListViewItem("Head Thermistor", printerStatus.HeadThermistorError, new string[] {"Error", "Normal"}, new Color[] {Color.Red, Color.Blue})); this.listViewItemCollection.Add(new ListViewItem("Voltage", printerStatus.VoltageError, new string[] {"Error", "Normal"}, new Color[] {Color.Red, Color.Blue})); } else { Device.BeginInvokeOnMainThread(() => { DisplayAlert(result.ToString(), null, "OK"); }); } this.contentPageComponent.UserInteractionEnabled = true; }