public static void DoUpdate() { if (Program.WindowsStoreApp) { CustomMessageBox.Show(Strings.Not_available_when_used_as_a_windows_store_app); return; } IProgressReporterDialogue frmProgressReporter = new ProgressReporterDialogue() { Text = "Check for Updates", StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen }; ThemeManager.ApplyThemeTo(frmProgressReporter); frmProgressReporter.DoWork += new DoWorkEventHandler(DoUpdateWorker_DoWork); frmProgressReporter.doWorkArgs.CancelRequestChanged += (sender, args) => { frmProgressReporter.doWorkArgs.CancelAcknowledged = true; }; frmProgressReporter.doWorkArgs.ForceExit = true; frmProgressReporter.UpdateProgressAndStatus(-1, "Checking for Updates"); frmProgressReporter.RunBackgroundOperationAsync(); frmProgressReporter.Dispose(); }
private void UpdateFWList() { pdr = new ProgressReporterDialogue(); pdr.DoWork -= pdr_DoWork; pdr.DoWork += pdr_DoWork; ThemeManager.ApplyThemeTo(pdr); pdr.RunBackgroundOperationAsync(); pdr.Dispose(); }
public static void DoUpdate() { ProgressReporterDialogue frmProgressReporter = new ProgressReporterDialogue() { Text = "Check for Updates", StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen }; ThemeManager.ApplyThemeTo(frmProgressReporter); frmProgressReporter.DoWork += new ProgressReporterDialogue.DoWorkEventHandler(DoUpdateWorker_DoWork); frmProgressReporter.UpdateProgressAndStatus(-1, "Checking for Updates"); frmProgressReporter.RunBackgroundOperationAsync(); frmProgressReporter.Dispose(); }
void doUI(string inputfn, string outputfn, bool showui = true) { this.inputfn = inputfn; this.outputfn = outputfn; prd = new ProgressReporterDialogue(); prd.DoWork += prd_DoWork; prd.UpdateProgressAndStatus(-1, Strings.Converting_bin_to_log); this.convertstatus += BinaryLog_convertstatus; ThemeManager.ApplyThemeTo(prd); prd.RunBackgroundOperationAsync(); prd.Dispose(); }
public void Open() { if (client.Client.Connected || IsOpen) { log.Info("udpserial socket already open"); return; } client.Close(); string dest = Port; dest = OnSettings("UDP_port", dest); if (System.Windows.Forms.DialogResult.Cancel == InputBox.Show("Listern Port", "Enter Local port (ensure remote end is already sending)", ref dest)) { return; } Port = dest; OnSettings("UDP_port", Port, true); ProgressReporterDialogue frmProgressReporter = new ProgressReporterDialogue { StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen, Text = "Connecting UDP" }; ApplyThemeTo(frmProgressReporter); frmProgressReporter.DoWork += frmProgressReporter_DoWork; frmProgressReporter.UpdateProgressAndStatus(-1, "Connecting UDP"); frmProgressReporter.RunBackgroundOperationAsync(); frmProgressReporter.Dispose(); }
private async void myDataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { // Ignore clicks that are not on button cells. if (e.RowIndex < 0) { return; } try { byte nodeID = (byte)myDataGridView1[iDDataGridViewTextBoxColumn.Index, e.RowIndex].Value; if (e.ColumnIndex == myDataGridView1.Columns["Parameter"].Index) { IProgressReporterDialogue prd = new ProgressReporterDialogue(); List <uavcan.uavcan_protocol_param_GetSet_res> paramlist = new List <uavcan.uavcan_protocol_param_GetSet_res>(); prd.doWorkArgs.ForceExit = true; prd.doWorkArgs.CancelRequestChanged += (sender2, args) => { prd.doWorkArgs.CancelAcknowledged = true; }; prd.DoWork += dialogue => { paramlist = can.GetParameters(nodeID); }; prd.UpdateProgressAndStatus(-1, Strings.GettingParams); prd.RunBackgroundOperationAsync(); if (!prd.doWorkArgs.CancelRequested) { new UAVCANParams(can, nodeID, paramlist).ShowUserControl(); } } else if (e.ColumnIndex == myDataGridView1.Columns["Restart"].Index) { can.RestartNode(nodeID); } else if (e.ColumnIndex == myDataGridView1.Columns["updateDataGridViewTextBoxColumn"].Index) { ProgressReporterDialogue prd = new ProgressReporterDialogue(); uavcan.FileSendProgressArgs filesend = (id, file, percent) => { prd.UpdateProgressAndStatus((int)percent, id + " " + file); }; can.FileSendProgress += filesend; if (CustomMessageBox.Show("Do you want to search the internet for an update?", "Update", CustomMessageBox.MessageBoxButtons.YesNo) == CustomMessageBox.DialogResult.Yes) { var devicename = myDataGridView1[nameDataGridViewTextBoxColumn.Index, e.RowIndex].Value.ToString(); var hwversion = double.Parse( myDataGridView1[hardwareVersionDataGridViewTextBoxColumn.Index, e.RowIndex].Value .ToString(), CultureInfo.InvariantCulture); var usebeta = false; if (CustomMessageBox.Show("Do you want to search for a beta firmware? (not recommended)", "Update", CustomMessageBox.MessageBoxButtons.YesNo) == CustomMessageBox.DialogResult.Yes) { usebeta = true; } var url = can.LookForUpdate(devicename, hwversion, usebeta); if (url != string.Empty) { try { prd.DoWork += dialogue => { var tempfile = Path.GetTempFileName(); Download.getFilefromNet(url, tempfile); try { can.Update(nodeID, devicename, hwversion, tempfile); } catch (Exception ex) { throw; } return; }; prd.RunBackgroundOperationAsync(); } catch (Exception ex) { CustomMessageBox.Show(ex.Message, Strings.ERROR); } } else { CustomMessageBox.Show(Strings.UpdateNotFound, Strings.UpdateNotFound); } } else { FileDialog fd = new OpenFileDialog(); fd.RestoreDirectory = true; fd.Filter = "*.bin|*.bin"; var dia = fd.ShowDialog(); if (fd.CheckFileExists && dia == DialogResult.OK) { try { prd.DoWork += dialogue => { can.Update(nodeID, myDataGridView1[nameDataGridViewTextBoxColumn.Index, e.RowIndex].Value.ToString(), 0, fd.FileName); return; }; prd.RunBackgroundOperationAsync(); } catch (Exception ex) { CustomMessageBox.Show(ex.Message, Strings.ERROR); } } } can.FileSendProgress -= filesend; prd.Dispose(); } } catch { } }
private void FirmwareUpdate(byte nodeID, bool beta = false) { ProgressReporterDialogue prd = new ProgressReporterDialogue(); uavcan.FileSendProgressArgs filesend = (id, file, percent) => { prd.UpdateProgressAndStatus((int)percent, id + " " + file); }; can.FileSendProgress += filesend; var devicename = can.GetNodeName(nodeID); var hwversion = double.Parse( can.NodeInfo[nodeID].hardware_version.major + "." + can.NodeInfo[nodeID].hardware_version.minor, CultureInfo.InvariantCulture); if (CustomMessageBox.Show("Do you want to search the internet for an update?", "Update", CustomMessageBox.MessageBoxButtons.YesNo) == CustomMessageBox.DialogResult.Yes) { var url = can.LookForUpdate(devicename, hwversion, beta); if (url != string.Empty) { try { var cancel = new CancellationTokenSource(); prd.DoWork += dialogue => { prd.UpdateProgressAndStatus(5, "Download FW"); var tempfile = Path.GetTempFileName(); Download.getFilefromNet(url, tempfile); uavcan.FileSendCompleteArgs file = (p, s) => { prd.UpdateProgressAndStatus(100, "File send complete"); }; uavcan.FileSendProgressArgs fileprog = (n, f, p) => { prd.UpdateProgressAndStatus((int)p, f); }; can.FileSendComplete += file; can.FileSendProgress += fileprog; try { can.Update(nodeID, devicename, hwversion, tempfile, cancel.Token); } catch (Exception) { throw; } finally { can.FileSendComplete -= file; can.FileSendProgress -= fileprog; } return; }; prd.btnCancel.Click += (sender, args) => { prd.doWorkArgs.CancelAcknowledged = true; cancel.Cancel(); }; prd.RunBackgroundOperationAsync(); } catch (Exception ex) { CustomMessageBox.Show(ex.Message, Strings.ERROR); } } else { CustomMessageBox.Show(Strings.UpdateNotFound, Strings.UpdateNotFound); } } else { FileDialog fd = new OpenFileDialog(); fd.RestoreDirectory = true; fd.Filter = "*.bin|*.bin"; var dia = fd.ShowDialog(); if (fd.CheckFileExists && dia == DialogResult.OK) { uavcan.FileSendCompleteArgs file = (p, s) => { prd.UpdateProgressAndStatus(100, "File send complete"); }; uavcan.FileSendProgressArgs fileprog = (n, f, p) => { prd.UpdateProgressAndStatus((int)p, f); }; can.FileSendComplete += file; can.FileSendProgress += fileprog; try { var cancel = new CancellationTokenSource(); prd.DoWork += dialogue => { can.Update(nodeID, devicename, 0, fd.FileName, cancel.Token); return; }; prd.btnCancel.Click += (sender, args) => { prd.doWorkArgs.CancelAcknowledged = true; cancel.Cancel(); }; prd.RunBackgroundOperationAsync(); } catch (Exception ex) { CustomMessageBox.Show(ex.Message, Strings.ERROR); } finally { can.FileSendComplete -= file; can.FileSendProgress -= fileprog; } } } can.FileSendProgress -= filesend; prd.Dispose(); }
private async void myDataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { // Ignore clicks that are not on button cells. if (e.RowIndex < 0 || e.ColumnIndex != myDataGridView1.Columns["updateDataGridViewTextBoxColumn"].Index && e.ColumnIndex != myDataGridView1.Columns["Parameter"].Index) { return; } byte nodeID = (byte)myDataGridView1[iDDataGridViewTextBoxColumn.Index, e.RowIndex].Value; if (e.ColumnIndex == myDataGridView1.Columns["Parameter"].Index) { var paramlist = can.GetParameters(nodeID); new UAVCANParams(can, nodeID, paramlist).ShowUserControl(); } else if (e.ColumnIndex == myDataGridView1.Columns["updateDataGridViewTextBoxColumn"].Index) { ProgressReporterDialogue prd = new ProgressReporterDialogue(); uavcan.FileSendProgressArgs filesend = (id, file, percent) => { prd.UpdateProgressAndStatus((int)percent, id + " " + file); }; can.FileSendProgress += filesend; if (CustomMessageBox.Show("Do you want to search the internet for an update?", "Update", CustomMessageBox.MessageBoxButtons.YesNo) == CustomMessageBox.DialogResult.Yes) { var devicename = myDataGridView1[nameDataGridViewTextBoxColumn.Index, e.RowIndex].Value.ToString(); var hwversion = double.Parse(myDataGridView1[hardwareVersionDataGridViewTextBoxColumn.Index, e.RowIndex].Value.ToString(), CultureInfo.InvariantCulture); var url = can.LookForUpdate(devicename, hwversion); if (url != string.Empty) { try { prd.DoWork += dialogue => { var tempfile = Path.GetTempFileName(); Download.getFilefromNet(url, tempfile); can.Update(nodeID, devicename, hwversion, tempfile); return; }; prd.RunBackgroundOperationAsync(); } catch (Exception ex) { CustomMessageBox.Show(ex.Message, Strings.ERROR); } } else { CustomMessageBox.Show(Strings.UpdateNotFound, Strings.UpdateNotFound); } } else { FileDialog fd = new OpenFileDialog(); fd.RestoreDirectory = true; fd.Filter = "*-crc.bin|*-crc.bin"; var dia = fd.ShowDialog(); if (fd.CheckFileExists && dia == DialogResult.OK) { try { prd.DoWork += dialogue => { can.Update(nodeID, myDataGridView1[nameDataGridViewTextBoxColumn.Index, e.RowIndex].Value.ToString(), 0, fd.FileName); return; }; prd.RunBackgroundOperationAsync(); } catch (Exception ex) { CustomMessageBox.Show(ex.Message, Strings.ERROR); } } } can.FileSendProgress -= filesend; prd.Dispose(); } }
public int WizardValidate() { comport = CMB_port.Text; if (comport == "") { CustomMessageBox.Show(Strings.SelectComport, Strings.ERROR); return(0); } if (!fwdone) { pdr = new ProgressReporterDialogue(); pdr.DoWork += pdr_DoWork; ThemeManager.ApplyThemeTo(pdr); pdr.RunBackgroundOperationAsync(); if (pdr.doWorkArgs.CancelRequested || !string.IsNullOrEmpty(pdr.doWorkArgs.ErrorMessage)) { return(0); } pdr.Dispose(); } if (MainV2.comPort.BaseStream.IsOpen) { MainV2.comPort.BaseStream.Close(); } // setup for over usb MainV2.comPort.BaseStream.BaudRate = 115200; MainV2.comPort.BaseStream.PortName = comport; MainV2.comPort.Open(true); // try again if (!MainV2.comPort.BaseStream.IsOpen) { CustomMessageBox.Show("Error connecting. Please unplug, plug back in, wait 10 seconds, and click OK", "Try Again"); MainV2.comPort.Open(true); } if (!MainV2.comPort.BaseStream.IsOpen) { return(0); } if (string.IsNullOrEmpty(pdr.doWorkArgs.ErrorMessage)) { if (Wizard.config.ContainsKey("fwtype") && Wizard.config.ContainsKey("fwframe")) { if (Wizard.config["fwtype"].ToString() == "copter" && Wizard.config["fwframe"].ToString() == "tri") { // check if its a tri, and skip the frame type screen return(2); } } if (Wizard.config["fwtype"].ToString() == "copter") { // check if its a quad, and show the frame type screen return(1); } if (Wizard.config["fwtype"].ToString() == "rover") { // check if its a rover, and show the compass cal screen - skip accel return(3); } else { // skip the frame type screen as its not valid for anythine else return(2); } } return(0); }
private void FirmwareUpdate(byte nodeID) { ProgressReporterDialogue prd = new ProgressReporterDialogue(); uavcan.FileSendProgressArgs filesend = (id, file, percent) => { prd.UpdateProgressAndStatus((int)percent, id + " " + file); }; can.FileSendProgress += filesend; var devicename = can.NodeInfo[nodeID].name.Aggregate("", (a, b) => a + (char)b).ToString(); var hwversion = double.Parse( can.NodeInfo[nodeID].hardware_version.major + "." + can.NodeInfo[nodeID].hardware_version.minor, CultureInfo.InvariantCulture); if (CustomMessageBox.Show("Do you want to search the internet for an update?", "Update", CustomMessageBox.MessageBoxButtons.YesNo) == CustomMessageBox.DialogResult.Yes) { var usebeta = false; if (CustomMessageBox.Show("Do you want to search for a beta firmware? (not recommended)", "Update", CustomMessageBox.MessageBoxButtons.YesNo) == CustomMessageBox.DialogResult.Yes) { usebeta = true; } var url = can.LookForUpdate(devicename, hwversion, usebeta); if (url != string.Empty) { try { prd.DoWork += dialogue => { var tempfile = Path.GetTempFileName(); Download.getFilefromNet(url, tempfile); try { can.Update(nodeID, devicename, hwversion, tempfile); } catch (Exception ex) { throw; } return; }; prd.RunBackgroundOperationAsync(); } catch (Exception ex) { CustomMessageBox.Show(ex.Message, Strings.ERROR); } } else { CustomMessageBox.Show(Strings.UpdateNotFound, Strings.UpdateNotFound); } } else { FileDialog fd = new OpenFileDialog(); fd.RestoreDirectory = true; fd.Filter = "*.bin|*.bin"; var dia = fd.ShowDialog(); if (fd.CheckFileExists && dia == DialogResult.OK) { try { prd.DoWork += dialogue => { can.Update(nodeID, devicename, 0, fd.FileName); return; }; prd.RunBackgroundOperationAsync(); } catch (Exception ex) { CustomMessageBox.Show(ex.Message, Strings.ERROR); } } } can.FileSendProgress -= filesend; prd.Dispose(); }