Пример #1
0
        void ReleaseDesignerOutlets()
        {
            if (MyLabel != null)
            {
                MyLabel.Dispose();
                MyLabel = null;
            }

            if (MyButton != null)
            {
                MyButton.Dispose();
                MyButton = null;
            }
        }
Пример #2
0
        void ReleaseDesignerOutlets()
        {
            if (MyLabel != null)
            {
                MyLabel.Dispose();
                MyLabel = null;
            }

            if (MyText != null)
            {
                MyText.Dispose();
                MyText = null;
            }
        }
        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();

            if (MainV2.joystick == null)
            {
                butlabel.Dispose();
                butnumberlist.Dispose();
                but_detect.Dispose();
                hbar.Dispose();
                cmbaction.Dispose();
                but_settings.Dispose();
                return;
            }

            var config = MainV2.joystick.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 (Settings.Instance["butno" + name] != null)
            //  butnumberlist.Text = (Settings.Instance["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 (Settings.Instance["butaction" + name] != null)
            //  cmbaction.Text = Settings.Instance["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;
            }
        }