using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Runtime.CompilerServices;
using System.Windows.Forms;
using TD.SandDock.Rendering;
using TD.Util;

namespace TD.SandDock
{
	[ToolboxItem(false)]
	[DefaultEvent("DockingStarted")]
	[Designer(typeof(DockContainerDesigner))]
	public class DockContainer : Control
	{
		public event EventHandler DockingStarted
		{
			[MethodImpl(MethodImplOptions.Synchronized)]
			add
			{
				this.u = (EventHandler)Delegate.Combine(this.u, value);
			}
			[MethodImpl(MethodImplOptions.Synchronized)]
			remove
			{
				this.u = (EventHandler)Delegate.Remove(this.u, value);
			}
		}

		public event EventHandler DockingFinished
		{
			[MethodImpl(MethodImplOptions.Synchronized)]
			add
			{
				this.v = (EventHandler)Delegate.Combine(this.v, value);
			}
			[MethodImpl(MethodImplOptions.Synchronized)]
			remove
			{
				this.v = (EventHandler)Delegate.Remove(this.v, value);
			}
		}

		public event ShowControlContextMenuEventHandler ShowControlContextMenu
		{
			[MethodImpl(MethodImplOptions.Synchronized)]
			add
			{
				this.w = (ShowControlContextMenuEventHandler)Delegate.Combine(this.w, value);
			}
			[MethodImpl(MethodImplOptions.Synchronized)]
			remove
			{
				this.w = (ShowControlContextMenuEventHandler)Delegate.Remove(this.w, value);
			}
		}

		public DockContainer()
		{
			this.b = new SplitLayoutSystem();
			this.b.SetDockContainer(this);
			base.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
			base.SetStyle(ControlStyles.DoubleBuffer, true);
			base.SetStyle(ControlStyles.ResizeRedraw, true);
			base.SetStyle(ControlStyles.Selectable, false);
			this.c = new ArrayList();
			this.p = new k(this);
			this.AllowDrop = true;
			this.i = new TD.Util.a(this);
			this.i.a(false);
			this.i.a(new TD.Util.a.b(this.a));
		}

		protected internal virtual void OnShowControlContextMenu(ShowControlContextMenuEventArgs e)
		{
			if (this.w != null)
			{
				this.w(this, e);
			}
			if (this.Manager != null)
			{
				this.Manager.OnShowControlContextMenu(e);
			}
		}

		protected override void Dispose(bool disposing)
		{
			if (disposing)
			{
				this.LayoutSystem.SetDockContainer(null);
				this.LayoutSystem.Dispose();
				this.p.c();
				if (this.e != null)
				{
					this.e.Dispose();
					this.e = null;
				}
				this.Manager = null;
				this.i.b(new TD.Util.a.b(this.a));
				this.i.c();
			}
			base.Dispose(disposing);
		}

		[DefaultValue(true)]
		public override bool AllowDrop
		{
			get
			{
				return base.AllowDrop;
			}
			set
			{
				base.AllowDrop = value;
			}
		}

		[Browsable(false)]
		public override DockStyle Dock
		{
			get
			{
				return base.Dock;
			}
			set
			{
				base.Dock = value;
				Orientation orientation = Orientation.Horizontal;
				if (this.Dock == DockStyle.Top || this.Dock == DockStyle.Bottom)
				{
					orientation = Orientation.Vertical;
				}
				if (this.b.SplitMode != orientation)
				{
					this.b.SplitMode = orientation;
				}
			}
		}

		[Browsable(false)]
		public override string Text
		{
			get
			{
				return base.Text;
			}
			set
			{
				base.Text = value;
			}
		}

		[Browsable(false)]
		public override Cursor Cursor
		{
			get
			{
				return base.Cursor;
			}
			set
			{
				base.Cursor = value;
			}
		}

		[Browsable(false)]
		public override Image BackgroundImage
		{
			get
			{
				return base.BackgroundImage;
			}
			set
			{
				base.BackgroundImage = value;
			}
		}

		[Browsable(false)]
		public override Color BackColor
		{
			get
			{
				return base.BackColor;
			}
			set
			{
				base.BackColor = value;
			}
		}

