Beispiel #1
0
        /// <include file='CodeDoc\DockPanel.xml' path='//CodeDoc/Class[@name="DockPanel"]/Method[@name="SetPaneIndex(DockPane, int)"]/*'/>
        public void SetPaneIndex(DockPane pane, int index)
        {
            int oldIndex = Panes.IndexOf(pane);

            if (oldIndex == -1)
            {
                throw(new ArgumentException(ResourceHelper.GetString("DockPanel.SetPaneIndex.InvalidPane")));
            }

            if (index < 0 || index > Panes.Count - 1)
            {
                if (index != -1)
                {
                    throw(new ArgumentOutOfRangeException(ResourceHelper.GetString("DockPanel.SetPaneIndex.InvalidIndex")));
                }
            }

            if (oldIndex == index)
            {
                return;
            }
            if (oldIndex == Panes.Count - 1 && index == -1)
            {
                return;
            }

            Panes.Remove(pane);
            if (index == -1)
            {
                Panes.Add(pane);
            }
            else if (oldIndex < index)
            {
                Panes.AddAt(pane, index - 1);
            }
            else
            {
                Panes.AddAt(pane, index);
            }

            if (pane.DockState == DockState.Float)
            {
                pane.FloatWindow.PerformLayout();
            }
            else if (DockHelper.IsDockWindowState(pane.DockState))
            {
                DockWindows[pane.DockState].PerformLayout();
            }
            else if (DockHelper.IsDockStateAutoHide(pane.DockState))
            {
                Refresh();
            }
        }
        public void SetPaneIndex(DockPane pane, int index)
        {
            int oldIndex = Panes.IndexOf(pane);

            if (oldIndex == -1)
            {
                throw(new ArgumentException(Strings.DockPanel_SetPaneIndex_InvalidPane));
            }

            if (index < 0 || index > Panes.Count - 1)
            {
                if (index != -1)
                {
                    throw(new ArgumentOutOfRangeException(Strings.DockPanel_SetPaneIndex_InvalidIndex));
                }
            }

            if (oldIndex == index)
            {
                return;
            }
            if (oldIndex == Panes.Count - 1 && index == -1)
            {
                return;
            }

            Panes.Remove(pane);
            if (index == -1)
            {
                Panes.Add(pane);
            }
            else if (oldIndex < index)
            {
                Panes.AddAt(pane, index - 1);
            }
            else
            {
                Panes.AddAt(pane, index);
            }
        }