From 7e040727a6009cf1e580dc8780559a1c949eec54 Mon Sep 17 00:00:00 2001 From: Calvin Date: Sat, 15 Oct 2016 11:06:02 -0300 Subject: Use fallback rendering if visual styles is disabled TabRenderer requires visual styles to function. If disabled, we can use a simplistic fallback instead. --- windoc/WinDoc/CustomDrawing.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/windoc/WinDoc/CustomDrawing.cs b/windoc/WinDoc/CustomDrawing.cs index ec75d385..54b26686 100644 --- a/windoc/WinDoc/CustomDrawing.cs +++ b/windoc/WinDoc/CustomDrawing.cs @@ -54,7 +54,15 @@ namespace WinDoc // We use a TabRenderer to get the nice system gradient e.Graphics.Clear (Color.White); clip = new Rectangle (1, e.Bounds.Y + 1, e.Node.TreeView.ClientRectangle.Width - 3, e.Bounds.Height - 3); - TabRenderer.DrawTabItem (e.Graphics, clip, e.Node.Text, nodeFont, System.Windows.Forms.VisualStyles.TabItemState.Normal); + // If we're using the classic theme, then we can't use TabRender. Fall back to a simpler view. + if (TabRenderer.IsSupported) { + TabRenderer.DrawTabItem(e.Graphics, clip, e.Node.Text, nodeFont, System.Windows.Forms.VisualStyles.TabItemState.Normal); + } else { + e.Graphics.FillRectangle(SystemBrushes.ActiveCaption, clip); + // The fallback rendering has more empty space than the tab rendering. Take advantage of it. + var fallbackNodeFont = new Font(nodeFont.FontFamily, nodeFont.Size + 2); + e.Graphics.DrawString(e.Node.Text, fallbackNodeFont, SystemBrushes.ActiveCaptionText, clip.X, clip.Y); + } using (var pen = new Pen (Color.Black, 1.0f)) e.Graphics.DrawLine (pen, new Point (clip.Left, clip.Bottom), new Point (clip.Right - 1, clip.Bottom)); } else { -- cgit v1.2.3