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; } } }
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; } }
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(); } } }
private void DockingControl_CancelledChanged(DockingControl control) { using (RedrawStopper stopRedraws = new RedrawStopper(this.Parent, true)) { Manager.SuspendLayout(); CancelControl(control); OnDockingControlCancelled(control); Manager.ResumeLayout(true); } }
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); }
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); } } }
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(); } } }
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); } }