/// <summary> /// Edits the specified object's value. /// </summary> /// <param name="designer"></param> /// <param name="objectToChange"></param> /// <param name="propName"></param> /// <returns></returns> public static object EditValue(ComponentDesigner designer, object objectToChange, string propName) { // Get PropertyDescriptor PropertyDescriptor descriptor = TypeDescriptor.GetProperties(objectToChange)[propName]; // Create a Context NuGenEditorServiceContext context = new NuGenEditorServiceContext(designer, descriptor); // Get Editor UITypeEditor editor = descriptor.GetEditor(typeof(UITypeEditor)) as UITypeEditor; // Get value to edit object value = descriptor.GetValue(objectToChange); // Edit value object newValue = editor.EditValue(context, context, value); if (newValue != value) { try { descriptor.SetValue(objectToChange, newValue); } catch (CheckoutException) { } } return newValue; }
/// <summary> /// Called when the EditApplicationCommands verb is activated. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">An <see cref="EventArgs"/> that contains no event data.</param> private void onVerbEditApplicationCommands(object sender, EventArgs e) { NuGenEditorServiceContext.EditValue(this, this.Component, "ApplicationCommands"); }
// Event handling method for the designer verb /// <summary> /// Called when the EditContextMenus verb is activated. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">An <see cref="EventArgs"/> that contains no event data.</param> private void onVerbEditContextMenus(object sender, EventArgs e) { NuGenEditorServiceContext.EditValue(this, this.Component, "ContextMenus"); }
/// <summary> /// Creates a method signature in the source code file for the default event /// on the component and navigates the user's cursor to that location. /// This method is invoked when the associated component is double-clicked. /// </summary> public override void DoDefaultAction() { NuGenEditorServiceContext.EditValue(this, this.Component, "ApplicationCommands"); }