ARCed.UI.DockContentHandler.SetDockState C# (CSharp) Method

SetDockState() private method

private SetDockState ( bool isHidden, DockState visibleState, DockPane oldPane ) : void
isHidden bool
visibleState DockState
oldPane DockPane
return void
        internal void SetDockState(bool isHidden, DockState visibleState, DockPane oldPane)
        {
            if (this.IsSuspendSetDockState)
                return;

            if (this.DockPanel == null && visibleState != DockState.Unknown)
                throw new InvalidOperationException(Strings.DockContentHandler_SetDockState_NullPanel);

            if (visibleState == DockState.Hidden || (visibleState != DockState.Unknown && !this.IsDockStateValid(visibleState)))
                throw new InvalidOperationException(Strings.DockContentHandler_SetDockState_InvalidState);

            DockPanel dockPanel = this.DockPanel;
            if (dockPanel != null)
                dockPanel.SuspendLayout(true);

            this.SuspendSetDockState();

            DockState oldDockState = this.DockState;

            if (this.m_isHidden != isHidden || oldDockState == DockState.Unknown)
            {
                this.m_isHidden = isHidden;
            }
            this.m_visibleState = visibleState;
            this.m_dockState = isHidden ? DockState.Hidden : visibleState;

            if (visibleState == DockState.Unknown)
                this.Pane = null;
            else
            {
                this.m_isFloat = (this.m_visibleState == DockState.Float);

                if (this.Pane == null)
                    this.Pane = this.DockPanel.DockPaneFactory.CreateDockPane(this.Content, visibleState, true);
                else if (this.Pane.DockState != visibleState)
                {
                    if (this.Pane.Contents.Count == 1)
                        this.Pane.SetDockState(visibleState);
                    else
                        this.Pane = this.DockPanel.DockPaneFactory.CreateDockPane(this.Content, visibleState, true);
                }
            }

            if (this.Form.ContainsFocus)
                if (this.DockState == DockState.Hidden || this.DockState == DockState.Unknown)
                    this.DockPanel.ContentFocusManager.GiveUpFocus(this.Content);

            this.SetPaneAndVisible(this.Pane);

            if (oldPane != null && !oldPane.IsDisposed && oldDockState == oldPane.DockState)
                RefreshDockPane(oldPane);

            if (this.Pane != null && this.DockState == this.Pane.DockState)
            {
                if ((this.Pane != oldPane) ||
                    (this.Pane == oldPane && oldDockState != oldPane.DockState))
                    // Avoid early refresh of hidden AutoHide panes
                    if ((this.Pane.DockWindow == null || this.Pane.DockWindow.Visible || this.Pane.IsHidden) && !this.Pane.IsAutoHide)
                        RefreshDockPane(this.Pane);
            }

            if (oldDockState != this.DockState)
            {
                if (this.DockState == DockState.Hidden || this.DockState == DockState.Unknown ||
                    DockHelper.IsDockStateAutoHide(this.DockState))
                    this.DockPanel.ContentFocusManager.RemoveFromList(this.Content);
                else
                    this.DockPanel.ContentFocusManager.AddToList(this.Content);

                this.OnDockStateChanged(EventArgs.Empty);
            }
            this.ResumeSetDockState();

            if (dockPanel != null)
                dockPanel.ResumeLayout(true, true);
        }