public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if ((context == null) || (provider == null)) { return(base.EditValue(context, provider, value)); } // Access the Property Browser's UI display service IWindowsFormsEditorService editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (editorService == null) { return(base.EditValue(context, provider, value)); } // Create an instance of the UI editor form IReportItem iri = context.Instance as IReportItem; if (iri == null) { return(base.EditValue(context, provider, value)); } PropertyReportItem pre = iri.GetPRI(); string[] names; PropertyBackground pb = value as PropertyBackground; if (pb != null) { names = pb.Names; } else { PropertyBackgroundImage pbi = value as PropertyBackgroundImage; if (pbi == null) { return(base.EditValue(context, provider, value)); } names = pbi.Names; } using (SingleCtlDialog scd = new SingleCtlDialog(pre.DesignCtl, pre.Draw, pre.Nodes, SingleCtlTypeEnum.BackgroundCtl, names)) { // Display the UI editor dialog if (editorService.ShowDialog(scd) == DialogResult.OK) { // Return the new property value from the UI editor form return(new PropertyBackground(pre)); } return(base.EditValue(context, provider, value)); } }
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(string) && value is PropertyBackground) { PropertyBackground pf = value as PropertyBackground; return(pf.ToString()); } return(base.ConvertTo(context, culture, value, destinationType)); }