public void setup(string[] paramnames, MAVLink.MAVLinkParamList paramlist)
        {
            base.SelectedIndexChanged -= MavlinkComboBox_SelectedIndexChanged;

            var paramname = paramnames.FirstOrDefault(a => paramlist.ContainsKey(a));

            if (paramname != null)
            {
                var source = ParameterMetaDataRepository.GetParameterOptionsInt(paramname, MainV2.comPort.MAV.cs.firmware.ToString());

                _source2 = source;

                this.DisplayMember = "Value";
                this.ValueMember   = "Key";
                this.DataSource    = source;

                this.ParamName = paramname;
                this.Name      = paramname;

                this.Enabled = true;
                this.Visible = true;

                enableControl(true);

                var item = paramlist[paramname];

                this.SelectedValue = (int)paramlist[paramname].Value;
            }
            else
            {
            }

            base.SelectedIndexChanged += new EventHandler(MavlinkComboBox_SelectedIndexChanged);
        }
        public void setup(List <KeyValuePair <int, string> > source, string paramname, MAVLink.MAVLinkParamList paramlist)
        {
            base.SelectedIndexChanged -= MavlinkComboBox_SelectedIndexChanged;

            _source2 = source;

            this.DisplayMember = "Value";
            this.ValueMember   = "Key";
            this.DataSource    = source;

            this.ParamName = paramname;
            this.Name      = paramname;

            if (paramlist.ContainsKey(paramname))
            {
                this.Enabled = true;
                this.Visible = true;

                enableControl(true);

                var item = paramlist[paramname];

                this.SelectedValue = (int)paramlist[paramname].Value;
            }

            base.SelectedIndexChanged += new EventHandler(MavlinkComboBox_SelectedIndexChanged);
        }
Exemplo n.º 3
0
        public void setup(string paramname, MAVLink.MAVLinkParamList paramlist)
        {
            this.ParamName = paramname;

            if (paramlist.ContainsKey(paramname))
            {
                this.Enabled = true;

                list = ParameterMetaDataRepository.GetParameterBitMaskInt(ParamName,
                                                                          MainV2.comPort.MAV.cs.firmware.ToString());
                chkcount = list.Count;

                int leftside = 9;
                int top      = 9;

                uint value = (uint)paramlist[paramname].Value;

                Type = paramlist[paramname].TypeAP;

                for (int a = 0; a < chkcount; a++)
                {
                    CheckBox chk = new CheckBox();
                    chk.AutoSize = true;
                    chk.Text     = list[a].Value.ToString();
                    chk.Location = new System.Drawing.Point(leftside, top);

                    chk.CheckedChanged -= MavlinkCheckBoxBitMask_CheckedChanged;

                    if ((value & (1 << list[a].Key)) > 0)
                    {
                        chk.Checked = true;
                    }

                    chklist.Add(new KeyValuePair <int, CheckBox>(list[a].Key, chk));
                    panel1.Controls.Add(chk);

                    chk.CheckedChanged += MavlinkCheckBoxBitMask_CheckedChanged;

                    //this.Controls.Add(new Label() { Location = chk.Location, Text = "test" });

                    leftside += chk.Width + 5;
                    if (leftside > 500)
                    {
                        top     += chk.Height + 5;
                        leftside = 9;
                    }
                }


                this.panel1.Height = top + 25;

                //this.Height = top + 25;
            }
            else
            {
                this.Enabled = false;
            }
        }
