示例#1
0
        /// <summary>
        /// Runs a common dialog box with a default owner.
        /// </summary>
        /// <returns>System.Windows.Forms.DialogResult.OK if the user clicks OK in the dialog box; otherwise, System.Windows.Forms.DialogResult.Cancel.</returns>
        public DialogResult ShowDialog()
        {
            var frmDialog = new SelectColorForm
            {
                OKButton_Image     = this.OKButton_Image,
                CancelButton_Image = this.CancelButton_Image,
                ShowPalette        = this.ShowPalette,
                CustomColors       = this.CustomColors,
                Color = this.Color
            };

            if (!string.IsNullOrEmpty(Title))
            {
                frmDialog.Text = Title;
            }
            if (!string.IsNullOrEmpty(ColorName))
            {
                frmDialog.ColorName = this.ColorName;
            }

            var Result = frmDialog.ShowDialog();

            if (Result != DialogResult.Cancel)
            {
                this.Color     = frmDialog.Color;
                this.ColorName = frmDialog.ColorName;
            }

            frmDialog?.Dispose();

            return(Result);
        }
示例#2
0
        /// <summary>
        /// Runs a common dialog box with the specified owner.
        /// </summary>
        /// <param name="owner">Any object that implements System.Windows.Forms.IWin32Window that represents the top-level window that will own the modal dialog box.</param>
        /// <returns>System.Windows.Forms.DialogResult.OK if the user clicks OK in the dialog box; otherwise, System.Windows.Forms.DialogResult.Cancel.</returns>
        public DialogResult ShowDialog(IWin32Window owner)
        {
            var frmDialog = new SelectColorForm
            {
                Color              = this.Color,
                ColorName          = this.ColorName,
                OKButton_Image     = this.OKButton_Image,
                CancelButton_Image = this.CancelButton_Image
            };

            if (!string.IsNullOrEmpty(Title))
            {
                frmDialog.Text = Title;
            }

            var Result = frmDialog.ShowDialog(owner);

            if (Result != DialogResult.Cancel)
            {
                this.Color     = frmDialog.Color;
                this.ColorName = frmDialog.ColorName;
            }

            frmDialog?.Dispose();

            return(Result);
        }