ARCed.UI.DockPanel.SetPaneIndex C# (CSharp) Method

SetPaneIndex() public method

public SetPaneIndex ( DockPane pane, int index ) : void
pane DockPane
index int
return void
        public void SetPaneIndex(DockPane pane, int index)
        {
            int oldIndex = this.Panes.IndexOf(pane);
            if (oldIndex == -1)
                throw (new ArgumentException(Strings.DockPanel_SetPaneIndex_InvalidPane));

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

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

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