/// <summary>
		/// Displays a task dialog with the given configuration options.
		/// </summary>
		/// <param name="options">
		/// A <see cref="T:IExtendFramework.Controls.AdvancedMessageBox.TaskDialogOptions"/> that specifies the
		/// configuration options for the dialog.
		/// </param>
		/// <returns>
		/// A <see cref="T:IExtendFramework.Controls.AdvancedMessageBox.TaskDialogResult"/> value that specifies
		/// which button is clicked by the user.
		/// </returns>
		public static TaskDialogResult Show(TaskDialogOptions options)
		{
			TaskDialogResult result = null;

			// Make a copy since we'll let Showing event possibly modify them
			TaskDialogOptions configOptions = options;

			OnShowing(new TaskDialogShowingEventArgs(ref configOptions));

			if (VistaTaskDialog.IsAvailableOnThisOS && !ForceEmulationMode)
			{
				try
				{
					result = ShowTaskDialog(configOptions);
				}
				catch (EntryPointNotFoundException)
				{
					// This can happen on some machines, usually when running Vista/7 x64
					// When it does, we'll work around the issue by forcing emulated mode
					// http://www.codeproject.com/Messages/3257715/How-to-get-it-to-work-on-Windows-7-64-bit.aspx
					ForceEmulationMode = true;
					result = ShowEmulatedTaskDialog(configOptions);
				}
			}
			else
			{
				result = ShowEmulatedTaskDialog(configOptions);
			}

			OnClosed(new TaskDialogClosedEventArgs(result));

			return result;
		}
        /// <summary>
        /// Displays a task dialog with the given configuration options.
        /// </summary>
        /// <param name="options">
        /// A <see cref="T:IExtendFramework.Controls.AdvancedMessageBox.TaskDialogOptions"/> that specifies the
        /// configuration options for the dialog.
        /// </param>
        /// <returns>
        /// A <see cref="T:IExtendFramework.Controls.AdvancedMessageBox.TaskDialogResult"/> value that specifies
        /// which button is clicked by the user.
        /// </returns>
        public static TaskDialogResult Show(TaskDialogOptions options)
        {
            TaskDialogResult result = null;

            // Make a copy since we'll let Showing event possibly modify them
            TaskDialogOptions configOptions = options;

            OnShowing(new TaskDialogShowingEventArgs(ref configOptions));

            if (VistaTaskDialog.IsAvailableOnThisOS && !ForceEmulationMode)
            {
                try
                {
                    result = ShowTaskDialog(configOptions);
                }
                catch (EntryPointNotFoundException)
                {
                    // This can happen on some machines, usually when running Vista/7 x64
                    // When it does, we'll work around the issue by forcing emulated mode
                    // http://www.codeproject.com/Messages/3257715/How-to-get-it-to-work-on-Windows-7-64-bit.aspx
                    ForceEmulationMode = true;
                    result             = ShowEmulatedTaskDialog(configOptions);
                }
            }
            else
            {
                result = ShowEmulatedTaskDialog(configOptions);
            }

            OnClosed(new TaskDialogClosedEventArgs(result));

            return(result);
        }
        private static TaskDialogResult ShowEmulatedTaskDialog(TaskDialogOptions options)
        {
            TaskDialog          td   = new TaskDialog();
            TaskDialogViewModel tdvm = new TaskDialogViewModel(options);

            td.DataContext = tdvm;

            if (options.Owner != null)
            {
                td.Owner = options.Owner;
            }

            td.ShowDialog();

            TaskDialogResult result           = null;
            int diagResult                    = -1;
            TaskDialogSimpleResult simpResult = TaskDialogSimpleResult.None;
            bool verificationChecked          = false;
            int  radioButtonResult            = -1;
            int? commandButtonResult          = null;
            int? customButtonResult           = null;

            diagResult          = tdvm.DialogResult;
            verificationChecked = tdvm.VerificationChecked;

            if (diagResult >= CommandButtonIDOffset)
            {
                simpResult          = TaskDialogSimpleResult.Command;
                commandButtonResult = diagResult - CommandButtonIDOffset;
            }
            else if (diagResult >= RadioButtonIDOffset)
            {
                simpResult        = TaskDialogSimpleResult.Radio;
                radioButtonResult = diagResult - RadioButtonIDOffset;
            }
            else if (diagResult >= CustomButtonIDOffset)
            {
                simpResult         = TaskDialogSimpleResult.Custom;
                customButtonResult = diagResult - CustomButtonIDOffset;
            }
            // This occurs usually when the red X button is clicked
            else if (diagResult == -1)
            {
                simpResult = TaskDialogSimpleResult.Cancel;
            }
            else
            {
                simpResult = (TaskDialogSimpleResult)diagResult;
            }

            result = new TaskDialogResult(
                simpResult,
                (String.IsNullOrEmpty(options.VerificationText) ? null : (bool?)verificationChecked),
                ((options.RadioButtons == null || options.RadioButtons.Length == 0) ? null : (int?)radioButtonResult),
                ((options.CommandButtons == null || options.CommandButtons.Length == 0) ? null : commandButtonResult),
                ((options.CustomButtons == null || options.CustomButtons.Length == 0) ? null : customButtonResult));

            return(result);
        }
        /// <summary>
        /// Displays a task dialog that has a message and that returns a result.
        /// </summary>
        /// <param name="owner">
        /// The <see cref="T:System.Windows.Window"/> that owns this dialog.
        /// </param>
        /// <param name="messageText">
        /// A <see cref="T:System.String"/> that specifies the text to display.
        /// </param>
        /// <returns>
        /// A <see cref="T:IExtendFramework.Controls.AdvancedMessageBox.TaskDialogSimpleResult"/> value that
        /// specifies which button is clicked by the user.
        /// </returns>
        public static TaskDialogSimpleResult ShowMessage(Window owner, string messageText)
        {
            TaskDialogOptions options = TaskDialogOptions.Default;

            options.Owner         = owner;
            options.Content       = messageText;
            options.CommonButtons = TaskDialogCommonButtons.Close;

            return(Show(options).Result);
        }
        /// <summary>
        /// Displays a task dialog that has a message and that returns a result.
        /// </summary>
        /// <param name="owner">
        /// The <see cref="T:System.Windows.Window"/> that owns this dialog.
        /// </param>
        /// <param name="messageText">
        /// A <see cref="T:System.String"/> that specifies the text to display.
        /// </param>
        /// <param name="caption">
        /// A <see cref="T:System.String"/> that specifies the title bar
        /// caption to display.
        /// </param>
        /// <param name="buttons">
        /// A <see cref="T:IExtendFramework.Controls.AdvancedMessageBox.TaskDialogCommonButtons"/> value that
        /// specifies which button or buttons to display.
        /// </param>
        /// <param name="icon">
        /// A <see cref="T:IExtendFramework.Controls.AdvancedMessageBox.VistaTaskDialogIcon"/> that specifies the
        /// icon to display.
        /// </param>
        /// <returns>
        /// A <see cref="T:IExtendFramework.Controls.AdvancedMessageBox.TaskDialogSimpleResult"/> value that
        /// specifies which button is clicked by the user.
        /// </returns>
        public static TaskDialogSimpleResult ShowMessage(Window owner, string messageText, string caption, TaskDialogCommonButtons buttons, VistaTaskDialogIcon icon)
        {
            TaskDialogOptions options = TaskDialogOptions.Default;

            options.Owner         = owner;
            options.Title         = caption;
            options.Content       = messageText;
            options.CommonButtons = buttons;
            options.MainIcon      = icon;

            return(Show(options).Result);
        }
