using System;
using System.Drawing;
using System.Windows.Forms;

namespace TD.SandDock
{
	internal abstract class a : IDisposable, IMessageFilter
	{
		public a(Control A_0, DockingHints A_1, bool A_2, int A_3) : this(A_0, A_1, A_2)
		{
			this.k = A_3;
		}

		public a(Control A_0, DockingHints A_1, bool A_2)
		{
			this.i = A_2;
			if (A_1 == DockingHints.TranslucentFill && !TD.SandDock.a.f())
			{
				A_1 = DockingHints.RubberBand;
			}
			this.f = A_1;
			this.d = A_0.FindForm();
			this.e = A_0;
			if (this.d != null)
			{
				this.d.Deactivate += this.a;
			}
			Application.AddMessageFilter(this);
			if (A_1 == DockingHints.TranslucentFill)
			{
				this.j = new l(A_2);
			}
		}

		internal static bool f()
		{
			bool result = false;
			if (Environment.OSVersion.Platform == PlatformID.Win32NT)
			{
				result = (Environment.OSVersion.Version >= new Version(5, 0, 0, 0));
			}
			return result;
		}

		protected void a(Rectangle A_0, bool A_1)
		{
			if (this.g == A_0)
			{
				return;
			}
			if (this.f == DockingHints.RubberBand)
			{
				this.e();
			}
			if (this.f == DockingHints.RubberBand)
			{
				if (this.i)
				{
					TD.SandDock.c.a(null, A_0, A_1, this.k);
				}
				else
				{
					TD.SandDock.c.a(null, A_0);
				}
				this.g = A_0;
				this.h = A_1;
				return;
			}
			if (this.j != null)
			{
				this.j.a(A_0, A_1);
			}
		}

		protected void l()
		{
			if (this.f == DockingHints.RubberBand)
			{
				this.e();
				return;
			}
			if (this.j != null)
			{
				this.j.Hide();
			}
		}

		private void e()
		{
			if (this.g != Rectangle.Empty)
			{
				if (this.i)
				{
					TD.SandDock.c.a(null, this.g, this.h, this.k);
				}
				else
				{
					TD.SandDock.c.a(null, this.g);
				}
			}
			this.g = Rectangle.Empty;
		}

		public virtual void a()
		{
			this.b();
		}

		public virtual void c()
		{
			this.b();
		}

		public virtual void b()
		{
			this.l();
			if (this.f == DockingHints.TranslucentFill)
			{
				this.j.Dispose();
				this.j = null;
			}
			if (this.d != null)
			{
				this.d.Deactivate -= this.a;
			}
			Application.RemoveMessageFilter(this);
			this.d = null;
			this.e = null;
		}

		private void a(object A_0, EventArgs A_1)
		{
			this.c();
		}

		private void d()
		{
			if (this.f == DockingHints.RubberBand)
			{
				this.e();
			}
		}

		public abstract void a(Point A_0);

		public bool a(ref Message A_0)
		{
			if (A_0.Msg == 15)
			{
				this.d();
			}
			if ((A_0.Msg == 256 || A_0.Msg == 257) && A_0.WParam.ToInt32() == 17)
			{
				this.a(Cursor.Position);
				return false;
			}
			if (A_0.Msg >= 256 && A_0.Msg <= 264)
			{
				this.c();
				return true;
			}
			return false;
		}

		private const int a = 256;

		private const int b = 257;

		private const int c = 15;

		private Form d = null;

		private Control e = null;

		private DockingHints f = DockingHints.TranslucentFill;

		private Rectangle g = Rectangle.Empty;

		private bool h = false;

		private bool i = false;

		private l j = null;

		private int k = 21;
	}
}
