public override object EditValue( ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context.Instance is object[]) { if (((object[])context.Instance).Length > 1) { return(null); } } //use IWindowsFormsEditorService object to display a control in the dropdown area IWindowsFormsEditorService frmsvr = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (frmsvr == null) { return(null); } FontItem font = null; if (value != null) { font = value as FontItem; } else { try { object obj = ((object[])context.Instance)[0]; PropertyGridConverters.TextPropertyConverter prop = (PropertyGridConverters.TextPropertyConverter)obj; CoronaObject objectSelected = prop.GetObjectSelected(); font = (objectSelected.DisplayObject.Figure as CGE_Figures.Texte).font2.FontItem; } catch (Exception ex) { return(null); } } FontPropertyEditor control = new FontPropertyEditor(font, frmsvr); frmsvr.DropDownControl(control); if (control.SelectedItems.Count > 0) { return(control.SelectedItems[0].Tag); } else { return(font); } }
public override object EditValue( ITypeDescriptorContext context, IServiceProvider provider, object value) { if(context.Instance is object[]) if (((object[])context.Instance).Length > 1) return null; //use IWindowsFormsEditorService object to display a control in the dropdown area IWindowsFormsEditorService frmsvr = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (frmsvr == null) return null; FontItem font = null; if (value != null) { font = value as FontItem; } else { try { object obj = ((object[])context.Instance)[0]; PropertyGridConverters.TextPropertyConverter prop = (PropertyGridConverters.TextPropertyConverter)obj; CoronaObject objectSelected = prop.GetObjectSelected(); font = (objectSelected.DisplayObject.Figure as CGE_Figures.Texte).font2.FontItem; } catch (Exception ex) { return null; } } FontPropertyEditor control = new FontPropertyEditor(font, frmsvr); frmsvr.DropDownControl(control); if (control.SelectedItems.Count > 0) return control.SelectedItems[0].Tag; else return font; }