Esempio n. 1
0
        private void CancelControl(DockingControl control)
        {
            DockingControlData data = _mapDockingControlToData[control];

            if (control.Cancelled)
            {
                if (data.Button == null)
                {
                    if (_dockingControls.GetVisibleDockedControlCount() == 0)
                    {
                        this.Visible = false;
                    }
                }
                else
                {
                    ToolStripButton button = _mapDockingControlToData[control].Button;
                    button.Visible = false;

                    AutoResizeControl autoResizeControl = _mapButtonToControl[button];
                    autoResizeControl.Visible = false;

                    if (ToolStripHelpers.GetVisibleButtonCount(_menuStrip) == 0)
                    {
                        _menuStrip.Visible = false;
                    }
                }
            }
            else
            {
                ToolStripButton button = _mapDockingControlToData[control].Button;

                if (button == null)
                {
                    this.Visible = true;
                }
                else
                {
                    button.Visible     = true;
                    _menuStrip.Visible = true;
                }
            }
        }
Esempio n. 2
0
        private void ShowControl(DockingControl control)
        {
            Form parentForm = this.ParentForm;

            using (RedrawStopper stopRedraws = new RedrawStopper(parentForm))
            {
                Manager.SuspendLayout();

                switch (this.Dock)
                {
                case DockStyle.Left:
                case DockStyle.Right:
                    this.Width = Math.Max(this.Width, PaddingWidth + control.Width);
                    break;

                case DockStyle.Top:
                case DockStyle.Bottom:
                    this.Height = Math.Max(this.Height, PaddingWidth + control.Height);
                    break;
                }

                this.Visible = true;

                control.Parent = this;

                ToolStripButton button = _mapDockingControlToData[control].Button;

                if (button != null)
                {
                    _menuStrip.Items.Remove(button);

                    AutoResizeControl autoResizeControl = _mapButtonToControl[button];
                    this.Controls.Remove(autoResizeControl);
                    autoResizeControl.Dispose();

                    _mapButtonToControl.Remove(button);
                }

                DockingControlData oldData = _mapDockingControlToData[control];
                _mapDockingControlToData[control] = new DockingControlData(null, oldData.AutoHideChangedHandler, oldData.CancelledChangedHandler);

                if (ToolStripHelpers.GetVisibleButtonCount(_menuStrip) == 0)
                {
                    _menuStrip.Visible = false;
                }

                _dockingControls.Remove(control);
                _dockingControls.Add(control);
                OnDockingControlAutoHide(control);

                if (control.Cancelled)
                {
                    CancelControl(control);
                }

                Manager.ResumeLayout(true);

                control.DraggingEnabled = true;
            }

            control.Focus();
            control.Select();

            if (parentForm != null)
            {
                parentForm.Invalidate(true);
            }
        }