Example #1
0
		// CORE SHOW METHODS:
		// All static Show() calls forward here - 
		// it is responsible for retrieving
		// or creating our cached TaskDialog instance, getting it configured,
		// and in turn calling the appropriate instance Show.

		private static TaskDialogResult ShowCoreStatic(
			string text,
			string instructionText,
			string caption) {
			CoreHelpers.ThrowIfNotVista();

			// If no instance cached yet, create it.
			if (staticDialog == null) {
				// New TaskDialog will automatically pick up defaults when 
				// a new config structure is created as part of ShowCore().
				staticDialog = new TaskDialog();
			}

			// Set the few relevant properties, 
			// and go with the defaults for the others.
			staticDialog.text = text;
			staticDialog.instructionText = instructionText;
			staticDialog.caption = caption;

			return staticDialog.Show();
		}
Example #2
0
		/// <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;
				}


			}
		}