private void Params_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == Value.Index) { var check = Params[e.ColumnIndex, e.RowIndex].EditedFormattedValue; var name = Params[Command.Index, e.RowIndex].Value.ToString(); var availableBitMask = ParameterMetaDataRepository.GetParameterBitMaskInt(name, MainV2.comPort.MAV.cs.firmware.ToString()); if (availableBitMask.Count > 0) { var mcb = new MavlinkCheckBoxBitMask(); var list = new MAVLink.MAVLinkParamList(); list.Add(new MAVLink.MAVLinkParam(name, double.Parse(check.ToString(), CultureInfo.InvariantCulture), MAVLink.MAV_PARAM_TYPE.INT32)); mcb.setup(name, list); mcb.ValueChanged += (o, s, value) => { Params[e.ColumnIndex, e.RowIndex].Value = value; Params.Invalidate(); mcb.Focus(); }; var frm = mcb.ShowUserControl(); frm.TopMost = true; } } }
private void Params_CellClick(object sender, CellClickEventArgs e) { // Only process the Description column if (e.RowIndex == -1 || startup) { return; } if (e.ColumnIndex == olvColumn2.Index) { var it = ((data)e.Model); var check = it.Value; var name = it.paramname; var availableBitMask = ParameterMetaDataRepository.GetParameterBitMaskInt(name, MainV2.comPort.MAV.cs.firmware.ToString()); if (availableBitMask.Count > 0) { var mcb = new MavlinkCheckBoxBitMask(); var list = new MAVLink.MAVLinkParamList(); list.Add(new MAVLink.MAVLinkParam(name, double.Parse(check.ToString(), CultureInfo.InvariantCulture), MAVLink.MAV_PARAM_TYPE.INT32)); mcb.setup(name, list); mcb.ValueChanged += (o, s, value) => { paramCompareForm_dtlvcallback(s, int.Parse(value)); ((data)e.HitTest.RowObject).Value = value; Params.RefreshItem(e.HitTest.Item); e.HitTest.SubItem.Text = value; Params.CancelCellEdit(); e.Handled = true; mcb.Focus(); }; var frm = mcb.ShowUserControl(); frm.TopMost = true; } } try { string descStr = e.SubItem.ModelValue.ToString(); ConfigRawParams.CheckForUrlAndLaunchInBrowser(descStr); } catch { } }
private void InitializeComponent() { this.INS_LOG_BAT_MASK = new MissionPlanner.Controls.MavlinkCheckBoxBitMask(); this.INS_LOG_BAT_CNT = new MissionPlanner.Controls.RangeControl(); this.but_fft = new MissionPlanner.Controls.MyButton(); this.LOG_BITMASK = new MissionPlanner.Controls.MavlinkCheckBoxBitMask(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.groupBox2 = new System.Windows.Forms.GroupBox(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.SuspendLayout(); // // INS_LOG_BAT_MASK // this.INS_LOG_BAT_MASK.Enabled = false; this.INS_LOG_BAT_MASK.Location = new System.Drawing.Point(6, 138); this.INS_LOG_BAT_MASK.Name = "INS_LOG_BAT_MASK"; this.INS_LOG_BAT_MASK.ParamName = null; this.INS_LOG_BAT_MASK.Size = new System.Drawing.Size(604, 115); this.INS_LOG_BAT_MASK.TabIndex = 3; this.INS_LOG_BAT_MASK.Value = 0F; // // INS_LOG_BAT_CNT // this.INS_LOG_BAT_CNT.DescriptionText = "Description"; this.INS_LOG_BAT_CNT.DisplayScale = 1F; this.INS_LOG_BAT_CNT.Increment = 1F; this.INS_LOG_BAT_CNT.LabelText = "Label"; this.INS_LOG_BAT_CNT.Location = new System.Drawing.Point(6, 19); this.INS_LOG_BAT_CNT.MaxRange = 10F; this.INS_LOG_BAT_CNT.MinRange = 0F; this.INS_LOG_BAT_CNT.Name = "INS_LOG_BAT_CNT"; this.INS_LOG_BAT_CNT.Size = new System.Drawing.Size(604, 108); this.INS_LOG_BAT_CNT.TabIndex = 4; this.INS_LOG_BAT_CNT.Value = "0"; // // but_fft // this.but_fft.Location = new System.Drawing.Point(629, 13); this.but_fft.Name = "but_fft"; this.but_fft.Size = new System.Drawing.Size(75, 23); this.but_fft.TabIndex = 5; this.but_fft.Text = "FFT"; this.but_fft.UseVisualStyleBackColor = true; this.but_fft.Click += new System.EventHandler(this.but_fft_Click); // // LOG_BITMASK // this.LOG_BITMASK.Enabled = false; this.LOG_BITMASK.Location = new System.Drawing.Point(6, 19); this.LOG_BITMASK.Name = "LOG_BITMASK"; this.LOG_BITMASK.ParamName = null; this.LOG_BITMASK.Size = new System.Drawing.Size(604, 105); this.LOG_BITMASK.TabIndex = 6; this.LOG_BITMASK.Value = 0F; // // groupBox1 // this.groupBox1.Controls.Add(this.INS_LOG_BAT_CNT); this.groupBox1.Controls.Add(this.INS_LOG_BAT_MASK); this.groupBox1.Location = new System.Drawing.Point(7, 3); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(616, 264); this.groupBox1.TabIndex = 8; this.groupBox1.TabStop = false; this.groupBox1.Text = "FFT Setup"; // // groupBox2 // this.groupBox2.Controls.Add(this.LOG_BITMASK); this.groupBox2.Location = new System.Drawing.Point(7, 273); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(616, 130); this.groupBox2.TabIndex = 9; this.groupBox2.TabStop = false; this.groupBox2.Text = "Please ensure IMU_RAW and IMU_FAST are turned off to use FFT"; // // ConfigFFT // this.Controls.Add(this.groupBox2); this.Controls.Add(this.but_fft); this.Controls.Add(this.groupBox1); this.Name = "ConfigFFT"; this.Size = new System.Drawing.Size(710, 411); this.groupBox1.ResumeLayout(false); this.groupBox2.ResumeLayout(false); this.ResumeLayout(false); }
private void AddControl(KeyValuePair <string, string> x, List <Control> toadd) //, ref int ypos) { if (!string.IsNullOrEmpty(x.Key)) { try { var controlAdded = false; var value = (MainV2.comPort.MAV.param[x.Key].Value).ToString("0.###"); var items = Controls.Find(x.Key, true); if (items.Length > 0) { if (items[0].GetType() == typeof(RangeControl)) { ((RangeControl)items[0]).ValueChanged -= Control_ValueChanged; ((RangeControl)items[0]).DeAttachEvents(); ((RangeControl)items[0]).Value = value; ThemeManager.ApplyThemeTo(((RangeControl)items[0])); ((RangeControl)items[0]).AttachEvents(); ((RangeControl)items[0]).ValueChanged += Control_ValueChanged; return; } if (items[0].GetType() == typeof(ValuesControl)) { ((ValuesControl)items[0]).ValueChanged -= Control_ValueChanged; ((ValuesControl)items[0]).Value = value; ((ValuesControl)items[0]).ValueChanged += Control_ValueChanged; return; } if (items[0].GetType() == typeof(MavlinkCheckBoxBitMask)) { ((MavlinkCheckBoxBitMask)items[0]).ValueChanged -= Control_ValueChanged; ((MavlinkCheckBoxBitMask)items[0]).Value = Convert.ToSingle(value); ((MavlinkCheckBoxBitMask)items[0]).ValueChanged += Control_ValueChanged; return; } } var description = ParameterMetaDataRepository.GetParameterMetaData(x.Key, ParameterMetaDataConstants.Description, MainV2.comPort.MAV.cs.firmware.ToString()); var displayName = x.Value + " (" + x.Key + ")"; var units = ParameterMetaDataRepository.GetParameterMetaData(x.Key, ParameterMetaDataConstants.Units, MainV2.comPort.MAV.cs.firmware.ToString()); // If this is a range var rangeRaw = ParameterMetaDataRepository.GetParameterMetaData(x.Key, ParameterMetaDataConstants.Range, MainV2.comPort.MAV.cs.firmware.ToString()); var incrementRaw = ParameterMetaDataRepository.GetParameterMetaData(x.Key, ParameterMetaDataConstants.Increment, MainV2.comPort.MAV.cs.firmware.ToString()); if (!string.IsNullOrEmpty(rangeRaw) && !string.IsNullOrEmpty(incrementRaw)) { float increment, intValue; float.TryParse(incrementRaw, NumberStyles.Float, CultureInfo.InvariantCulture, out increment); // this is in local culture float.TryParse(value, out intValue); var rangeParts = rangeRaw.Split(' '); if (rangeParts.Count() == 2 && increment > 0) { float lowerRange; float.TryParse(rangeParts[0], NumberStyles.Float, CultureInfo.InvariantCulture, out lowerRange); float upperRange; float.TryParse(rangeParts[1], NumberStyles.Float, CultureInfo.InvariantCulture, out upperRange); float displayscale = 1; // var rangeControl = new RangeControl(); if (units.ToLower() == "centi-degrees") { //Console.WriteLine(x.Key + " scale"); displayscale = 100; units = "Degrees (Scaled)"; increment /= 100; } else if (units.ToLower() == "centimeters") { //Console.WriteLine(x.Key + " scale"); // displayscale = 100; // units = "Meters (Scaled)"; // increment /= 100; } var desc = FitDescriptionText(units, description, tableLayoutPanel1.Width); var rangeControl = new RangeControl(x.Key, desc, displayName, increment, displayscale, lowerRange, upperRange, value); rangeControl.Width = tableLayoutPanel1.Width - 50; //Console.WriteLine("{0} {1} {2} {3} {4}", x.Key, increment, lowerRange, upperRange, value); ThemeManager.ApplyThemeTo(rangeControl); if (intValue < lowerRange) { rangeControl.NumericUpDownControl.BackColor = Color.Orange; } if (intValue > upperRange) { rangeControl.NumericUpDownControl.BackColor = Color.Orange; } rangeControl.AttachEvents(); rangeControl.ValueChanged += Control_ValueChanged; // set pos rangeControl.Location = new Point(0, y); // add control - let it autosize height toadd.Add(rangeControl); // add height for next control y += rangeControl.Height; controlAdded = true; } } // try bitmask next if (!controlAdded) { var availableBitMask = ParameterMetaDataRepository.GetParameterBitMaskInt(x.Key, MainV2.comPort.MAV.cs.firmware.ToString()); if (availableBitMask.Count > 0) { var bitmask = new MavlinkCheckBoxBitMask(); bitmask.Name = x.Key; bitmask.setup(x.Key, MainV2.comPort.MAV.param); bitmask.myLabel1.Text = displayName; bitmask.label1.Text = FitDescriptionText(units, description, tableLayoutPanel1.Width - 50); bitmask.Width = tableLayoutPanel1.Width - 50; ThemeManager.ApplyThemeTo(bitmask); // set pos bitmask.Location = new Point(0, y); // add control - let it autosize height toadd.Add(bitmask); // add height for next control y += bitmask.Height; bitmask.ValueChanged += Control_ValueChanged; controlAdded = true; } } if (!controlAdded) { // If this is a subset of values var availableValuesRaw = ParameterMetaDataRepository.GetParameterMetaData(x.Key, ParameterMetaDataConstants.Values, MainV2.comPort.MAV.cs.firmware.ToString()); if (!string.IsNullOrEmpty(availableValuesRaw)) { var availableValues = availableValuesRaw.Split(','); if (availableValues.Any()) { var valueControl = new ValuesControl(); valueControl.Width = tableLayoutPanel1.Width - 50; valueControl.Name = x.Key; valueControl.DescriptionText = FitDescriptionText(units, description, tableLayoutPanel1.Width); valueControl.LabelText = displayName; ThemeManager.ApplyThemeTo(valueControl); var splitValues = new List <KeyValuePair <string, string> >(); // Add the values to the ddl foreach (var val in availableValues) { var valParts = val.Split(':'); splitValues.Add(new KeyValuePair <string, string>(valParts[0].Trim(), (valParts.Length > 1) ? valParts[1].Trim() : valParts[0].Trim())); } ; valueControl.ComboBoxControl.DisplayMember = "Value"; valueControl.ComboBoxControl.ValueMember = "Key"; valueControl.ComboBoxControl.DataSource = splitValues; valueControl.ComboBoxControl.SelectedValue = value; valueControl.ValueChanged += Control_ValueChanged; // set pos valueControl.Location = new Point(0, y); // add control - let it autosize height toadd.Add(valueControl); // add height for next control y += valueControl.Height; } } } } // if there is an error simply dont show it, ie bad pde file, bad scale etc catch (Exception ex) { log.Error(ex); } } }
private void Params_CellContentClick(object sender, DataGridViewCellEventArgs e) { // Only process the Description column if (e.RowIndex == -1 || startup) { return; } if (e.ColumnIndex == 4) { try { string descStr = Params[e.ColumnIndex, e.RowIndex].Value.ToString(); CheckForUrlAndLaunchInBrowser(descStr); } catch { } } if (e.ColumnIndex == Value.Index) { var check = Params[e.ColumnIndex, e.RowIndex].EditedFormattedValue; var name = Params[Command.Index, e.RowIndex].Value.ToString(); var availableBitMask = ParameterMetaDataRepository.GetParameterBitMaskInt(name, MainV2.comPort.MAV.cs.firmware.ToString()); if (availableBitMask.Count > 0) { var mcb = new MavlinkCheckBoxBitMask(); var list = new MAVLink.MAVLinkParamList(); list.Add(new MAVLink.MAVLinkParam(name, double.Parse(check.ToString(), CultureInfo.InvariantCulture), MAVLink.MAV_PARAM_TYPE.INT32)); mcb.setup(name, list); mcb.ValueChanged += (o, s, value) => { Params[e.ColumnIndex, e.RowIndex].Value = value; Params.Invalidate(); mcb.Focus(); }; var frm = mcb.ShowUserControl(); frm.TopMost = true; } } if (e.ColumnIndex == 5) { var check = Params[e.ColumnIndex, e.RowIndex].EditedFormattedValue; var name = Params[Command.Index, e.RowIndex].Value.ToString(); if (check != null && (bool)check) { // add entry Settings.Instance.AppendList("fav_params", name); } else { // remove entry var list = Settings.Instance.GetList("fav_params"); Settings.Instance.SetList("fav_params", list.Where(s => s != name)); } Params.Sort(Command, ListSortDirection.Ascending); } }