コード例 #1
0
ファイル: TaskDialog.cs プロジェクト: robertbaker/SevenUpdate
 /// <summary>Applies the core dialog settings.</summary>
 /// <param name="settings">The dialog settings.</param>
 void ApplyCoreSettings(NativeTaskDialogSettings settings)
 {
     ApplyGeneralNativeConfiguration(settings.NativeConfiguration);
     ApplyTextConfiguration(settings.NativeConfiguration);
     ApplyOptionConfiguration(settings.NativeConfiguration);
     ApplyControlConfiguration(settings);
 }
コード例 #2
0
ファイル: TaskDialog.cs プロジェクト: robertbaker/SevenUpdate
        /// <summary>Applies the control configuration.</summary>
        /// <param name="settings">The task dialog settings.</param>
        void ApplyControlConfiguration(NativeTaskDialogSettings settings)
        {
            // Deal with progress bars/marquees.
            if (progressBar != null)
            {
                if (progressBar.State == TaskDialogProgressBarState.Marquee)
                {
                    settings.NativeConfiguration.TaskDialogFlags |= TaskDialogOptions.ShowMarqueeProgressBar;
                }
                else
                {
                    settings.NativeConfiguration.TaskDialogFlags |= TaskDialogOptions.ShowProgressBar;
                }
            }

            // Build the native struct arrays that NativeTaskDialog needs - though NTD will handle the heavy lifting
            // marshalling to make sure all the cleanup is centralized there.
            if (buttons.Count > 0 || commandLinks.Count > 0)
            {
                // These are the actual arrays/lists of the structs that we'll copy to the unmanaged heap.
                List <TaskDialogButtonBase> sourceList = buttons.Count > 0 ? buttons : commandLinks;
                settings.Buttons = BuildButtonStructArray(sourceList);

                // Apply option flag that forces all custom buttons to render as command links.
                if (commandLinks.Count > 0)
                {
                    settings.NativeConfiguration.TaskDialogFlags |= TaskDialogOptions.UseCommandLinks;
                }

                // Set default button and add elevation icons to appropriate buttons.
                settings.NativeConfiguration.DefaultButtonIndex = FindDefaultButtonId(sourceList);

                ApplyElevatedIcons(settings, sourceList);
            }

            if (radioButtons.Count <= 0)
            {
                return;
            }

            settings.RadioButtons = BuildButtonStructArray(radioButtons);

            // Set default radio button - radio buttons don't support.
            int defaultRadioButton = FindDefaultButtonId(radioButtons);

            settings.NativeConfiguration.DefaultRadioButtonIndex = defaultRadioButton;

            if (defaultRadioButton == 0)
            {
                settings.NativeConfiguration.TaskDialogFlags |= TaskDialogOptions.NoDefaultRadioButton;
            }
        }
コード例 #3
0
        /// <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;
        }
コード例 #4
0
ファイル: TaskDialog.cs プロジェクト: robertbaker/SevenUpdate
        /// <summary>Applies the elevated icons.</summary>
        /// <param name="settings">The dialog settings.</param>
        /// <param name="controls">The dialog controls.</param>
        static void ApplyElevatedIcons(NativeTaskDialogSettings settings, IEnumerable <TaskDialogButtonBase> controls)
        {
            foreach (TaskDialogButton control in controls)
            {
                if (control.UseElevationIcon)
                {
                    if (settings.ElevatedButtons == null)
                    {
                        settings.ElevatedButtons = new List <int>();
                    }

                    settings.ElevatedButtons.Add(control.Id);
                }
            }
        }
コード例 #5
0
ファイル: TaskDialog.cs プロジェクト: robertbaker/SevenUpdate
        /// <summary>Applies the supplemental settings.</summary>
        /// <param name="settings">The dialog settings.</param>
        void ApplySupplementalSettings(NativeTaskDialogSettings settings)
        {
            if (progressBar != null)
            {
                if (progressBar.State != TaskDialogProgressBarState.Marquee)
                {
                    settings.ProgressBarMinimum = progressBar.Minimum;
                    settings.ProgressBarMaximum = progressBar.Maximum;
                    settings.ProgressBarValue   = progressBar.Value;
                    settings.ProgressBarState   = progressBar.State;
                }
            }

            if (HelpInvoked != null)
            {
                settings.InvokeHelp = true;
            }
        }
コード例 #6
0
ファイル: TaskDialog.cs プロジェクト: robertbaker/SevenUpdate
        /// <summary>Shows the core dialog</summary>
        /// <returns>Returns the result of the <c>TaskDialog</c>.</returns>
        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.
                var 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);
                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);
                footerCheckBoxChecked = nativeDialog.CheckBoxChecked;
            }
            finally
            {
                CleanUp();
                nativeDialog = null;
            }

            return(result);
        }