Example #1
0
        private void SetParent(Control value)
        {
            if (Parent == value)
            {
                return;
            }

            //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            // Workaround of .Net Framework bug:
            // Change the parent of a control with focus may result in the first
            // MDI child form get activated.
            //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            IDockContent contentFocused = GetFocusedContent();

            if (contentFocused != null)
            {
                DockPanel.SaveFocus();
            }

            //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

            Parent = value;

            //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            // Workaround of .Net Framework bug:
            // Change the parent of a control with focus may result in the first
            // MDI child form get activated.
            //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            if (contentFocused != null)
            {
                contentFocused.DockHandler.Activate();
            }
            //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        }
Example #2
0
        private void SetParent(Control value)
        {
            if (Form.Parent == value)
            {
                return;
            }

            //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            // Workaround of .Net Framework bug:
            // Change the parent of a control with focus may result in the first
            // MDI child form get activated.
            //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            bool bRestoreFocus = false;

            if (Form.ContainsFocus)
            {
                //Suggested as a fix for a memory leak by bugreports
                if (value == null && !IsFloat)
                {
                    DockPanel.ContentFocusManager.GiveUpFocus(this.Content);
                }
                else
                {
                    DockPanel.SaveFocus();
                    bRestoreFocus = true;
                }
            }
            //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

            Form.Parent = value;

            //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            // Workaround of .Net Framework bug:
            // Change the parent of a control with focus may result in the first
            // MDI child form get activated.
            //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            if (bRestoreFocus)
            {
                Activate();
            }
            //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        }
Example #3
0
        private void InternalSetDockState(DockState value)
        {
            if (m_dockState == value)
            {
                return;
            }

            DockState             oldDockState = m_dockState;
            INestedPanesContainer oldContainer = NestedPanesContainer;

            m_dockState = value;

            SuspendRefreshStateChange();

            IDockContent contentFocused = GetFocusedContent();

            if (contentFocused != null)
            {
                DockPanel.SaveFocus();
            }

            if (!IsFloat)
            {
                DockWindow = DockPanel.DockWindows[DockState];
            }
            else if (FloatWindow == null)
            {
                FloatWindow = DockPanel.FloatWindowFactory.CreateFloatWindow(DockPanel, this);
            }

            if (contentFocused != null)
            {
                DockPanel.ContentFocusManager.Activate(contentFocused);
            }

            ResumeRefreshStateChange(oldContainer, oldDockState);
        }
Example #4
0
        private void RefreshStateChange(INestedPanesContainer oldContainer, DockState oldDockState)
        {
            lock (this)
            {
                if (IsRefreshStateChangeSuspended)
                {
                    return;
                }

                SuspendRefreshStateChange();
            }

            DockPanel.SuspendLayout(true);

            IDockContent contentFocused = GetFocusedContent();

            if (contentFocused != null)
            {
                DockPanel.SaveFocus();
            }
            SetParent();

            if (ActiveContent != null)
            {
                ActiveContent.DockHandler.SetDockState(ActiveContent.DockHandler.IsHidden, DockState, ActiveContent.DockHandler.Pane);
            }
            foreach (IDockContent content in Contents)
            {
                if (content.DockHandler.Pane == this)
                {
                    content.DockHandler.SetDockState(content.DockHandler.IsHidden, DockState, content.DockHandler.Pane);
                }
            }

            if (oldContainer != null)
            {
                Control oldContainerControl = (Control)oldContainer;
                if (oldContainer.DockState == oldDockState && !oldContainerControl.IsDisposed)
                {
                    oldContainerControl.PerformLayout();
                }
            }
            if (DockHelper.IsDockStateAutoHide(oldDockState))
            {
                DockPanel.RefreshActiveAutoHideContent();
            }

            if (NestedPanesContainer.DockState == DockState)
            {
                ((Control)NestedPanesContainer).PerformLayout();
            }
            if (DockHelper.IsDockStateAutoHide(DockState))
            {
                DockPanel.RefreshActiveAutoHideContent();
            }

            if (DockHelper.IsDockStateAutoHide(oldDockState) ||
                DockHelper.IsDockStateAutoHide(DockState))
            {
                DockPanel.RefreshAutoHideStrip();
                DockPanel.PerformLayout();
            }

            ResumeRefreshStateChange();

            if (contentFocused != null)
            {
                contentFocused.DockHandler.Activate();
            }

            DockPanel.ResumeLayout(true, true);

            if (oldDockState != DockState)
            {
                OnDockStateChanged(EventArgs.Empty);
            }
        }