示例#1
0
        private void BUT_writePIDS_Click(object sender, EventArgs e)
        {
            if (Common.MessageShowAgain("Write Raw Params Tree", "Are you Sure?") != DialogResult.OK)
            {
                return;
            }

            // sort with enable at the bottom - this ensures params are set before the function is disabled
            var temp = new List <string>();

            foreach (var item in _changes.Keys)
            {
                temp.Add((string)item);
            }

            temp.SortENABLE();

            foreach (string value in temp)
            {
                try
                {
                    MainV2.comPort.setParam(value, (float)_changes[value]);

                    _changes.Remove(value);
                }
                catch
                {
                    CustomMessageBox.Show("Set " + value + " Failed");
                }
            }

            Params.Refresh();
        }
        private void BUT_writePIDS_Click(object sender, EventArgs e)
        {
            if (Common.MessageShowAgain("Write Raw Params", "Are you Sure?") != DialogResult.OK)
            {
                return;
            }

            // sort with enable at the bottom - this ensures params are set before the function is disabled
            var temp = new List <string>();

            foreach (var item in _changes.Keys)
            {
                temp.Add((string)item);
            }

            temp.SortENABLE();

            foreach (string value in temp)
            {
                try
                {
                    MainV2.comPort.setParam(value, (float)_changes[value]);

                    try
                    {
                        // set control as well
                        var textControls = Controls.Find(value, true);
                        if (textControls.Length > 0)
                        {
                            ThemeManager.ApplyThemeTo(textControls[0]);
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        // set param table as well
                        foreach (DataGridViewRow row in Params.Rows)
                        {
                            if (row.Cells[0].Value.ToString() == value)
                            {
                                row.Cells[1].Style.BackColor = ThemeManager.ControlBGColor;
                                _changes.Remove(value);
                                break;
                            }
                        }
                    }
                    catch
                    {
                    }
                }
                catch
                {
                    CustomMessageBox.Show("Set " + value + " Failed");
                }
            }
        }
示例#3
0
        private void BUT_writePIDS_Click(object sender, EventArgs e)
        {
            // Prevent upload mission if UAV is armed!
            if (MainV2.comPort.MAV.cs.armed && !Settings.isDevMode)
            {
                if (MessageBox.Show("UAV is Armed! Are You sure want to write parameters?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
                {
                    return;
                }
            }


            if (Common.MessageShowAgain("Write Raw Params Tree", "Are you Sure?") != DialogResult.OK)
            {
                return;
            }

            // sort with enable at the bottom - this ensures params are set before the function is disabled
            var temp = new List <string>();

            foreach (var item in _changes.Keys)
            {
                temp.Add((string)item);
            }

            temp.SortENABLE();

            foreach (string value in temp)
            {
                try
                {
                    MainV2.comPort.setParam(value, (float)_changes[value]);

                    _changes.Remove(value);
                }
                catch
                {
                    CustomMessageBox.Show("Set " + value + " Failed");
                }
            }

            Params.Refresh();
        }
        private void BUT_writePIDS_Click(object sender, EventArgs e)
        {
            if (Common.MessageShowAgain("Write Raw Params", "Are you Sure?") != DialogResult.OK)
            {
                return;
            }

            // sort with enable at the bottom - this ensures params are set before the function is disabled
            var temp = new List <string>();

            foreach (var item in _changes.Keys)
            {
                temp.Add((string)item);
            }

            temp.SortENABLE();

            int failed = 0;

            foreach (string value in temp)
            {
                try
                {
                    _can.SetParameter(_node, value, _changes[value]);

                    try
                    {
                        // set control as well
                        var textControls = Controls.Find(value, true);
                        if (textControls.Length > 0)
                        {
                            ThemeManager.ApplyThemeTo(textControls[0]);
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        // set param table as well
                        foreach (DataGridViewRow row in Params.Rows)
                        {
                            if (row.Cells[0].Value.ToString() == value)
                            {
                                row.Cells[1].Style.BackColor = ThemeManager.ControlBGColor;
                                _changes.Remove(value);
                                break;
                            }
                        }
                    }
                    catch
                    {
                    }
                }
                catch (Exception ex)
                {
                    log.Error(ex);
                    failed++;
                    CustomMessageBox.Show("Set " + value + " Failed " + ex.ToString());
                }
            }

            _can.SaveConfig(_node);

            if (failed > 0)
            {
                CustomMessageBox.Show("Some Parameters Failed to be saved.", "Saved");
            }
            else
            {
                CustomMessageBox.Show("Parameters successfully saved.", "Saved");
            }
        }
        private void BUT_writePIDS_Click(object sender, EventArgs e)
        {
            if (Common.MessageShowAgain("Write Raw Params Tree", "Are you Sure?") != DialogResult.OK)
                return;

            // sort with enable at the bottom - this ensures params are set before the function is disabled
            var temp = new List<string>();
            foreach (var item in _changes.Keys)
            {
                temp.Add((string)item);
            }

            temp.SortENABLE();

            foreach (string value in temp)
            {
                try
                {
                    MainV2.comPort.setParam(value, (float) _changes[value]);

                    _changes.Remove(value);
                }
                catch
                {
                    CustomMessageBox.Show("Set " + value + " Failed");
                }
            }

            Params.Refresh();
        }
        private void BUT_writePIDS_Click(object sender, EventArgs e)
        {
            if (Common.MessageShowAgain("Write Raw Params", "Are you Sure?") != DialogResult.OK)
                return;

            // sort with enable at the bottom - this ensures params are set before the function is disabled
            var temp = new List<string>();
            foreach (var item in _changes.Keys)
            {
                temp.Add((string)item);
            }

            temp.SortENABLE();

            foreach (string value in temp)
            {
                try
                {
                    MainV2.comPort.setParam(value, (float) _changes[value]);

                    try
                    {
                        // set control as well
                        var textControls = Controls.Find(value, true);
                        if (textControls.Length > 0)
                        {
                            ThemeManager.ApplyThemeTo(textControls[0]);
                        }
                    }
                    catch
                    {
                    }

                    try
                    {
                        // set param table as well
                        foreach (DataGridViewRow row in Params.Rows)
                        {
                            if (row.Cells[0].Value.ToString() == value)
                            {
                                row.Cells[1].Style.BackColor = ThemeManager.ControlBGColor;
                                _changes.Remove(value);
                                break;
                            }
                        }
                    }
                    catch
                    {
                    }
                }
                catch
                {
                    CustomMessageBox.Show("Set " + value + " Failed");
                }
            }
        }