		[Browsable(false)]
		public override Color ForeColor
		{
			get
			{
				return base.ForeColor;
			}
			set
			{
				base.ForeColor = value;
			}
		}

		internal bool HasSingleControlLayoutSystem
		{
			get
			{
				return this.LayoutSystem.LayoutSystems.Count == 1 && this.LayoutSystem.LayoutSystems[0] is ControlLayoutSystem;
			}
		}

		[Browsable(false)]
		public Guid Guid
		{
			get
			{
				return this.h;
			}
			set
			{
				this.h = value;
			}
		}

		[Description("Indicates the type of visual artifacts drawn to the screen to indicate size and position while docking.")]
		[DefaultValue(typeof(DockingHints), "TranslucentFill")]
		[Category("Appearance")]
		public DockingHints DockingHints
		{
			get
			{
				return this.f;
			}
			set
			{
				this.f = value;
			}
		}

		[Description("Indicates the method of user interaction during a docking operation.")]
		[DefaultValue(typeof(DockingManager), "Standard")]
		[Category("Behavior")]
		public DockingManager DockingManager
		{
			get
			{
				return this.g;
			}
			set
			{
				this.g = value;
			}
		}

		[Browsable(false)]
		[DefaultValue(typeof(WhidbeyRenderer), null)]
		[Category("Appearance")]
		[Description("The renderer used to calculate object metrics and draw contents.")]
		public virtual RendererBase Renderer
		{
			get
			{
				return this.d;
			}
			set
			{
				this.d = value;
				this.o();
			}
		}

		internal RendererBase WorkingRenderer
		{
			get
			{
				if (this.d != null)
				{
					return this.d;
				}
				if (this.a != null && this.a.Renderer != null)
				{
					return this.a.Renderer;
				}
				if (this.e == null)
				{
					this.e = new WhidbeyRenderer();
				}
				return this.e;
			}
		}

		internal k AutoHideManager
		{
			get
			{
				return this.p;
			}
		}

		internal Rectangle AutoHideBounds
		{
			get
			{
				return this.t;
			}
		}

		[Browsable(false)]
		[DefaultValue(false)]
		public bool AutoHideVisible
		{
			get
			{
				return this.q;
			}
		}

		internal int ContentSize
		{
			get
			{
				return this.s;
			}
		}

		internal bool Empty
		{
			get
			{
				return this.LayoutSystem.LayoutSystems.Count == 0;
			}
		}

		internal int CurrentSize
		{
			get
			{
				if (this.Vertical)
				{
					return this.n.Width;
				}
				return this.n.Height;
			}
		}

		[DefaultValue(true)]
		[Category("Behavior")]
		[Description("Indicates whether this container will allow the user to resize it.")]
		public bool Sizable
		{
			get
			{
				return this.o;
			}
			set
			{
				this.o = value;
				this.LayoutChildren();
			}
		}

		[Description("The smallest size this container will allow the user to choose.")]
		[DefaultValue(50)]
		[Category("Layout")]
		public new int MinimumSize
		{
			get
			{
				return this.j;
			}
			set
			{
				this.j = value;
			}
		}

		[DefaultValue(300)]
		[Description("The largest size this container will allow the user to choose.")]
		[Category("Layout")]
		public new int MaximumSize
		{
			get
			{
				return this.k;
			}
			set
			{
				this.k = value;
			}
		}

		[Browsable(false)]
		public bool Collapsed
		{
			get
			{
				return this.r;
			}
		}

		internal object a(Type A_0)
		{
			return this.GetService(A_0);
		}

		internal bool FriendDesignMode
		{
			get
			{
				return base.DesignMode;
			}
		}

		[Browsable(false)]
		public SandDockManager Manager
		{
			get
			{
				return this.a;
			}
			set
			{
				if (this.a != null)
				{
					this.a.b(this);
				}
				this.a = value;
				if (this.a != null)
				{
					this.a.a(this);
					DockControl[] array = this.r();
					foreach (DockControl dockControl in array)
					{
						if (dockControl.Manager != this.a)
						{
							dockControl.Manager = this.a;
						}
					}
				}
			}
		}

		protected override Size DefaultSize
		{
			get
			{
				return new Size(0, 0);
			}
		}

