public override void PaintValue(PaintValueEventArgs e) { base.PaintValue(e); string s = e.Value as string; if (s != null) { Color color; if (!Color.TryParse(s, out color)) { return; } using (Brush brush = (Brush) new SolidBrush((System.Drawing.Color)color.ToArgbColor(DxfIndexedColorSet.AcadClassicIndexedColors))) e.Graphics.FillRectangle(brush, e.Bounds); } else { if (!(e.Value is Color)) { return; } using (Brush brush = (Brush) new SolidBrush((System.Drawing.Color)((Color)e.Value).ToArgbColor(DxfIndexedColorSet.AcadClassicIndexedColors))) e.Graphics.FillRectangle(brush, e.Bounds); } }
public override object ConvertFrom( ITypeDescriptorContext context, CultureInfo culture, object value) { string s = value as string; Color color; if (s != null && Color.TryParse(s, out color)) { return((object)color); } return(value); }