public override void SetValue(object component, object value) { IProperty p = value as IProperty; if (p != null) { _owner.AddProperty(p); } }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context != null && context.Instance != null && provider != null) { IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null) { MethodDataTransfer mdt = context.Instance as MethodDataTransfer; if (mdt == null) { IAction act = context.Instance as IAction; if (act != null) { mdt = act.ActionMethod as MethodDataTransfer; } } if (mdt != null) { FrmObjectExplorer dlg = DesignUtil.GetPropertySelector(null, mdt.Action.ScopeMethod, null); dlg.SetMultipleSelection(true); dlg.ObjectSubType = EnumObjectSelectSubType.Property; if (edSvc.ShowDialog(dlg) == System.Windows.Forms.DialogResult.OK) { if (dlg.SelectedProperties != null) { foreach (IProperty p in dlg.SelectedProperties) { mdt.AddProperty(p); } PropertyGrid pg = null; Type t = edSvc.GetType(); PropertyInfo pif0 = t.GetProperty("OwnerGrid"); if (pif0 != null) { object g = pif0.GetValue(edSvc, null); pg = g as PropertyGrid; } if (pg != null && pg.SelectedGridItem != null) { pg.SelectedGridItem.Expanded = true; } mdt.OnChanged(); return(true); } } } } } return(string.Empty); }