コード例 #1
0
ファイル: InputBox.cs プロジェクト: AdmiralCurtiss/FaceCopy
        /// <summary>
        /// Displays a prompt in a dialog box, waits for the user to input text or click a button.
        /// </summary>
        /// <param name="prompt">String expression displayed as the message in the dialog box</param>
        /// <param name="title">String expression displayed in the title bar of the dialog box</param>
        /// <param name="defaultResponse">String expression displayed in the text box as the default response</param>
        /// <param name="validator">Delegate used to validate the text</param>
        /// <param name="xpos">Numeric expression that specifies the distance of the left edge of the dialog box from the left edge of the screen.</param>
        /// <param name="ypos">Numeric expression that specifies the distance of the upper edge of the dialog box from the top of the screen</param>
        /// <returns>An InputBoxResult object with the Text and the OK property set to true when OK was clicked.</returns>
        public static InputBoxResult Show( string prompt, string title, string defaultResponse, InputBoxValidatingHandler validator, int xpos, int ypos, bool multiline )
        {
            using ( InputBox form = new InputBox() ) {
                if ( multiline ) {
                    form.textBoxText.Multiline = true;
                    form.textBoxText.Height += 300;
                    form.Height += 300;
                }

                form.labelPrompt.Text = prompt;
                form.Text = title;
                form.textBoxText.Text = defaultResponse;
                if ( xpos >= 0 && ypos >= 0 ) {
                    form.StartPosition = FormStartPosition.Manual;
                    form.Left = xpos;
                    form.Top = ypos;
                }
                form.Validator = validator;

                DialogResult result = form.ShowDialog();

                InputBoxResult retval = new InputBoxResult();
                if ( result == DialogResult.OK ) {
                    retval.Text = form.textBoxText.Text;
                    retval.OK = true;
                }
                return retval;
            }
        }
コード例 #2
0
        /// <summary>
        ///     Displays a prompt in a dialog box, waits for the user to input text or click a button.
        /// </summary>
        /// <param name="prompt">String expression displayed as the message in the dialog box</param>
        /// <param name="title">String expression displayed in the title bar of the dialog box</param>
        /// <param name="defaultResponse">String expression displayed in the text box as the default response</param>
        /// <param name="validator">Delegate used to validate the text</param>
        /// <param name="xPosition">
        ///     Numeric expression that specifies the distance of the left edge of the dialog box from the left edge
        ///     of the screen.
        /// </param>
        /// <param name="yPosition">
        ///     Numeric expression that specifies the distance of the upper edge of the dialog box from the top of
        ///     the screen
        /// </param>
        /// <returns>An InputBoxResult object with the Text and the OK property set to true when OK was clicked.</returns>
        public static InputBoxResult Show(string prompt, string title, string defaultResponse,
                                          InputBoxValidatingHandler validator, int xPosition, int yPosition)
        {
            using (var form = new InputBox())
            {
                form.LabelPrompt.Text = prompt;
                form.Text             = title;
                form.TextBoxText.Text = defaultResponse;
                if (xPosition >= 0 && yPosition >= 0)
                {
                    form.StartPosition = FormStartPosition.Manual;
                    form.Left          = xPosition;
                    form.Top           = yPosition;
                }
                form.Validator = validator;

                var result = form.ShowDialog();

                var returnValue = new InputBoxResult();

                if (result != DialogResult.OK)
                {
                    return(returnValue);
                }

                returnValue.Text = form.TextBoxText.Text;
                returnValue.Ok   = true;

                return(returnValue);
            }
        }