Example #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TaskDialogViewModel"/> class.
        /// </summary>
        /// <param name="options">Options to use.</param>
        public TaskDialogViewModel(TaskDialogOptions options)
            : this()
        {
            this.options = options;

            FixAllButtonLabelAccessKeys();

            // If radio buttons are defined, set the dialog result to the default selected radio
            if (RadioButtons.Count > 0)
            {
                _dialogResult = RadioButtons[DefaultButtonIndex].ID;
            }
        }
        /// <summary>
        /// Displays a task dialog that has a message and that returns a result.
        /// </summary>
        /// <param name="owner">
        /// The <see cref="T:System.Windows.Window"/> that owns this dialog.
        /// </param>
        /// <param name="title">
        /// A <see cref="T:System.String"/> that specifies the title bar
        /// caption to display.
        /// </param>
        /// <param name="mainInstruction">
        /// A <see cref="T:System.String"/> that specifies the main text to display.
        /// </param>
        /// <param name="content">
        /// A <see cref="T:System.String"/> that specifies the body text to display.
        /// </param>
        /// <param name="expandedInfo">
        /// A <see cref="T:System.String"/> that specifies the expanded text to display when toggled.
        /// </param>
        /// <param name="verificationText">
        /// A <see cref="T:System.String"/> that specifies the text to display next to a checkbox.
        /// </param>
        /// <param name="footerText">
        /// A <see cref="T:System.String"/> that specifies the footer text to display.
        /// </param>
        /// <param name="buttons">
        /// A <see cref="T:IExtendFramework.Controls.AdvancedMessageBox.TaskDialogCommonButtons"/> value that
        /// specifies which button or buttons to display.
        /// </param>
        /// <param name="mainIcon">
        /// A <see cref="T:IExtendFramework.Controls.AdvancedMessageBox.VistaTaskDialogIcon"/> that specifies the
        /// main icon to display.
        /// </param>
        /// <param name="footerIcon">
        /// A <see cref="T:IExtendFramework.Controls.AdvancedMessageBox.VistaTaskDialogIcon"/> that specifies the
        /// footer icon to display.
        /// </param>
        /// <returns></returns>
        public static TaskDialogSimpleResult ShowMessage(Window owner, string title, string mainInstruction, string content, string expandedInfo, string verificationText, string footerText, TaskDialogCommonButtons buttons, VistaTaskDialogIcon mainIcon, VistaTaskDialogIcon footerIcon)
        {
            TaskDialogOptions options = TaskDialogOptions.Default;

            if (owner != null)
            {
                options.Owner = owner;
            }
            if (!String.IsNullOrEmpty(title))
            {
                options.Title = title;
            }
            if (!String.IsNullOrEmpty(mainInstruction))
            {
                options.MainInstruction = mainInstruction;
            }
            if (!String.IsNullOrEmpty(content))
            {
                options.Content = content;
            }
            if (!String.IsNullOrEmpty(expandedInfo))
            {
                options.ExpandedInfo = expandedInfo;
            }
            if (!String.IsNullOrEmpty(verificationText))
            {
                options.VerificationText = verificationText;
            }
            if (!String.IsNullOrEmpty(footerText))
            {
                options.FooterText = footerText;
            }
            options.CommonButtons = buttons;
            options.MainIcon      = mainIcon;
            options.FooterIcon    = footerIcon;

            return(Show(options).Result);
        }
		/// <summary>
		/// Initializes a new instance of the <see cref="TaskDialogViewModel"/> class.
		/// </summary>
		/// <param name="options">Options to use.</param>
		public TaskDialogViewModel(TaskDialogOptions options)
			: this()
		{
			this.options = options;

			FixAllButtonLabelAccessKeys();

			// If radio buttons are defined, set the dialog result to the default selected radio
			if (RadioButtons.Count > 0)
			{
				_dialogResult = RadioButtons[DefaultButtonIndex].ID;
			}
		}
		private static TaskDialogResult ShowEmulatedTaskDialog(TaskDialogOptions options)
		{
			TaskDialog td = new TaskDialog();
			TaskDialogViewModel tdvm = new TaskDialogViewModel(options);

			td.DataContext = tdvm;

			if (options.Owner != null)
			{
				td.Owner = options.Owner;
			}

			td.ShowDialog();

			TaskDialogResult result = null;
			int diagResult = -1;
			TaskDialogSimpleResult simpResult = TaskDialogSimpleResult.None;
			bool verificationChecked = false;
			int radioButtonResult = -1;
			int? commandButtonResult = null;
			int? customButtonResult = null;

			diagResult = tdvm.DialogResult;
			verificationChecked = tdvm.VerificationChecked;

			if (diagResult >= CommandButtonIDOffset)
			{
				simpResult = TaskDialogSimpleResult.Command;
				commandButtonResult = diagResult - CommandButtonIDOffset;
			}
			else if (diagResult >= RadioButtonIDOffset)
			{
				simpResult = TaskDialogSimpleResult.Radio;
				radioButtonResult = diagResult - RadioButtonIDOffset;
			}
			else if (diagResult >= CustomButtonIDOffset)
			{
				simpResult = TaskDialogSimpleResult.Custom;
				customButtonResult = diagResult - CustomButtonIDOffset;
			}
			// This occurs usually when the red X button is clicked
			else if (diagResult == -1)
			{
				simpResult = TaskDialogSimpleResult.Cancel;
			}
			else
			{
				simpResult = (TaskDialogSimpleResult)diagResult;
			}

			result = new TaskDialogResult(
				simpResult,
				(String.IsNullOrEmpty(options.VerificationText) ? null : (bool?)verificationChecked),
				((options.RadioButtons == null || options.RadioButtons.Length == 0) ? null : (int?)radioButtonResult),
				((options.CommandButtons == null || options.CommandButtons.Length == 0) ? null : commandButtonResult),
				((options.CustomButtons == null || options.CustomButtons.Length == 0) ? null : customButtonResult));

			return result;
		}
