Skip to content

Commit 43f83c9

Browse files
committed
- Custom themed TreeViewEx added, not used atm (slower and not feature complete)
- Minor obsidian theme fix
1 parent 32aeaf9 commit 43f83c9

File tree

4 files changed

+112
-2
lines changed

4 files changed

+112
-2
lines changed

External/Themes/FullThemes/ObsidianTheme/$(BaseDir)/Settings/Themes/CURRENT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ VS2005DockPaneStrip.DocTabActiveBorder=#2F393C
9999
VS2005DockPaneStrip.DocTabActiveForeColor=#D1D1D1
100100
VS2005DockPaneStrip.DocTabInactiveBorder=#666D73
101101
VS2005DockPaneStrip.ToolActiveBorderColor=#6D767C
102-
VS2005DockPaneStrip.ToolBorderColor=#6D767C
102+
VS2005DockPaneStrip.ToolBorderColor=#8D9494
103103
VS2005DockPaneStrip.ToolActiveForeColor=#333333
104104
VS2005DockPaneStrip.ToolSeparatorColor=#CCCCCC
105105
VS2005DockPaneStrip.ImageColor=#3A4345

External/Themes/FullThemes/ObsidianTheme/$(BaseDir)/Settings/Themes/Obsidian.fdi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ VS2005DockPaneStrip.DocTabActiveBorder=#2F393C
9999
VS2005DockPaneStrip.DocTabActiveForeColor=#D1D1D1
100100
VS2005DockPaneStrip.DocTabInactiveBorder=#666D73
101101
VS2005DockPaneStrip.ToolActiveBorderColor=#6D767C
102-
VS2005DockPaneStrip.ToolBorderColor=#6D767C
102+
VS2005DockPaneStrip.ToolBorderColor=#8D9494
103103
VS2005DockPaneStrip.ToolActiveForeColor=#333333
104104
VS2005DockPaneStrip.ToolSeparatorColor=#CCCCCC
105105
VS2005DockPaneStrip.ImageColor=#3A4345
Binary file not shown.

PluginCore/PluginCore/Controls/Common.cs

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.IO;
23
using System.Drawing;
34
using System.Drawing.Drawing2D;
45
using System.ComponentModel.Design;
@@ -276,6 +277,115 @@ protected override void WndProc(ref Message message)
276277
}
277278

