// Here we walk our controls collection and // sort the various controls by type. private void SortDialogControls() { foreach (TaskDialogControl control in controls) { if (control is TaskDialogButtonBase && String.IsNullOrEmpty(((TaskDialogButtonBase)control).Text)) { if (control is TaskDialogCommandLink && String.IsNullOrEmpty(((TaskDialogCommandLink)control).Instruction)) { throw new InvalidOperationException( "Button text must be non-empty"); } } // Loop through child controls // and sort the controls based on type. if (control is TaskDialogCommandLink) { commandLinks.Add((TaskDialogCommandLink)control); } else if (control is TaskDialogRadioButton) { if (radioButtons == null) { radioButtons = new List <TaskDialogButtonBase>(); } radioButtons.Add((TaskDialogRadioButton)control); } else if (control is TaskDialogButtonBase) { if (buttons == null) { buttons = new List <TaskDialogButtonBase>(); } buttons.Add((TaskDialogButtonBase)control); } else if (control is TaskDialogProgressBar) { if (progressBar != null) { throw new InvalidOperationException( "Can't have more than one progress bar in dialog."); } progressBar = (TaskDialogProgressBar)control; } else if (control is TaskDialogMarquee) { if (marquee != null) { throw new InvalidOperationException( "Can't have more than one marquee in dialog."); } marquee = (TaskDialogMarquee)control; } else { throw new ArgumentException("Unknown dialog control type."); } } }
private void ComplexTDClicked(object sender, RoutedEventArgs e) { taskDialog = FindTaskDialog("complexTD"); bar = (TaskDialogProgressBar)taskDialog.Controls["ProgressBar"]; taskDialog.ExpandedText += " Link: <A HREF=\"Http://www.microsoft.com\">Microsoft</A>"; taskDialog.Show(); }
// Cleans up data and structs from a single // native dialog Show() invocation. private void CleanUp() { // Reset values that would be considered // 'volatile' in a given instance. if (progressBar != null) { progressBar.Reset(); } if (marquee != null) { marquee.Reset(); } // Clean out sorted control lists - // though we don't of course clear the main controls collection, // so the controls are still around; we'll // resort on next show, since the collection may have changed. if (buttons != null) { buttons.Clear(); } if (commandLinks != null) { commandLinks.Clear(); } if (radioButtons != null) { radioButtons.Clear(); } progressBar = null; marquee = null; // Have the native dialog clean up the rest. if (nativeDialog != null) { nativeDialog.Dispose(); } }
// Cleans up data and structs from a single native dialog Show() invocation private void CleanUp() { // Reset values that would be considered 'volatile' in a given instance if (progressBar != null) { progressBar.Reset(); } if (marquee != null) { marquee.Reset(); } // Clean out sorted control lists - though we don't of course clear the main controls collection, // so the controls are still around; we'll resort on next show, since the // collection may have changed if (buttons != null) buttons.Clear(); if (commandLinks != null) commandLinks.Clear(); if (radioButtons != null) radioButtons.Clear(); progressBar = null; marquee = null; // Have the native dialog clean up the rest if (nativeDialog != null) nativeDialog.Dispose(); }
// Here we walk our controls collection and sort the various controls by type. private void SortDialogControls() { foreach (TaskDialogControl control in controls) { if (control is TaskDialogButtonBase && String.IsNullOrEmpty(((TaskDialogButtonBase)control).Text)) { if (control is TaskDialogCommandLink && String.IsNullOrEmpty(((TaskDialogCommandLink)control).Instruction)) throw new InvalidOperationException("Button text must be non-empty"); } // Loop through child controls and sort the controls based on type if (control is TaskDialogCommandLink) { commandLinks.Add((TaskDialogCommandLink)control); } else if (control is TaskDialogRadioButton) { if (radioButtons == null) radioButtons = new List<TaskDialogButtonBase>(); radioButtons.Add((TaskDialogRadioButton)control); } else if (control is TaskDialogButtonBase) { if (buttons == null) buttons = new List<TaskDialogButtonBase>(); buttons.Add((TaskDialogButtonBase)control); } else if (control is TaskDialogProgressBar) { if (progressBar != null) throw new InvalidOperationException("can't have more than one progress bar in dialog"); progressBar = (TaskDialogProgressBar)control; } else if (control is TaskDialogMarquee) { if (marquee != null) throw new InvalidOperationException("can't have more than one marquee in dialog"); marquee = (TaskDialogMarquee)control; } else { throw new ArgumentException("Unknown dialog control type"); } } }