コード例 #1
0
        private static DialogResult InputBox(string title, string nameText, string apiText, ref string nvalue, ref string value)
        {
            Form      form         = new Form();
            Label     label        = new Label();
            Label     label2       = new Label();
            TextBox   textBox      = new TextBox();
            TextBox   textbox2     = new TextBox();
            Button    buttonOk     = new Button();
            Button    buttonCancel = new Button();
            LinkLabel osuapiurl    = new LinkLabel();

            form.Text              = title;
            label.Text             = nameText;
            label2.Text            = apiText;
            textBox.Text           = nvalue;
            textbox2.Text          = value;
            osuapiurl.Text         = "Get API";
            osuapiurl.LinkClicked += new LinkLabelLinkClickedEventHandler(Osuevent);

            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);
            label2.SetBounds(9, 70, 372, 13);
            textbox2.SetBounds(12, 86, 372, 20);
            osuapiurl.SetBounds(9, 122, 75, 23);
            buttonOk.SetBounds(228, 122, 75, 23);
            buttonCancel.SetBounds(309, 122, 75, 23);

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

            form.ClientSize = new Size(396, 157);
            form.Controls.AddRange(new Control[] { label, textBox, label2, textbox2, osuapiurl, 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;

            DialogResult dialogResult = form.ShowDialog();

            nvalue = textBox.Text;
            value  = textbox2.Text;
            return(dialogResult);
        } //InputBox Code from Y2J. Thanks! @ https://dotblogs.com.tw/aquarius6913/2014/09/03/146444
コード例 #2
0
        public static int InputBox(string title, string promptText) // Affichage de boîte information qui se ferme toute seule
        {
            Form        form     = new Form();
            LinkLabel   texte    = new LinkLabel();
            ProgressBar Progress = new ProgressBar();

            Progress.Minimum = 0;
            Progress.Maximum = 100;

            form.Text  = title;
            texte.Text = promptText;
            texte.SetBounds(9, 20, 372, 13);
            Progress.SetBounds(9, 30, 372, 20);

            texte.AutoSize  = true;
            Progress.Anchor = Progress.Anchor | AnchorStyles.Right;

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

            Progress.Style = System.Windows.Forms.ProgressBarStyle.Marquee;

            form.Show();

            for (int i = 0; i < 100; i++)
            {
                Thread.Sleep(10); // --> Timer au tick

                Progress.Value += 1;
                form.Show();
            }

            int Res = Progress.Value;

            if (Res == 100)
            {
                form.Close();
            }

            return(Res);
        }
コード例 #3
0
        public void Display(Rule rule)
        {
            this.rule = rule;
            int    startY = 4;
            int    startX = 4;
            int    index  = 0;
            string prefix = "";

            control.SuspendLayout();
            control.Controls.Clear();

            Label lbl = new Label();

            lbl.Text     = rule.TriggerText;
            lbl.AutoSize = true;
            control.Controls.Add(lbl);
            lbl.SetBounds(2, startX, lbl.Width, lbl.Height);
            startY += lbl.Height + 4;

            // show conditions
            foreach (RuleCondition rc in rule.Conditions)
            {
                LinkLabel ll = new LinkLabel();
                ll.AutoSize = true;
                SetLinkLabel(ll, prefix, rc);
                ll.Click += new EventHandler(ll_Click);
                ll.SetBounds(startX, startY, ll.Width, ll.Height);
                ll.Tag = new RulePartTag(rc, 0, index);
                control.Controls.Add(ll);
                startY += ll.Height;
                startX  = 12;
                prefix  = textAnd + " ";
                index++;
            }

            // show actions
            startX = 4;
            prefix = "";
            index  = 0;
            foreach (RuleAction ra in rule.Actions)
            {
                LinkLabel ll = new LinkLabel();
                ll.AutoSize = true;
                SetLinkLabel(ll, prefix, ra);
                ll.Click += new EventHandler(ll_Click);
                ll.SetBounds(startX, startY, ll.Width, ll.Height);
                ll.Tag = new RulePartTag(ra, 1, index);
                control.Controls.Add(ll);
                startY += ll.Height;
                startX  = 12;
                prefix  = textAnd + " ";
            }

            //show exceptions
            startX = 4;
            prefix = "";
            index  = 0;
            foreach (RuleCondition rc in rule.Exceptions)
            {
                LinkLabel ll = new LinkLabel();
                ll.AutoSize = true;
                SetLinkLabel(ll, prefix, rc);
                ll.Click += new EventHandler(ll_Click);
                ll.SetBounds(startX, startY, ll.Width, ll.Height);
                ll.Tag = new RulePartTag(rc, 2, index);
                control.Controls.Add(ll);
                startY += ll.Height;
                startX  = 12;
                prefix  = textOr + " ";
            }

            control.ResumeLayout();
        }