A Task Dialog. This is like a MessageBox but with many more features. TaskDialog requires Windows Longhorn or later.
        /// <summary>
        /// TaskDialog wrapped in a CommonDialog class. THis is required to work well in
        /// MMC 2.1. In MMC 2.1 you must use the ShowDialog methods on the MMC classes to
        /// correctly show a modal dialog. This class will allow you to do this and keep access
        /// to the results of the TaskDialog.
        /// </summary>
        /// <param name="taskDialog">The TaskDialog to show.</param>
        public TaskDialogCommonDialog( TaskDialog taskDialog )
        {
            if ( taskDialog == null )
            {
                throw new ArgumentNullException ( "taskDialog" );
            }

            this.taskDialog = taskDialog;
        }
Beispiel #2
0
        public EmulateTaskDialog( TaskDialog newTaskDialog )
        {
            // http://dotnetperls.com/Content/Segoe-Tahoma-Windows-Forms.aspx
            // http://www.codeproject.com/KB/cs/AdjustingFontAndLayout.aspx
            // For some discussion about setting program fonts.
            this.Font = SystemFonts.MessageBoxFont;

            InitializeComponent ( );

            this.taskDialog = newTaskDialog;

            BuildForm ( );

            // Setup the default settings.

            if ( this.defaultRadioButton != null )
            {
                this.defaultRadioButton.Checked = true;
            }

            // Only can set focus after everything has been build.
            if ( this.taskDialog.DefaultButton != 0 )
            {
                // Set the default button.
                if ( this.taskDialogButtons.TryGetValue ( this.taskDialog.DefaultButton, out this.defaultButton ) )
                {
                    this.defaultButton.Select ( );
                }
                else
                {
                    if ( this.flowLayoutPanelSubAreaButtons.Controls.Count > 0 )
                    {
                        // Select left-most button.
                        this.flowLayoutPanelSubAreaButtons.Controls[this.flowLayoutPanelSubAreaButtons.Controls.Count - 1].Select ( );
                    }
                }
            }
            else
            {
                if ( this.flowLayoutPanelSubAreaButtons.Controls.Count > 0 )
                {
                    // Set the left-most button to be the default. Dictionary does
                    // not keep the order of the button that is added in, so this
                    // work around is used.
                    //
                    // Layout right to left, left-most item is at the end of the list.
                    this.flowLayoutPanelSubAreaButtons.Controls[this.flowLayoutPanelSubAreaButtons.Controls.Count - 1].Select ( );
                }
            }

            if ( this.taskDialog.Callback != null )
            {
                timer.Start ( );
            }
        }