internal override void Attach(IFileDialogCustomize dialog) { Debug.Assert(dialog != null, "CommonFileDialogComboBox.Attach: dialog parameter can not be null"); // Add the combo box control dialog.AddComboBox(this.Id); // Add the combo box items for (int index = 0; index < items.Count; index++) { dialog.AddControlItem(this.Id, index, items[index].Text); } // Set the currently selected item if (selectedIndex >= 0 && selectedIndex < items.Count) { dialog.SetSelectedControlItem(this.Id, this.selectedIndex); } else if (selectedIndex != -1) { throw new IndexOutOfRangeException(LocalizedMessages.ComboBoxIndexOutsideBounds); } // Make this control prominent if needed if (IsProminent) { dialog.MakeProminent(this.Id); } // Sync additional properties SyncUnmanagedProperties(); }
/// <summary> /// Attach the RadioButtonList control to the dialog object /// </summary> /// <param name="dialog">The target dialog</param> internal override void Attach(IFileDialogCustomize dialog) { Debug.Assert(dialog != null, "CommonFileDialogRadioButtonList.Attach: dialog parameter can not be null"); // Add the radio button list control dialog.AddRadioButtonList(this.Id); // Add the radio button list items for (int index = 0; index < items.Count; index++) { dialog.AddControlItem(this.Id, index, items[index].Text); } // Set the currently selected item if (selectedIndex >= 0 && selectedIndex < items.Count) { dialog.SetSelectedControlItem(this.Id, this.selectedIndex); } else if (selectedIndex != -1) { throw new IndexOutOfRangeException(LocalizedMessages.RadioButtonListIndexOutOfBounds); } // Sync unmanaged properties with managed properties SyncUnmanagedProperties(); }
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); } } }
/// <summary> /// Attach the RadioButtonList control to the dialog object /// </summary> /// <param name="dialog">The target dialog</param> internal override void Attach(IFileDialogCustomize dialog) { Debug.Assert(dialog != null, "CommonFileDialogRadioButtonList.Attach: dialog parameter can not be null"); // Add the radio button list control dialog.AddRadioButtonList(this.Id); // Add the radio button list items for (int index = 0; index < items.Count; index++) dialog.AddControlItem(this.Id, index, items[index].Text); // Set the currently selected item if (selectedIndex >= 0 && selectedIndex < items.Count) { dialog.SetSelectedControlItem(this.Id, this.selectedIndex); } else if (selectedIndex != -1) { throw new IndexOutOfRangeException("Index was outside the bounds of the CommonFileDialogRadioButtonList."); } // Sync unmanaged properties with managed properties SyncUnmanagedProperties(); }
/// <summary> /// Called when a control currently in the collection /// has a property changed. /// </summary> /// <param name="propertyName">The name of the property changed.</param> /// <param name="control">The control whose property has changed.</param> public virtual void ApplyControlPropertyChange(string propertyName, DialogControl control) { if (control == null) { throw new ArgumentNullException("control"); } CommonFileDialogControl dialogControl = null; if (propertyName == "Text") { CommonFileDialogTextBox textBox = control as CommonFileDialogTextBox; if (textBox != null) { customize.SetEditBoxText(control.Id, textBox.Text); } else { customize.SetControlLabel(control.Id, textBox.Text); } } else if (propertyName == "Visible" && (dialogControl = control as CommonFileDialogControl) != null) { ShellNativeMethods.ControlState state; customize.GetControlState(control.Id, out state); if (dialogControl.Visible == true) { state |= ShellNativeMethods.ControlState.Visible; } else if (dialogControl.Visible == false) { state &= ~ShellNativeMethods.ControlState.Visible; } customize.SetControlState(control.Id, state); } else if (propertyName == "Enabled" && dialogControl != null) { ShellNativeMethods.ControlState state; customize.GetControlState(control.Id, out state); if (dialogControl.Enabled == true) { state |= ShellNativeMethods.ControlState.Enable; } else if (dialogControl.Enabled == false) { state &= ~ShellNativeMethods.ControlState.Enable; } customize.SetControlState(control.Id, state); } else if (propertyName == "SelectedIndex") { CommonFileDialogRadioButtonList list; CommonFileDialogComboBox box; if ((list = control as CommonFileDialogRadioButtonList) != null) { customize.SetSelectedControlItem(list.Id, list.SelectedIndex); } else if ((box = control as CommonFileDialogComboBox) != null) { customize.SetSelectedControlItem(box.Id, box.SelectedIndex); } } else if (propertyName == "IsChecked") { CommonFileDialogCheckBox checkBox = control as CommonFileDialogCheckBox; if (checkBox != null) { customize.SetCheckButtonState(checkBox.Id, checkBox.IsChecked); } } }
/// <summary> /// Attach the ComboBox control to the dialog object /// </summary> /// <param name="dialog">The target dialog</param> internal override void Attach(IFileDialogCustomize dialog) { Debug.Assert(dialog != null, "CommonFileDialogComboBox.Attach: dialog parameter can not be null"); // Add the combo box control dialog.AddComboBox(this.Id); // Add the combo box items for (int index = 0; index < items.Count; index++) dialog.AddControlItem(this.Id, index, items[index].Text); // Set the currently selected item if (selectedIndex >= 0 && selectedIndex < items.Count) { dialog.SetSelectedControlItem(this.Id, this.selectedIndex); } else if (selectedIndex != -1) { throw new IndexOutOfRangeException("Index was outside the bounds of the CommonFileDialogComboBox."); } // Make this control prominent if needed if (IsProminent) dialog.MakeProminent(this.Id); // Sync additional properties SyncUnmanagedProperties(); }