public ViewDockSideTab(ViewDockSide side, ViewHost viewHost, ViewBase view) : base(view, Utility.InvertAnchor(side.Side)) { Verify.Argument.IsNotNull(side, "side"); Verify.Argument.IsNotNull(viewHost, "viewHost"); _side = side; _viewHost = viewHost; }
/// <summary>Undocks this <see cref="ViewHost"/>.</summary> private void Undock() { switch(Status) { case ViewHostStatus.AutoHide: { _dockSide.RemoveHost(this); switch(_dockSide.Side) { case AnchorStyles.Left: { var w = Width - ViewConstants.SideDockPanelBorderSize; var h = Height; Width = w; _header.Width = w; if(_views.Count > 1) { SpawnTabs(new Size(w, h)); _viewContainer.SetBounds( 0, 0, w, h - Renderer.TabHeight - Renderer.HeaderHeight, BoundsSpecified.Width | BoundsSpecified.Height); } else { _viewContainer.Width = w; } } break; case AnchorStyles.Top: { var w = Width; var h = Height - ViewConstants.SideDockPanelBorderSize; Height = h; if(_views.Count > 1) { SpawnTabs(new Size(w, h)); UpdateContentPanelBounds(); } else { _viewContainer.Height = h - Renderer.HeaderHeight; } } break; case AnchorStyles.Right: { var w = Width - ViewConstants.SideDockPanelBorderSize; var h = Height; Width = w; _header.SetBounds(0, 0, w, Renderer.HeaderHeight, BoundsSpecified.X | BoundsSpecified.Width); if(_views.Count > 1) { SpawnTabs(new Size(w, h)); UpdateContentPanelBounds(); } else { _viewContainer.SetBounds(0, 0, w, 0, BoundsSpecified.X | BoundsSpecified.Width); } } break; case AnchorStyles.Bottom: { var w = Width; var h = Height - ViewConstants.SideDockPanelBorderSize; Height = h; _header.Top = 0; if(_views.Count > 1) { SpawnTabs(new Size(w, h)); UpdateContentPanelBounds(); } else { _viewContainer.SetBounds(0, Renderer.HeaderHeight, 0, h, BoundsSpecified.Y | BoundsSpecified.Height); } } break; default: throw new ApplicationException("Unexpected ViewDockSide.Side: " + _dockSide.Side); } _dockSide = null; } break; case ViewHostStatus.DockedOnFloat: case ViewHostStatus.Docked: { var parent = Parent; if(parent != null) { parent.DisableRedraw(); try { var split = parent as ViewSplit; if(split != null) { split.Remove(this); return; } else { throw new ApplicationException("Unexpeceted ViewHost.Parent: " + parent); } } finally { if(!parent.IsDisposed) { parent.EnableRedraw(); parent.RedrawWindow(); } } } } break; case ViewHostStatus.Floating: { var parent = (Form)TopLevelControl; Parent = null; parent.Close(); parent.Dispose(); Anchor = ViewConstants.AnchorDefault; } break; case ViewHostStatus.Offscreen: case ViewHostStatus.Disposed: throw new InvalidOperationException(); default: throw new ApplicationException(); } Status = ViewHostStatus.Offscreen; }
/// <summary> /// Releases the unmanaged resources used by the <see cref="T:System.Windows.Forms.Control"/> and its child controls and optionally releases the managed resources. /// </summary> /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param> protected override void Dispose(bool disposing) { if(disposing) { if(_ownerForm != null) { _ownerForm.Activated -= OnOwnerFormActivated; _ownerForm.Deactivate -= OnOwnerFormDeactivated; _ownerForm = null; } foreach(var view in _views) { view.TextChanged -= OnViewTextChanged; } RemoveHeader(); RemoveTabs(); RemoveFooter(); _dockingProcess.Dispose(); _resizingProcess.Dispose(); _viewContainer.Dispose(); _dockMarkers.Dispose(); _dockSide = null; _status = ViewHostStatus.Disposed; } lock(_viewHosts) { _viewHosts.Remove(this); } base.Dispose(disposing); }
internal void UnpinFromTop() { var h = Height - Renderer.HeaderHeight; _grid.PerformDock(this, DockResult.AutoHideTop); _dockSide = _grid.TopSide; RemoveTabs(); Height += ViewConstants.SideDockPanelBorderSize; _viewContainer.Height = h; }
public override void RenderViewDockSide(ViewDockSide side, PaintEventArgs e) { using(var brush = new SolidBrush(ColorTable.ViewDockSideBackground)) { e.Graphics.FillRectangle(brush, e.ClipRectangle); } }
public SideEntry(ViewDockSide side) : this() { Verify.Argument.IsNotNull(side, "side"); _side = side.Side; foreach(var host in side) { _hosts.Add(new HostEntry(host)); } }
private void KillBottomSide() { if(_bottom != null) { _bottom.Parent = null; _bottom.Dispose(); _bottom = null; _rootControl.Height += Renderer.SideTabHeight; var vcs = Height - Renderer.SideTabHeight * 2; if(_bottom != null) vcs -= Renderer.SideTabHeight; if(_left != null) { var h = _left.Height; var len = _left.OptimalLength; if(h < len) { if(len > vcs) len = vcs; _left.Height = len; } } if(_right != null) { var h = _right.Height; var len = _right.OptimalLength; if(h < len) { if(len > vcs) len = vcs; _right.Height = len; } } } }
internal void UnpinFromRight() { var w = Width; _grid.PerformDock(this, DockResult.AutoHideRight); _dockSide = _grid.RightSide; _viewContainer.SuspendLayout(); if(_tabs == null) { _viewContainer.SetBounds( ViewConstants.SideDockPanelBorderSize, 0, w, 0, BoundsSpecified.X | BoundsSpecified.Width); } else { _viewContainer.SetBounds( ViewConstants.SideDockPanelBorderSize, 0, w, Height - Renderer.HeaderHeight, BoundsSpecified.X | BoundsSpecified.Width | BoundsSpecified.Height); RemoveTabs(); } Width += ViewConstants.SideDockPanelBorderSize; _header.SetBounds( ViewConstants.SideDockPanelBorderSize, 0, w, 0, BoundsSpecified.X | BoundsSpecified.Width); _viewContainer.ResumeLayout(true); }
private void SpawnRightSide() { Verify.State.IsTrue(_right == null); var size = Size; var bounds = new Rectangle( size.Width - Renderer.SideTabHeight, ViewConstants.Spacing, Renderer.SideTabHeight, 0); int hspace = size.Width - Renderer.SideTabHeight - ViewConstants.Spacing * 2; if(_left != null) hspace -= Renderer.SideTabHeight; if(_top != null) { if(_top.Width > hspace) { _top.Width = hspace; } bounds.Y += Renderer.SideTabHeight; } if(_bottom != null) { if(_bottom.Width > hspace) { _bottom.Width = hspace; } } _rootControl.Width -= Renderer.SideTabHeight; _right = new ViewDockSide(this, AnchorStyles.Right) { Anchor = AnchorStyles.Right | AnchorStyles.Top, Bounds = bounds, Parent = this, }; }
private void SpawnLeftSide() { Verify.State.IsTrue(_left == null); var size = Size; var bounds = new Rectangle( 0, ViewConstants.Spacing, Renderer.SideTabHeight, 0); int hspace = size.Width - (Renderer.SideTabHeight + ViewConstants.Spacing * 2); if(_right != null) hspace -= Renderer.SideTabHeight; if(_top != null) { if(_top.Width > hspace) { _top.Bounds = new Rectangle( Renderer.SideTabHeight + ViewConstants.Spacing, 0, hspace, Renderer.SideTabHeight); } else { _top.Left += Renderer.SideTabHeight; } bounds.Y += Renderer.SideTabHeight; } if(_bottom != null) { if(_bottom.Width > hspace) { _bottom.Bounds = new Rectangle( Renderer.SideTabHeight + ViewConstants.Spacing, size.Height - Renderer.SideTabHeight, hspace, Renderer.SideTabHeight); } else { _bottom.Left += Renderer.SideTabHeight; } } _rootControl.SetBounds( _rootControl.Left + Renderer.SideTabHeight, 0, _rootControl.Width - Renderer.SideTabHeight, 0, BoundsSpecified.X | BoundsSpecified.Width); _left = new ViewDockSide(this, AnchorStyles.Left) { Anchor = AnchorStyles.Left | AnchorStyles.Top, Bounds = bounds, Parent = this, }; }
private void SpawnBottomSide() { Verify.State.IsTrue(_bottom == null); var size = Size; var bounds = new Rectangle( ViewConstants.Spacing, size.Height - Renderer.SideTabHeight, 0, Renderer.SideTabHeight); int vspace = size.Height - Renderer.SideTabHeight - ViewConstants.Spacing * 2; if(_top != null) vspace -= Renderer.SideTabHeight; if(_left != null) { if(_left.Height > vspace) { _left.Height = vspace; } bounds.X += Renderer.SideTabHeight; } if(_right != null) { if(_right.Height > vspace) { _right.Height = vspace; } } _rootControl.Height -= Renderer.SideTabHeight; _bottom = new ViewDockSide(this, AnchorStyles.Bottom) { Anchor = AnchorStyles.Left | AnchorStyles.Bottom, Bounds = bounds, Parent = this, }; }
private void RemoveTopSide() { if(_top != null) { _top.Parent = null; _top.Dispose(); _top = null; var bounds = _rootControl.Bounds; bounds.Y -= Renderer.SideTabHeight; bounds.Height += Renderer.SideTabHeight; _rootControl.Bounds = bounds; var vcs = Height - Renderer.SideTabHeight * 2; if(_bottom != null) vcs -= Renderer.SideTabHeight; if(_left != null) { var h = _left.Height; var len = _left.OptimalLength; if(h >= len) { _left.Top = ViewConstants.Spacing; } else { if(len > vcs) len = vcs; _left.SetBounds( 0, ViewConstants.Spacing, Renderer.SideTabHeight, len, BoundsSpecified.Y | BoundsSpecified.Height); } } if(_right != null) { var h = _right.Height; var len = _right.OptimalLength; if(h >= len) { _right.Top = ViewConstants.Spacing; } else { if(len > vcs) len = vcs; _right.SetBounds( 0, ViewConstants.Spacing, Renderer.SideTabHeight, len, BoundsSpecified.Y | BoundsSpecified.Height); } } } }
private void RemoveRightSide() { if(_right != null) { _right.Parent = null; _right.Dispose(); _right = null; _rootControl.Width += Renderer.SideTabHeight; var hcs = Width - ViewConstants.Spacing * 2; if(_left != null) hcs -= Renderer.SideTabHeight; if(_top != null) { var w = _top.Width; var len = _top.OptimalLength; if(w < len) { if(len > hcs) len = hcs; _top.Width = len; } } if(_bottom != null) { var w = _bottom.Height; var len = _bottom.OptimalLength; if(w < len) { if(len > hcs) len = hcs; _bottom.Width = len; } } } }
private void RemoveLeftSide() { if(_left != null) { _left.Parent = null; _left.Dispose(); _left = null; var bounds = _rootControl.Bounds; bounds.X -= Renderer.SideTabHeight; bounds.Width += Renderer.SideTabHeight; _rootControl.Bounds = bounds; var hcs = Width - ViewConstants.Spacing * 2; if(_right != null) hcs -= Renderer.SideTabHeight; if(_top != null) { var w = _top.Width; var len = _top.OptimalLength; if(w >= len) { _top.Left = ViewConstants.Spacing; } else { if(len > hcs) len = hcs; _top.SetBounds( ViewConstants.Spacing, 0, len, Renderer.SideTabHeight, BoundsSpecified.X | BoundsSpecified.Width); } } if(_bottom != null) { var w = _bottom.Height; var len = _bottom.OptimalLength; if(w >= len) { _bottom.Left = ViewConstants.Spacing; } else { if(len > hcs) len = hcs; _bottom.SetBounds( ViewConstants.Spacing, 0, len, Renderer.SideTabHeight, BoundsSpecified.X | BoundsSpecified.Width); } } } }
private void RemoveAllSides() { SuspendLayout(); if(_left != null) { _left.Parent = null; _left.Dispose(); _left = null; } if(_top != null) { _top.Parent = null; _top.Dispose(); _top = null; } if(_right != null) { _right.Parent = null; _right.Dispose(); _right = null; } if(_bottom != null) { _bottom.Parent = null; _bottom.Dispose(); _bottom = null; } RootControl.SetBounds( ViewConstants.Spacing, ViewConstants.Spacing, Width - ViewConstants.Spacing * 2, Height - ViewConstants.Spacing * 2, BoundsSpecified.All); ResumeLayout(true); }
internal void UnpinFromBottom() { var h = Height; _grid.PerformDock(this, DockResult.AutoHideBottom); _dockSide = _grid.BottomSide; _viewContainer.SuspendLayout(); var headerHeight = Renderer.HeaderHeight; if(_tabs == null) { _viewContainer.Top = headerHeight + ViewConstants.SideDockPanelBorderSize; } else { _viewContainer.SetBounds( 0, ViewConstants.SideDockPanelBorderSize + headerHeight, 0, h - headerHeight, BoundsSpecified.Y | BoundsSpecified.Height); RemoveTabs(); } _header.Top = ViewConstants.SideDockPanelBorderSize; Height += ViewConstants.SideDockPanelBorderSize; _viewContainer.ResumeLayout(true); }
internal void UnpinFromLeft() { var w = Width; _grid.PerformDock(this, DockResult.AutoHideLeft); _dockSide = _grid.LeftSide; Width = w + ViewConstants.SideDockPanelBorderSize; if(_tabs != null) { RemoveTabs(); _viewContainer.Height += Renderer.TabHeight; } _header.Width = w; _viewContainer.Width = w; }
private void SpawnTopSide() { Verify.State.IsTrue(_top == null); var size = Size; var bounds = new Rectangle( ViewConstants.Spacing, 0, 0, Renderer.SideTabHeight); int vspace = size.Height - Renderer.SideTabHeight - ViewConstants.Spacing * 2; if(_bottom != null) vspace -= Renderer.SideTabHeight; if(_left != null) { if(_left.Height > vspace) { _left.Bounds = new Rectangle( 0, Renderer.SideTabHeight + ViewConstants.Spacing, Renderer.SideTabHeight, vspace); } else { _left.Top += Renderer.SideTabHeight; } bounds.X += Renderer.SideTabHeight; } if(_right != null) { if(_right.Height > vspace) { _right.Bounds = new Rectangle( size.Width - Renderer.SideTabHeight, Renderer.SideTabHeight + ViewConstants.Spacing, Renderer.SideTabHeight, vspace); } else { _right.Top += Renderer.SideTabHeight; } } _rootControl.SetBounds( 0, _rootControl.Top + Renderer.SideTabHeight, 0, _rootControl.Height - Renderer.SideTabHeight, BoundsSpecified.Y | BoundsSpecified.Height); _top = new ViewDockSide(this, AnchorStyles.Top) { Anchor = AnchorStyles.Left | AnchorStyles.Top, Bounds = bounds, Parent = this, }; }
public abstract void RenderViewDockSide(ViewDockSide side, PaintEventArgs e);
/// <summary> /// Releases the unmanaged resources used by the <see cref="T:System.Windows.Forms.Control"/> and its child controls and optionally releases the managed resources. /// </summary> /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param> protected override void Dispose(bool disposing) { lock(_grids) { _grids.Remove(this); } if(disposing) { _dockMarkers.Dispose(); if(_left != null) { _left.Dispose(); _left = null; } if(_top != null) { _top.Dispose(); _top = null; } if(_right != null) { _right.Dispose(); _right = null; } if(_bottom != null) { _bottom.Dispose(); _bottom = null; } if(_popupsStack != null) { _popupsStack.Dispose(); _popupsStack = null; } _rootControl = null; _floatingViewForms.Clear(); } base.Dispose(disposing); }