private void AddTabControl(DockingControl control, int index) { System.Diagnostics.Debug.Assert(!control.AutoHide, "Can't dock auto hidden controls"); TabPage page = null; if (_dockingControlToPageMap.ContainsKey(control)) { System.Diagnostics.Debug.Fail("Can't add a tab page multiple times"); } else { page = new TabPage(control.Title); _dockingControlToPageMap.Add(control, page); } if (index < 0 || index >= _tabControl.TabPages.Count) { _tabControl.TabPages.Add(page); } else { _tabControl.TabPages.Insert(index, page); } _tabControl.SelectedTab = page; control.Parent = page; control.Dock = DockStyle.Fill; }
protected virtual void OnAddControl(DockingControl control) { if (ControlAdded != null) { ControlAdded(this, control); } }
protected virtual void OnDockingControlCancelled(DockingControl control) { if (!control.AutoHide) { _dockControlContainerHandler.OnDockingControlCancelled(control); } }
public AutoResizeControl(DockingControl control, DockControlContainer container) { InitializeComponent(); this.Width = control.Width; this.Height = control.Height; _animator = new ControlResizeAnimator(this, control.Width); _inner = control; _container = container; _inner.Parent = this; _inner.Dock = DockStyle.Fill; DragHandler dragHandler = new DragHandler(this, new DragHandlerHitTester(HitTestSizeArea)); _dragHandler = new SplitterDragHandler(dragHandler, SplitterDragHandlerDirection.EastWest); _dragHandler.EndSplitterDrag += new SplitterDragEndHandler(_dragHandler_EndSplitterDrag); _autoHideHandler = new AutoHideControlHandler(this); _autoHideHandler.Hide += new Darwen.Windows.Forms.General.AutoHideHandler(_autoHideHandler_Hide); _paddingDrawHandler = new PaddingDrawHandler(this); }
private void AddControlHelper(DockingControl control, int index) { int controlIndex = _dockingControls.IndexOf(control); if (!_inExternalAddControl && controlIndex >= 0) { if (controlIndex == index) { control.Child.Focus(); control.Child.Select(); return; } else { DockingControlMovedHelper(control, controlIndex, index); } } else { if (controlIndex >= 0) { if (index >= controlIndex) { index -= 1; } } _dockingControls.Remove(control); _dockingControls.Insert(index, control); OnDockingControlAdded(control, index); } control.Child.Select(); Manager.PerformLayout(); }
protected virtual void OnDockingControlAdded(DockingControl control, int index) { if (!control.Cancelled && !control.AutoHide) { _dockControlContainerHandler.OnDockingControlAdded(control, index); } }
protected virtual void OnDockingControlMoved(DockingControl control, int oldIndex, int newIndex) { if (!control.Cancelled && !control.AutoHide) { _dockControlContainerHandler.OnDockingControlMoved(control, oldIndex, newIndex); } }
protected virtual void OnDockingControlRemoved(DockingControl control) { if (!control.Cancelled) { _dockControlContainerHandler.OnDockingControlRemoved(control); } }
private void RemoveTabControl(DockingControl control) { TabPage page = _dockingControlToPageMap[control]; _tabControl.TabPages.Remove(page); _dockingControlToPageMap.Remove(control); }
public void OnDockingControlAdded(DockingControl control, int index) { if (!_container.Controls.Contains(control)) { _container.Controls.Add(control); } RepositionControls(); }
public void OnDockingControlCancelled(DockingControl control) { if (control.Cancelled) { RemoveTabControl(control); } else { AddTabControl(control, -1); } }
public void OnDockingControlAutoHide(DockingControl control) { if (control.AutoHide) { RemoveTabControl(control); } else { AddTabControl(control, -1); } }
public IDockingControl Add(string title, Control control) { System.Diagnostics.Debug.Assert(_manager != null, "Manager has not been set"); DockingControl dockingControl = new DockingControl(control, _manager); Add(dockingControl); dockingControl.Title = title; OnAddControl(dockingControl); return(dockingControl); }
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 OnDockingControlCancelled(DockingControl control) { if (control.Cancelled) { _container.Controls.Remove(control); } else { OnDockingControlAdded(control, 0); } RepositionControls(); }
private void DockingControlMovedHelper(DockingControl control, int oldIndex, int newIndex) { if (oldIndex != newIndex) { _dockingControls.RemoveAt(oldIndex); _dockingControls.Insert((newIndex > oldIndex) ? newIndex - 1 : newIndex, control); if (!control.AutoHide && !control.Cancelled) { OnDockingControlMoved(control, oldIndex, newIndex); } } }
public void OnDockingControlAutoHide(DockingControl control) { if (control.AutoHide) { _container.Controls.Remove(control); } else { OnDockingControlAdded(control, 0); } RepositionControls(); }
private void AddControl(DockingControl control, int dockIndex, int dimension) { Manager.SuspendLayout(); if (!_mapDockingControlToData.ContainsKey(control)) { DockingControlData dockingControlData = new DockingControlData(null, new AutoHideChangedHandler(DockingControl_AutoHideChanged), new CancelledChangedHandler(DockingControl_CancelledChanged)); _mapDockingControlToData.Add(control, dockingControlData); control.AutoHideChanged += dockingControlData.AutoHideChangedHandler; control.CancelledChanged += dockingControlData.CancelledChangedHandler; } switch (Dock) { case DockStyle.Left: case DockStyle.Right: if (_dockingControls.Count == 0) { this.Width = Math.Min(MaxInitialDockSize, PaddingWidth + dimension); } break; case DockStyle.Top: case DockStyle.Bottom: if (_dockingControls.Count == 0) { this.Height = Math.Min(MaxInitialDockSize, PaddingWidth + dimension); } break; } if (dockIndex < 0 || dockIndex >= _dockingControls.Count) { AddControlHelper(control, _dockingControls.Count); } else { AddControlHelper(control, dockIndex); } Manager.ResumeLayout(true); CheckVisibility(); }
private void DockingControl_AutoHideChanged(DockingControl control) { Manager.SuspendLayout(); if (control.AutoHide) { AutoHideControl(control); } else { ShowControl(control); } Manager.ResumeLayout(true); }
private static DockingControl GetControlBefore(DockControlContainer container, int index) { DockingControl controlBefore = null; for (int indexBefore = index - 1; controlBefore == null && indexBefore >= 0; indexBefore -= 1) { controlBefore = container.DockedControlList[indexBefore]; if (controlBefore.AutoHide || controlBefore.Cancelled) { controlBefore = null; } } return(controlBefore); }
private void SetupZOrder(List <DockingControl> dockingControls) { System.Diagnostics.Debug.Assert(dockingControls.Count == _splitters.Count + 1); for (int dockingControlIndex = 0; dockingControlIndex < dockingControls.Count; dockingControlIndex += 1) { DockingControl control = dockingControls[dockingControlIndex]; control.BringToFront(); if (dockingControlIndex < _splitters.Count) { Splitter splitter = _splitters[dockingControlIndex]; splitter.BringToFront(); } } }
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); }
private static DockingControl GetControlAfter(DockControlContainer container, int index) { DockingControl controlAfter = null; for (int indexAfter = index + 1; controlAfter == null && indexAfter < container.DockedControlList.Count; indexAfter += 1) { controlAfter = container.DockedControlList[indexAfter]; if (controlAfter.AutoHide || controlAfter.Cancelled) { controlAfter = null; } } return(controlAfter); }
public FloatingForm(DockingControl inner, DockingManagerControl manager) { InitializeComponent(); _manager = manager; _inner = inner; _cancelledChangedHandler = new CancelledChangedHandler(Inner_CancelledChanged); _inner.CancelledChanged += _cancelledChangedHandler; this.SuspendLayout(); this.Controls.Add(inner); inner.Dock = DockStyle.Fill; this.Padding = new Padding(PaddingSize, PaddingSize, PaddingSize, PaddingSize); this.ResumeLayout(true); _dragSizer = new ControlDragSizer(this); }
private void _toolStripCaption_CaptionDrag(object sender, MouseEventArgs e) { Point pointInScreen = this.PointToScreen(e.Location); DockControlContainer container = _manager.GetContainerAtPoint(_manager.PointToClient(pointInScreen)); if (container == null) { Rectangle dragRectangle = DockControlHelpers.GetDropXorDragRect(_manager, pointInScreen, DockingBarSize); if (!dragRectangle.IsEmpty) { _dragger.SetRectangle(_manager.RectangleToScreen(dragRectangle)); return; } } else { Rectangle rectangleToDraw = GetContainerDragDrawRectangle(container, pointInScreen); if (!rectangleToDraw.IsEmpty) { _dragger.SetRectangle(rectangleToDraw); return; } if (container.Tabbed) { _dragger.SetRectangle(container.RectangleToScreen(container.ClientRectangle)); return; } else { DockingControl control = container.GetDockingControlAtPoint(container.PointToClient(pointInScreen)); if (control != null) { Point pointInControl = control.PointToClient(pointInScreen); rectangleToDraw = GetContolDragDrawRectangle(container, control, pointInControl); _dragger.SetRectangle(control.RectangleToScreen(rectangleToDraw)); return; } } } _dragger.MoveTo(e.Location); }
private void Inner_CancelledChanged(DockingControl control) { if (control == _inner) { if (_inner.Cancelled) { this.Visible = false; } else if (Loaded) { this.Visible = true; } else { this.Show(_manager.ParentForm); } } }
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; } } }
private void TestCursor(Point location) { foreach (ToolStripItem item in this.Items) { if (item is ToolStripButton && item.Bounds.Contains(location)) { DisposeCursor(); return; } } DockingControl parent = Parent as DockingControl; if (parent != null && !parent.AutoHide) { if (_setCursor == null) { _setCursor = new SetCursor(this, Cursors.SizeAll); } } }
public void RemoveControl(DockingControl control) { Manager.SuspendLayout(); DockingControlData data = _mapDockingControlToData[control]; control.AutoHideChanged -= data.AutoHideChangedHandler; control.CancelledChanged -= data.CancelledChangedHandler; _mapDockingControlToData.Remove(control); if (data.Button != null) { _mapButtonToControl.Remove(data.Button); } _dockingControls.Remove(control); OnDockingControlRemoved(control); CheckVisibility(); Manager.ResumeLayout(true); }
public void OnDockingControlMoved(DockingControl control, int oldIndex, int newIndex) { RemoveTabControl(control); AddTabControl(control, (oldIndex <= newIndex) ? newIndex : newIndex - 1); }