protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); _dragTab = null; if (_tabArea.DropdownRectangle.Contains(e.Location)) { if (_tabArea.DropdownHot) { _tabArea.ShowMenu(this, new Point(_tabArea.DropdownRectangle.Left, _tabArea.DropdownRectangle.Bottom - 2)); } return; } if (_tabArea.ClickedCloseButton == null) { return; } var closeRect = RectangleToTabArea(_tabArea.ClickedCloseButton.CloseButtonRectangle); if (closeRect.Contains(e.Location)) { _tabArea.ClickedCloseButton.DockContent.Close(); } }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); if (_tabArea.DropdownRectangle.Contains(e.Location)) { _tabArea.DropdownHot = true; return; } foreach (var tab in _tabs.Values) { var rect = RectangleToTabArea(tab.ClientRectangle); if (rect.Contains(e.Location)) { if (e.Button == MouseButtons.Middle) { tab.DockContent.Close(); return; } var closeRect = RectangleToTabArea(tab.CloseButtonRectangle); if (closeRect.Contains(e.Location)) { _tabArea.ClickedCloseButton = tab; return; } else { DockPanel.ActiveContent = tab.DockContent; EnsureVisible(); _dragTab = tab; return; } } } if (VisibleContent != null) { DockPanel.ActiveContent = VisibleContent; } }
private void PaintToolWindowTab(Graphics g, DarkDockTab tab) { var tabRect = tab.ClientRectangle; var isVisibleTab = VisibleContent == tab.DockContent; var bgColor = isVisibleTab ? Colours.GreyBackground : Colours.DarkBackground; if (tab.Hot && !isVisibleTab) { bgColor = Colours.MediumBackground; } using (var b = new SolidBrush(bgColor)) { g.FillRectangle(b, tabRect); } // Draw separators if (tab.ShowSeparator) { using (var p = new Pen(Colours.DarkBorder)) { g.DrawLine(p, tabRect.Right - 1, tabRect.Top, tabRect.Right - 1, tabRect.Bottom); } } var tabTextFormat = new StringFormat { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center, FormatFlags = StringFormatFlags.NoWrap, Trimming = StringTrimming.EllipsisCharacter }; var textColor = isVisibleTab ? Colours.BlueHighlight : Colours.DisabledText; using (var b = new SolidBrush(textColor)) { var textRect = new Rectangle(tabRect.Left + 5, tabRect.Top, tabRect.Width - 5, tabRect.Height); g.DrawString(tab.DockContent.DockText, Font, b, textRect, tabTextFormat); } }
private void PaintDocumentTab(Graphics g, DarkDockTab tab) { var tabRect = RectangleToTabArea(tab.ClientRectangle); var isVisibleTab = VisibleContent == tab.DockContent; var isActiveGroup = DockPanel.ActiveGroup == this; var bgColor = isVisibleTab ? Colours.BlueSelection : Colours.DarkBackground; if (!isActiveGroup) { bgColor = isVisibleTab ? Colours.GreySelection : Colours.DarkBackground; } if (tab.Hot && !isVisibleTab) { bgColor = Colours.MediumBackground; } using (var b = new SolidBrush(bgColor)) { g.FillRectangle(b, tabRect); } // Draw separators if (tab.ShowSeparator) { using (var p = new Pen(Colours.DarkBorder)) { g.DrawLine(p, tabRect.Right - 1, tabRect.Top, tabRect.Right - 1, tabRect.Bottom); } } var xOffset = 0; // Draw icon if (tab.DockContent.Icon != null) { g.DrawImage(tab.DockContent.Icon, tabRect.Left + 5, tabRect.Top + 4); xOffset += tab.DockContent.Icon.Width + 2; } var tabTextFormat = new StringFormat { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center, FormatFlags = StringFormatFlags.NoWrap, Trimming = StringTrimming.EllipsisCharacter }; // Draw text var textColor = isVisibleTab ? Colours.LightText : Colours.DisabledText; using (var b = new SolidBrush(textColor)) { var textRect = new Rectangle(tabRect.Left + 5 + xOffset, tabRect.Top, tabRect.Width - tab.CloseButtonRectangle.Width - 7 - 5 - xOffset, tabRect.Height); g.DrawString(tab.DockContent.DockText, Font, b, textRect, tabTextFormat); } // Close button var img = tab.CloseButtonHot ? DockIcons.inactive_close_selected : DockIcons.inactive_close; if (isVisibleTab) { if (isActiveGroup) { img = tab.CloseButtonHot ? DockIcons.close_selected : DockIcons.close; } else { img = tab.CloseButtonHot ? DockIcons.close_selected : DockIcons.active_inactive_close; } } var closeRect = RectangleToTabArea(tab.CloseButtonRectangle); g.DrawImage(img, closeRect.Left, closeRect.Top); }