コード例 #1
0
        public static string PromptOption(string Question, string[] Options)
        {
            if (Options.Length == 1)
            {
                return(Options.Single());
            }

            var Form = new Form {
                Size = new System.Drawing.Size(270, 120)
            };

            VSContainer ThemeContainer = new VSContainer()
            {
                Form          = Form,
                FormOrWhole   = VSContainer.__FormOrWhole.Form,
                AllowMaximize = false,
                AllowMinimize = false,
                NoTitleWrap   = true,
                Text          = Question
            };

            Form.Controls.Add(ThemeContainer);


            VSComboBox ComboBox = new VSComboBox()
            {
                Size     = new System.Drawing.Size(235, 30),
                Location = new System.Drawing.Point(10, 40)
            };

            foreach (string Language in Options)
            {
                ComboBox.Items.Add(Language);
            }

            ComboBox.SelectedIndex = 0;

            ThemeContainer.Controls.Add(ComboBox);

            Timer Timer = null;

            if (ThemeContainer.Text.Length > 20)
            {
                ThemeContainer.ShowDots = true;
                ThemeContainer.Text    += " ";
                Timer          = new Timer();
                Timer.Interval = 80;
                Timer.Tick    += (a, b) => {
                    ThemeContainer.Text = ThemeContainer.Text.Substring(1) + ThemeContainer.Text[0];
                };
                Timer.Enabled = true;
            }

            Form.ShowDialog(Main.Instance);
            Timer?.Dispose();

            return(ComboBox.SelectedItem.ToString());
        }
コード例 #2
0
        public static int PromptValue(string Question, int Min = 0, int Max = int.MaxValue, int Default = 0)
        {
            var Form = new Form {
                Size = new System.Drawing.Size(270, 120)
            };

            VSContainer ThemeContainer = new VSContainer()
            {
                Form          = Form,
                FormOrWhole   = VSContainer.__FormOrWhole.Form,
                AllowMaximize = false,
                AllowMinimize = false,
                ShowIcon      = false,
                Text          = Question
            };

            Form.Controls.Add(ThemeContainer);


            VSNormalTextBox TextBox = new VSNormalTextBox()
            {
                Size     = new System.Drawing.Size(235, 30),
                Location = new System.Drawing.Point(10, 40)
            };

            TextBox.Text = $"{Default}";

            ThemeContainer.Controls.Add(TextBox);

            int Value = 0;

            do
            {
                Form.ShowDialog(Main.Instance);
            } while (!int.TryParse(TextBox.Text, out Value) || (Value < Min) || (Value > Max));

            return(Value);
        }