bool IDialogControlHost.IsControlPropertyChangeAllowed( string propertyName, DialogControl control) { CommonFileDialog.GenerateNotImplementedException(); return(false); }
public void OnItemSelected(IFileDialogCustomize pfdc, int dwIDCtl, int dwIDItem) { // Find control DialogControl control = this.parent.controls.GetControlbyId(dwIDCtl); // Process ComboBox and/or RadioButtonList if (control is ICommonFileDialogIndexedControls) { // Update selected item and raise SelectedIndexChanged event ICommonFileDialogIndexedControls controlInterface = control as ICommonFileDialogIndexedControls; controlInterface.SelectedIndex = dwIDItem; controlInterface.RaiseSelectedIndexChangedEvent(); } // Process Menu else if (control is CommonFileDialogMenu) { CommonFileDialogMenu menu = control as CommonFileDialogMenu; // Find the menu item that was clicked and invoke it's click event foreach (CommonFileDialogMenuItem item in menu.Items) { if (item.Id == dwIDItem) { item.RaiseClickEvent(); break; } } } }
// Called when a control currently in the collection has a property changing - this is // basically to screen out property changes that cannot occur while the dialog is showing // because the Win32 API has no way for us to propagate the changes until we re-invoke the Win32 call bool IDialogControlHost.IsControlPropertyChangeAllowed(string propertyName, DialogControl control) { Debug.Assert(control is TaskDialogControl, "Property changing for a control that is not a TaskDialogControl-derived type"); Debug.Assert(propertyName != "Name", "Name changes at any time are not supported - public API should have blocked this"); bool canChange = false; if (!NativeDialogShowing) { canChange = true; } else { // If the dialog is showing, we can only allow some properties to change switch (propertyName) { // Properties that CAN'T be changed while dialog is showing case "Text": case "Default": canChange = false; break; // Properties that CAN be changed while dialog is showing case "ShowElevationIcon": case "Enabled": canChange = true; break; default: Debug.Assert(true, "Unknown property name coming through property changing handler"); break; } } return(canChange); }
public override bool Equals(object obj) { DialogControl control = obj as DialogControl; if (control != null) { return(this.Id == control.Id); } return(false); }
public void OnButtonClicked(IFileDialogCustomize pfdc, int dwIDCtl) { // Find control DialogControl control = this.parent.controls.GetControlbyId(dwIDCtl); // Call corresponding event if (control is CommonFileDialogButton) { ((CommonFileDialogButton)control).RaiseClickEvent(); } }
public void OnCheckButtonToggled(IFileDialogCustomize pfdc, int dwIDCtl, bool bChecked) { // Find control DialogControl control = this.parent.controls.GetControlbyId(dwIDCtl); // Update control and call corresponding event if (control is CommonFileDialogCheckBox) { CommonFileDialogCheckBox box = control as CommonFileDialogCheckBox; box.IsChecked = bChecked; box.RaiseCheckedChangedEvent(); } }
/// <summary> /// Recursively searches for a given control id in the /// collection passed via the <paramref name="ctrlColl"/> parameter. /// </summary> /// /// <param name="ctrlColl">A Collection<CommonFileDialogControl></param> /// <param name="id">An int containing the identifier of the control /// being searched for.</param> /// /// <returns>A DialogControl who's Id matches the value of the /// <paramref name="id"/> parameter.</returns> /// internal DialogControl GetSubControlbyId(IEnumerable <T> ctrlColl, int id) { DialogControl foundControl = null; int iSubCtrlCount = 0; // if ctrlColl is null, it will throw in the foreach. if (ctrlColl == null) { return(null); } foreach (DialogControl control in ctrlColl) { // Match? if (control.Id == id) { return(control); } // Search GroupBox child items if (control is CommonFileDialogGroupBox) { CommonFileDialogGroupBox groupBox = control as CommonFileDialogGroupBox; // recurse and search the GroupBox iSubCtrlCount = ((CommonFileDialogGroupBox)control).Items.Count; if (iSubCtrlCount > 0) { foundControl = this.GetSubControlbyId( groupBox.Items as IEnumerable <T>, id); // make sure something was actually found if (foundControl != null) { return(foundControl); } } } } // Control id not found - likely an error, but the calling // function should ultimately decide. return(null); }
protected override void RemoveItem(int index) { // Notify that we're about to remove a control - should throw if dialog showing if (!hostingDialog.IsCollectionChangeAllowed()) { throw new InvalidOperationException("Modifying controls collection while dialog is showing is not supported"); } DialogControl control = (DialogControl)Items[index]; // Unparent and remove control.HostingDialog = null; base.RemoveItem(index); hostingDialog.ApplyCollectionChanged(); }
void IDialogControlHost.ApplyControlPropertyChange(string propertyName, DialogControl control) { if (propertyName == "Text") { customize.SetControlLabel(control.Id, ((CommonFileDialogControl)control).Text); } else if (propertyName == "Enabled" || propertyName == "Visible") { CommonFileDialogControl dialogControl = control as CommonFileDialogControl; SafeNativeMethods.CDCONTROLSTATE state = SafeNativeMethods.CDCONTROLSTATE.CDCS_INACTIVE; if (dialogControl.Enabled == true) { state |= SafeNativeMethods.CDCONTROLSTATE.CDCS_ENABLED; } if (dialogControl.Visible == true) { state |= SafeNativeMethods.CDCONTROLSTATE.CDCS_VISIBLE; } customize.SetControlState(control.Id, state); } else if (propertyName == "SelectedIndex") { if (control is CommonFileDialogRadioButtonList) { CommonFileDialogRadioButtonList list = control as CommonFileDialogRadioButtonList; customize.SetSelectedControlItem(control.Id, list.SelectedIndex); } else if (control is CommonFileDialogComboBox) { CommonFileDialogComboBox box = control as CommonFileDialogComboBox; customize.SetSelectedControlItem(control.Id, box.SelectedIndex); } } else if (propertyName == "IsChecked") { if (control is CommonFileDialogCheckBox) { CommonFileDialogCheckBox checkBox = control as CommonFileDialogCheckBox; customize.SetCheckButtonState(control.Id, checkBox.IsChecked); } } }
// 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) { // One of the progress bar flavors? if (control is TaskDialogMarquee) { if (propertyName == "State") { nativeDialog.UpdateProgressBarState(marquee.State); } else { Debug.Assert(true, "Unknown property being set"); } } else 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": if (control is TaskDialogRadioButton) { nativeDialog.UpdateRadioButtonEnabled(button.Id, button.Enabled); } else { nativeDialog.UpdateButtonEnabled(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; }
void IDialogControlHost.ApplyControlPropertyChange(string propertyName, DialogControl control) { if (propertyName == "Text") { customize.SetControlLabel(control.Id, ((CommonFileDialogControl)control).Text); } else if (propertyName == "Enabled" || propertyName == "Visible") { CommonFileDialogControl dialogControl = control as CommonFileDialogControl; SafeNativeMethods.CDCONTROLSTATE state = SafeNativeMethods.CDCONTROLSTATE.CDCS_INACTIVE; if (dialogControl.Enabled == true) state |= SafeNativeMethods.CDCONTROLSTATE.CDCS_ENABLED; if (dialogControl.Visible == true) state |= SafeNativeMethods.CDCONTROLSTATE.CDCS_VISIBLE; customize.SetControlState(control.Id, state); } else if (propertyName == "SelectedIndex") { if (control is CommonFileDialogRadioButtonList) { CommonFileDialogRadioButtonList list = control as CommonFileDialogRadioButtonList; customize.SetSelectedControlItem(control.Id, list.SelectedIndex); } else if (control is CommonFileDialogComboBox) { CommonFileDialogComboBox box = control as CommonFileDialogComboBox; customize.SetSelectedControlItem(control.Id, box.SelectedIndex); } } else if (propertyName == "IsChecked") { if (control is CommonFileDialogCheckBox) { CommonFileDialogCheckBox checkBox = control as CommonFileDialogCheckBox; customize.SetCheckButtonState(control.Id, checkBox.IsChecked); } } }
bool IDialogControlHost.IsControlPropertyChangeAllowed(string propertyName, DialogControl control) { CommonFileDialog.GenerateNotImplementedException(); return false; }
void IDialogControlHost.ApplyControlPropertyChange(string propertyName, DialogControl control) { throw new Exception("The method or operation is not implemented."); }
bool IDialogControlHost.IsControlPropertyChangeAllowed(string propertyName, DialogControl control) { throw new Exception("The method or operation is not implemented."); }
// Called when a control currently in the collection has a property changing - this is // basically to screen out property changes that cannot occur while the dialog is showing // because the Win32 API has no way for us to propagate the changes until we re-invoke the Win32 call bool IDialogControlHost.IsControlPropertyChangeAllowed(string propertyName, DialogControl control) { Debug.Assert(control is TaskDialogControl, "Property changing for a control that is not a TaskDialogControl-derived type"); Debug.Assert(propertyName != "Name", "Name changes at any time are not supported - public API should have blocked this"); bool canChange = false; if (!NativeDialogShowing) canChange = true; else { // If the dialog is showing, we can only allow some properties to change switch (propertyName) { // Properties that CAN'T be changed while dialog is showing case "Text": case "Default": canChange = false; break; // Properties that CAN be changed while dialog is showing case "ShowElevationIcon": case "Enabled": canChange = true; break; default: Debug.Assert(true, "Unknown property name coming through property changing handler"); break; } } return canChange; }
// 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) { // One of the progress bar flavors? if (control is TaskDialogMarquee) { if (propertyName == "State") nativeDialog.UpdateProgressBarState(marquee.State); else Debug.Assert(true, "Unknown property being set"); } else 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(progressBar.Minimum, progressBar.Maximum); 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 { // 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; }
void IDialogControlHost.ApplyControlPropertyChange( string propertyName, DialogControl control) { CommonFileDialog.GenerateNotImplementedException(); }