278279
}
280+
281+
public class TreeViewEx : TreeView
282+
{
283+
private static Int32 SIZE1 = ScaleHelper.Scale(1);
284+
private static Int32 SIZE2 = ScaleHelper.Scale(2);
285+
private static Int32 SIZE3 = ScaleHelper.Scale(3);
286+
287+
public TreeViewEx() : base()
288+
{
289+
this.DrawMode = TreeViewDrawMode.OwnerDrawAll;
290+
this.DrawNode += OnDrawNode;
291+
this.DragOver += OnDragOver;
292+
this.ShowPlusMinus = true;
293+
}
294+
295+
protected override CreateParams CreateParams
296+
{
297+
get
298+
{
299+
CreateParams cp = base.CreateParams;
300+
cp.ExStyle |= 0x02000000; // WS_CLIPCHILDREN
301+
return cp;
302+
}
303+
}
304+
305+
private void OnDragOver(Object sender, DragEventArgs e)
306+
{
307+
Point point = this.PointToClient(new Point(e.X, e.Y));
308+
TreeViewHitTestInfo hit = this.HitTest(point);
309+
if (hit.Node != null) this.SelectedNode = hit.Node;
310+
}
311+
312+
private void OnDrawNode(Object sender, DrawTreeNodeEventArgs e)
313+
{
314+
e.DrawDefault = false;
315+
Rectangle bounds = e.Node.Bounds;
316+
Color backHl = PluginBase.MainForm.GetThemeColor("TreeView.Highlight", SystemColors.Highlight);
317+
Color foreHl = PluginBase.MainForm.GetThemeColor("TreeView.HighlightText", SystemColors.HighlightText);
318+
SolidBrush brushFore = new SolidBrush(e.Node.TreeView.LineColor);
319+
SolidBrush brushBack = new SolidBrush(e.Node.TreeView.BackColor);
320+
if (bounds.IsEmpty || !e.Node.IsVisible) return;
321+
if ((e.State & TreeNodeStates.Focused) != 0)
322+
{
323+
e.Graphics.FillRectangle(new SolidBrush(backHl), Rectangle.Inflate(bounds, 1, 0));
324+
}
325+
else if ((e.State & TreeNodeStates.Selected) != 0)
326+
{
327+
e.Graphics.FillRectangle(new SolidBrush(Color.Gray), Rectangle.Inflate(bounds, 1, 0));
328+
}
329+
else e.Graphics.FillRectangle(brushBack, bounds);
330+
if (e.Node.Nodes.Count > 0)
331+
{
332+
Point[] arrow;
333+
Point middle = new Point(bounds.Left - 28, bounds.Top + bounds.Height / 2);
334+
if (e.Node.IsExpanded)
335+
{
336+
arrow = new Point[]
337+
{
338+
new Point(middle.X - SIZE3, middle.Y - 1),
339+
new Point(middle.X + SIZE3 + 1, middle.Y - 1),
340+
new Point(middle.X, middle.Y + SIZE3)
341+
};
342+
e.Graphics.FillPolygon(brushFore, arrow);
343+
arrow = new Point[]
344+
{
345+
new Point(middle.X - SIZE1, middle.Y - 1),
346+
new Point(middle.X + SIZE1 + 1, middle.Y - 1),
347+
new Point(middle.X, middle.Y + SIZE1)
348+
};
349+
e.Graphics.FillPolygon(brushBack, arrow);
350+
}
351+
else
352+
{
353+
arrow = new Point[]
354+
{
355+
new Point(middle.X - SIZE2, middle.Y - 2 * SIZE2),
356+
new Point(middle.X - SIZE2, middle.Y + 2 * SIZE2),
357+
new Point(middle.X + SIZE2, middle.Y)
358+
};
359+
e.Graphics.FillPolygon(brushFore, arrow);
360+
arrow = new Point[]
361+
{
362+
new Point(middle.X - SIZE1 - 1, middle.Y - 2 * SIZE1),
363+
new Point(middle.X - SIZE1 - 1, middle.Y + 2 * SIZE1),
364+
new Point(middle.X + SIZE1 - 1, middle.Y)
365+
};
366+
e.Graphics.FillPolygon(brushBack, arrow);
367+
}
368+
}
369+
if (e.Node.ImageIndex != -1)
370+
{
371+
Point nodePt = new Point(bounds.Location.X - 20, bounds.Location.Y + 1);
372+
Image nodeImg = e.Node.TreeView.ImageList.Images[e.Node.ImageIndex];
373+
e.Graphics.DrawImage(nodeImg, nodePt);
374+
}
375+
Rectangle textRect = bounds;
376+
Font nodeFont = e.Node.NodeFont;
377+
Color textColor = e.Node.ForeColor;
378+
textRect = Rectangle.Inflate(textRect, 2, 0);
379+
if (nodeFont == null) nodeFont = ((TreeView)sender).Font;
380+
if (nodeFont.Bold) textRect.X += 1;
381+
if ((e.State & TreeNodeStates.Focused) != 0) textColor = foreHl;
382+
if ((e.State & TreeNodeStates.Selected) != 0) textColor = foreHl;
383+
if ((e.State & TreeNodeStates.Hot) != 0) nodeFont = new Font(nodeFont, FontStyle.Underline);
384+
TextRenderer.DrawText(e.Graphics, e.Node.Text, nodeFont, textRect, textColor);
385+
}
386+
387+
}
388+
279389
public class ToolStripComboBoxEx : ToolStripControlHost
280390
{
281391
public ToolStripComboBoxEx() : base(new FlatCombo())

0 commit comments

Comments
 (0)