/// <summary> /// This should launch an open file dialog instead of the usual thing. /// </summary> /// <param name="context">ITypeDescriptorContext</param> /// <param name="provider">IServiceProvider</param> /// <param name="value">The object being displayed</param> /// <returns>A new version of the object if the dialog was ok.</returns> public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { _original = value as IPointScheme; _editCopy = _original.Copy(); IWindowsFormsEditorService dialogProvider = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); NamedList<IPointCategory> cats = new NamedList<IPointCategory>(_editCopy.Categories, "Category"); CollectionPropertyGrid frm = new CollectionPropertyGrid(cats); frm.ChangesApplied += FrmChangesApplied; frm.AddItemClicked += FrmAddItemClicked; dialogProvider.ShowDialog(frm); return _original; // don't bother swapping out the edit copy, just store copies of the categories when changes are applied. }
/// <summary> /// This should launch an open file dialog instead of the usual thing. /// </summary> /// <param name="context">ITypeDescriptorContext.</param> /// <param name="provider">IServiceProvider.</param> /// <param name="value">The object being displayed.</param> /// <returns>A new version of the object if the dialog was ok.</returns> public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { _original = value as IPointScheme; _editCopy = _original.Copy(); IWindowsFormsEditorService dialogProvider = (IWindowsFormsEditorService)provider?.GetService(typeof(IWindowsFormsEditorService)); NamedList <IPointCategory> cats = new NamedList <IPointCategory>(_editCopy.Categories, "Category"); CollectionPropertyGrid frm = new CollectionPropertyGrid(cats); frm.ChangesApplied += FrmChangesApplied; frm.AddItemClicked += FrmAddItemClicked; dialogProvider?.ShowDialog(frm); return(_original); // don't bother swapping out the edit copy, just store copies of the categories when changes are applied. }