		[Browsable(false)]
		public virtual bool IsFloating
		{
			get
			{
				return false;
			}
		}

		internal bool Vertical
		{
			get
			{
				return this.Dock == DockStyle.Left || this.Dock == DockStyle.Right;
			}
		}

		[Browsable(false)]
		public virtual SplitLayoutSystem LayoutSystem
		{
			get
			{
				return this.b;
			}
			set
			{
				if (value == null)
				{
					throw new ArgumentNullException();
				}
				if (this.b != null)
				{
					this.b.SetDockContainer(null);
				}
				this.b = value;
				this.b.SetDockContainer(this);
				this.LayoutSystemsChanged();
			}
		}

		internal void b(LayoutSystemBase A_0)
		{
			float width = A_0.f.Width;
			float height = A_0.f.Height;
			switch (this.Dock)
			{
			case DockStyle.Top:
				this.a(this.LayoutSystem, true, A_0, Orientation.Horizontal);
				return;
			case DockStyle.Bottom:
				this.a(this.LayoutSystem, false, A_0, Orientation.Horizontal);
				return;
			case DockStyle.Left:
				this.a(this.LayoutSystem, true, A_0, Orientation.Vertical);
				return;
			case DockStyle.Right:
				this.a(this.LayoutSystem, false, A_0, Orientation.Vertical);
				return;
			default:
				return;
			}
		}

		private void a(SplitLayoutSystem A_0, bool A_1, LayoutSystemBase A_2, Orientation A_3)
		{
			int num = (A_2.f.Width < A_2.f.Height) ? ((int)A_2.f.Width) : ((int)A_2.f.Height);
			if (A_0.SplitMode == A_3)
			{
				if (A_1)
				{
					this.LayoutSystem.LayoutSystems.Add(A_2);
				}
				else
				{
					this.LayoutSystem.LayoutSystems.Insert(0, A_2);
				}
			}
			else if (A_0.LayoutSystems.Count == 1 && A_0.LayoutSystems[0] is SplitLayoutSystem && ((SplitLayoutSystem)A_0.LayoutSystems[0]).SplitMode == A_3)
			{
				SplitLayoutSystem splitLayoutSystem = (SplitLayoutSystem)A_0.LayoutSystems[0];
				if (A_1)
				{
					splitLayoutSystem.LayoutSystems.Add(A_2);
				}
				else
				{
					splitLayoutSystem.LayoutSystems.Insert(0, A_2);
				}
			}
			else
			{
				this.a(A_0, A_1, A_2);
			}
			if (A_0.SplitMode == Orientation.Horizontal)
			{
				base.Width += num + 4;
			}
			else
			{
				base.Height += num + 4;
			}
			this.w();
		}

		private void a(SplitLayoutSystem A_0, bool A_1, LayoutSystemBase A_2)
		{
			int num = (A_2.f.Width < A_2.f.Height) ? ((int)A_2.f.Width) : ((int)A_2.f.Height);
			Size size = A_0.Bounds.Size;
			checked
			{
				LayoutSystemBase[] array = new LayoutSystemBase[(uint)A_0.LayoutSystems.Count];
				A_0.LayoutSystems.CopyTo(array, 0);
				A_0.LayoutSystems.b = true;
				A_0.LayoutSystems.Clear();
				if (array.Length == 1 && array[0] is SplitLayoutSystem)
				{
					SplitLayoutSystem splitLayoutSystem = (SplitLayoutSystem)array[0];
					array = new LayoutSystemBase[(uint)splitLayoutSystem.LayoutSystems.Count];
					splitLayoutSystem.LayoutSystems.CopyTo(array, 0);
					splitLayoutSystem.LayoutSystems.Clear();
				}
				SplitLayoutSystem splitLayoutSystem2 = new SplitLayoutSystem(size.Width, size.Height, A_0.SplitMode, array);
				Orientation splitMode = (A_0.SplitMode == Orientation.Horizontal) ? Orientation.Vertical : Orientation.Horizontal;
				A_2.f = new SizeF((float)num, (float)num);
				SplitLayoutSystem layoutSystem;
				if (A_1)
				{
					layoutSystem = new SplitLayoutSystem(0, 0, splitMode, new LayoutSystemBase[]
					{
						splitLayoutSystem2,
						A_2
					});
				}
				else
				{
					layoutSystem = new SplitLayoutSystem(0, 0, splitMode, new LayoutSystemBase[]
					{
						A_2,
						splitLayoutSystem2
					});
				}
				A_0.LayoutSystems.Add(layoutSystem);
				A_0.LayoutSystems.b = false;
				this.LayoutSystemsChanged(true, false);
			}
		}

