internal NativeTaskDialogSettings()
        {
            NativeConfiguration = new TaskDialogNativeMethods.TaskDialogConfiguration();

            // Apply standard settings.
            NativeConfiguration.size            = (uint)Marshal.SizeOf(NativeConfiguration);
            NativeConfiguration.parentHandle    = IntPtr.Zero;
            NativeConfiguration.instance        = IntPtr.Zero;
            NativeConfiguration.taskDialogFlags = TaskDialogNativeMethods.TaskDialogOptions.AllowCancel;
            NativeConfiguration.commonButtons   = TaskDialogNativeMethods.TaskDialogCommonButtons.Ok;
            NativeConfiguration.mainIcon        = new TaskDialogNativeMethods.IconUnion(0);
            NativeConfiguration.footerIcon      = new TaskDialogNativeMethods.IconUnion(0);
            NativeConfiguration.width           = TaskDialogDefaults.IdealWidth;

            // Zero out all the custom button fields.
            NativeConfiguration.buttonCount             = 0;
            NativeConfiguration.radioButtonCount        = 0;
            NativeConfiguration.buttons                 = IntPtr.Zero;
            NativeConfiguration.radioButtons            = IntPtr.Zero;
            NativeConfiguration.defaultButtonIndex      = 0;
            NativeConfiguration.defaultRadioButtonIndex = 0;

            // Various text defaults.
            NativeConfiguration.windowTitle          = TaskDialogDefaults.Caption;
            NativeConfiguration.mainInstruction      = TaskDialogDefaults.MainInstruction;
            NativeConfiguration.content              = TaskDialogDefaults.Content;
            NativeConfiguration.verificationText     = null;
            NativeConfiguration.expandedInformation  = null;
            NativeConfiguration.expandedControlText  = null;
            NativeConfiguration.collapsedControlText = null;
            NativeConfiguration.footerText           = null;
        }
Beispiel #2
0
 /// <summary>
 /// Sets important text properties.
 /// </summary>
 /// <param name="dialogConfig">An instance of a <see cref="TaskDialogNativeMethods.TaskDialogConfiguration"/> object.</param>
 private void ApplyTextConfiguration(TaskDialogNativeMethods.TaskDialogConfiguration dialogConfig)
 {
     // note that nulls or empty strings are fine here.
     dialogConfig.content              = text;
     dialogConfig.windowTitle          = caption;
     dialogConfig.mainInstruction      = instructionText;
     dialogConfig.expandedInformation  = detailsExpandedText;
     dialogConfig.expandedControlText  = detailsExpandedLabel;
     dialogConfig.collapsedControlText = detailsCollapsedLabel;
     dialogConfig.footerText           = footerText;
     dialogConfig.verificationText     = 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.callback = new TaskDialogNativeMethods.TaskDialogCallback(DialogProc);

            ShowState = DialogShowState.PreShow;

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

            // Other miscellaneous sets.
            dialogConfig.mainIcon      = new TaskDialogNativeMethods.IconUnion((int)icon);
            dialogConfig.footerIcon    = new TaskDialogNativeMethods.IconUnion((int)footerIcon);
            dialogConfig.commonButtons = (TaskDialogNativeMethods.TaskDialogCommonButtons)standardButtons;
        }
Beispiel #5
0
        private void ApplyOptionConfiguration(TaskDialogNativeMethods.TaskDialogConfiguration dialogConfig)
        {
            // Handle options - start with no options set.
            TaskDialogNativeMethods.TaskDialogOptions options = TaskDialogNativeMethods.TaskDialogOptions.None;
            if (cancelable)
            {
                options |= TaskDialogNativeMethods.TaskDialogOptions.AllowCancel;
            }
            if (footerCheckBoxChecked.HasValue && footerCheckBoxChecked.Value)
            {
                options |= TaskDialogNativeMethods.TaskDialogOptions.CheckVerificationFlag;
            }
            if (hyperlinksEnabled)
            {
                options |= TaskDialogNativeMethods.TaskDialogOptions.EnableHyperlinks;
            }
            if (detailsExpanded)
            {
                options |= TaskDialogNativeMethods.TaskDialogOptions.ExpandedByDefault;
            }
            if (Tick != null)
            {
                options |= TaskDialogNativeMethods.TaskDialogOptions.UseCallbackTimer;
            }
            if (startupLocation == TaskDialogStartupLocation.CenterOwner)
            {
                options |= TaskDialogNativeMethods.TaskDialogOptions.PositionRelativeToWindow;
            }

            // 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.TaskDialogOptions.ExpandFooterArea;
            }

            // Finally, apply options to config.
            dialogConfig.taskDialogFlags = options;
        }
Beispiel #6
0
 internal static extern HResult TaskDialogIndirect(
     [In] TaskDialogNativeMethods.TaskDialogConfiguration taskConfig,
     [Out] out int button,
     [Out] out int radioButton,
     [MarshalAs(UnmanagedType.Bool), Out] out bool verificationFlagChecked);