context: using System;
  using System.Collections;
  using System.Windows.Forms;
  using System.Drawing;
  using System.Drawing.Drawing2D;
  using System.Collections.Generic;
  using System.Diagnostics.CodeAnalysis;
  
  namespace WeifenLuo.WinFormsUI.Docking
  {
  	public abstract partial class AutoHideStripBase : Control
  	{
          [SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
          protected class Tab : IDisposable
          {
              private IDockContent m_content;
  
              protected internal Tab(IDockContent content)
              {
                  m_content = content;
              }
  
              public IDockContent Content
              {
                  get { return m_content; }
              }
  
              public virtual void Dispose()
              {
              }
          }
  
          [SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
          protected sealed class TabCollection : IEnumerable<Tab>
          {
              #region IEnumerable Members
              IEnumerator<Tab> IEnumerable<Tab>.GetEnumerator()
              {
                  for (int i = 0; i < Count; i++)
                      yield return this[i];
              }
  
              IEnumerator IEnumerable.GetEnumerator()
              {
                  for (int i = 0; i < Count; i++)
                      yield return this[i];
              }
              #endregion
  
              internal TabCollection(DockPane pane)
              {
                  m_dockPane = pane;
              }
  
              private DockPane m_dockPane = null;
              public DockPane DockPane
              {
                  get { return m_dockPane; }
              }
  
              public DockPanel DockPanel
              {
                  get { return DockPane.DockPanel; }
              }
  
              public int Count
              {
                  get { return DockPane.DisplayingContents.Count; }
              }
  
              public Tab this[int index]
              {
                  get
                  {
                      IDockContent content = DockPane.DisplayingContents[index];
                      if (content == null)
                          throw (new ArgumentOutOfRangeException("index"));
                      if (content.DockHandler.AutoHideTab == null)
                          content.DockHandler.AutoHideTab = (DockPanel.AutoHideStripControl.CreateTab(content));
                      return content.DockHandler.AutoHideTab as Tab;
                  }
              }
  
              public bool Contains(Tab tab)
              {
                  return (IndexOf(tab) != -1);
              }
  
              public bool Contains(IDockContent content)
              {
                  return (IndexOf(content) != -1);
              }
  
              public int IndexOf(Tab tab)
              {
                  if (tab == null)
                      return -1;
  
                  return IndexOf(tab.Content);
              }
  
              public int IndexOf(IDockContent content)
              {
                  return DockPane.DisplayingContents.IndexOf(content);
              }
          }
  
          [SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
          protected class Pane : IDisposable
          {
              private DockPane m_dockPane;
  
              protected internal Pane(DockPane dockPane)
              {
                  m_dockPane = dockPane;
              }
  
              public DockPane DockPane
              {
                  get { return m_dockPane; }
              }
  
              public TabCollection AutoHideTabs
              {
                  get
                  {
                      if (DockPane.AutoHideTabs == null)
                          DockPane.AutoHideTabs = new TabCollection(DockPane);
                      return DockPane.AutoHideTabs as TabCollection;
                  }
              }
  
              public virtual void Dispose()
              {
              }
          }
  
          [SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
          protected sealed class PaneCollection : IEnumerable<Pane>
          {
              private class AutoHideState
              {
                  public DockState m_dockState;
                  public bool m_selected = false;
  
                  public AutoHideState(DockState dockState)
                  {
                      m_dockState = dockState;
                  }
  
                  public DockState DockState
                  {
                      get { return m_dockState; }
                  }
  
                  public bool Selected
                  {
                      get { return m_selected; }
                      set { m_selected = value; }
                  }
              }
  
              private class AutoHideStateCollection
              {
                  private AutoHideState[] m_states;
  
                  public AutoHideStateCollection()
                  {
                      m_states = new AutoHideState[]	{	
  												new AutoHideState(DockState.DockTopAutoHide),
  												new AutoHideState(DockState.DockBottomAutoHide),
  												new AutoHideState(DockState.DockLeftAutoHide),
  												new AutoHideState(DockState.DockRightAutoHide)
  											};
                  }
  
                  public AutoHideState this[DockState dockState]
                  {
                      get
                      {
                          for (int i = 0; i < m_states.Length; i++)
                          {
                              if (m_states[i].DockState == dockState)
                                  return m_states[i];
                          }
                          throw new ArgumentOutOfRangeException("dockState");
                      }
                  }
  
                  public bool ContainsPane(DockPane pane)
                  {
                      if (pane.IsHidden)
                          return false;
  
                      for (int i = 0; i < m_states.Length; i++)
                      {
                          if (m_states[i].DockState == pane.DockState && m_states[i].Selected)
                              return true;
                      }
                      return false;
                  }
              }
  
              internal PaneCollection(DockPanel panel, DockState dockState)
              {
                  m_dockPanel = panel;
                  m_states = new AutoHideStateCollection();
                  States[DockState.DockTopAutoHide].Selected = (dockState == DockState.DockTopAutoHide);
                  States[DockState.DockBottomAutoHide].Selected = (dockState == DockState.DockBottomAutoHide);
                  States[DockState.DockLeftAutoHide].Selected = (dockState == DockState.DockLeftAutoHide);
                  States[DockState.DockRightAutoHide].Selected = (dockState == DockState.DockRightAutoHide);
              }
  
              private DockPanel m_dockPanel;
              public DockPanel DockPanel
              {
                  get { return m_dockPanel; }
              }
  
              private AutoHideStateCollection m_states;
              private AutoHideStateCollection States
              {
                  get { return m_states; }
              }
  
              public int Count
              {
                  get
                  {
                      int count = 0;
                      foreach (DockPane pane in DockPanel.Panes)
                      {
                          if (States.ContainsPane(pane))
                              count++;
                      }
  
                      return count;
                  }
              }
  
              public Pane this[int index]
              {
                  get
                  {
                      int count = 0;
                      foreach (DockPane pane in DockPanel.Panes)
                      {
                          if (!States.ContainsPane(pane))
                              continue;
  
                          if (count == index)
                          {
                              if (pane.AutoHidePane == null)
                                  pane.AutoHidePane = DockPanel.AutoHideStripControl.CreatePane(pane);
                              return pane.AutoHidePane as Pane;
                          }
  
                          count++;
                      }
                      throw new ArgumentOutOfRangeException("index");
                  }
              }
  
              public bool Contains(Pane pane)
              {
                  return (IndexOf(pane) != -1);
              }
  
              public int IndexOf(Pane pane)
              {
                  if (pane == null)
                      return -1;
  
                  int index = 0;
                  foreach (DockPane dockPane in DockPanel.Panes)
                  {
                      if (!States.ContainsPane(pane.DockPane))
                          continue;
  
                      if (pane == dockPane.AutoHidePane)
                          return index;
  
                      index++;
                  }
                  return -1;
              }
  
              #region IEnumerable Members
  
              IEnumerator<Pane> IEnumerable<Pane>.GetEnumerator()
              {
                  for (int i = 0; i < Count; i++)
                      yield return this[i];
              }
  
              IEnumerator IEnumerable.GetEnumerator()
              {
                  for (int i = 0; i < Count; i++)
                      yield return this[i];
              }
  
              #endregion
          }
  
  		protected AutoHideStripBase(DockPanel panel)
  		{
  			m_dockPanel = panel;
  			m_panesTop = new PaneCollection(panel, DockState.DockTopAutoHide);
  			m_panesBottom = new PaneCollection(panel, DockState.DockBottomAutoHide);
  			m_panesLeft = new PaneCollection(panel, DockState.DockLeftAutoHide);
  			m_panesRight = new PaneCollection(panel, DockState.DockRightAutoHide);
  
  			SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
  			SetStyle(ControlStyles.Selectable, false);
  		}
  
  		private DockPanel m_dockPanel;
  		protected DockPanel DockPanel
  		{
  			get	{	return m_dockPanel;	}
  		}
  
  		private PaneCollection m_panesTop;
  		protected PaneCollection PanesTop
  		{
  			get	{	return m_panesTop;	}
  		}
  
  		private PaneCollection m_panesBottom;
  		protected PaneCollection PanesBottom
  		{
  
gt: 			get	{	return m_panesBottom;	}