		internal void m()
		{
			this.AutoHideManager.a(true);
			this.b.SetDockContainer(null);
			foreach (object obj in this.c)
			{
				LayoutSystemBase layoutSystemBase = (LayoutSystemBase)obj;
				if (layoutSystemBase is ControlLayoutSystem)
				{
					((ControlLayoutSystem)layoutSystemBase).Controls.Clear();
				}
			}
			SplitLayoutSystem splitLayoutSystem = this.b;
			this.b = new SplitLayoutSystem();
			splitLayoutSystem.Dispose();
		}

		internal DockControl[] r()
		{
			ArrayList arrayList = new ArrayList();
			foreach (object obj in this.c)
			{
				LayoutSystemBase layoutSystemBase = (LayoutSystemBase)obj;
				if (layoutSystemBase is ControlLayoutSystem)
				{
					ControlLayoutSystem controlLayoutSystem = (ControlLayoutSystem)layoutSystemBase;
					foreach (object obj2 in controlLayoutSystem.Controls)
					{
						DockControl value = (DockControl)obj2;
						arrayList.Add(value);
					}
				}
			}
			DockControl[] array = new DockControl[checked((uint)arrayList.Count)];
			arrayList.CopyTo(array);
			return array;
		}

		internal void o()
		{
			this.LayoutChildren();
		}

		[Browsable(false)]
		public bool CanShowCollapsed
		{
			get
			{
				return this.Dock == DockStyle.Left || this.Dock == DockStyle.Top || this.Dock == DockStyle.Right || this.Dock == DockStyle.Bottom;
			}
		}

		protected override void OnFontChanged(EventArgs e)
		{
			base.OnFontChanged(e);
			this.LayoutChildren();
		}

		internal void b(Size A_0)
		{
			if (this.s < this.j)
			{
				if (this.Vertical)
				{
					this.s = A_0.Width;
				}
				else
				{
					this.s = A_0.Height;
				}
				if (this.s < this.j)
				{
					this.s = this.j;
				}
				if (this.s > this.k)
				{
					this.s = this.k;
				}
			}
		}

		public LayoutSystemBase GetLayoutSystemAt(Point position)
		{
			LayoutSystemBase layoutSystemBase = null;
			foreach (object obj in this.c)
			{
				LayoutSystemBase layoutSystemBase2 = (LayoutSystemBase)obj;
				if (layoutSystemBase2.Bounds.Contains(position) && (!(layoutSystemBase2 is ControlLayoutSystem) || !((ControlLayoutSystem)layoutSystemBase2).Collapsed))
				{
					layoutSystemBase = layoutSystemBase2;
					if (layoutSystemBase is ControlLayoutSystem)
					{
						break;
					}
				}
			}
			return layoutSystemBase;
		}

		internal virtual void LayoutSystemsChanged()
		{
			this.LayoutSystemsChanged(false, false);
		}

		internal virtual void LayoutSystemsChanged(bool skipResize, bool skipOptimize)
		{
			this.c.Clear();
			this.x = null;
			this.a(this.b);
			if (!skipResize)
			{
				this.w();
			}
			if (!skipOptimize)
			{
				Application.Idle += this.b;
			}
		}

		private void b(object A_0, EventArgs A_1)
		{
			Application.Idle -= this.b;
			bool flag = false;
			for (;;)
			{
				bool flag2 = this.LayoutSystem.Optimize();
				if (!flag2)
				{
					break;
				}
				flag = true;
			}
			if (flag)
			{
				this.LayoutSystemsChanged(true, true);
			}
		}