Exemplo n.º 4
0
 public void setup(double OnValue, double OffValue, string[] paramname, MAVLink.MAVLinkParamList paramlist,
                   Control enabledisable = null)
 {
     foreach (var s in paramname)
     {
         if (paramlist.ContainsKey(s))
         {
             setup(OnValue, OffValue, s, paramlist, enabledisable);
             return;
         }
     }
 }
        public void setup(double OnValue, double OffValue, string paramname, MAVLink.MAVLinkParamList paramlist,
                          Control enabledisable = null, Action callbackonchange = null)
        {
            base.CheckedChanged -= MavlinkCheckBox_CheckedChanged;

            this.CallBackOnChange = callbackonchange;
            this.OnValue          = OnValue;
            this.OffValue         = OffValue;
            this.ParamName        = paramname;
            this._control         = enabledisable;

            if (paramlist.ContainsKey(paramname))
            {
                this.Enabled = true;
                this.Visible = true;

                if (paramlist[paramname].Value == OnValue)
                {
                    this.Checked = true;
                    enableBGControl(true);
                }
                else if (paramlist[paramname].Value == OffValue)
                {
                    this.Checked = false;
                    enableBGControl(false);
                }
                else
                {
                    this.CheckState = System.Windows.Forms.CheckState.Indeterminate;
                    enableBGControl(false);
                }
            }
            else
            {
                this.Enabled = false;
            }

            base.CheckedChanged += new EventHandler(MavlinkCheckBox_CheckedChanged);
        }
Exemplo n.º 6
0
        public void setup(Type source, string paramname, MAVLink.MAVLinkParamList paramlist)//, string paramname2 = "", Control enabledisable = null)
        {
            base.SelectedIndexChanged -= MavlinkComboBox_SelectedIndexChanged;

            _source = source;

            this.DataSource = Enum.GetNames(source);

            this.ParamName = paramname;

            if (paramlist.ContainsKey(paramname))
            {
                this.Enabled = true;
                this.Visible = true;

                enableControl(true);

                this.Text = Enum.GetName(source, (Int32)paramlist[paramname].Value);
            }

            base.SelectedIndexChanged += new EventHandler(MavlinkComboBox_SelectedIndexChanged);
        }
Exemplo n.º 7
0
        public void setup(float Min, float Max, float Scale, float Increment, string[] paramname,
                          MAVLink.MAVLinkParamList paramlist, Control enabledisable = null)
        {
            this.ValueChanged -= MavlinkNumericUpDown_ValueChanged;

            // default to first item
            this.ParamName = paramname[0];
            // set a new item is first item doesnt exist
            foreach (var paramn in paramname)
            {
                if (paramlist.ContainsKey(paramn))
                {
                    this.ParamName = paramn;
                    break;
                }
            }

            // update local name
            Name = ParamName;
            // set min and max of both are equal
            double mint = Min, maxt = Max;

            if (ParameterMetaDataRepository.GetParameterRange(ParamName, ref mint, ref maxt,
                                                              MainV2.comPort.MAV.cs.firmware.ToString()))
            {
                Min = (float)mint;
                Max = (float)maxt;
            }

            if (Min == Max)
            {
                log.InfoFormat("{0} {1} = {2}", ParamName, Min, Max);
            }

            double Inc = 0;

            if (ParameterMetaDataRepository.GetParameterIncrement(ParamName, ref Inc,
                                                                  MainV2.comPort.MAV.cs.firmware.ToString()))
            {
                if (Inc > this.DecimalPlaces)
                {
                    Increment = (float)Inc;
                }
            }

            _scale             = Scale;
            this.Minimum       = (decimal)(Min);
            this.Maximum       = (decimal)(Max);
            this.Increment     = (decimal)(Increment);
            this.DecimalPlaces = BitConverter.GetBytes(decimal.GetBits((decimal)Increment)[3])[2];

            this._control = enabledisable;

            if (paramlist.ContainsKey(ParamName))
            {
                this.Enabled = true;
                this.Visible = true;

                enableControl(true);

                decimal value = (decimal)((float)paramlist[ParamName] / _scale);

                int dec = BitConverter.GetBytes(decimal.GetBits((decimal)value)[3])[2];

                if (dec > this.DecimalPlaces)
                {
                    this.DecimalPlaces = dec;
                }

                if (value < this.Minimum)
                {
                    this.Minimum = value;
                }
                if (value > this.Maximum)
                {
                    this.Maximum = value;
                }

                base.Value = value;
            }
            else
            {
                this.Enabled = false;
                enableControl(false);
            }

            this.ValueChanged += new EventHandler(MavlinkNumericUpDown_ValueChanged);
        }