private static void buttonIcons_Click(object sender, EventArgs e) { // Show icons on the taskdialog TaskDialog tdIcons = new TaskDialog(); currentTaskDialog = tdIcons; tdIcons.Cancelable = true; tdIcons.Caption = "Icons Sample"; tdIcons.InstructionText = "Main Instructions"; tdIcons.FooterText = "Footer Text"; TaskDialogRadioButton radioNone = new TaskDialogRadioButton("radioNone", "None"); radioNone.Default = true; // default is no icons radioNone.Click += new EventHandler(iconsRadioButton_Click); TaskDialogRadioButton radioError = new TaskDialogRadioButton("radioError", "Error"); radioError.Click += new EventHandler(iconsRadioButton_Click); TaskDialogRadioButton radioWarning = new TaskDialogRadioButton("radioWarning", "Warning"); radioWarning.Click += new EventHandler(iconsRadioButton_Click); TaskDialogRadioButton radioInformation = new TaskDialogRadioButton("radioInformation", "Information"); radioInformation.Click += new EventHandler(iconsRadioButton_Click); TaskDialogRadioButton radioShield = new TaskDialogRadioButton("radioShield", "Shield"); radioShield.Click += new EventHandler(iconsRadioButton_Click); tdIcons.Controls.Add(radioNone); tdIcons.Controls.Add(radioError); tdIcons.Controls.Add(radioWarning); tdIcons.Controls.Add(radioInformation); tdIcons.Controls.Add(radioShield); tdIcons.Show(); currentTaskDialog = null; }
static void buttonEnableDisable_Click(object sender, EventArgs e) { // Enable/disable sample TaskDialog tdEnableDisable = new TaskDialog(); tdEnableDisable.Cancelable = true; tdEnableDisable.Caption = "Enable/Disable Sample"; tdEnableDisable.InstructionText = "Click on the buttons to enable or disable the radiobutton."; enableButton = new TaskDialogButton("enableButton", "Enable"); enableButton.Default = true; enableButton.Click += new EventHandler(enableButton_Click); disableButton = new TaskDialogButton("disableButton", "Disable"); disableButton.Click += new EventHandler(disableButton_Click); enableDisableRadioButton = new TaskDialogRadioButton("enableDisableRadioButton", "Sample Radio button"); enableDisableRadioButton.Enabled = false; tdEnableDisable.Controls.Add(enableDisableRadioButton); tdEnableDisable.Controls.Add(enableButton); tdEnableDisable.Controls.Add(disableButton); TaskDialogResult tdr = tdEnableDisable.Show(); enableDisableRadioButton = null; enableButton.Click -= new EventHandler(enableButton_Click); disableButton.Click -= new EventHandler(disableButton_Click); enableButton = null; disableButton = null; }
// Called when a control currently in the collection // has a property changed - this handles propagating // the new property values to the Win32 API. // If there isn't a way to change the Win32 value, then we // should have already screened out the property set // in NotifyControlPropertyChanging. void IDialogControlHost.ApplyControlPropertyChange(string propertyName, DialogControl control) { // We only need to apply changes to the // native dialog when it actually exists. if (NativeDialogShowing) { if (control is TaskDialogProgressBar) { if (!progressBar.HasValidValues) { throw new ArgumentException( "Progress bar must have a value between Minimum and Maximum."); } switch (propertyName) { case "State": nativeDialog.UpdateProgressBarState(progressBar.State); break; case "Value": nativeDialog.UpdateProgressBarValue(progressBar.Value); break; case "Minimum": case "Maximum": nativeDialog.UpdateProgressBarRange(); break; default: Debug.Assert(true, "Unknown property being set"); break; } } else if (control is TaskDialogButton) { TaskDialogButton button = (TaskDialogButton)control; switch (propertyName) { case "ShowElevationIcon": nativeDialog.UpdateElevationIcon(button.Id, button.ShowElevationIcon); break; case "Enabled": nativeDialog.UpdateButtonEnabled(button.Id, button.Enabled); break; default: Debug.Assert(true, "Unknown property being set"); break; } } else if (control is TaskDialogRadioButton) { TaskDialogRadioButton button = (TaskDialogRadioButton)control; switch (propertyName) { case "Enabled": nativeDialog.UpdateRadioButtonEnabled(button.Id, button.Enabled); break; default: Debug.Assert(true, "Unknown property being set"); break; } } else { // Do nothing with property change - // note that this shouldn't ever happen, we should have // either thrown on the changing event, or we handle above. Debug.Assert(true, "Control property changed notification not handled properly - being ignored"); } } return; }