internal NativeTaskDialogSettings()
        {
            nativeConfiguration = new TaskDialogNativeMethods.TASKDIALOGCONFIG();

            // Apply standard settings.
            nativeConfiguration.cbSize = (uint)Marshal.SizeOf(nativeConfiguration);
            nativeConfiguration.hwndParent = IntPtr.Zero;
            nativeConfiguration.hInstance = IntPtr.Zero;
            nativeConfiguration.dwFlags = TaskDialogNativeMethods.TASKDIALOG_FLAGS.TDF_ALLOW_DIALOG_CANCELLATION;
            nativeConfiguration.dwCommonButtons = TaskDialogNativeMethods.TASKDIALOG_COMMON_BUTTON_FLAGS.TDCBF_OK_BUTTON;
            nativeConfiguration.MainIcon = new TaskDialogNativeMethods.TASKDIALOGCONFIG_ICON_UNION(0);
            nativeConfiguration.FooterIcon = new TaskDialogNativeMethods.TASKDIALOGCONFIG_ICON_UNION(0);
            nativeConfiguration.cxWidth = TaskDialogDefaults.IdealWidth;

            // Zero out all the custom button fields.
            nativeConfiguration.cButtons = 0;
            nativeConfiguration.cRadioButtons = 0;
            nativeConfiguration.pButtons = IntPtr.Zero;
            nativeConfiguration.pRadioButtons = IntPtr.Zero;
            nativeConfiguration.nDefaultButton = 0;
            nativeConfiguration.nDefaultRadioButton = 0;

            // Various text defaults.
            nativeConfiguration.pszWindowTitle = TaskDialogDefaults.Caption;
            nativeConfiguration.pszMainInstruction = TaskDialogDefaults.MainInstruction;
            nativeConfiguration.pszContent = TaskDialogDefaults.Content;
            nativeConfiguration.pszVerificationText = null;
            nativeConfiguration.pszExpandedInformation = null;
            nativeConfiguration.pszExpandedControlText = null;
            nativeConfiguration.pszCollapsedControlText = null;
            nativeConfiguration.pszFooter = null;
        }
        internal NativeTaskDialogSettings()
        {
            nativeConfiguration = new TaskDialogNativeMethods.TASKDIALOGCONFIG();

            // Apply standard settings.
            nativeConfiguration.cbSize          = (uint)Marshal.SizeOf(nativeConfiguration);
            nativeConfiguration.hwndParent      = IntPtr.Zero;
            nativeConfiguration.hInstance       = IntPtr.Zero;
            nativeConfiguration.dwFlags         = TaskDialogNativeMethods.TASKDIALOG_FLAGS.TDF_ALLOW_DIALOG_CANCELLATION;
            nativeConfiguration.dwCommonButtons = TaskDialogNativeMethods.TASKDIALOG_COMMON_BUTTON_FLAGS.TDCBF_OK_BUTTON;
            nativeConfiguration.MainIcon        = new TaskDialogNativeMethods.TASKDIALOGCONFIG_ICON_UNION(0);
            nativeConfiguration.FooterIcon      = new TaskDialogNativeMethods.TASKDIALOGCONFIG_ICON_UNION(0);
            nativeConfiguration.cxWidth         = TaskDialogDefaults.IdealWidth;

            // Zero out all the custom button fields.
            nativeConfiguration.cButtons            = 0;
            nativeConfiguration.cRadioButtons       = 0;
            nativeConfiguration.pButtons            = IntPtr.Zero;
            nativeConfiguration.pRadioButtons       = IntPtr.Zero;
            nativeConfiguration.nDefaultButton      = 0;
            nativeConfiguration.nDefaultRadioButton = 0;

            // Various text defaults.
            nativeConfiguration.pszWindowTitle          = TaskDialogDefaults.Caption;
            nativeConfiguration.pszMainInstruction      = TaskDialogDefaults.MainInstruction;
            nativeConfiguration.pszContent              = TaskDialogDefaults.Content;
            nativeConfiguration.pszVerificationText     = null;
            nativeConfiguration.pszExpandedInformation  = null;
            nativeConfiguration.pszExpandedControlText  = null;
            nativeConfiguration.pszCollapsedControlText = null;
            nativeConfiguration.pszFooter = null;
        }
 /// <summary>
 /// Sets important text properties.
 /// </summary>
 /// <param name="dialogConfig">An instance of a <see cref="TaskDialogNativeMethods.TASKDIALOGCONFIG"/> object.</param>
 private void ApplyTextConfiguration(TaskDialogNativeMethods.TASKDIALOGCONFIG dialogConfig)
 {
     // note that nulls or empty strings are fine here.
     dialogConfig.pszContent              = text;
     dialogConfig.pszWindowTitle          = caption;
     dialogConfig.pszMainInstruction      = instructionText;
     dialogConfig.pszExpandedInformation  = detailsExpandedText;
     dialogConfig.pszExpandedControlText  = detailsExpandedLabel;
     dialogConfig.pszCollapsedControlText = detailsCollapsedLabel;
     dialogConfig.pszFooter           = footerText;
     dialogConfig.pszVerificationText = checkBoxText;
 }
        // Configuration is applied at dialog creation time.
        internal NativeTaskDialog( 
            NativeTaskDialogSettings settings,
            TaskDialog outerDialog)
        {
            nativeDialogConfig = settings.NativeConfiguration;
            this.settings = settings;

            // Wireup dialog proc message loop for this instance.
            nativeDialogConfig.pfCallback =
                new TaskDialogNativeMethods.PFTASKDIALOGCALLBACK(DialogProc);

            // Keep a reference to the outer shell, so we can notify.
            this.outerDialog = outerDialog;
        }
