コード例 #1
0
        private void _splitterDragHandler_EndSplitterDrag(SplitterDragHandler sender, int size)
        {
            using (RedrawStopper stopRedraws = new RedrawStopper(this.ParentForm, true))
            {
                switch (this.Dock)
                {
                case DockStyle.Bottom:
                    this.Height -= size;
                    this.Height  = Math.Max(this.MinimumSize.Height, this.Height);
                    break;

                case DockStyle.Left:
                    this.Width += size;
                    this.Width  = Math.Max(this.MinimumSize.Width, this.Width);
                    break;

                case DockStyle.Right:
                    this.Width -= size;
                    this.Width  = Math.Max(this.MinimumSize.Width, this.Width);
                    break;

                case DockStyle.Top:
                    this.Height += size;
                    this.Height  = Math.Max(this.MinimumSize.Height, this.Height);
                    break;

                default:
                    break;
                }
            }
        }
コード例 #2
0
        private void SwitchTabbedStatus()
        {
            using (RedrawStopper stopRedraws = new RedrawStopper(this, true))
            {
                IDockControlContainerHandler newHandler = null;

                if (this.Tabbed)
                {
                    newHandler = new TabbedDockControlContainerHandler(this);
                }
                else
                {
                    newHandler = new SplitterDockControlContainerHandler(this);
                }

                _dockControlContainerHandler.RemoveAllControls();

                foreach (DockingControl control in _dockingControls)
                {
                    if (!control.AutoHide)
                    {
                        newHandler.OnDockingControlAdded(control, -1);

                        if (control.Cancelled)
                        {
                            newHandler.OnDockingControlCancelled(control);
                        }
                    }
                }

                _dockControlContainerHandler = newHandler;
            }
        }
コード例 #3
0
        internal void SelectControl(Control control, bool ensureVisible)
        {
            using (RedrawStopper stopRedraws = new RedrawStopper(this, true))
            {
                if (ensureVisible && control != null)
                {
                    MakeVisible(control);
                }

                if (_activeControl != null)
                {
                    _activeControl.Visible = false;
                    _controlButtonMap[_activeControl].Checked = false;
                }

                if (control != null)
                {
                    control.Visible = true;
                    control.Focus();
                    control.Select();
                    _controlButtonMap[control].Checked = true;
                }

                if (_activeControl != control)
                {
                    _activeControl = control;
                    OnSelectedControlChanged();
                }
            }
        }
コード例 #4
0
        private void DockingControl_CancelledChanged(DockingControl control)
        {
            using (RedrawStopper stopRedraws = new RedrawStopper(this.Parent, true))
            {
                Manager.SuspendLayout();

                CancelControl(control);

                OnDockingControlCancelled(control);

                Manager.ResumeLayout(true);
            }
        }
コード例 #5
0
        public void DockControl(DockingControl control, int dockAtIndex, int dimension)
        {
            using (RedrawStopper stopRedraws = new RedrawStopper(this))
            {
                DockControlContainer oldContainer = ControlHelpers.FindParentControl <DockControlContainer>(control);

                if (oldContainer != null && oldContainer != this)
                {
                    oldContainer.RemoveControl(control);
                }

                AddControl(control, dockAtIndex, dimension);
            }

            Invalidate(true);
        }
コード例 #6
0
        public void FloatControl(Rectangle bounds)
        {
            using (RedrawStopper redrawStopper = new RedrawStopper(_manager.ParentForm, true))
            {
                if (this.AutoHide)
                {
                    this.AutoHide = false;
                }

                DockControlContainer oldContainer = _container;
                Form parentForm = this.ParentForm;

                if (oldContainer != null)
                {
                    oldContainer.RemoveControl(this);
                }

                if (_floatingForm == null || parentForm != _floatingForm)
                {
                    _floatingForm = new FloatingForm(this, _manager);
                    _autoHidetoolStripButton.Visible = false;
                    _tabsToolStripButton.Visible     = false;
                }

                _floatingForm.Bounds = bounds;

                if (_floatingForm.Visible)
                {
                    _floatingForm.Invalidate();
                }
                else if (_floatingForm.Loaded)
                {
                    _floatingForm.Visible = !this.Cancelled;
                }
                else if (!this.Cancelled)
                {
                    _floatingForm.Show(parentForm);
                }
            }
        }
コード例 #7
0
        protected virtual void OnEndCaptionDrag(Point dropPoint, Rectangle endDragBounds)
        {
            using (RedrawStopper stopRedraws = new RedrawStopper(_manager, true))
            {
                DockControlContainer container = GetDropContainer(dropPoint);

                if (container == null)
                {
                    endDragBounds.X      -= FloatingForm.PaddingSize;
                    endDragBounds.Y      -= FloatingForm.PaddingSize;
                    endDragBounds.Width  += 2 * FloatingForm.PaddingSize;
                    endDragBounds.Height += 2 * FloatingForm.PaddingSize;
                    FloatControl(endDragBounds);
                }
                else
                {
                    int dimension = DockControlHelpers.GetDockedDimension(this, container.Dock);
                    container = DockControlHelpers.CreateNewContainerIfNecessary(_manager, container, PointToScreen(dropPoint), DockingBarSize);
                    DockControl(dropPoint, container, dimension);
                    RemoveFloatingForm();
                }
            }
        }
コード例 #8
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);
            }
        }