예제 #1
0
        public static Form LoadingBox(string title, string promptText)
        {
            Form form = new Form();

            System.Windows.Forms.Label label = new System.Windows.Forms.Label();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainV2));
            form.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));

            form.Text  = title;
            label.Text = promptText;

            label.SetBounds(9, 50, 372, 13);

            label.AutoSize = true;

            form.ClientSize = new Size(396, 107);
            form.Controls.AddRange(new Control[] { label });
            form.ClientSize      = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height);
            form.FormBorderStyle = FormBorderStyle.FixedDialog;
            form.StartPosition   = FormStartPosition.CenterScreen;
            form.MinimizeBox     = false;
            form.MaximizeBox     = false;

            MainV2.fixtheme(form);

            form.Show();
            form.Refresh();
            label.Refresh();
            Application.DoEvents();
            return(form);
        }
예제 #2
0
        public static DialogResult MessageShowAgain(string title, string promptText)
        {
            Form form = new Form();

            System.Windows.Forms.Label label = new System.Windows.Forms.Label();
            CheckBox chk      = new CheckBox();
            MyButton buttonOk = new MyButton();

            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainV2));
            form.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));

            form.Text  = title;
            label.Text = promptText;

            chk.Tag      = ("SHOWAGAIN_" + title.Replace(" ", "_"));
            chk.AutoSize = true;
            chk.Text     = "Show me again?";
            chk.Checked  = true;
            chk.Location = new Point(9, 80);

            if (MainV2.config[(string)chk.Tag] != null && (string)MainV2.config[(string)chk.Tag] == "False") // skip it
            {
                form.Dispose();
                chk.Dispose();
                buttonOk.Dispose();
                label.Dispose();
                return(DialogResult.OK);
            }

            chk.CheckStateChanged += new EventHandler(chk_CheckStateChanged);

            buttonOk.Text         = "OK";
            buttonOk.DialogResult = DialogResult.OK;
            buttonOk.Location     = new Point(form.Right - 100, 80);

            label.SetBounds(9, 40, 372, 13);

            label.AutoSize = true;

            form.ClientSize = new Size(396, 107);
            form.Controls.AddRange(new Control[] { label, chk, buttonOk });
            form.ClientSize      = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height);
            form.FormBorderStyle = FormBorderStyle.FixedDialog;
            form.StartPosition   = FormStartPosition.CenterScreen;
            form.MinimizeBox     = false;
            form.MaximizeBox     = false;

            MainV2.fixtheme(form);

            return(form.ShowDialog());
        }
예제 #3
0
        //from http://www.csharp-examples.net/inputbox/
        public static DialogResult InputBox(string title, string promptText, ref string value)
        {
            Form form = new Form();

            System.Windows.Forms.Label label = new System.Windows.Forms.Label();
            TextBox  textBox      = new TextBox();
            MyButton buttonOk     = new MyButton();
            MyButton buttonCancel = new MyButton();

            form.TopMost = true;

            form.Text    = title;
            label.Text   = promptText;
            textBox.Text = value;

            buttonOk.Text             = "OK";
            buttonCancel.Text         = "Cancel";
            buttonOk.DialogResult     = DialogResult.OK;
            buttonCancel.DialogResult = DialogResult.Cancel;

            label.SetBounds(9, 20, 372, 13);
            textBox.SetBounds(12, 36, 372, 20);
            buttonOk.SetBounds(228, 72, 75, 23);
            buttonCancel.SetBounds(309, 72, 75, 23);

            label.AutoSize      = true;
            textBox.Anchor      = textBox.Anchor | AnchorStyles.Right;
            buttonOk.Anchor     = AnchorStyles.Bottom | AnchorStyles.Right;
            buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;

            form.ClientSize = new Size(396, 107);
            form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel });
            form.ClientSize      = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height);
            form.FormBorderStyle = FormBorderStyle.FixedDialog;
            form.StartPosition   = FormStartPosition.CenterScreen;
            form.MinimizeBox     = false;
            form.MaximizeBox     = false;
            form.AcceptButton    = buttonOk;
            form.CancelButton    = buttonCancel;

            MainV2.fixtheme(form);

            DialogResult dialogResult = form.ShowDialog();

            if (dialogResult == DialogResult.OK)
            {
                value = textBox.Text;
            }
            return(dialogResult);
        }
