示例#1
0
        void tabStatus_Resize(object sender, EventArgs e)
        {
            // localise it
            //Control tabStatus = sender as Control;

            //  tabStatus.SuspendLayout();

            //foreach (Control temp in tabStatus.Controls)
            {
                //  temp.DataBindings.Clear();
                //temp.Dispose();
            }
            //tabStatus.Controls.Clear();

            int x = 10;
            int y = 10;

            object thisBoxed = MainV2.comPort.MAV.cs;
            Type test = thisBoxed.GetType();

            PropertyInfo[] props = test.GetProperties();

            //props

            foreach (var field in props)
            {
                // field.Name has the field's name.
                object fieldValue;
                TypeCode typeCode;
                try
                {
                    fieldValue = field.GetValue(thisBoxed, null); // Get value

                    if (fieldValue == null)
                        continue;
                    // Get the TypeCode enumeration. Multiple types get mapped to a common typecode.
                    typeCode = Type.GetTypeCode(fieldValue.GetType());
                }
                catch
                {
                    continue;
                }

                MyLabel lbl1 = null;
                MyLabel lbl2 = null;
                try
                {
                    var temp = tabStatus.Controls.Find(field.Name, false);

                    if (temp.Length > 0)
                        lbl1 = (MyLabel) temp[0];

                    var temp2 = tabStatus.Controls.Find(field.Name + "value", false);

                    if (temp2.Length > 0)
                        lbl2 = (MyLabel) temp2[0];
                }
                catch
                {
                }


                if (lbl1 == null)
                    lbl1 = new MyLabel();

                lbl1.Location = new Point(x, y);
                lbl1.Size = new Size(90, 13);
                lbl1.Text = field.Name;
                lbl1.Name = field.Name;
                lbl1.Visible = true;

                if (lbl2 == null)
                    lbl2 = new MyLabel();

                lbl2.AutoSize = false;

                lbl2.Location = new Point(lbl1.Right + 5, y);
                lbl2.Size = new Size(50, 13);
                //if (lbl2.Name == "")
                lbl2.DataBindings.Clear();
                lbl2.DataBindings.Add(new Binding("Text", bindingSourceStatusTab, field.Name, false,
                    DataSourceUpdateMode.Never, "0"));
                lbl2.Name = field.Name + "value";
                lbl2.Visible = true;
                //lbl2.Text = fieldValue.ToString();

                tabStatus.Controls.Add(lbl1);
                tabStatus.Controls.Add(lbl2);


                x += 0;
                y += 15;

                if (y > tabStatus.Height - 30)
                {
                    x = lbl2.Right + 10; //+= 165;
                    y = 10;
                }
            }

            tabStatus.Width = x;

            ThemeManager.ApplyThemeTo(tabStatus);
        }
        private void InitializeComponent()
        {
            this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
            this.label1 = new System.Windows.Forms.Label();
            this.panel1 = new System.Windows.Forms.Panel();
            this.myLabel1 = new MissionPlanner.Controls.MyLabel();
            this.tableLayoutPanel1.SuspendLayout();
            this.SuspendLayout();
            // 
            // tableLayoutPanel1
            // 
            this.tableLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.tableLayoutPanel1.AutoSize = true;
            this.tableLayoutPanel1.ColumnCount = 1;
            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
            this.tableLayoutPanel1.Controls.Add(this.label1, 0, 0);
            this.tableLayoutPanel1.Controls.Add(this.panel1, 0, 1);
            this.tableLayoutPanel1.Location = new System.Drawing.Point(3, 28);
            this.tableLayoutPanel1.Name = "tableLayoutPanel1";
            this.tableLayoutPanel1.Padding = new System.Windows.Forms.Padding(0, 5, 0, 10);
            this.tableLayoutPanel1.RowCount = 2;
            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
            this.tableLayoutPanel1.Size = new System.Drawing.Size(337, 84);
            this.tableLayoutPanel1.TabIndex = 4;
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(3, 5);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(35, 13);
            this.label1.TabIndex = 0;
            this.label1.Text = "label1";
            // 
            // panel1
            // 
            this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.panel1.Location = new System.Drawing.Point(3, 21);
            this.panel1.Name = "panel1";
            this.panel1.Size = new System.Drawing.Size(331, 50);
            this.panel1.TabIndex = 1;
            // 
            // myLabel1
            // 
            this.myLabel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.myLabel1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold);
            this.myLabel1.Location = new System.Drawing.Point(3, 3);
            this.myLabel1.Name = "myLabel1";
            this.myLabel1.resize = false;
            this.myLabel1.Size = new System.Drawing.Size(337, 23);
            this.myLabel1.TabIndex = 3;
            this.myLabel1.Text = "myLabel1";
            // 
            // MavlinkCheckBoxBitMask
            // 
            this.Controls.Add(this.tableLayoutPanel1);
            this.Controls.Add(this.myLabel1);
            this.Name = "MavlinkCheckBoxBitMask";
            this.Size = new System.Drawing.Size(343, 115);
            this.tableLayoutPanel1.ResumeLayout(false);
            this.tableLayoutPanel1.PerformLayout();
            this.ResumeLayout(false);
            this.PerformLayout();

        }
