public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (ui == null) { ui = new System.Windows.Forms.TGIBlockListEditorForm.MainForm(); //ui.Icon = ((System.Drawing.Icon)(new ComponentResourceManager(typeof(MainForm)).GetObject("$this.Icon"))); ui.Icon = Settings.Default.FormIcon; } TGIBlockListCTD ctd = value as TGIBlockListCTD; DependentList <TGIBlock> list = ctd.owner[ctd.field].Value as DependentList <TGIBlock>; ui.Items = list; DialogResult dr = edSvc.ShowDialog(ui); if (dr != DialogResult.OK) { return(value); } list.Clear(); list.AddRange(ui.Items); return(value); }
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { TGIBlockListCTD ctd = value as TGIBlockListCTD; DependentList <TGIBlock> list = ctd.owner[ctd.field].Value as DependentList <TGIBlock>; if (typeof(string).Equals(destinationType)) { return(list == null ? "(null)" : "(TGI Blocks: 0x" + list.Count.ToString("X") + ")"); } return(base.ConvertTo(context, culture, value, destinationType)); }
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { TGIBlockListCTD ctd = value as TGIBlockListCTD; ICollection ary = (ICollection)ctd.owner[ctd.field].Value; AApiVersionedFieldsCTD.TypedValuePropertyDescriptor[] pds = new AApiVersionedFieldsCTD.TypedValuePropertyDescriptor[ary.Count]; string fmt = "[{0:X" + ary.Count.ToString("X").Length + "}] {1}"; int i = 0; foreach (var o in ary) { try { pds[i] = new AApiVersionedFieldsCTD.TypedValuePropertyDescriptor(ctd.owner, String.Format(fmt, i, ctd.field), new Attribute[] { }); } catch (Exception ex) { throw ex; } i++; } return(new PropertyDescriptorCollection(pds)); }