Example #10
0
		private static TaskDialogResult ShowTaskDialog(TaskDialogOptions options)
		{
			VistaTaskDialog vtd = new VistaTaskDialog();

			vtd.WindowTitle = options.Title;
			vtd.MainInstruction = options.MainInstruction;
			vtd.Content = options.Content;
			vtd.ExpandedInformation = options.ExpandedInfo;
			vtd.Footer = options.FooterText;

			if (options.CommandButtons != null && options.CommandButtons.Length > 0)
			{
				List<VistaTaskDialogButton> lst = new List<VistaTaskDialogButton>();
				for (int i = 0; i < options.CommandButtons.Length; i++)
				{
					try
					{
						VistaTaskDialogButton button = new VistaTaskDialogButton();
						button.ButtonId = CommandButtonIDOffset + i;
						button.ButtonText = options.CommandButtons[i];
						lst.Add(button);
					}
					catch (FormatException)
					{
					}
				}
				vtd.Buttons = lst.ToArray();
				if (options.DefaultButtonIndex.HasValue
					&& options.DefaultButtonIndex >= 0
					&& options.DefaultButtonIndex.Value < vtd.Buttons.Length)
					vtd.DefaultButton = vtd.Buttons[options.DefaultButtonIndex.Value].ButtonId;
			}
			else if (options.RadioButtons != null && options.RadioButtons.Length > 0)
			{
				List<VistaTaskDialogButton> lst = new List<VistaTaskDialogButton>();
				for (int i = 0; i < options.RadioButtons.Length; i++)
				{
					try
					{
						VistaTaskDialogButton button = new VistaTaskDialogButton();
						button.ButtonId = RadioButtonIDOffset + i;
						button.ButtonText = options.RadioButtons[i];
						lst.Add(button);
					}
					catch (FormatException)
					{
					}
				}
				vtd.RadioButtons = lst.ToArray();
				vtd.NoDefaultRadioButton = (!options.DefaultButtonIndex.HasValue || options.DefaultButtonIndex.Value == -1);
				if (options.DefaultButtonIndex.HasValue
					&& options.DefaultButtonIndex >= 0
					&& options.DefaultButtonIndex.Value < vtd.RadioButtons.Length)
					vtd.DefaultButton = vtd.RadioButtons[options.DefaultButtonIndex.Value].ButtonId;
			}

			bool hasCustomCancel = false;

			if (options.CustomButtons != null && options.CustomButtons.Length > 0)
			{
				List<VistaTaskDialogButton> lst = new List<VistaTaskDialogButton>();
				for (int i = 0; i < options.CustomButtons.Length; i++)
				{
					try
					{
						VistaTaskDialogButton button = new VistaTaskDialogButton();
						button.ButtonId = CustomButtonIDOffset + i;
						button.ButtonText = options.CustomButtons[i];

						if (!hasCustomCancel)
						{
							hasCustomCancel =
								(button.ButtonText == "Close"
								|| button.ButtonText == "Cancel");
						}

						lst.Add(button);
					}
					catch (FormatException)
					{
					}
				}

				vtd.Buttons = lst.ToArray();
				if (options.DefaultButtonIndex.HasValue
					&& options.DefaultButtonIndex.Value >= 0
					&& options.DefaultButtonIndex.Value < vtd.Buttons.Length)
					vtd.DefaultButton = vtd.Buttons[options.DefaultButtonIndex.Value].ButtonId;
				vtd.CommonButtons = VistaTaskDialogCommonButtons.None;
			}
			else
			{
				vtd.CommonButtons = ConvertCommonButtons(options.CommonButtons);

				if (options.DefaultButtonIndex.HasValue
					&& options.DefaultButtonIndex >= 0)
					vtd.DefaultButton = GetButtonIdForCommonButton(options.CommonButtons, options.DefaultButtonIndex.Value);
			}

			vtd.MainIcon = options.MainIcon;
			vtd.FooterIcon = options.FooterIcon;
			vtd.EnableHyperlinks = false;
			vtd.ShowProgressBar = false;
			vtd.AllowDialogCancellation =
				(options.AllowDialogCancellation
				|| hasCustomCancel
				|| options.CommonButtons == TaskDialogCommonButtons.Close
				|| options.CommonButtons == TaskDialogCommonButtons.OKCancel
				|| options.CommonButtons == TaskDialogCommonButtons.YesNoCancel);
			vtd.CallbackTimer = false;
			vtd.ExpandedByDefault = false;
			vtd.ExpandFooterArea = false;
			vtd.PositionRelativeToWindow = true;
			vtd.RightToLeftLayout = false;
			vtd.NoDefaultRadioButton = false;
			vtd.CanBeMinimized = false;
			vtd.ShowMarqueeProgressBar = false;
			vtd.UseCommandLinks = (options.CommandButtons != null && options.CommandButtons.Length > 0);
			vtd.UseCommandLinksNoIcon = false;
			vtd.VerificationText = options.VerificationText;
			vtd.VerificationFlagChecked = false;
			vtd.ExpandedControlText = "Hide details";
			vtd.CollapsedControlText = "Show details";
			vtd.Callback = null;

			TaskDialogResult result = null;
			int diagResult = 0;
			TaskDialogSimpleResult simpResult = TaskDialogSimpleResult.None;
			bool verificationChecked = false;
			int radioButtonResult = -1;
			int? commandButtonResult = null;
			int? customButtonResult = null;

			diagResult = vtd.Show((vtd.CanBeMinimized ? null : options.Owner), out verificationChecked, out radioButtonResult);

			if (diagResult >= CommandButtonIDOffset)
			{
				simpResult = TaskDialogSimpleResult.Command;
				commandButtonResult = diagResult - CommandButtonIDOffset;
			}
			else if (radioButtonResult >= RadioButtonIDOffset)
			{
				simpResult = TaskDialogSimpleResult.Radio;
				radioButtonResult -= RadioButtonIDOffset;
			}
			else if (diagResult >= CustomButtonIDOffset)
			{
				simpResult = TaskDialogSimpleResult.Custom;
				customButtonResult = diagResult - CustomButtonIDOffset;
			}
			else
			{
				simpResult = (TaskDialogSimpleResult)diagResult;
			}

			result = new TaskDialogResult(
				simpResult,
				(String.IsNullOrEmpty(options.VerificationText) ? null : (bool?)verificationChecked),
				((options.RadioButtons == null || options.RadioButtons.Length == 0) ? null : (int?)radioButtonResult),
				((options.CommandButtons == null || options.CommandButtons.Length == 0) ? null : commandButtonResult),
				((options.CustomButtons == null || options.CustomButtons.Length == 0) ? null : customButtonResult));

			return result;
		}
		/// <summary>
		/// Initializes a new instance of the <see cref="TaskDialogShowingEventArgs"/> class.
		/// </summary>
		/// <param name="configOptions">The configuration options for the TaskDialog.</param>
		internal TaskDialogShowingEventArgs(ref TaskDialogOptions configOptions)
		{
			ConfigurationOptions = configOptions;
		}