コード例 #3
0
        /// <summary>
        /// 顯示文字輸入對話窗。
        /// </summary>
        /// <param name="prompt">提示文字。</param>
        /// <param name="title">對話窗標題。</param>
        /// <param name="validator">驗證輸入文字的事件處理常式。</param>
        /// <param name="xpos">對話窗的 X 座標。若為 -1 則採用預設值(螢幕中央)。</param>
        /// <param name="ypos">對話窗的 Y 座標。若為 -1 則採用預設值(螢幕中央)。</param>
        /// <param name="maxLength">最大長度。</param>
        /// <param name="value">文字方塊的預設值/傳回值。</param>
        /// <returns>傳回 DialogResult,若為 DialogResult.OK,則一併傳回 value 參數。</returns>
        public static DialogResult ShowDialog(string prompt, string title, InputBoxValidatingHandler validator, int xpos, int ypos, int maxLength, ref string value)
        {
            using (InputBox form = new InputBox())
            {
                form.lblPrompt.Text    = prompt;
                form.Text              = title;
                form.txtText.MaxLength = maxLength;
                form.txtText.Text      = value;
                if (xpos >= 0 && ypos >= 0)
                {
                    form.StartPosition = FormStartPosition.Manual;
                    form.Left          = xpos;
                    form.Top           = ypos;
                }
                form.Validator = validator;

                DialogResult result = form.ShowDialog();

                if (result == DialogResult.OK)
                {
                    value = form.txtText.Text;
                }
                return(result);
            }
        }
コード例 #4
0
        /// <summary>
        /// Displays a prompt in a dialog box, waits for the user to input text or click a button.
        /// </summary>
        /// <param name="prompt">String expression displayed as the message in the dialog box</param>
        /// <param name="title">String expression displayed in the title bar of the dialog box</param>
        /// <param name="defaultResponse">String expression displayed in the text box as the default response</param>
        /// <param name="validator">Delegate used to validate the text</param>
        /// <param name="xpos">Numeric expression that specifies the distance of the left edge of the dialog box from the left edge of the screen.</param>
        /// <param name="ypos">Numeric expression that specifies the distance of the upper edge of the dialog box from the top of the screen</param>
        /// <returns>An InputBoxResult object with the Text and the OK property set to true when OK was clicked.</returns>
        public static InputBoxResult Show(string prompt, string title, string defaultResponse,
                                          InputBoxValidatingHandler validator, int xpos, int ypos)
        {
            using (InputBox form = new InputBox())
            {
                form.labelPrompt.Text = prompt;
                form.Text             = title;
                form.textBoxText.Text = defaultResponse;
                if (xpos >= 0 && ypos >= 0)
                {
                    form.StartPosition = FormStartPosition.Manual;
                    form.Left          = xpos;
                    form.Top           = ypos;
                }
                form.Validator = validator;

                DialogResult result = form.ShowDialog();

                InputBoxResult retval = new InputBoxResult();
                if (result == DialogResult.OK)
                {
                    retval.Text = form.textBoxText.Text;
                    retval.OK   = true;
                }
                return(retval);
            }
        }
コード例 #5
0
ファイル: InputBox.cs プロジェクト: hoeness2/mcebuddy2
        /// <summary>
        /// Displays a prompt in a dialog box, waits for the user to input text or click a button.
        /// </summary>
        /// <param name="prompt">String expression displayed as the message in the dialog box</param>
        /// <param name="title">String expression displayed in the title bar of the dialog box</param>
        /// <param name="defaultResponse">String expression displayed in the text box as the default response</param>
        /// <param name="validator">Delegate used to validate the text</param>
        /// <param name="keyPressHandler">Delete used to handle keypress events of the textbox</param>
        /// <param name="xpos">Numeric expression that specifies the distance of the left edge of the dialog box from the left edge of the screen.</param>
        /// <param name="ypos">Numeric expression that specifies the distance of the upper edge of the dialog box from the top of the screen</param>
        /// <returns>An InputBoxResult object with the Text and the OK property set to true when OK was clicked.</returns>
        public static InputBoxResult Show(string prompt, string title, string defaultResponse, InputBoxValidatingHandler validator, KeyPressEventHandler keyPressHandler, int xpos, int ypos)
        {
            using (InputBox form = new InputBox())
            {
                form.label.Text = prompt;
                form.Text = title;
                form.textBox.Text = defaultResponse;
                if (xpos >= 0 && ypos >= 0)
                {
                    form.StartPosition = FormStartPosition.Manual;
                    form.Left = xpos;
                    form.Top = ypos;
                }

                form.Validator = validator;
                form.KeyPressed = keyPressHandler;

                DialogResult result = form.ShowDialog();

                InputBoxResult retval = new InputBoxResult();
                if (result == DialogResult.OK)
                {
                    retval.Text = form.textBox.Text;
                    retval.OK = true;
                }

                return retval;
            }
        }