Exemple #5
0
        // Configuration is applied at dialog creation time.
        internal NativeTaskDialog(
            NativeTaskDialogSettings settings,
            TaskDialog outerDialog)
        {
            nativeDialogConfig = settings.NativeConfiguration;
            this.settings      = settings;

            // Wireup dialog proc message loop for this instance.
            nativeDialogConfig.pfCallback =
                new TaskDialogNativeMethods.PFTASKDIALOGCALLBACK(DialogProc);

            // Keep a reference to the outer shell, so we can notify.
            this.outerDialog = outerDialog;
        }
        private void ApplyGeneralNativeConfiguration(TaskDialogNativeMethods.TASKDIALOGCONFIG dialogConfig)
        {
            // If an owner wasn't specifically specified,
            // we'll use the app's main window.
            if (ownerWindow != IntPtr.Zero)
            {
                dialogConfig.hwndParent = ownerWindow;
            }

            // Other miscellaneous sets.
            dialogConfig.MainIcon =
                new TaskDialogNativeMethods.TASKDIALOGCONFIG_ICON_UNION((int)icon);
            dialogConfig.FooterIcon =
                new TaskDialogNativeMethods.TASKDIALOGCONFIG_ICON_UNION((int)footerIcon);
            dialogConfig.dwCommonButtons =
                (TaskDialogNativeMethods.TASKDIALOG_COMMON_BUTTON_FLAGS)standardButtons;
        }
        private void ApplyOptionConfiguration(TaskDialogNativeMethods.TASKDIALOGCONFIG dialogConfig)
        {
            // Handle options - start with no options set.
            TaskDialogNativeMethods.TASKDIALOG_FLAGS options = TaskDialogNativeMethods.TASKDIALOG_FLAGS.NONE;
            if (cancelable)
            {
                options |= TaskDialogNativeMethods.TASKDIALOG_FLAGS.TDF_ALLOW_DIALOG_CANCELLATION;
            }
            if (footerCheckBoxChecked.HasValue && footerCheckBoxChecked.Value)
            {
                options |= TaskDialogNativeMethods.TASKDIALOG_FLAGS.TDF_VERIFICATION_FLAG_CHECKED;
            }
            if (hyperlinksEnabled)
            {
                options |= TaskDialogNativeMethods.TASKDIALOG_FLAGS.TDF_ENABLE_HYPERLINKS;
            }
            if (detailsExpanded)
            {
                options |= TaskDialogNativeMethods.TASKDIALOG_FLAGS.TDF_EXPANDED_BY_DEFAULT;
            }
            if (Tick != null)
            {
                options |= TaskDialogNativeMethods.TASKDIALOG_FLAGS.TDF_CALLBACK_TIMER;
            }
            if (startupLocation == TaskDialogStartupLocation.CenterOwner)
            {
                options |= TaskDialogNativeMethods.TASKDIALOG_FLAGS.TDF_POSITION_RELATIVE_TO_WINDOW;
            }

            // Note: no validation required, as we allow this to
            // be set even if there is no expanded information
            // text because that could be added later.
            // Default for Win32 API is to expand into (and after)
            // the content area.
            if (expansionMode == TaskDialogExpandedDetailsLocation.ExpandFooter)
            {
                options |= TaskDialogNativeMethods.TASKDIALOG_FLAGS.TDF_EXPAND_FOOTER_AREA;
            }

            // Finally, apply options to config.
            dialogConfig.dwFlags = options;
        }
 internal static extern HRESULT TaskDialogIndirect(
     [In] TaskDialogNativeMethods.TASKDIALOGCONFIG pTaskConfig,
     [Out] out int pnButton,
     [Out] out int pnRadioButton,
     [MarshalAs(UnmanagedType.Bool)][Out] out bool pVerificationFlagChecked);