/// <summary>Initializes a new instance of the <see cref="NativeTaskDialogSettings" /> class.</summary> internal NativeTaskDialogSettings() { NativeConfiguration = new TaskDialogConfiguration(); // Apply standard settings. NativeConfiguration.Size = (uint)Marshal.SizeOf(NativeConfiguration); NativeConfiguration.ParentHandle = IntPtr.Zero; NativeConfiguration.Instance = IntPtr.Zero; NativeConfiguration.TaskDialogFlags = TaskDialogOptions.AllowCancel; NativeConfiguration.CommonButtons = TaskDialogCommonButtons.Ok; NativeConfiguration.MainIcon = new IconUnion(0); NativeConfiguration.FooterIcon = new 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; }
/// <summary>Sets important text properties.</summary> /// <param name="dialogConfig">An instance of a <see cref="TaskDialogConfiguration" /> object.</param> void ApplyTextConfiguration(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; }
/// <summary>Initializes a new instance of the <see cref="NativeTaskDialog" /> class.</summary> /// <param name="settings">The settings.</param> /// <param name="outerDialog">The outer dialog.</param> internal NativeTaskDialog(NativeTaskDialogSettings settings, TaskDialog outerDialog) { nativeDialogConfig = settings.NativeConfiguration; this.settings = settings; // Wireup dialog proc message loop for this instance. nativeDialogConfig.Callback = DialogProc; ShowState = DialogShowState.PreShow; // Keep a reference to the outer shell, so we can notify. this.outerDialog = outerDialog; }
/// <summary>Initializes a new instance of the <see cref="NativeTaskDialog" /> class.</summary> /// <param name="settings">The settings.</param> /// <param name="outerDialog">The outer dialog.</param> internal NativeTaskDialog(NativeTaskDialogSettings settings, TaskDialog outerDialog) { nativeDialogConfig = settings.NativeConfiguration; this.settings = settings; // Wireup dialog proc message loop for this instance. nativeDialogConfig.Callback = DialogProc; ShowState = DialogShowState.PreShow; // Keep a reference to the outer shell, so we can notify. this.outerDialog = outerDialog; }
/// <summary>Applies the core settings.</summary> /// <param name="dialogConfig">The settings for the dialog</param> void ApplyGeneralNativeConfiguration(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 IconUnion((int)icon); dialogConfig.FooterIcon = new IconUnion((int)footerIcon); dialogConfig.CommonButtons = (TaskDialogCommonButtons)standardButtons; }
/// <summary>Applies the option configuration.</summary> /// <param name="dialogConfig">The dialog config.</param> void ApplyOptionConfiguration(TaskDialogConfiguration dialogConfig) { // Handle options - start with no options set. var options = TaskDialogOptions.None; if (canCancel) { options |= TaskDialogOptions.AllowCancel; } if (footerCheckBoxChecked.HasValue && footerCheckBoxChecked.Value) { options |= TaskDialogOptions.CheckVerificationFlag; } if (hyperlinksEnabled) { options |= TaskDialogOptions.EnableHyperlinks; } if (detailsExpanded) { options |= TaskDialogOptions.ExpandedByDefault; } if (Tick != null) { options |= TaskDialogOptions.UseCallbackTimer; } if (startupLocation == TaskDialogStartupLocation.CenterOwner) { options |= 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 |= TaskDialogOptions.ExpandFooterArea; } // Finally, apply options to config. dialogConfig.TaskDialogFlags = options; }