namespace PerpetuumSoft.Widgets
{
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Drawing.Design;
    using System.Drawing.Drawing2D;

    internal class ShapeEditor : UITypeEditor
    {
        public override bool GetPaintValueSupported(ITypeDescriptorContext context)
        {
            return true;
        }

        public override void PaintValue(PaintValueEventArgs e)
        {
            Rectangle rect = e.get_Bounds();
            e.get_Graphics().FillRectangle(Brushes.get_Black(), rect);
            rect.X++;
            rect.Y++;
            rect.Width -= 2;
            rect.Height -= 2;
            ShapeKinds shape = (ShapeKinds) e.get_Value();
            GraphicsPath path = ShapeGenerator.GenerateShape(shape, rect);
            e.get_Graphics().FillPath(Brushes.get_Yellow(), path);
        }
    }
}
