internal void EEPROM_View_float_TextChanged(object sender, EventArgs e) { if (startup) { return; } float value = 0; var name = ((Control)sender).Name; // do domainupdown state check try { if (sender.GetType() == typeof(NumericUpDown)) { value = (float)((NumericUpDown)sender).Value; MAVLinkInterface.modifyParamForDisplay(false, ((Control)sender).Name, ref value); changes[name] = value; } else if (sender.GetType() == typeof(ComboBox)) { value = (int)((ComboBox)sender).SelectedValue; changes[name] = value; } ((Control)sender).BackColor = Color.Green; } catch (Exception) { ((Control)sender).BackColor = Color.Red; } }
/// <summary> /// fill numeric up down boxs with there value /// </summary> public void PopulateData() { // process hashdefines and // display; foreach (string value in _mavinterface.MAV.param.Keys) { if (value == null || value == "") // older ap version have a null param { continue; } Control[] text = this.Controls.Find(value, true); foreach (Control ctl in text) { try { float numbervalue = (float)_mavinterface.MAV.param[value]; MAVLinkInterface.modifyParamForDisplay(true, value, ref numbervalue); NumericUpDown thisctl = ((NumericUpDown)ctl); thisctl.Validated -= thisctl_Validated; thisctl.ValueChanged -= thisctl_Validated; thisctl.Value = (decimal)numbervalue; thisctl.Enabled = true; thisctl.Validated += thisctl_Validated; thisctl.ValueChanged += thisctl_Validated; } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } } }
void thisctl_Validated(object sender, EventArgs e) { string param = ((NumericUpDown)sender).Name; ((Control)sender).BackColor = Color.Green; foreach (string item in (List <string>)_linkedParams[param]) { float value = (float)((NumericUpDown)sender).Value; MAVLinkInterface.modifyParamForDisplay(false, param, ref value); _changed[item] = value; } }
internal void EEPROM_View_float_TextChanged(object sender, EventArgs e) { if (startup == true) { return; } float value = 0; string name = ((Control)sender).Name; // do domainupdown state check try { if (sender.GetType() == typeof(NumericUpDown)) { value = (float)((NumericUpDown)sender).Value; MAVLinkInterface.modifyParamForDisplay(false, ((Control)sender).Name, ref value); changes[name] = value; } else if (sender.GetType() == typeof(ComboBox)) { value = (int)((ComboBox)sender).SelectedValue; changes[name] = value; } ((Control)sender).BackColor = Color.Green; } catch (Exception) { ((Control)sender).BackColor = Color.Red; } try { // enable roll and pitch pairing for ac2 if (CHK_lockrollpitch.Checked) { if (name.StartsWith("RATE_") || name.StartsWith("STB_") || name.StartsWith("ACRO_")) { if (name.Contains("_RLL_")) { string newname = name.Replace("_RLL_", "_PIT_"); Control[] arr = this.Controls.Find(newname, true); changes[newname] = value; if (arr.Length > 0) { arr[0].Text = ((Control)sender).Text; arr[0].BackColor = Color.Green; } } else if (name.Contains("_PIT_")) { string newname = name.Replace("_PIT_", "_RLL_"); Control[] arr = this.Controls.Find(newname, true); changes[newname] = value; if (arr.Length > 0) { arr[0].Text = ((Control)sender).Text; arr[0].BackColor = Color.Green; } } } } // keep nav_lat and nav_lon paired if (name.Contains("NAV_LAT_")) { string newname = name.Replace("NAV_LAT_", "NAV_LON_"); Control[] arr = this.Controls.Find(newname, true); changes[newname] = value; if (arr.Length > 0) { arr[0].Text = ((Control)sender).Text; arr[0].BackColor = Color.Green; } } // keep loiter_lat and loiter_lon paired if (name.Contains("LOITER_LAT_")) { string newname = name.Replace("LOITER_LAT_", "LOITER_LON_"); Control[] arr = this.Controls.Find(newname, true); changes[newname] = value; if (arr.Length > 0) { arr[0].Text = ((Control)sender).Text; arr[0].BackColor = Color.Green; } } // keep nav_lat and nav_lon paired if (name.Contains("HLD_LAT_")) { string newname = name.Replace("HLD_LAT_", "HLD_LON_"); Control[] arr = this.Controls.Find(newname, true); changes[newname] = value; if (arr.Length > 0) { arr[0].Text = ((Control)sender).Text; arr[0].BackColor = Color.Green; } } } catch { } }
internal void processToScreen() { toolTip1.RemoveAll(); disableNumericUpDownControls(this); // process hashdefines and update display foreach (string value in MainV2.comPort.MAV.param.Keys) { if (value == null || value == "") { continue; } //System.Diagnostics.Debug.WriteLine("Doing: " + value); string name = value; Control[] text = this.Controls.Find(name, true); foreach (Control ctl in text) { try { if (ctl.GetType() == typeof(NumericUpDown)) { float numbervalue = (float)MainV2.comPort.MAV.param[value]; MAVLinkInterface.modifyParamForDisplay(true, value, ref numbervalue); NumericUpDown thisctl = ((NumericUpDown)ctl); thisctl.Maximum = 9000; thisctl.Minimum = -9000; thisctl.Value = (decimal)numbervalue; thisctl.Increment = (decimal)0.0001; if (thisctl.Name.EndsWith("_P") || thisctl.Name.EndsWith("_I") || thisctl.Name.EndsWith("_D") || thisctl.Name.EndsWith("_LOW") || thisctl.Name.EndsWith("_HIGH") || thisctl.Value == 0 || thisctl.Value.ToString("0.####", new System.Globalization.CultureInfo("en-US")).Contains(".")) { thisctl.DecimalPlaces = 4; } else { thisctl.Increment = (decimal)1; thisctl.DecimalPlaces = 1; } if (thisctl.Name.ToUpper().EndsWith("THR_RATE_IMAX")) { thisctl.Maximum = 1000; // is a pwm thisctl.Minimum = 0; } else if (thisctl.Name.EndsWith("_IMAX")) { thisctl.Maximum = 1800; thisctl.Minimum = -1800; } thisctl.Enabled = true; ThemeManager.ApplyThemeTo(thisctl); thisctl.Validated += null; if (tooltips[value] != null) { try { toolTip1.SetToolTip(ctl, ((paramsettings)tooltips[value]).desc); } catch { } } thisctl.Validated += new EventHandler(EEPROM_View_float_TextChanged); } else if (ctl.GetType() == typeof(ComboBox)) { ComboBox thisctl = ((ComboBox)ctl); thisctl.SelectedValue = (int)(float)MainV2.comPort.MAV.param[value]; thisctl.Validated += new EventHandler(ComboBox_Validated); ThemeManager.ApplyThemeTo(thisctl); } } catch { } } if (text.Length == 0) { //Console.WriteLine(name + " not found"); } } }
internal void processToScreen() { toolTip1.RemoveAll(); disableNumericUpDownControls(this); // process hashdefines and update display foreach (string value in MainV2.comPort.MAV.param.Keys) { if (value == null || value == "") { continue; } var name = value; var text = Controls.Find(name, true); foreach (var ctl in text) { try { if (ctl.GetType() == typeof(NumericUpDown)) { var numbervalue = (float)MainV2.comPort.MAV.param[value]; MAVLinkInterface.modifyParamForDisplay(true, value, ref numbervalue); var thisctl = ((NumericUpDown)ctl); thisctl.Maximum = 9000; thisctl.Minimum = -9000; thisctl.Value = (decimal)numbervalue; thisctl.Increment = (decimal)0.001; if (thisctl.Name.EndsWith("_P") || thisctl.Name.EndsWith("_I") || thisctl.Name.EndsWith("_D") || thisctl.Name.EndsWith("_LOW") || thisctl.Name.EndsWith("_HIGH") || thisctl.Value == 0 || thisctl.Value.ToString("0.###", new CultureInfo("en-US")).Contains(".")) { thisctl.DecimalPlaces = 3; } else { thisctl.Increment = 1; thisctl.DecimalPlaces = 1; } if (thisctl.Name.EndsWith("_IMAX")) { thisctl.Maximum = 180; thisctl.Minimum = -180; } thisctl.Enabled = true; try { thisctl.Parent.Visible = true; } catch { } ThemeManager.ApplyThemeTo(thisctl); thisctl.Validated += EEPROM_View_float_TextChanged; } else if (ctl.GetType() == typeof(ComboBox)) { var thisctl = ((ComboBox)ctl); thisctl.SelectedIndex = (int)(float)MainV2.comPort.MAV.param[value]; thisctl.Validated += ComboBox_Validated; ThemeManager.ApplyThemeTo(thisctl); } } catch { } } if (text.Length == 0) { //Console.WriteLine(name + " not found"); } } }