using System.Drawing;

namespace TD.SandDock.Rendering
{
	public class BoxModel
	{
		private BoxEdges a;

		private BoxEdges b;

		private int c;

		private int d;

		public int ExtraWidth => a.Left + a.Right + b.Left + b.Right;

		public int ExtraHeight => a.Top + a.Bottom + b.Top + b.Bottom;

		public Size InnerSize => new Size(c - a.Left - a.Right, d - a.Top - a.Bottom);

		public int Height
		{
			get
			{
				return d;
			}
			set
			{
				d = value;
			}
		}

		public int Width
		{
			get
			{
				return c;
			}
			set
			{
				c = value;
			}
		}

		public BoxEdges Margin
		{
			get
			{
				return a;
			}
			set
			{
				a = value;
			}
		}

		public BoxEdges Padding
		{
			get
			{
				return b;
			}
			set
			{
				b = value;
			}
		}

		public BoxModel()
		{
			a = new BoxEdges();
			b = new BoxEdges();
		}

		public BoxModel(int width, int height, int paddingLeft, int paddingTop, int paddingRight, int paddingBottom, int marginLeft, int marginTop, int marginRight, int marginBottom)
		{
			c = width;
			d = height;
			b = new BoxEdges(paddingLeft, paddingTop, paddingRight, paddingBottom);
			a = new BoxEdges(marginLeft, marginTop, marginRight, marginBottom);
		}

		public Rectangle RemovePadding(Rectangle source)
		{
			source.X += b.Left;
			source.Y += b.Top;
			source.Width -= b.Left + b.Right;
			source.Height -= b.Top + b.Bottom;
			return source;
		}

		public Rectangle RemoveMargin(Rectangle source)
		{
			source.X += a.Left;
			source.Y += a.Top;
			source.Width -= a.Left + a.Right;
			source.Height -= a.Top + a.Bottom;
			return source;
		}
	}
}
