Пример #1
0
        public static string GetInputWait(string message,
                                          string title,
                                          string current = "",
                                          Predicate <string> validFunc = null)
        {
            var inputDialog = new MultilineInput();

            inputDialog.MessageLbl.Text = message;
            inputDialog.Text            = title;

            inputDialog.InputTxt.Text = current;

            if (validFunc != null)
            {
                inputDialog.validate = validFunc;
            }

            inputDialog.InputTxt.Enabled = inputDialog.validate(current);

            return((inputDialog.ShowDialog() == DialogResult.OK) ?
                   inputDialog.InputTxt.Text : "");
        }
Пример #2
0
        public static void GetInput(string message,
                                    string title,
                                    Action <string> onReturn,
                                    string current = "",
                                    Predicate <string> validFunc = null)
        {
            var inputDialog = new MultilineInput();

            inputDialog.StartPosition = FormStartPosition.CenterScreen;

            inputDialog.MessageLbl.Text = message;
            inputDialog.Text            = title;

            inputDialog.InputTxt.Text = current;

            if (validFunc != null)
            {
                inputDialog.validate = validFunc;
            }

            inputDialog.InputTxt.Enabled = inputDialog.validate(current);

            inputDialog.FormClosing += (s, e) =>
            {
                if (inputDialog.DialogResult == DialogResult.OK)
                {
                    onReturn(inputDialog.InputTxt.Text);
                }
                else
                {
                    onReturn("");
                }
            };

            inputDialog.Show();
        }