示例#3
0
        void doButtontoUI(string name, int x, int y)
        {
            MyLabel lbl = new MyLabel();
            ComboBox cmbbutton = new ComboBox();
            Controls.MyButton mybut = new Controls.MyButton();
            HorizontalProgressBar hbar = new HorizontalProgressBar();
            ComboBox cmbaction = new ComboBox();

            // do this here so putting in text works
            this.Controls.AddRange(new Control[] { lbl, cmbbutton, mybut, hbar, cmbaction });

            lbl.Location = new Point(x, y);
            lbl.Size = new Size(47, 13);
            lbl.Text = "Button " + name;

            cmbbutton.Location = new Point(72, y);
            cmbbutton.Size = new Size(70, 21);
            cmbbutton.DataSource = getButtonNumbers();
            cmbbutton.DropDownStyle = ComboBoxStyle.DropDownList;
            cmbbutton.Name = "cmbbutton" + name;
            if (MainV2.config["butno" + name] != null)
                cmbbutton.Text = (MainV2.config["butno" + name].ToString());
            cmbbutton.SelectedIndexChanged += new EventHandler(cmbbutton_SelectedIndexChanged);

            mybut.Location = new Point(BUT_detch1.Left, y);
            mybut.Size = BUT_detch1.Size;
            mybut.Text = BUT_detch1.Text;
            mybut.Name = "mybut" + name;
            mybut.Click += new EventHandler(BUT_detbutton_Click);

            hbar.Location = new Point(progressBar1.Left, y);
            hbar.Size = progressBar1.Size;
            hbar.Name = "hbar" + name;

            cmbaction.Location = new Point(hbar.Right + 5, y);
            cmbaction.Size = new Size(100, 21);

            cmbaction.DataSource = Common.getModesList(MainV2.comPort.MAV.cs);
            cmbaction.ValueMember = "Key";
            cmbaction.DisplayMember = "Value";

            cmbaction.DropDownStyle = ComboBoxStyle.DropDownList;
            cmbaction.Name = "cmbaction" + name;
            if (MainV2.config["butaction" + name] != null)
                cmbaction.Text = MainV2.config["butaction" + name].ToString();

            this.Height += 25;
        }
        void doButtontoUI(string name, int x, int y)
        {
            MyLabel butlabel = new MyLabel();
            ComboBox butnumberlist = new ComboBox();
            Controls.MyButton but_detect = new Controls.MyButton();
            HorizontalProgressBar hbar = new HorizontalProgressBar();
            ComboBox cmbaction = new ComboBox();
            Controls.MyButton but_settings = new Controls.MyButton();

            var config = Joystick.self.getButton(int.Parse(name));

            // do this here so putting in text works
            this.Controls.AddRange(new Control[] { butlabel, butnumberlist, but_detect, hbar, cmbaction, but_settings });

            butlabel.Location = new Point(x, y);
            butlabel.Size = new Size(47, 13);
            butlabel.Text = "Button " + (int.Parse(name)  +1);

            butnumberlist.Location = new Point(72, y);
            butnumberlist.Size = new Size(70, 21);
            butnumberlist.DataSource = getButtonNumbers();
            butnumberlist.DropDownStyle = ComboBoxStyle.DropDownList;
            butnumberlist.Name = "cmbbutton" + name;
            //if (MainV2.config["butno" + name] != null)
              //  butnumberlist.Text = (MainV2.config["butno" + name].ToString());
            //if (config.buttonno != -1)
                butnumberlist.Text = config.buttonno.ToString();
            butnumberlist.SelectedIndexChanged += new EventHandler(cmbbutton_SelectedIndexChanged);

            but_detect.Location = new Point(BUT_detch1.Left, y);
            but_detect.Size = BUT_detch1.Size;
            but_detect.Text = BUT_detch1.Text;
            but_detect.Name = "mybut" + name;
            but_detect.Click += new EventHandler(BUT_detbutton_Click);

            hbar.Location = new Point(progressBarRoll.Left, y);
            hbar.Size = progressBarRoll.Size;
            hbar.Name = "hbar" + name;

            cmbaction.Location = new Point(hbar.Right + 5, y);
            cmbaction.Size = new Size(100, 21);

            cmbaction.DataSource = Enum.GetNames(typeof(Joystick.buttonfunction)); //Common.getModesList(MainV2.comPort.MAV.cs);
            //cmbaction.ValueMember = "Key";
            //cmbaction.DisplayMember = "Value";
            cmbaction.Tag = name;
            cmbaction.DropDownStyle = ComboBoxStyle.DropDownList;
            cmbaction.Name = "cmbaction" + name;
            //if (MainV2.config["butaction" + name] != null)
              //  cmbaction.Text = MainV2.config["butaction" + name].ToString();
            //if (config.function != Joystick.buttonfunction.ChangeMode)
                cmbaction.Text = config.function.ToString();
            cmbaction.SelectedIndexChanged += cmbaction_SelectedIndexChanged;

            but_settings.Location = new Point(cmbaction.Right + 5, y);
            but_settings.Size = BUT_detch1.Size;
            but_settings.Text = "Settings";
            but_settings.Name = "butsettings" + name;
            but_settings.Click += but_settings_Click;
            but_settings.Tag = cmbaction;

            if ((but_settings.Bottom + 30) > this.Height)
                this.Height += 25;
        }
 private void InitializeComponent()
 {
     this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
     this.label1            = new System.Windows.Forms.Label();
     this.panel1            = new System.Windows.Forms.Panel();
     this.myLabel1          = new MissionPlanner.Controls.MyLabel();
     this.tableLayoutPanel1.SuspendLayout();
     this.SuspendLayout();
     //
     // tableLayoutPanel1
     //
     this.tableLayoutPanel1.Anchor =
         ((System.Windows.Forms.AnchorStyles)
              ((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                 | System.Windows.Forms.AnchorStyles.Left)
                | System.Windows.Forms.AnchorStyles.Right)));
     this.tableLayoutPanel1.AutoSize    = true;
     this.tableLayoutPanel1.ColumnCount = 1;
     this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
     this.tableLayoutPanel1.Controls.Add(this.label1, 0, 0);
     this.tableLayoutPanel1.Controls.Add(this.panel1, 0, 1);
     this.tableLayoutPanel1.Location = new System.Drawing.Point(3, 28);
     this.tableLayoutPanel1.Name     = "tableLayoutPanel1";
     this.tableLayoutPanel1.Padding  = new System.Windows.Forms.Padding(0, 5, 0, 10);
     this.tableLayoutPanel1.RowCount = 2;
     this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
     this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
     this.tableLayoutPanel1.Size     = new System.Drawing.Size(337, 84);
     this.tableLayoutPanel1.TabIndex = 4;
     //
     // label1
     //
     this.label1.AutoSize = true;
     this.label1.Location = new System.Drawing.Point(3, 5);
     this.label1.Name     = "label1";
     this.label1.Size     = new System.Drawing.Size(35, 13);
     this.label1.TabIndex = 0;
     this.label1.Text     = "label1";
     //
     // panel1
     //
     this.panel1.Dock     = System.Windows.Forms.DockStyle.Fill;
     this.panel1.Location = new System.Drawing.Point(3, 21);
     this.panel1.Name     = "panel1";
     this.panel1.Size     = new System.Drawing.Size(331, 50);
     this.panel1.TabIndex = 1;
     //
     // myLabel1
     //
     this.myLabel1.Anchor =
         ((System.Windows.Forms.AnchorStyles)
              (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                | System.Windows.Forms.AnchorStyles.Right)));
     this.myLabel1.Font     = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold);
     this.myLabel1.Location = new System.Drawing.Point(3, 3);
     this.myLabel1.Name     = "myLabel1";
     this.myLabel1.resize   = false;
     this.myLabel1.Size     = new System.Drawing.Size(337, 23);
     this.myLabel1.TabIndex = 3;
     this.myLabel1.Text     = "myLabel1";
     //
     // MavlinkCheckBoxBitMask
     //
     this.Controls.Add(this.tableLayoutPanel1);
     this.Controls.Add(this.myLabel1);
     this.Name = "MavlinkCheckBoxBitMask";
     this.Size = new System.Drawing.Size(343, 115);
     this.tableLayoutPanel1.ResumeLayout(false);
     this.tableLayoutPanel1.PerformLayout();
     this.ResumeLayout(false);
     this.PerformLayout();
 }