예제 #1
0
        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);
        }
예제 #2
0
		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;
		}