/// <summary> /// Dispose TaskDialog Resources /// </summary> /// <param name="disposing">If true, indicates that this is being called via Dispose rather than via the finalizer.</param> public void Dispose(bool disposing) { if (!disposed) { disposed = true; if (disposing) { // Clean up managed resources. if (nativeDialog != null && nativeDialog.ShowState == DialogShowState.Showing) { nativeDialog.NativeClose(TaskDialogResult.Cancel); } buttons = null; radioButtons = null; commandLinks = null; } // Clean up unmanaged resources SECOND, NTD counts on // being closed before being disposed. if (nativeDialog != null) { nativeDialog.Dispose(); nativeDialog = null; } if (staticDialog != null) { staticDialog.Dispose(); staticDialog = null; } } }
internal void UpdateProgressBarRange() { AssertCurrentlyShowing(); // Build range LPARAM - note it is in REVERSE intuitive order. long range = NativeTaskDialog.MakeLongLParam( settings.ProgressBarMaximum, settings.ProgressBarMinimum); SendMessageHelper(TaskDialogNativeMethods.TASKDIALOG_MESSAGES.TDM_SET_PROGRESS_BAR_RANGE, 0, range); }
internal void UpdateProgressBarRange() { AssertCurrentlyShowing(); // Build range LPARAM - note it is in REVERSE intuitive order. long range = NativeTaskDialog.MakeLongLParam( settings.ProgressBarMaximum, settings.ProgressBarMinimum); SendMessageHelper(TaskDialogNativeMethods.TaskDialogMessages.SetProgressBarRange, 0, range); }
internal void UpdateProgressBarRange(int?min = null, int?max = null) { AssertCurrentlyShowing(); if (min.HasValue) { settings.ProgressBarMinimum = min.Value; } if (max.HasValue) { settings.ProgressBarMaximum = max.Value; } // Build range LPARAM - note it is in REVERSE intuitive order. var range = NativeTaskDialog.MakeLongLParam(settings.ProgressBarMaximum, settings.ProgressBarMinimum); SendMessageHelper(TaskDialogNativeMethods.TaskDialogMessages.SetProgressBarRange, 0, range); }
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); 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); }
// Analyzes the final state of the NativeTaskDialog instance and creates the // final TaskDialogResult that will be returned from the public API private static TaskDialogResult ConstructDialogResult(NativeTaskDialog native) { Debug.Assert(native.ShowState == DialogShowState.Closed, "dialog result being constructed for unshown dialog."); TaskDialogResult result = TaskDialogResult.Cancel; TaskDialogStandardButtons standardButton = MapButtonIdToStandardButton(native.SelectedButtonId); // If returned ID isn't a standard button, let's fetch if (standardButton == TaskDialogStandardButtons.None) { result = TaskDialogResult.CustomButtonClicked; } else { result = (TaskDialogResult)standardButton; } return(result); }
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); 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; }
// 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 native) { Debug.Assert(native.ShowState == DialogShowState.Closed, "dialog result being constructed for unshown dialog."); TaskDialogResult result = TaskDialogResult.Cancel; TaskDialogStandardButtons standardButton = MapButtonIdToStandardButton(native.SelectedButtonID); // If returned ID isn't a standard button, let's fetch if (standardButton == TaskDialogStandardButtons.None) result = TaskDialogResult.CustomButtonClicked; else result = (TaskDialogResult)standardButton; return result; }
/// <summary> /// Dispose TaskDialog Resources /// </summary> /// <param name="disposing">If true, indicates that this is being called via Dispose rather than via the finalizer.</param> public virtual void Dispose(bool disposing) { if (!disposed) { disposed = true; if (disposing) { // Clean up managed resources. if (nativeDialog != null && nativeDialog.ShowState == DialogShowState.Showing) { nativeDialog.NativeClose(TaskDialogResult.Cancel); } buttons = null; radioButtons = null; commandLinks = null; } // Clean up unmanaged resources SECOND, NTD counts on // being closed before being disposed. if (nativeDialog != null) { nativeDialog.Dispose(); nativeDialog = null; } if (staticDialog != null) { staticDialog.Dispose(); staticDialog = null; } } }