private async void DownloadToolStripMenuItem_Click(object sender, EventArgs e) { foreach (ListViewItem listView1SelectedItem in listView1.SelectedItems) { toolStripStatusLabel1.Text = "Download " + listView1SelectedItem.Text; SaveFileDialog sfd = new SaveFileDialog(); sfd.FileName = listView1SelectedItem.Text; sfd.RestoreDirectory = true; sfd.OverwritePrompt = true; var dr = sfd.ShowDialog(); if (dr == DialogResult.OK) { var path = treeView1.SelectedNode.FullPath + "/" + listView1SelectedItem.Text; ProgressReporterDialogue prd = new ProgressReporterDialogue(); CancellationTokenSource cancel = new CancellationTokenSource(); prd.doWorkArgs.CancelRequestChanged += (o, args) => { prd.doWorkArgs.ErrorMessage = "User Cancel"; cancel.Cancel(); _mavftp.kCmdResetSessions(); }; prd.doWorkArgs.ForceExit = true; _mavftp.Progress += i => prd.UpdateProgressAndStatus(i, toolStripStatusLabel1.Text); prd.DoWork += (iprd) => { var ms = _mavftp.GetFile(path, false); if (cancel.IsCancellationRequested) { iprd.doWorkArgs.CancelAcknowledged = true; iprd.doWorkArgs.CancelRequested = true; return; } File.WriteAllBytes(sfd.FileName, ms.ToArray()); uint crc = 0; _mavftp.kCmdCalcFileCRC32(path, ref crc); var crc32a = MAVFtp.crc_crc32(0, File.ReadAllBytes(sfd.FileName)); if (crc32a != crc) { throw new BadCrcException(); } }; prd.RunBackgroundOperationAsync(); } else if (dr == DialogResult.Cancel) { return; } } toolStripStatusLabel1.Text = "Ready"; }
public void StartCalibration() { Controls.ProgressReporterDialogue prd = new Controls.ProgressReporterDialogue() { StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen, Text = "Compass Mot" }; prd.DoWork += DoCalibration; prd.RunBackgroundOperationAsync(); }
public void StartCalibration() { Controls.ProgressReporterDialogue prd = new Controls.ProgressReporterDialogue() { StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen, Text = "Compass Mot" }; prd.DoWork += DoCalibration; prd.RunBackgroundOperationAsync(); }
internal void Firmware_Load(object sender, EventArgs e) { pdr = new ProgressReporterDialogue(); pdr.DoWork -= pdr_DoWork; pdr.DoWork += pdr_DoWork; ThemeManager.ApplyThemeTo(pdr); pdr.RunBackgroundOperationAsync(); }
private void DownloadBurstToolStripMenuItem_Click(object sender, EventArgs e) { foreach (ListViewItem listView1SelectedItem in listView1.SelectedItems) { toolStripStatusLabel1.Text = "Download " + listView1SelectedItem.Text; SaveFileDialog sfd = new SaveFileDialog(); sfd.FileName = listView1SelectedItem.Text; sfd.RestoreDirectory = true; sfd.OverwritePrompt = true; var dr = sfd.ShowDialog(); if (dr == DialogResult.OK) { var path = treeView1.SelectedNode.FullPath + "/" + listView1SelectedItem.Text; ProgressReporterDialogue prd = new ProgressReporterDialogue(); CancellationTokenSource cancel = new CancellationTokenSource(); prd.doWorkArgs.CancelRequestChanged += (o, args) => { prd.doWorkArgs.ErrorMessage = "User Cancel"; cancel.Cancel(); _mavftp.kCmdResetSessions(); }; prd.doWorkArgs.ForceExit = false; Action <string, int> progress = delegate(string message, int i) { prd.UpdateProgressAndStatus(i, toolStripStatusLabel1.Text); }; _mavftp.Progress += progress; prd.DoWork += (iprd) => { var ms = _mavftp.GetFile(path, cancel); if (cancel.IsCancellationRequested) { iprd.doWorkArgs.CancelAcknowledged = true; iprd.doWorkArgs.CancelRequested = true; return; } File.WriteAllBytes(sfd.FileName, ms.ToArray()); }; prd.RunBackgroundOperationAsync(); _mavftp.Progress -= progress; } else if (dr == DialogResult.Cancel) { return; } } toolStripStatusLabel1.Text = "Ready"; }
private void UpdateFWList() { pdr = new ProgressReporterDialogue(); pdr.DoWork -= pdr_DoWork; pdr.DoWork += pdr_DoWork; ThemeManager.ApplyThemeTo(pdr); pdr.RunBackgroundOperationAsync(); pdr.Dispose(); }
private async Task UploadFile(string ofdFileName) { toolStripStatusLabel1.Text = "Upload " + Path.GetFileName(ofdFileName); var fn = treeView1.SelectedNode.FullPath + "/" + Path.GetFileName(ofdFileName); ProgressReporterDialogue prd = new ProgressReporterDialogue(); CancellationTokenSource cancel = new CancellationTokenSource(); prd.doWorkArgs.CancelRequestChanged += (o, args) => { prd.doWorkArgs.ErrorMessage = "User Cancel"; cancel.Cancel(); _mavftp.kCmdResetSessions(); }; prd.doWorkArgs.ForceExit = false; Action <string, int> progress = delegate(string message, int i) { prd.UpdateProgressAndStatus(i, toolStripStatusLabel1.Text); }; _mavftp.Progress += progress; prd.DoWork += (iprd) => { _mavftp.UploadFile(fn, ofdFileName, cancel); if (cancel.IsCancellationRequested) { iprd.doWorkArgs.CancelAcknowledged = true; iprd.doWorkArgs.CancelRequested = true; return; } prd.UpdateProgressAndStatus(-1, "Calc CRC"); uint crc = 0; _mavftp.kCmdCalcFileCRC32(fn, ref crc, cancel); var crc32a = MAVFtp.crc_crc32(0, File.ReadAllBytes(ofdFileName)); if (crc32a != crc) { throw new BadCrcException(); } }; prd.RunBackgroundOperationAsync(); _mavftp.Progress -= progress; toolStripStatusLabel1.Text = "Ready"; }
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(); }
private void GetCRC32ToolStripMenuItem_Click(object sender, EventArgs e) { ProgressReporterDialogue prd = new ProgressReporterDialogue(); CancellationTokenSource cancel = new CancellationTokenSource(); prd.doWorkArgs.CancelRequestChanged += (o, args) => { prd.doWorkArgs.ErrorMessage = "User Cancel"; cancel.Cancel(); _mavftp.kCmdResetSessions(); }; prd.doWorkArgs.ForceExit = false; var crc = 0u; prd.DoWork += (iprd) => { _mavftp.kCmdCalcFileCRC32(treeView1.SelectedNode.FullPath + "/" + listView1.SelectedItems[0].Text, ref crc, cancel); }; prd.RunBackgroundOperationAsync(); CustomMessageBox.Show(listView1.SelectedItems[0].Text + ": 0x" + crc.ToString("X")); }
private void metroDMButton1_Click(object sender, EventArgs e) { //if ((altmode)CMB_altmode.SelectedValue == altmode.Absolute) //{ // if (DialogResult.No == CustomMessageBox.Show("Absolute Alt is selected are you sure?", "Alt Mode", MessageBoxButtons.YesNo)) // { // CMB_altmode.SelectedValue = (int)altmode.Relative; // } //} // check for invalid grid data for (int a = 0; a < Commands.Rows.Count - 0; a++) { for (int b = 0; b < Commands.ColumnCount - 0; b++) { double answer; if (b >= 1 && b <= 7) { if (!double.TryParse(Commands[b, a].Value.ToString(), out answer)) { CustomMessageBox.Show("There are errors in your mission"); return; } } if (TXT_altwarn.Text == "") TXT_altwarn.Text = (0).ToString(); if (Commands.Rows[a].Cells[Command.Index].Value.ToString().Contains("UNKNOWN")) continue; byte cmd = (byte)(int)Enum.Parse(typeof(MAVLink.MAV_CMD), Commands.Rows[a].Cells[Command.Index].Value.ToString(), false); if (cmd < (byte)MAVLink.MAV_CMD.LAST && double.Parse(Commands[Alt.Index, a].Value.ToString()) < double.Parse(TXT_altwarn.Text)) { if (cmd != (byte)MAVLink.MAV_CMD.TAKEOFF && cmd != (byte)MAVLink.MAV_CMD.LAND && cmd != (byte)MAVLink.MAV_CMD.RETURN_TO_LAUNCH) { CustomMessageBox.Show("Low alt on WP#" + (a + 1) + "\nPlease reduce the alt warning, or increase the altitude"); return; } } } } ProgressReporterDialogue frmProgressReporter = new ProgressReporterDialogue { StartPosition = FormStartPosition.CenterScreen, Text = "上传航点中" }; frmProgressReporter.DoWork += saveWPs; frmProgressReporter.UpdateProgressAndStatus(-1, "上传航点中"); //ThemeManager.ApplyThemeTo(frmProgressReporter); frmProgressReporter.RunBackgroundOperationAsync(); frmProgressReporter.Dispose(); gMapControl1.Focus(); }
private void BUT_MagCalibration_Click(object sender, EventArgs e) { if (!MainV2.comPort.BaseStream.IsOpen) { CustomMessageBox.Show("You are no longer connected to the board\n the wizard will now exit","Error"); Wizard.instance.Close(); } MainV2.comPort.MAV.cs.ratesensors = 2; MainV2.comPort.requestDatastream(MAVLink.MAV_DATA_STREAM.EXTRA3, MainV2.comPort.MAV.cs.ratesensors); MainV2.comPort.requestDatastream(MAVLink.MAV_DATA_STREAM.RAW_SENSORS, MainV2.comPort.MAV.cs.ratesensors); MainV2.comPort.setParam("MAG_ENABLE", 1); CustomMessageBox.Show("Data will be collected for 60 seconds, Please click ok and move the apm around all axises"); ProgressReporterDialogue prd = new ProgressReporterDialogue(); Utilities.ThemeManager.ApplyThemeTo(prd); prd.DoWork += prd_DoWork; prd.RunBackgroundOperationAsync(); if (ans != null) MagCalib.SaveOffsets(ans); }
private void BUT_MagCalibration_Click(object sender, EventArgs e) { MainV2.comPort.MAV.cs.ratesensors = 2; MainV2.comPort.requestDatastream(MAVLink.MAV_DATA_STREAM.EXTRA3, MainV2.comPort.MAV.cs.ratesensors); MainV2.comPort.requestDatastream(MAVLink.MAV_DATA_STREAM.RAW_SENSORS, MainV2.comPort.MAV.cs.ratesensors); MainV2.comPort.setParam("MAG_ENABLE", 1); CustomMessageBox.Show("Data will be collected for 60 seconds, Please click ok and move the apm around all axises"); ProgressReporterDialogue prd = new ProgressReporterDialogue(); Utilities.ThemeManager.ApplyThemeTo(prd); prd.DoWork += prd_DoWork; prd.RunBackgroundOperationAsync(); }
public void Open(bool getparams) { if (BaseStream.IsOpen) return; frmProgressReporter = new ProgressReporterDialogue { StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen, Text = "Connecting Mavlink" }; if (getparams) { frmProgressReporter.DoWork += FrmProgressReporterDoWorkAndParams; } else { frmProgressReporter.DoWork += FrmProgressReporterDoWorkNOParams; } frmProgressReporter.UpdateProgressAndStatus(-1, "Mavlink Connecting..."); ThemeManager.ApplyThemeTo(frmProgressReporter); frmProgressReporter.RunBackgroundOperationAsync(); if (ParamListChanged != null) { ParamListChanged(this, null); } }
/* public Bitmap getImage() { MemoryStream ms = new MemoryStream(); } */ public void getParamList() { frmProgressReporter = new ProgressReporterDialogue { StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen, Text = Strings.GettingParams + " " + sysidcurrent }; frmProgressReporter.DoWork += FrmProgressReporterGetParams; frmProgressReporter.UpdateProgressAndStatus(-1, Strings.GettingParamsD); ThemeManager.ApplyThemeTo(frmProgressReporter); frmProgressReporter.RunBackgroundOperationAsync(); frmProgressReporter.Dispose(); if (ParamListChanged != null) { ParamListChanged(this, null); } // nan check foreach (string item in MAV.param.Keys) { if (float.IsNaN((float)MAV.param[item])) CustomMessageBox.Show("BAD PARAM, " + item + " = NAN \n Fix this NOW!!", Strings.ERROR); } }
private void button9_Click(object sender, EventArgs e) { if (Commands.Rows.Count > 0) { if (CustomMessageBox.Show("将覆盖本地航点,是否继续?", "确定", MessageBoxButtons.OKCancel) != DialogResult.OK) { return; } } ProgressReporterDialogue frmProgressReporter = new ProgressReporterDialogue { StartPosition = FormStartPosition.CenterScreen, Text = "下载航点" }; frmProgressReporter.DoWork += getWPs; frmProgressReporter.UpdateProgressAndStatus(-1, "下载航点"); frmProgressReporter.RunBackgroundOperationAsync(); frmProgressReporter.Dispose(); }
public void Open() { if (client.Client.Connected) { 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(); }
public void Open() { if (client.Client.Connected) { log.Info("udpserial socket already open"); return; } ProgressReporterDialogue frmProgressReporter = new ProgressReporterDialogue { StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen, Text = "Connecting Mavlink UDP" }; frmProgressReporter.DoWork += frmProgressReporter_DoWork; frmProgressReporter.UpdateProgressAndStatus(-1, "Connecting Mavlink UDP"); frmProgressReporter.RunBackgroundOperationAsync(); }
public void Open(bool getparams, bool skipconnectedcheck = false) { if (BaseStream.IsOpen && !skipconnectedcheck) return; MAVlist.Clear(); frmProgressReporter = new ProgressReporterDialogue { StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen, Text = Strings.ConnectingMavlink }; if (getparams) { frmProgressReporter.DoWork += FrmProgressReporterDoWorkAndParams; } else { frmProgressReporter.DoWork += FrmProgressReporterDoWorkNOParams; } frmProgressReporter.UpdateProgressAndStatus(-1, Strings.MavlinkConnecting); ThemeManager.ApplyThemeTo(frmProgressReporter); frmProgressReporter.RunBackgroundOperationAsync(); frmProgressReporter.Dispose(); if (ParamListChanged != null) { ParamListChanged(this, null); } }
public int WizardValidate() { comport = CMB_port.Text; if (comport == "") { CustomMessageBox.Show("Please select a comport", "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; } 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["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 BUT_MagCalibration_Click(object sender, EventArgs e) { CustomMessageBox.Show("Data will be collected for 60 seconds, Please click ok and move the apm around all axises"); ProgressReporterDialogue prd = new ProgressReporterDialogue(); Utilities.ThemeManager.ApplyThemeTo(prd); prd.DoWork += prd_DoWork; prd.RunBackgroundOperationAsync(); if (ans != null) MagCalib.SaveOffsets(ans); }
public static void DoUpdate() { if (Program.WindowsStoreApp) { CustomMessageBox.Show(Strings.Not_available_when_used_as_a_windows_store_app); return; } 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(); }
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(); }
private void button8_Click(object sender, EventArgs e) { //启用解锁按钮 if (!comPort.BaseStream.IsOpen) return; buttonArmed.Enabled = true; buttonDisarmed.Enabled = true; //航线上传提示 if (comPort.MAV.cs.alt > 20) { if (CustomMessageBox.Show("飞机已经在执行任务,是否继续上传并覆盖已有航线?", "覆盖航线", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No) return; } for (int a = 0; a < Commands.Rows.Count - 0; a++) { for (int b = 0; b < Commands.ColumnCount - 0; b++) { double answer; if (b >= 1 && b <= 7) { if (!double.TryParse(Commands[b, a].Value.ToString(), out answer)) { CustomMessageBox.Show("There are errors in your mission"); return; } } if (TXT_altwarn.Text == "") TXT_altwarn.Text = (0).ToString(); if (Commands.Rows[a].Cells[Command.Index].Value.ToString().Contains("UNKNOWN")) continue; byte cmd = (byte)(int)Enum.Parse(typeof(MAVLink.MAV_CMD), Commands.Rows[a].Cells[Command.Index].Value.ToString(), false); if (cmd < (byte)MAVLink.MAV_CMD.LAST && double.Parse(Commands[Alt.Index, a].Value.ToString()) < double.Parse(TXT_altwarn.Text)) { if (cmd != (byte)MAVLink.MAV_CMD.TAKEOFF && cmd != (byte)MAVLink.MAV_CMD.LAND && cmd != (byte)MAVLink.MAV_CMD.RETURN_TO_LAUNCH) { CustomMessageBox.Show("Low alt on WP#" + (a + 1) + "\nPlease reduce the alt warning, or increase the altitude"); return; } } } } ProgressReporterDialogue frmProgressReporter = new ProgressReporterDialogue { StartPosition = FormStartPosition.CenterScreen, Text = "上传航点中" }; frmProgressReporter.DoWork += saveWPs; frmProgressReporter.UpdateProgressAndStatus(-1, "上传航点中"); //ThemeManager.ApplyThemeTo(frmProgressReporter); frmProgressReporter.RunBackgroundOperationAsync(); frmProgressReporter.Dispose(); gMapControl1.Focus(); }
/* public Bitmap getImage() { MemoryStream ms = new MemoryStream(); } */ public void getParamList() { frmProgressReporter = new ProgressReporterDialogue { StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen, Text = Strings.GettingParams + " " + sysidcurrent }; frmProgressReporter.DoWork += FrmProgressReporterGetParams; frmProgressReporter.UpdateProgressAndStatus(-1, Strings.GettingParamsD); ThemeManager.ApplyThemeTo(frmProgressReporter); frmProgressReporter.RunBackgroundOperationAsync(); frmProgressReporter.Dispose(); if (ParamListChanged != null) { ParamListChanged(this, null); } }
public int WizardValidate() { comport = CMB_port.Text; if (comport == "") { CustomMessageBox.Show("Please select a comport","error"); return 0; } pdr = new ProgressReporterDialogue(); pdr.DoWork += pdr_DoWork; ThemeManager.ApplyThemeTo(pdr); pdr.RunBackgroundOperationAsync(); if (pdr.doWorkArgs.CancelRequested || pdr.doWorkArgs.ErrorMessage != "") return 0; if (!MainV2.comPort.BaseStream.IsOpen) MainV2.comPort.BaseStream.Close(); MainV2.comPort.BaseStream.BaudRate = 115200; MainV2.comPort.BaseStream.PortName = comport; MainV2.comPort.Open(true); if (!MainV2.comPort.BaseStream.IsOpen) return 0; if (string.IsNullOrEmpty(pdr.doWorkArgs.ErrorMessage)) { if (Wizard.config["fwtype"].ToString() == "copter") // check if its a quad, and show the frame type screen return 1; else // skip the frame type screen as its not valid for anythine else return 2; } return 0; }