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
	{
		private SandDockManager m_a = null;

		private SplitLayoutSystem m_b = null;

		internal ArrayList c = null;

		private RendererBase m_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_m = Rectangle.Empty;

		private Rectangle n = Rectangle.Empty;

		private bool m_o = true;

		private k p = null;

		private bool q = false;

		private bool m_r = false;

		private int s = 0;

		private Rectangle t = Rectangle.Empty;

		private EventHandler m_u;

		private EventHandler v;

		private ShowControlContextMenuEventHandler m_w;

		internal LayoutSystemBase x = null;

		[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 (Dock == DockStyle.Top || Dock == DockStyle.Bottom)
				{
					orientation = Orientation.Vertical;
				}
				if (this.m_b.SplitMode != orientation)
				{
					this.m_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
			{
				if (LayoutSystem.LayoutSystems.Count == 1)
				{
					return LayoutSystem.LayoutSystems[0] is ControlLayoutSystem;
				}
				return false;
			}
		}

		[Browsable(false)]
		public Guid Guid
		{
			get
			{
				return h;
			}
			set
			{
				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 f;
			}
			set
			{
				f = value;
			}
		}

		[Description("Indicates the method of user interaction during a docking operation.")]
		[DefaultValue(typeof(DockingManager), "Standard")]
		[Category("Behavior")]
		public DockingManager DockingManager
		{
			get
			{
				return g;
			}
			set
			{
				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.m_d;
			}
			set
			{
				this.m_d = value;
				o();
			}
		}

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

		internal k AutoHideManager => p;

		internal Rectangle AutoHideBounds => t;

		[Browsable(false)]
		[DefaultValue(false)]
		public bool AutoHideVisible => q;

		internal int ContentSize => s;

		internal bool Empty => LayoutSystem.LayoutSystems.Count == 0;

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

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

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

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

		[Browsable(false)]
		public bool Collapsed => this.m_r;

		internal bool FriendDesignMode => base.DesignMode;

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

		protected override Size DefaultSize => new Size(0, 0);

		[Browsable(false)]
		public virtual bool IsFloating => false;

		internal bool Vertical
		{
			get
			{
				if (Dock != DockStyle.Left)
				{
					return Dock == DockStyle.Right;
				}
				return true;
			}
		}

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

		[Browsable(false)]
		public bool CanShowCollapsed
		{
			get
			{
				if (Dock != DockStyle.Left && Dock != DockStyle.Top && Dock != DockStyle.Right)
				{
					return Dock == DockStyle.Bottom;
				}
				return true;
			}
		}

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

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

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

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

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

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

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

		internal void b(LayoutSystemBase A_0)
		{
			_ = A_0.f.Width;
			_ = A_0.f.Height;
			switch (Dock)
			{
			case DockStyle.Right:
				a(LayoutSystem, A_1: false, A_0, Orientation.Vertical);
				break;
			case DockStyle.Left:
				a(LayoutSystem, A_1: true, A_0, Orientation.Vertical);
				break;
			case DockStyle.Top:
				a(LayoutSystem, A_1: true, A_0, Orientation.Horizontal);
				break;
			case DockStyle.Bottom:
				a(LayoutSystem, A_1: false, A_0, Orientation.Horizontal);
				break;
			}
		}

		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)
				{
					LayoutSystem.LayoutSystems.Add(A_2);
				}
				else
				{
					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
			{
				a(A_0, A_1, A_2);
			}
			if (A_0.SplitMode == Orientation.Horizontal)
			{
				base.Width += num + 4;
			}
			else
			{
				base.Height += num + 4;
			}
			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);
				ref SizeF reference = ref A_2.f;
				reference = new SizeF(num, num);
				SplitLayoutSystem layoutSystem = ((!A_1) ? new SplitLayoutSystem(0, 0, splitMode, new LayoutSystemBase[2] { A_2, splitLayoutSystem2 }) : new SplitLayoutSystem(0, 0, splitMode, new LayoutSystemBase[2] { splitLayoutSystem2, A_2 }));
				A_0.LayoutSystems.Add(layoutSystem);
				A_0.LayoutSystems.b = false;
				LayoutSystemsChanged(skipResize: true, skipOptimize: false);
			}
		}

		internal void m()
		{
			AutoHideManager.a(A_0: true);
			this.m_b.SetDockContainer(null);
			foreach (LayoutSystemBase item in this.c)
			{
				if (item is ControlLayoutSystem)
				{
					((ControlLayoutSystem)item).Controls.Clear();
				}
			}
			SplitLayoutSystem splitLayoutSystem = this.m_b;
			this.m_b = new SplitLayoutSystem();
			splitLayoutSystem.Dispose();
		}

		internal DockControl[] r()
		{
			ArrayList arrayList = new ArrayList();
			foreach (LayoutSystemBase item in this.c)
			{
				if (!(item is ControlLayoutSystem))
				{
					continue;
				}
				ControlLayoutSystem controlLayoutSystem = (ControlLayoutSystem)item;
				foreach (DockControl control in controlLayoutSystem.Controls)
				{
					arrayList.Add(control);
				}
			}
			DockControl[] array = new DockControl[checked((uint)arrayList.Count)];
			arrayList.CopyTo(array);
			return array;
		}

		internal void o()
		{
			LayoutChildren();
		}

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

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

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

		internal virtual void LayoutSystemsChanged()
		{
			LayoutSystemsChanged(skipResize: false, skipOptimize: false);
		}

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

		private void b(object A_0, EventArgs A_1)
		{
			Application.Idle -= b;
			bool flag = false;
			bool flag2 = false;
			while (LayoutSystem.Optimize())
			{
				flag2 = true;
			}
			if (flag2)
			{
				LayoutSystemsChanged(skipResize: true, skipOptimize: true);
			}
		}

		private void a(LayoutSystemBase A_0)
		{
			this.c.Add(A_0);
			if (!(A_0 is SplitLayoutSystem))
			{
				return;
			}
			foreach (LayoutSystemBase layoutSystem in ((SplitLayoutSystem)A_0).LayoutSystems)
			{
				a(layoutSystem);
			}
		}

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

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

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

		internal void u()
		{
			LayoutChildren();
		}

		public void LayoutChildren()
		{
			n = DisplayRectangle;
			int num = TD.SandDock.k.a();
			if (q)
			{
				switch (Dock)
				{
				case DockStyle.Left:
				{
					ref Rectangle reference4 = ref t;
					reference4 = new Rectangle(n.Location, new Size(num, n.Height));
					n.Offset(num, 0);
					n.Width -= num;
					break;
				}
				case DockStyle.Right:
				{
					ref Rectangle reference3 = ref t;
					reference3 = new Rectangle(n.Right - num, n.Top, num, n.Height);
					n.Width -= num;
					break;
				}
				case DockStyle.Top:
				{
					ref Rectangle reference2 = ref t;
					reference2 = new Rectangle(n.Location, new Size(n.Width, num));
					n.Offset(0, num);
					n.Height -= num;
					break;
				}
				case DockStyle.Bottom:
				{
					ref Rectangle reference = ref t;
					reference = new Rectangle(n.Left, n.Bottom - num, n.Width, num);
					n.Height -= num;
					break;
				}
				}
			}
			else
			{
				t = Rectangle.Empty;
			}
			if (this.m_o)
			{
				switch (Dock)
				{
				case DockStyle.Left:
				{
					ref Rectangle reference8 = ref this.m_m;
					reference8 = new Rectangle(n.Right - 4, n.Top, 4, n.Height);
					n.Width -= 4;
					break;
				}
				case DockStyle.Right:
				{
					ref Rectangle reference7 = ref this.m_m;
					reference7 = new Rectangle(n.Left, n.Top, 4, n.Height);
					n.Offset(4, 0);
					n.Width -= 4;
					break;
				}
				case DockStyle.Top:
				{
					ref Rectangle reference6 = ref this.m_m;
					reference6 = new Rectangle(n.Left, n.Bottom - 4, n.Width, 4);
					n.Height -= 4;
					break;
				}
				case DockStyle.Bottom:
				{
					ref Rectangle reference5 = ref this.m_m;
					reference5 = new Rectangle(n.Left, n.Top, n.Width, 4);
					n.Offset(0, 4);
					n.Height -= 4;
					break;
				}
				default:
					this.m_m = Rectangle.Empty;
					break;
				}
			}
			else
			{
				this.m_m = Rectangle.Empty;
			}
			if (!this.m_r)
			{
				if (Vertical)
				{
					if (n.Width > 0)
					{
						s = n.Width;
					}
				}
				else if (n.Height > 0)
				{
					s = n.Height;
				}
			}
			a(this.m_b, n);
			Invalidate();
		}

		private void a(ArrayList A_0, SplitLayoutSystem A_1)
		{
			foreach (LayoutSystemBase layoutSystem in A_1.LayoutSystems)
			{
				if (layoutSystem is ControlLayoutSystem)
				{
					A_0.Add(layoutSystem);
				}
				else
				{
					a(A_0, (SplitLayoutSystem)layoutSystem);
				}
			}
		}

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

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

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

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

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

		protected override void OnDragOver(DragEventArgs drgevent)
		{
			base.OnDragOver(drgevent);
			Point point = PointToClient(new Point(drgevent.X, drgevent.Y));
			if (t.Contains(point))
			{
				p.b(point);
			}
			else
			{
				GetLayoutSystemAt(point)?.OnDragOver(drgevent);
			}
		}

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

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

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

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

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

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

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

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

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

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

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

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