using System;
using System.Drawing;
using System.Runtime.CompilerServices;
using System.Windows.Forms;

namespace TD.SandDock
{
	internal class h : TD.SandDock.a
	{
		[MethodImpl(MethodImplOptions.Synchronized)]
		public void b(h.a A_0)
		{
			this.e = (h.a)Delegate.Combine(this.e, A_0);
		}

		[MethodImpl(MethodImplOptions.Synchronized)]
		public void a(h.a A_0)
		{
			this.e = (h.a)Delegate.Remove(this.e, A_0);
		}

		[MethodImpl(MethodImplOptions.Synchronized)]
		public void a(EventHandler A_0)
		{
			this.f = (EventHandler)Delegate.Combine(this.f, A_0);
		}

		[MethodImpl(MethodImplOptions.Synchronized)]
		public void b(EventHandler A_0)
		{
			this.f = (EventHandler)Delegate.Remove(this.f, A_0);
		}

		public h(SandDockManager A_0, DockContainer A_1, Point A_2) : base(A_1, A_0.DockingHints, false)
		{
			this.a = A_1;
			Rectangle left = Rectangle.Empty;
			if (A_0 != null)
			{
				left = TD.SandDock.e.a(A_0, false);
				left = new Rectangle(A_1.PointToClient(left.Location), left.Size);
			}
			int num = A_1.CurrentSize;
			switch (A_1.Dock)
			{
			case DockStyle.Top:
				this.b = A_2.Y - (num - A_1.MinimumSize);
				this.c = Math.Min(A_2.Y + (A_1.MaximumSize - num), A_1.Parent.ClientRectangle.Height - A_1.Top);
				if (left != Rectangle.Empty && this.c > left.Bottom)
				{
					this.c = left.Bottom;
				}
				break;
			case DockStyle.Bottom:
				this.b = Math.Max(A_2.Y - (A_1.MaximumSize - num), -A_1.Top);
				this.c = A_2.Y + (num - A_1.MinimumSize);
				if (left != Rectangle.Empty && this.b < left.Top)
				{
					this.b = left.Top;
				}
				break;
			case DockStyle.Left:
				this.b = A_2.X - (num - A_1.MinimumSize);
				this.c = Math.Min(A_2.X + (A_1.MaximumSize - num), A_1.Parent.ClientRectangle.Width - A_1.Left);
				if (left != Rectangle.Empty && this.c > left.Right)
				{
					this.c = left.Right;
				}
				break;
			case DockStyle.Right:
				this.b = Math.Max(A_2.X - (A_1.MaximumSize - num), -A_1.Left);
				this.c = A_2.X + (num - A_1.MinimumSize);
				if (left != Rectangle.Empty && this.b < left.Left)
				{
					this.b = left.Left;
				}
				break;
			}
			this.a(A_2);
		}

		public override void a(Point A_0)
		{
			Rectangle empty = Rectangle.Empty;
			if (this.a.Vertical)
			{
				empty = new Rectangle(A_0.X - 2, 0, 4, this.a.Height);
				if (empty.X < this.b)
				{
					empty.X = this.b;
				}
				if (empty.X > this.c - 4)
				{
					empty.X = this.c - 4;
				}
			}
			else
			{
				empty = new Rectangle(0, A_0.Y - 2, this.a.Width, 4);
				if (empty.Y < this.b)
				{
					empty.Y = this.b;
				}
				if (empty.Y > this.c - 4)
				{
					empty.Y = this.c - 4;
				}
			}
			switch (this.a.Dock)
			{
			case DockStyle.Top:
				this.d = this.a.Height + (empty.Y - this.a.Height);
				break;
			case DockStyle.Bottom:
				this.d = this.a.Height - empty.Y;
				break;
			case DockStyle.Left:
				this.d = this.a.Width + (empty.X - this.a.Width);
				break;
			case DockStyle.Right:
				this.d = this.a.Width - empty.X;
				break;
			}
			base.a(new Rectangle(this.a.PointToScreen(empty.Location), empty.Size), false);
		}

		public override void a()
		{
			base.a();
			if (this.e != null)
			{
				this.e(this.d);
			}
		}

		public override void c()
		{
			base.c();
			if (this.f != null)
			{
				this.f(this, EventArgs.Empty);
			}
		}

		public override void b()
		{
			base.b();
			this.a = null;
		}

		private new DockContainer a = null;

		private new int b;

		private new int c;

		private int d = 0;

		private h.a e;

		private new EventHandler f;

		public new delegate void a(int A_0);
	}
}