Example #12
0
 void UserGuideToolStripMenuItem_Click(object sender, EventArgs e)
 {
     TaskDialogOptions o = new TaskDialogOptions();
     o.Content = "Sorry, this is unavailable";
     o.MainInstruction = "Unavailable!";
     o.Title = "Unavailable";
     o.ExpandedInfo = "This is coming soon";
     TaskDialog.Show(o);
 }
        private static TaskDialogResult ShowTaskDialog(TaskDialogOptions options)
        {
            VistaTaskDialog vtd = new VistaTaskDialog();

            vtd.WindowTitle         = options.Title;
            vtd.MainInstruction     = options.MainInstruction;
            vtd.Content             = options.Content;
            vtd.ExpandedInformation = options.ExpandedInfo;
            vtd.Footer = options.FooterText;

            if (options.CommandButtons != null && options.CommandButtons.Length > 0)
            {
                List <VistaTaskDialogButton> lst = new List <VistaTaskDialogButton>();
                for (int i = 0; i < options.CommandButtons.Length; i++)
                {
                    try
                    {
                        VistaTaskDialogButton button = new VistaTaskDialogButton();
                        button.ButtonId   = CommandButtonIDOffset + i;
                        button.ButtonText = options.CommandButtons[i];
                        lst.Add(button);
                    }
                    catch (FormatException)
                    {
                    }
                }
                vtd.Buttons = lst.ToArray();
                if (options.DefaultButtonIndex.HasValue &&
                    options.DefaultButtonIndex >= 0 &&
                    options.DefaultButtonIndex.Value < vtd.Buttons.Length)
                {
                    vtd.DefaultButton = vtd.Buttons[options.DefaultButtonIndex.Value].ButtonId;
                }
            }
            else if (options.RadioButtons != null && options.RadioButtons.Length > 0)
            {
                List <VistaTaskDialogButton> lst = new List <VistaTaskDialogButton>();
                for (int i = 0; i < options.RadioButtons.Length; i++)
                {
                    try
                    {
                        VistaTaskDialogButton button = new VistaTaskDialogButton();
                        button.ButtonId   = RadioButtonIDOffset + i;
                        button.ButtonText = options.RadioButtons[i];
                        lst.Add(button);
                    }
                    catch (FormatException)
                    {
                    }
                }
                vtd.RadioButtons         = lst.ToArray();
                vtd.NoDefaultRadioButton = (!options.DefaultButtonIndex.HasValue || options.DefaultButtonIndex.Value == -1);
                if (options.DefaultButtonIndex.HasValue &&
                    options.DefaultButtonIndex >= 0 &&
                    options.DefaultButtonIndex.Value < vtd.RadioButtons.Length)
                {
                    vtd.DefaultButton = vtd.RadioButtons[options.DefaultButtonIndex.Value].ButtonId;
                }
            }

            bool hasCustomCancel = false;

            if (options.CustomButtons != null && options.CustomButtons.Length > 0)
            {
                List <VistaTaskDialogButton> lst = new List <VistaTaskDialogButton>();
                for (int i = 0; i < options.CustomButtons.Length; i++)
                {
                    try
                    {
                        VistaTaskDialogButton button = new VistaTaskDialogButton();
                        button.ButtonId   = CustomButtonIDOffset + i;
                        button.ButtonText = options.CustomButtons[i];

                        if (!hasCustomCancel)
                        {
                            hasCustomCancel =
                                (button.ButtonText == "Close" ||
                                 button.ButtonText == "Cancel");
                        }

                        lst.Add(button);
                    }
                    catch (FormatException)
                    {
                    }
                }

                vtd.Buttons = lst.ToArray();
                if (options.DefaultButtonIndex.HasValue &&
                    options.DefaultButtonIndex.Value >= 0 &&
                    options.DefaultButtonIndex.Value < vtd.Buttons.Length)
                {
                    vtd.DefaultButton = vtd.Buttons[options.DefaultButtonIndex.Value].ButtonId;
                }
                vtd.CommonButtons = VistaTaskDialogCommonButtons.None;
            }
            else
            {
                vtd.CommonButtons = ConvertCommonButtons(options.CommonButtons);

                if (options.DefaultButtonIndex.HasValue &&
                    options.DefaultButtonIndex >= 0)
                {
                    vtd.DefaultButton = GetButtonIdForCommonButton(options.CommonButtons, options.DefaultButtonIndex.Value);
                }
            }

            vtd.MainIcon                = options.MainIcon;
            vtd.FooterIcon              = options.FooterIcon;
            vtd.EnableHyperlinks        = false;
            vtd.ShowProgressBar         = false;
            vtd.AllowDialogCancellation =
                (options.AllowDialogCancellation ||
                 hasCustomCancel ||
                 options.CommonButtons == TaskDialogCommonButtons.Close ||
                 options.CommonButtons == TaskDialogCommonButtons.OKCancel ||
                 options.CommonButtons == TaskDialogCommonButtons.YesNoCancel);
            vtd.CallbackTimer            = false;
            vtd.ExpandedByDefault        = false;
            vtd.ExpandFooterArea         = false;
            vtd.PositionRelativeToWindow = true;
            vtd.RightToLeftLayout        = false;
            vtd.NoDefaultRadioButton     = false;
            vtd.CanBeMinimized           = false;
            vtd.ShowMarqueeProgressBar   = false;
            vtd.UseCommandLinks          = (options.CommandButtons != null && options.CommandButtons.Length > 0);
            vtd.UseCommandLinksNoIcon    = false;
            vtd.VerificationText         = options.VerificationText;
            vtd.VerificationFlagChecked  = false;
            vtd.ExpandedControlText      = "Hide details";
            vtd.CollapsedControlText     = "Show details";
            vtd.Callback = null;

            TaskDialogResult result           = null;
            int diagResult                    = 0;
            TaskDialogSimpleResult simpResult = TaskDialogSimpleResult.None;
            bool verificationChecked          = false;
            int  radioButtonResult            = -1;
            int? commandButtonResult          = null;
            int? customButtonResult           = null;

            diagResult = vtd.Show((vtd.CanBeMinimized ? null : options.Owner), out verificationChecked, out radioButtonResult);

            if (diagResult >= CommandButtonIDOffset)
            {
                simpResult          = TaskDialogSimpleResult.Command;
                commandButtonResult = diagResult - CommandButtonIDOffset;
            }
            else if (radioButtonResult >= RadioButtonIDOffset)
            {
                simpResult         = TaskDialogSimpleResult.Radio;
                radioButtonResult -= RadioButtonIDOffset;
            }
            else if (diagResult >= CustomButtonIDOffset)
            {
                simpResult         = TaskDialogSimpleResult.Custom;
                customButtonResult = diagResult - CustomButtonIDOffset;
            }
            else
            {
                simpResult = (TaskDialogSimpleResult)diagResult;
            }

            result = new TaskDialogResult(
                simpResult,
                (String.IsNullOrEmpty(options.VerificationText) ? null : (bool?)verificationChecked),
                ((options.RadioButtons == null || options.RadioButtons.Length == 0) ? null : (int?)radioButtonResult),
                ((options.CommandButtons == null || options.CommandButtons.Length == 0) ? null : commandButtonResult),
                ((options.CustomButtons == null || options.CustomButtons.Length == 0) ? null : customButtonResult));

            return(result);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="TaskDialogShowingEventArgs"/> class.
 /// </summary>
 /// <param name="configOptions">The configuration options for the TaskDialog.</param>
 internal TaskDialogShowingEventArgs(ref TaskDialogOptions configOptions)
 {
     ConfigurationOptions = configOptions;
 }