예제 #4
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            try
            {
                if (MainV2.joystick == null || MainV2.joystick.enabled == false)
                {
                    //Console.WriteLine(DateTime.Now.Millisecond + " start ");
                    Joystick joy = MainV2.joystick;
                    if (joy == null)
                    {
                        joy = new Joystick();
                        joy.setChannel(1, (Joystick.joystickaxis)Enum.Parse(typeof(Joystick.joystickaxis), CMB_CH1.Text), revCH1.Checked, int.Parse(expo_ch1.Text));
                        joy.setChannel(2, (Joystick.joystickaxis)Enum.Parse(typeof(Joystick.joystickaxis), CMB_CH2.Text), revCH2.Checked, int.Parse(expo_ch2.Text));
                        joy.setChannel(3, (Joystick.joystickaxis)Enum.Parse(typeof(Joystick.joystickaxis), CMB_CH3.Text), revCH3.Checked, int.Parse(expo_ch3.Text));
                        joy.setChannel(4, (Joystick.joystickaxis)Enum.Parse(typeof(Joystick.joystickaxis), CMB_CH4.Text), revCH4.Checked, int.Parse(expo_ch4.Text));
                        joy.setChannel(5, (Joystick.joystickaxis)Enum.Parse(typeof(Joystick.joystickaxis), CMB_CH5.Text), revCH5.Checked, int.Parse(expo_ch5.Text));
                        joy.setChannel(6, (Joystick.joystickaxis)Enum.Parse(typeof(Joystick.joystickaxis), CMB_CH6.Text), revCH6.Checked, int.Parse(expo_ch6.Text));
                        joy.setChannel(7, (Joystick.joystickaxis)Enum.Parse(typeof(Joystick.joystickaxis), CMB_CH7.Text), revCH7.Checked, int.Parse(expo_ch7.Text));
                        joy.setChannel(8, (Joystick.joystickaxis)Enum.Parse(typeof(Joystick.joystickaxis), CMB_CH8.Text), revCH8.Checked, int.Parse(expo_ch8.Text));

                        joy.elevons = CHK_elevons.Checked;

                        joy.AcquireJoystick(CMB_joysticks.Text);

                        joy.name = CMB_joysticks.Text;

                        noButtons = joy.getNumButtons();

                        for (int f = 0; f < noButtons; f++)
                        {
                            string name = (f + 1).ToString();

                            doButtontoUI(name, 10, 290 + f * 25);

                            joy.setButton(f, int.Parse(this.Controls.Find("cmbbutton" + name, false)[0].Text), this.Controls.Find("cmbaction" + name, false)[0].Text);
                        }

                        MainV2.joystick = joy;

                        MainV2.fixtheme(this);

                        CMB_joysticks.SelectedIndex = CMB_joysticks.Items.IndexOf(joy.name);
                    }

                    MainV2.joystick.elevons = CHK_elevons.Checked;

                    MainV2.cs.rcoverridech1 = joy.getValueForChannel(1, CMB_joysticks.Text);
                    MainV2.cs.rcoverridech2 = joy.getValueForChannel(2, CMB_joysticks.Text);
                    MainV2.cs.rcoverridech3 = joy.getValueForChannel(3, CMB_joysticks.Text);
                    MainV2.cs.rcoverridech4 = joy.getValueForChannel(4, CMB_joysticks.Text);
                    MainV2.cs.rcoverridech5 = joy.getValueForChannel(5, CMB_joysticks.Text);
                    MainV2.cs.rcoverridech6 = joy.getValueForChannel(6, CMB_joysticks.Text);
                    MainV2.cs.rcoverridech7 = joy.getValueForChannel(7, CMB_joysticks.Text);
                    MainV2.cs.rcoverridech8 = joy.getValueForChannel(8, CMB_joysticks.Text);

                    //Console.WriteLine(DateTime.Now.Millisecond + " end ");
                }
            }
            catch { }

            progressBar1.Value           = MainV2.cs.rcoverridech1;
            progressBar2.Value           = MainV2.cs.rcoverridech2;
            progressBar3.Value           = MainV2.cs.rcoverridech3;
            progressBar4.Value           = MainV2.cs.rcoverridech4;
            horizontalProgressBar1.Value = MainV2.cs.rcoverridech5;
            horizontalProgressBar2.Value = MainV2.cs.rcoverridech6;
            horizontalProgressBar3.Value = MainV2.cs.rcoverridech7;
            horizontalProgressBar4.Value = MainV2.cs.rcoverridech8;

            try
            {
                for (int f = 0; f < noButtons; f++)
                {
                    string name = (f + 1).ToString();

                    ((HorizontalProgressBar)this.Controls.Find("hbar" + name, false)[0]).Value = MainV2.joystick.isButtonPressed(f) ? 100 : 0;
                }
            }
            catch {  } // this is for buttons - silent fail
        }