The following HatchStyleEditor class draws a graphical representation for values in the HatchStyle enumeration. HatchStyleEditor is derived from UITypeEditor and overrides the GetPaintValueSupported method and returns true. GetPaintValueSupported indicates that this editor supports the painting of a representation of an object’s value.
PaintValue paints the representative value to the canvas.
public class HatchStyleEditor : UITypeEditor
{
public override bool GetPaintValueSupported(ITypeDescriptorContext context)
{
return true;
}
public override void PaintValue(PaintValueEventArgs e)
{
if (e.Value is HatchStyle)
{
HatchStyle hatch = (HatchStyle) e.Value;
Brush br = new HatchBrush(hatch, SystemColors.WindowText, SystemColors.Window);
e.Graphics.FillRectangle(br, e.Bounds);
br.Dispose();
}
}
}
Share with