		private void a(LayoutSystemBase A_0)
		{
			this.c.Add(A_0);
			if (A_0 is SplitLayoutSystem)
			{
				foreach (object obj in ((SplitLayoutSystem)A_0).LayoutSystems)
				{
					LayoutSystemBase a_ = (LayoutSystemBase)obj;
					this.a(a_);
				}
			}
		}

		internal void w()
		{
			ArrayList arrayList = new ArrayList();
			this.a(arrayList, this.b);
			bool flag = false;
			bool flag2 = false;
			foreach (object obj in arrayList)
			{
				ControlLayoutSystem controlLayoutSystem = (ControlLayoutSystem)obj;
				if (controlLayoutSystem.Collapsed && this.CanShowCollapsed)
				{
					flag2 = true;
				}
				else
				{
					flag = true;
				}
			}
			this.q = flag2;
			this.r = (flag2 && !flag);
			if (this.Dock != DockStyle.None && this.Dock != DockStyle.Fill)
			{
				int num = 0;
				if (this.q)
				{
					num += TD.SandDock.k.a();
				}
				if (!this.r && flag)
				{
					num += this.s + (this.Sizable ? 4 : 0);
				}
				if (this.Vertical)
				{
					base.Width = num;
				}
				else
				{
					base.Height = num;
				}
			}
			this.LayoutChildren();
		}

		protected override void OnHandleCreated(EventArgs e)
		{
			base.OnHandleCreated(e);
			this.LayoutChildren();
		}

		internal void a(LayoutSystemBase A_0, Rectangle A_1)
		{
			if (!base.IsHandleCreated)
			{
				return;
			}
			using (Graphics graphics = base.CreateGraphics())
			{
				if (A_0 == this.b)
				{
					A_0.Layout(this.WorkingRenderer, graphics, A_1, this.IsFloating);
				}
				else
				{
					A_0.Layout(this.WorkingRenderer, graphics, A_1, false);
				}
				if (this.q)
				{
					this.p.a(this.WorkingRenderer, graphics, this.t);
				}
			}
		}

		internal void u()
		{
			this.LayoutChildren();
		}

		public void LayoutChildren()
		{
			this.n = this.DisplayRectangle;
			int num = TD.SandDock.k.a();
			if (this.q)
			{
				switch (this.Dock)
				{
				case DockStyle.Top:
					this.t = new Rectangle(this.n.Location, new Size(this.n.Width, num));
					this.n.Offset(0, num);
					this.n.Height = this.n.Height - num;
					break;
				case DockStyle.Bottom:
					this.t = new Rectangle(this.n.Left, this.n.Bottom - num, this.n.Width, num);
					this.n.Height = this.n.Height - num;
					break;
				case DockStyle.Left:
					this.t = new Rectangle(this.n.Location, new Size(num, this.n.Height));
					this.n.Offset(num, 0);
					this.n.Width = this.n.Width - num;
					break;
				case DockStyle.Right:
					this.t = new Rectangle(this.n.Right - num, this.n.Top, num, this.n.Height);
					this.n.Width = this.n.Width - num;
					break;
				}
			}
			else
			{
				this.t = Rectangle.Empty;
			}
			if (this.o)
			{
				switch (this.Dock)
				{
				case DockStyle.Top:
					this.m = new Rectangle(this.n.Left, this.n.Bottom - 4, this.n.Width, 4);
					this.n.Height = this.n.Height - 4;
					break;
				case DockStyle.Bottom:
					this.m = new Rectangle(this.n.Left, this.n.Top, this.n.Width, 4);
					this.n.Offset(0, 4);
					this.n.Height = this.n.Height - 4;
					break;
				case DockStyle.Left:
					this.m = new Rectangle(this.n.Right - 4, this.n.Top, 4, this.n.Height);
					this.n.Width = this.n.Width - 4;
					break;
				case DockStyle.Right:
					this.m = new Rectangle(this.n.Left, this.n.Top, 4, this.n.Height);
					this.n.Offset(4, 0);
					this.n.Width = this.n.Width - 4;
					break;
				default:
					this.m = Rectangle.Empty;
					break;
				}
			}
			else
			{
				this.m = Rectangle.Empty;
			}
			if (!this.r)
			{
				if (this.Vertical)
				{
					if (this.n.Width > 0)
					{
						this.s = this.n.Width;
					}
				}
				else if (this.n.Height > 0)
				{
					this.s = this.n.Height;
				}
			}
			this.a(this.b, this.n);
			base.Invalidate();
		}

