Beispiel #1
0
        /// <summary>
        /// Docks the bar to the specified side of the reference bar.
        /// </summary>
        /// <param name="barToDock">Bar to dock.</param>
        /// <param name="referenceBar">Reference bar.</param>
        /// <param name="dockToReferenceBarSide">Side of the reference bar to dock the bar to.</param>
        public void Dock(Bar barToDock, Bar referenceBar, eDockSide dockToReferenceBarSide)
        {
            if (dockToReferenceBarSide == eDockSide.None)
                throw new ArgumentException("eDockSide.None is not supported value for dockToReferenceBarSide parameter. Use Float method to make floating bar.");
            if (referenceBar.DockSide == eDockSide.None)
                throw new ArgumentException("referenceBar must be docked to be used as reference for docking.");

            if (barToDock.LayoutType != eLayoutType.DockContainer)
            {
                barToDock.DockSide = dockToReferenceBarSide;
                return;
            }

            if (dockToReferenceBarSide == eDockSide.Document)
            {
                System.Collections.ArrayList list = new System.Collections.ArrayList(barToDock.Items.Count);
                barToDock.Items.CopyTo(list);
                DockContainerItem firstItem = null;
                foreach (BaseItem item in list)
                {
                    DockContainerItem dockitem = item as DockContainerItem;
                    if (dockitem != null)
                    {
                        if (firstItem == null) firstItem = dockitem;
                        dockitem.Displayed = false;
                        if (dockitem.OriginalBarName == "")
                        {
                            dockitem.OriginalBarName = barToDock.Name;
                            dockitem.OriginalPosition = barToDock.Items.IndexOf(dockitem);
                        }
                        barToDock.Items.Remove(dockitem);
                        referenceBar.Items.Add(dockitem);
                    }
                }
                referenceBar.RecalcLayout();

                if (firstItem != null)
                    referenceBar.SelectedDockContainerItem = firstItem;
                referenceBar.InvokeBarDockEvents();

                if (barToDock.CustomBar)
                {
                    this.Bars.Remove(barToDock);
                    barToDock.Dispose();
                }
                else
                {
                    barToDock.Visible = false;
                }
            }
            else
            {
                DocumentDockUIManager dockManager = GetDocumentUIManager(referenceBar.DockSide);
                if (!this.Bars.Contains(barToDock))
                    this.Bars.Add(barToDock);
                dockManager.Dock(referenceBar, barToDock, dockToReferenceBarSide);
            }
        }