コード例 #6
0
        /// <summary>
        /// Displays a prompt in a dialog box, waits for the user to input text or click a button.
        /// </summary>
        /// <param name="prompt">String expression displayed as the message in the dialog box</param>
        /// <param name="title">String expression displayed in the title bar of the dialog box</param>
        /// <param name="defaultResponse">String expression displayed in the text box as the default response</param>
        /// <param name="validator">Delegate used to validate the text</param>
        /// <param name="xpos">Numeric expression that specifies the distance of the left edge of the dialog box from the left edge of the screen.</param>
        /// <param name="ypos">Numeric expression that specifies the distance of the upper edge of the dialog box from the top of the screen</param>
        /// <returns>An InputBoxResult object with the Text and the OK property set to true when OK was clicked.</returns>
        public static InputBoxResult Show(String prompt, String title, String tip,
                                          String defaultResponse, InputBoxValidatingHandler validator,
                                          Int32 xpos, Int32 ypos)
        {
            using (InputBox form = new InputBox()) {
                form.labelPrompt.Text = prompt;
                form.Text             = title;
                form.textBoxText.Text = defaultResponse;

                //201807 -- custom code
                ToolTip buttonToolTip = new ToolTip();
                buttonToolTip.ToolTipTitle = "Remember...";
                buttonToolTip.UseFading    = true;
                buttonToolTip.UseAnimation = true;
                buttonToolTip.IsBalloon    = false;
                buttonToolTip.ShowAlways   = true;
                buttonToolTip.AutoPopDelay = 5000;
                buttonToolTip.InitialDelay = 1000;
                buttonToolTip.ReshowDelay  = 500;
                buttonToolTip.SetToolTip(form.textBoxText, tip);
                //custom code -- end


                if (xpos >= 0 && ypos >= 0)
                {
                    form.StartPosition = FormStartPosition.Manual;
                    form.Left          = xpos;
                    form.Top           = ypos;
                }
                form.Validator = validator;

                DialogResult result = form.ShowDialog();

                InputBoxResult retval = new InputBoxResult();
                if (result == DialogResult.OK)
                {
                    retval.Text = form.textBoxText.Text;
                    retval.OK   = true;
                }
                return(retval);
            }
        }
コード例 #7
0
ファイル: InputBox.cs プロジェクト: AdmiralCurtiss/FaceCopy
 private void buttonCancel_Click( object sender, System.EventArgs e )
 {
     this.Validator = null;
     this.Close();
 }
コード例 #8
0
ファイル: InputBox.cs プロジェクト: AdmiralCurtiss/FaceCopy
 /// <summary>
 /// Displays a prompt in a dialog box, waits for the user to input text or click a button.
 /// </summary>
 /// <param name="prompt">String expression displayed as the message in the dialog box</param>
 /// <param name="title">String expression displayed in the title bar of the dialog box</param>
 /// <param name="defaultResponse">String expression displayed in the text box as the default response</param>
 /// <param name="validator">Delegate used to validate the text</param>
 /// <returns>An InputBoxResult object with the Text and the OK property set to true when OK was clicked.</returns>
 public static InputBoxResult Show( string prompt, string title, string defaultText, InputBoxValidatingHandler validator, bool multiline )
 {
     return Show( prompt, title, defaultText, validator, -1, -1, multiline );
 }