		private void a(ArrayList A_0, SplitLayoutSystem A_1)
		{
			foreach (object obj in A_1.LayoutSystems)
			{
				LayoutSystemBase layoutSystemBase = (LayoutSystemBase)obj;
				if (layoutSystemBase is ControlLayoutSystem)
				{
					A_0.Add(layoutSystemBase);
				}
				else
				{
					this.a(A_0, (SplitLayoutSystem)layoutSystemBase);
				}
			}
		}

		protected override void OnResize(EventArgs e)
		{
			base.OnResize(e);
			this.LayoutChildren();
		}

		protected override void OnMouseLeave(EventArgs e)
		{
			base.OnMouseLeave(e);
			if (this.x != null)
			{
				this.x.OnMouseLeave();
				this.x = null;
			}
			this.Cursor = Cursors.Default;
		}

		protected override void OnDoubleClick(EventArgs e)
		{
			base.OnDoubleClick(e);
			if (this.x != null)
			{
				this.x.OnMouseDoubleClick();
			}
		}

		protected override void OnMouseDown(MouseEventArgs e)
		{
			base.OnMouseDown(e);
			if (this.x != null)
			{
				this.x.OnMouseDown(e);
				return;
			}
			if (this.t.Contains(e.X, e.Y))
			{
				this.p.c(e);
				return;
			}
			if (this.m.Contains(e.X, e.Y) && this.Manager != null && e.Button == MouseButtons.Left)
			{
				if (this.l != null)
				{
					this.l.b();
				}
				this.l = new h(this.Manager, this, new Point(e.X, e.Y));
				this.l.a(new EventHandler(this.a));
				this.l.b(new h.a(this.a));
			}
		}

		protected override void OnMouseUp(MouseEventArgs e)
		{
			base.OnMouseUp(e);
			if (this.x != null)
			{
				this.x.OnMouseUp(e);
				return;
			}
			if (this.l != null)
			{
				this.l.a();
				return;
			}
			if (this.t.Contains(e.X, e.Y))
			{
				this.p.b(e);
				return;
			}
		}

		protected override void OnDragOver(DragEventArgs drgevent)
		{
			base.OnDragOver(drgevent);
			Point point = base.PointToClient(new Point(drgevent.X, drgevent.Y));
			if (this.t.Contains(point))
			{
				this.p.b(point);
				return;
			}
			LayoutSystemBase layoutSystemAt = this.GetLayoutSystemAt(point);
			if (layoutSystemAt != null)
			{
				layoutSystemAt.OnDragOver(drgevent);
			}
		}

		protected override void OnMouseMove(MouseEventArgs e)
		{
			base.OnMouseMove(e);
			if (base.Capture)
			{
				if (this.x != null)
				{
					this.x.OnMouseMove(e);
					return;
				}
				if (this.l != null)
				{
					this.l.a(new Point(e.X, e.Y));
				}
				return;
			}
			else
			{
				if (this.t.Contains(e.X, e.Y))
				{
					this.p.d(e);
					return;
				}
				LayoutSystemBase layoutSystemAt = this.GetLayoutSystemAt(new Point(e.X, e.Y));
				if (layoutSystemAt != null)
				{
					if (this.x != null && this.x != layoutSystemAt)
					{
						this.x.OnMouseLeave();
					}
					layoutSystemAt.OnMouseMove(e);
					this.x = layoutSystemAt;
					return;
				}
				if (this.x != null)
				{
					this.x.OnMouseLeave();
					this.x = null;
				}
				if (!this.m.Contains(e.X, e.Y))
				{
					this.Cursor = Cursors.Default;
					return;
				}
				if (this.Vertical)
				{
					this.Cursor = Cursors.VSplit;
					return;
				}
				this.Cursor = Cursors.HSplit;
				return;
			}
		}

