Beispiel #1
0
        internal void UpdateProgressBarRange()
        {
            AssertCurrentlyShowing();

            // Build range LPARAM - note it is in REVERSE intuitive order.
            long range = NativeTaskDialog.MakeLongLParam(
                settings.ProgressBarMaximum,
                settings.ProgressBarMinimum);

            SendMessageHelper(SafeNativeMethods.TASKDIALOG_MESSAGES.TDM_SET_PROGRESS_BAR_RANGE, 0, range);
        }
Beispiel #2
0
        // Analyzes the final state of the NativeTaskDialog instance and creates the 
        // final TaskDialogResult that will be returned from the public API
        private TaskDialogResult ConstructDialogResult(NativeTaskDialog nativeDialog)
        {
            Debug.Assert(nativeDialog.ShowState == NativeDialogShowState.Closed, "dialog result being constructed for unshown dialog");

            string customButton = null;
            string radioButton = null;
            bool checkBoxChecked = false;
            TaskDialogButtonBase button;

            TaskDialogStandardButton standardButton = MapButtonIdToStandardButton(nativeDialog.SelectedButtonID);

            // If returned ID isn't a standard button, let's fetch 
            if (standardButton == TaskDialogStandardButton.None)
            {
                button = GetButtonForId(nativeDialog.SelectedButtonID);
                if (button == null)
                    throw new InvalidOperationException("received bad control ID from Win32 callback");
                customButton = button.Name;
            }

            // If there were radio buttons and one was selected, figure out which one
            if (radioButtons.Count > 0 && nativeDialog.SelectedRadioButtonID != NativeMethods.NO_DEFAULT_BUTTON_SPECIFIED)
            {
                button = GetButtonForId(nativeDialog.SelectedRadioButtonID);
                if (button == null)
                    throw new InvalidOperationException("received bad control ID from Win32 callback");
                radioButton = button.Name;
            }
            checkBoxChecked = nativeDialog.CheckBoxChecked;

            return new TaskDialogResult(
                standardButton,
                customButton,
                radioButton,
                checkBoxChecked);
        }
Beispiel #3
0
        private TaskDialogResult ShowCore()
        {
            TaskDialogResult result;

            try
            {
                // Populate control lists, based on current contents - note we are
                // somewhat late-bound on our control lists, to support XAML scenarios
                SortDialogControls();

                // First, let's make sure it even makes sense to try a show
                ValidateCurrentDialogSettings();

                // Create settings object for new dialog, based on current state
                NativeTaskDialogSettings settings = new NativeTaskDialogSettings();
                ApplyCoreSettings(settings);
                ApplySupplementalSettings(settings);

                // Show the dialog.
                // NOTE: this is a BLOCKING call; the dialog proc callbacks
                // will be executed by the same thread as the Show() call before 
                // the thread of execution contines to the end of this method.
                nativeDialog = new NativeTaskDialog(settings, this);
                isShowing = true;
                nativeDialog.NativeShow();

                // Build and return dialog result to public API - leaving it
                // null after an exception is thrown is fine in this case
                result = ConstructDialogResult(nativeDialog);
            }
            finally
            {
                isShowing = false;
                CleanUp();
                nativeDialog = null;
            }

            return result;
        }