Пример #1
0
        /// <summary>
        /// Show input dialog box
        /// </summary>
        /// <param name="theme">Theme</param>
        /// <param name="message">Message</param>
        /// <param name="defaultValue">Default value</param>
        /// <param name="title">Title</param>
        /// <param name="isNumberOnly">Number input</param>
        /// <param name="topMost">Set the form to top most</param>
        /// <param name="isFilename">Filename input</param>
        /// <param name="filterOnKeyPressed">Apply filter on key pressed</param>
        /// <returns></returns>
        public static DialogResult ShowDialog(Theme theme, string message, string defaultValue, string title = "", bool isNumberOnly = false, bool topMost = false, bool isFilename = false, bool filterOnKeyPressed = false)
        {
            var frm = new frmDialogBox(title, message, theme)
            {
                Content          = defaultValue,
                TopMost          = topMost,
                FilterOnKeyPress = filterOnKeyPressed,
            };

            if (isNumberOnly)
            {
                frm.Filter   = NumberFilter;
                frm.MaxLimit = 10;
            }

            if (isFilename)
            {
                frm.Filter   = FilenameFilter;
                frm.MaxLimit = 256;
            }

            if (frm.ShowDialog() == DialogResult.OK)
            {
                //Save input data
                InputBox.Message = frm.Content;
            }

            return(frm.DialogResult);
        }
Пример #2
0
        /// <summary>
        /// Show input dialog box
        /// </summary>
        /// <param name="title">Title</param>
        /// <param name="message">Message</param>
        /// <param name="defaultValue">Default value</param>
        /// <param name="isNumberOnly">Number input</param>
        /// <param name="topMost">Set the form to top most</param>
        /// <param name="isFilename">Filename input</param>
        /// <returns></returns>
        public static DialogResult ShowDialog(string title, string message, string defaultValue, bool @isNumberOnly = false, bool @topMost = false, bool isFilename = false)
        {
            frmDialogBox f = new frmDialogBox(title, message)
            {
                Content = defaultValue,
                TopMost = topMost
            };

            if (isNumberOnly)
            {
                f.Filter   = NumberFilter;
                f.MaxLimit = 10;
            }

            if (isFilename)
            {
                f.Filter   = FilenameFilter;
                f.MaxLimit = 256;
            }

            if (f.ShowDialog() == DialogResult.OK)
            {
                //Save input data
                InputBox.Message = f.Content;
            }

            return(f.DialogResult);
        }