public TASKDIALOGCONFIG(bool construct)
        {
            this.cbSize     = (uint)Marshal.SizeOf(typeof(TASKDIALOGCONFIG));
            this.hwndParent = System.IntPtr.Zero;
            this.hInstance  = System.IntPtr.Zero;

            this.dwFlags = TASKDIALOG_FLAGS.NONE;
            //if(Program.Translation.Properties.RightToLeft) dwFlags |= VtdFlags.RtlLayout;

            this.dwCommonButtons         = TASKDIALOG_COMMON_BUTTON_FLAGS.TDCBF_NONE_BUTTON;
            this.pszWindowTitle          = null;
            this.MainIcon                = new TASKDIALOGCONFIG_ICON_UNION( );
            this.pszMainInstruction      = string.Empty;
            this.pszContent              = string.Empty;
            this.cButtons                = 0;
            this.pButtons                = System.IntPtr.Zero;
            this.nDefaultButton          = 0;
            this.cRadioButtons           = 0;
            this.pRadioButtons           = System.IntPtr.Zero;
            this.nDefaultRadioButton     = 0;
            this.pszVerificationText     = null;
            this.pszExpandedInformation  = null;
            this.pszExpandedControlText  = null;
            this.pszCollapsedControlText = null;
            this.FooterIcon              = new TASKDIALOGCONFIG_ICON_UNION( );
            this.pszFooter               = null;
            this.pfCallback              = null;
            this.lpCallbackData          = System.IntPtr.Zero;
            this.cxWidth = 0;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Displays a task dialog with the given configuration options.
        /// </summary>
        /// <param name="allowDialogCancellation">Indicates that the dialog should be able to be closed using Alt-F4,
        /// Escape, and the title bar's close button even if no cancel button
        /// is specified the CommonButtons.</param>
        /// <param name="callback">A callback that receives messages from the Task Dialog when
        /// various events occur.</param>
        /// <param name="callbackData">Reference object that is passed to the callback.</param>
        /// <param name="commandLinks">Command links.</param>
        /// <param name="commonButtons">Standard push buttons.</param>
        /// <param name="content">Supplemental text that expands on the principal text.</param>
        /// <param name="customButtons">Buttons that are not from the set of standard buttons. Use an
        /// ampersand to denote an access key.</param>
        /// <param name="customFooterIcon">A small 16x16 icon that signifies the purpose of the footer text,
        /// using a custom Icon resource. If defined <paramref name="footerIcon"/>
        /// will be ignored.</param>
        /// <param name="customMainIcon">A large 32x32 icon that signifies the purpose of the dialog, using
        /// a custom Icon resource. If defined <paramref name="mainIcon"/> will be
        /// ignored.</param>
        /// <param name="defaultButtonIndex">Zero-based index of the button to have focus by default.</param>
        /// <param name="enableCallbackTimer">Indicates that the task dialog's callback is to be called
        /// approximately every 200 milliseconds.</param>
        /// <param name="expandedByDefault">Indicates that the expanded info should be displayed when the
        /// dialog is initially displayed.</param>
        /// <param name="expandedInfo">Extra text that will be hidden by default.</param>
        /// <param name="expandToFooter">Indicates that the expanded info should be displayed at the bottom
        /// of the dialog's footer area instead of immediately after the
        /// dialog's content.</param>
        /// <param name="footerIcon">A small 16x16 icon that signifies the purpose of the footer text,
        /// using one of the built-in system icons.</param>
        /// <param name="footerText">Additional footer text.</param>
        /// <param name="mainIcon">A large 32x32 icon that signifies the purpose of the dialog, using
        /// one of the built-in system icons.</param>
        /// <param name="mainInstruction">Principal text.</param>
        /// <param name="owner">The owner window of the task dialog box.</param>
        /// <param name="radioButtons">Application-defined options for the user.</param>
        /// <param name="showMarqueeProgressBar">Indicates that an Marquee Progress Bar is to be displayed.</param>
        /// <param name="showProgressBar">Indicates that a Progress Bar is to be displayed.</param>
        /// <param name="title">Caption of the window.</param>
        /// <param name="verificationByDefault">Indicates that the verification checkbox in the dialog is checked
        /// when the dialog is initially displayed.</param>
        /// <param name="verificationText">Text accompanied by a checkbox, typically for user feedback such as
        /// Do-not-show-this-dialog-again options.</param>
        /// <returns>
        /// A <see cref="T:TaskDialogInterop.TaskDialogResult"/> value that specifies
        /// which button is clicked by the user.
        /// </returns>
        /// <remarks>
        /// Use of this method will ignore any TaskDialogOptions.Default settings.
        /// If you want to make use of defaults, create your own TaskDialogOptions starting with TaskDialogOptions.Default
        /// and pass it into the Show method.
        /// </remarks>
        public static TaskDialogResult Show(
            bool allowDialogCancellation          = false,
            TaskDialogCallback callback           = null,
            object callbackData                   = null,
            string[] commandLinks                 = null,
            TaskDialogCommonButtons commonButtons = TaskDialogCommonButtons.None,
            string content         = null,
            string[] customButtons = null,
            System.Drawing.Icon customFooterIcon = null,
            System.Drawing.Icon customMainIcon   = null,
            int?defaultButtonIndex    = null,
            bool enableCallbackTimer  = false,
            bool expandedByDefault    = false,
            string expandedInfo       = null,
            bool expandToFooter       = false,
            TaskDialogIcon footerIcon = TaskDialogIcon.None,
            string footerText         = null,
            TaskDialogIcon mainIcon   = TaskDialogIcon.None,
            string mainInstruction    = null,
            IntPtr owner                = default(IntPtr),
            string[] radioButtons       = null,
            bool showMarqueeProgressBar = false,
            bool showProgressBar        = false,
            string title                = null,
            bool verificationByDefault  = false,
            string verificationText     = null)
        {
            TaskDialogOptions options = new TaskDialogOptions()
            {
                AllowDialogCancellation = allowDialogCancellation,
                Callback            = callback,
                CallbackData        = callbackData,
                CommandLinks        = commandLinks,
                CommonButtons       = commonButtons,
                Content             = content,
                CustomButtons       = customButtons,
                CustomFooterIcon    = customFooterIcon,
                CustomMainIcon      = customMainIcon,
                DefaultButtonIndex  = defaultButtonIndex,
                EnableCallbackTimer = enableCallbackTimer,
                ExpandedByDefault   = expandedByDefault,
                ExpandedInfo        = expandedInfo,
                ExpandToFooter      = expandToFooter,
                FooterIcon          = footerIcon,
                FooterText          = footerText,
                MainIcon            = mainIcon,
                MainInstruction     = mainInstruction,
                Owner                  = owner,
                RadioButtons           = radioButtons,
                ShowMarqueeProgressBar = showMarqueeProgressBar,
                ShowProgressBar        = showProgressBar,
                Title                  = title,
                VerificationByDefault  = verificationByDefault,
                VerificationText       = verificationText
            };

            return(TaskDialog.Show(options));
        }
Ejemplo n.º 3
0
        private int PrivateCallback([In] IntPtr hwnd, [In] uint msg, [In] UIntPtr wparam, [In] IntPtr lparam, [In] IntPtr refData)
        {
            TaskDialogCallback callback = Callback;

            if (callback != null)
            {
                // Prepare arguments for the callback to the user we are insulating from Interop casting sillyness.

                // Future: Consider reusing a single ActiveTaskDialog object and mark it as destroyed on the destry notification.
                ActiveTaskDialog           activeDialog = new ActiveTaskDialog(hwnd);
                TaskDialogNotificationArgs args         = new TaskDialogNotificationArgs();
                args.Notification = (TaskDialogNotification)msg;
                switch (args.Notification)
                {
                case TaskDialogNotification.ButtonClicked:
                case TaskDialogNotification.RadioButtonClicked:
                    args.ButtonId = (int)wparam;
                    break;

                case TaskDialogNotification.HyperlinkClicked:
                    args.Hyperlink = Marshal.PtrToStringUni(lparam);
                    break;

                case TaskDialogNotification.Timer:
                    args.TimerTickCount = (uint)wparam;
                    break;

                case TaskDialogNotification.VerificationClicked:
                    args.VerificationFlagChecked = (wparam != UIntPtr.Zero);
                    break;

                case TaskDialogNotification.ExpandoButtonClicked:
                    args.Expanded = (wparam != UIntPtr.Zero);
                    break;
                }

                return(callback(activeDialog, args, CallbackData) ? 1 : 0);
            }

            return(0); // false;
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Resets the Task Dialog to the state when first constructed, all properties set to their default value.
 /// </summary>
 public void Reset()
 {
     this.windowTitle = null;
     this.mainInstruction = null;
     this.content = null;
     this.commonButtons = 0;
     this.mainIcon = VistaTaskDialogIcon.None;
     this.customMainIcon = null;
     this.footerIcon = VistaTaskDialogIcon.None;
     this.customFooterIcon = null;
     this.buttons = new VistaTaskDialogButton[0];
     this.radioButtons = new VistaTaskDialogButton[0];
     this.flags = 0;
     this.defaultButton = 0;
     this.defaultRadioButton = 0;
     this.verificationText = null;
     this.expandedInformation = null;
     this.expandedControlText = null;
     this.collapsedControlText = null;
     this.footer = null;
     this.callback = null;
     this.callbackData = null;
     this.width = 0;
 }