		protected override void OnPaint(PaintEventArgs e)
		{
			try
			{
				this.WorkingRenderer.StartRenderSession();
				if (!this.r)
				{
					this.b.Paint(this.WorkingRenderer, e.Graphics, this.Font);
				}
				if (this.q)
				{
					this.p.a(e.Graphics, this.t);
				}
				if (this.o && !this.r)
				{
					this.WorkingRenderer.DrawSplitter(e.Graphics, this.m, (this.Dock == DockStyle.Top || this.Dock == DockStyle.Bottom) ? Orientation.Horizontal : Orientation.Vertical);
				}
				this.WorkingRenderer.FinishRenderSession();
			}
			catch
			{
			}
		}

		protected override void OnPaintBackground(PaintEventArgs pevent)
		{
			this.WorkingRenderer.DrawDockContainerBackground(pevent.Graphics, this.DisplayRectangle);
		}

		internal void c(object A_0, EventArgs A_1)
		{
			foreach (object obj in this.c)
			{
				LayoutSystemBase layoutSystemBase = (LayoutSystemBase)obj;
				if (layoutSystemBase is ControlLayoutSystem)
				{
					ControlLayoutSystem controlLayoutSystem = (ControlLayoutSystem)layoutSystemBase;
					if (controlLayoutSystem.i())
					{
						break;
					}
				}
			}
		}

		internal void d(object A_0, EventArgs A_1)
		{
			foreach (object obj in this.c)
			{
				LayoutSystemBase layoutSystemBase = (LayoutSystemBase)obj;
				if (layoutSystemBase is ControlLayoutSystem)
				{
					((ControlLayoutSystem)layoutSystemBase).g();
				}
			}
		}

		private void a()
		{
			this.l.b(new EventHandler(this.a));
			this.l.a(new h.a(this.a));
			this.l = null;
		}

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

		private void a(int A_0)
		{
			this.a();
			if (this.Vertical)
			{
				base.Width = A_0;
				return;
			}
			base.Height = A_0;
		}

		internal ControlLayoutSystem b(SplitLayoutSystem A_0)
		{
			foreach (object obj in A_0.LayoutSystems)
			{
				LayoutSystemBase layoutSystemBase = (LayoutSystemBase)obj;
				if (layoutSystemBase is ControlLayoutSystem)
				{
					return (ControlLayoutSystem)layoutSystemBase;
				}
				if (layoutSystemBase is SplitLayoutSystem)
				{
					ControlLayoutSystem controlLayoutSystem = this.b((SplitLayoutSystem)layoutSystemBase);
					if (controlLayoutSystem != null)
					{
						return controlLayoutSystem;
					}
				}
			}
			return null;
		}

		protected internal virtual void OnDockingStarted(EventArgs e)
		{
			if (this.u != null)
			{
				this.u(this, e);
			}
			if (this.Manager != null)
			{
				this.Manager.OnDockingStarted(e);
			}
		}

		protected internal virtual void OnDockingFinished(EventArgs e)
		{
			if (this.v != null)
			{
				this.v(this, e);
			}
			if (this.Manager != null)
			{
				this.Manager.OnDockingFinished(e);
			}
		}

		private string a(Point A_0)
		{
			LayoutSystemBase layoutSystemAt = this.GetLayoutSystemAt(A_0);
			if (layoutSystemAt is ControlLayoutSystem)
			{
				return ((ControlLayoutSystem)layoutSystemAt).GetToolTipText(A_0);
			}
			return "";
		}

		private SandDockManager a = null;

		private SplitLayoutSystem b = null;

		internal ArrayList c = null;

		private RendererBase d = null;

		private RendererBase e;

		private DockingHints f = DockingHints.TranslucentFill;

		private DockingManager g = DockingManager.Standard;

		private Guid h = Guid.NewGuid();

		private TD.Util.a i = null;

		private int j = 50;

		private int k = 300;

		private h l = null;

		private Rectangle m = Rectangle.Empty;

		private Rectangle n = Rectangle.Empty;

		private bool o = true;

		private k p = null;

		private bool q = false;

		private bool r = false;

		private int s = 0;

		private Rectangle t = Rectangle.Empty;

		private EventHandler u;

		private EventHandler v;

		private ShowControlContextMenuEventHandler w;

		internal LayoutSystemBase x = null;
	}
}
