using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;

namespace Sentience
{
    public static class Drawing
    {
        public static void Box(Graphics graphics, PointF position, String label, Size size, Color color) 
        {
            Box(graphics, position, label, size, color, Color.Empty);
        }

        public static void Box(Graphics graphics, PointF position, String label, Size size, Color color, Color fillColor)
        {
            position = new PointF(position.X - size.Width / 2, position.Y - size.Height / 2);

            if (fillColor != Color.Empty)
                FillBox(graphics, position, size, fillColor);

            Drawing.Text(graphics, label,
                Defaults.DefaultFont,
                Brushes.Blue,
                new PointF(position.X - size.Width / 2, position.Y - size.Height / 2));

            graphics.DrawRectangle(new Pen(color),
                position.X,
                position.Y,
                size.Width,
                size.Height);   
        }

        public static void Circle(Graphics graphics, PointF position, float radius, Color color, Color fillColor)
        {
            if (fillColor != Color.Empty)
                FillCircle(graphics, position, radius, fillColor);
        }

        public static void Text(Graphics graphics, String label, Font font, Brush brush, PointF position)
        {
            graphics.DrawString(label,
                font,
                brush,
                position,
                StringFormat.GenericDefault);
        }

        public static void Line(Graphics graphics, PointF startPosition, PointF endPosition, Color color)
        {
            graphics.DrawLine(new Pen(color),
                startPosition,
                endPosition);
        }

        public static void FillBox(Graphics graphics, PointF position, Size size, Color color)
        {
            graphics.FillRectangle(new SolidBrush(color),
                position.X,
                position.Y,
                size.Width,
                size.Height);
        }

        public static void FillCircle(Graphics graphics, PointF position, float radius, Color color)
        {
            graphics.FillEllipse(new SolidBrush(color),
                position.X - radius, 
                position.Y - radius, 
                radius * 2, 
                radius * 2);
        }
    }
}