コード例 #9
0
 /// <summary>
 /// Displays a prompt in a dialog box, waits for the user to input text or click a button.
 /// </summary>
 /// <param name="prompt">String expression displayed as the message in the dialog box</param>
 /// <param name="title">String expression displayed in the title bar of the dialog box</param>
 /// <param name="defaultResponse">String expression displayed in the text box as the default response</param>
 /// <param name="validator">Delegate used to validate the text</param>
 /// <returns>An InputBoxResult object with the Text and the OK property set to true when OK was clicked.</returns>
 public static InputBoxResult Show(string prompt, string title, string defaultText, InputBoxValidatingHandler validator)
 {
     return(Show(prompt, title, defaultText, validator, -1, -1));
 }
コード例 #10
0
 private void buttonCancel_Click(object sender, EventArgs e)
 {
     Validator = null;
     Close();
 }
コード例 #11
0
ファイル: InputBox.cs プロジェクト: Reborn-Team/MidsReborn
        private static InputBoxResult Show(string prompt, string title, string defaultResponse, InputBoxIcon icon, InputBoxValidatingHandler validator, int xpos, int ypos)
        {
            using var form = new InputBox
                  {
                      inputLabel   = { Text = prompt },
                      Text         = title,
                      inputTextBox = { Text = defaultResponse },
                      inputIcon    = { Image = inputImages.Images[(int)icon] }
                  };
            if (xpos >= 0 && ypos >= 0)
            {
                form.StartPosition = FormStartPosition.Manual;
                form.Left          = xpos;
                form.Top           = ypos;
            }
            else if (xpos == -1 && ypos == -1)
            {
                form.StartPosition = FormStartPosition.CenterParent;
            }
            form.Validator = validator;

            var result = form.ShowDialog();

            var returnVal = new InputBoxResult();

            if (result != DialogResult.OK)
            {
                return(returnVal);
            }
            returnVal.Text = form.inputTextBox.Text;
            returnVal.OK   = true;
            return(returnVal);
        }
コード例 #12
0
 /// <summary>
 /// Displays a prompt in a dialog box, waits for the user to input text or click a button.
 /// </summary>
 /// <param name="prompt">String expression displayed as the message in the dialog box</param>
 /// <param name="title">String expression displayed in the title bar of the dialog box</param>
 /// <param name="validator">Delegate used to validate the text</param>
 /// <param name="value">文字方塊的預設值/傳回值。</param>
 /// <returns>傳回 DialogResult,若為 DialogResult.OK,則一併傳回 value 參數。</returns>
 public static DialogResult ShowDialog(string prompt, string title, InputBoxValidatingHandler validator, ref string value)
 {
     return(ShowDialog(prompt, title, validator, -1, -1, -1, ref value));
 }
コード例 #13
0
ファイル: InputBox.cs プロジェクト: reedy/AutoWikiBrowser
 private void buttonCancel_Click(object sender, EventArgs e)
 {
     Validator = null;
     Close();
 }
コード例 #14
0
ファイル: InputBox.cs プロジェクト: hoeness2/mcebuddy2
 /// <summary>
 /// Displays a prompt in a dialog box, waits for the user to input text or click a button.
 /// </summary>
 /// <param name="prompt">String expression displayed as the message in the dialog box</param>
 /// <param name="title">String expression displayed in the title bar of the dialog box</param>
 /// <param name="defaultResponse">String expression displayed in the text box as the default response</param>
 /// <param name="validator">Delegate used to validate the text</param>
 /// <param name="keyPressHandler">Delete used to handle keypress events of the textbox</param>
 /// <returns>An InputBoxResult object with the Text and the OK property set to true when OK was clicked.</returns>
 public static InputBoxResult Show(string prompt, string title, string defaultText, InputBoxValidatingHandler validator, KeyPressEventHandler keyPressHandler)
 {
     return Show(prompt, title, defaultText, validator, keyPressHandler, -1, -1);
 }