@@ -8,39 +8,32 @@ internal static class TreeViewAdvThemeExtender
88 {
99 internal static void SubscribeToThemes ( )
1010 {
11- Theme . OnCurrentChanged += ( ) => { AssignRendersTheme ( Theme . Current ) ; } ;
11+ Theme . OnCurrentChanged += ( ) => { AssignRendersTheme ( ) ; } ;
1212 Theme . OnApplyToControl += ( control , theme ) => {
1313 if ( control is TreeViewAdv treeView )
1414 {
15- treeView . BackColor = theme . TreeBackgroundColor ;
16- treeView . ForeColor = theme . TreeTextColor ;
17- treeView . LineColor = theme . TreeOutlineColor ;
15+ treeView . BackColor = theme . BackgroundColor ;
16+ treeView . ForeColor = theme . ForegroundColor ;
17+ treeView . LineColor = theme . ForegroundColor ;
1818 return true ;
1919 }
2020 return false ;
2121 } ;
2222 }
2323
24- internal static void AssignRendersTheme ( Theme current )
24+ internal static void AssignRendersTheme ( )
2525 {
2626 TreeViewAdv . CustomPlusMinusRenderFunc = ( g , rect , isExpanded ) =>
2727 {
2828 int x = rect . Left ;
2929 int y = rect . Top + 5 ;
3030 int size = 8 ;
31- using ( Brush brush = new SolidBrush ( current . BackgroundColor ) )
31+ g . FillRectangle ( Theme . BackgroundBrush , x - 1 , y - 1 , size + 4 , size + 4 ) ;
32+ g . DrawRectangle ( Theme . ForegroundPen , x , y , size , size ) ;
33+ g . DrawLine ( Theme . ForegroundPen , x + 2 , y + size / 2 , x + size - 2 , y + size / 2 ) ;
34+ if ( ! isExpanded )
3235 {
33- g . FillRectangle ( brush , x - 1 , y - 1 , size + 4 , size + 4 ) ;
34- }
35- using ( Pen pen = new Pen ( current . TreeOutlineColor ) )
36- {
37-
38- g . DrawRectangle ( pen , x , y , size , size ) ;
39- g . DrawLine ( pen , x + 2 , y + size / 2 , x + size - 2 , y + size / 2 ) ;
40- if ( ! isExpanded )
41- {
42- g . DrawLine ( pen , x + size / 2 , y + 2 , x + size / 2 , y + size - 2 ) ;
43- }
36+ g . DrawLine ( Theme . ForegroundPen , x + size / 2 , y + 2 , x + size / 2 , y + size - 2 ) ;
4437 }
4538 } ;
4639
@@ -49,46 +42,34 @@ internal static void AssignRendersTheme(Theme current)
4942 int x = rect . Left ;
5043 int y = rect . Top + 1 ;
5144 int size = 12 ;
52- using ( Brush brush = new SolidBrush ( current . BackgroundColor ) )
53- {
54- g . FillRectangle ( brush , x - 1 , y - 1 , 12 , 12 ) ;
55- }
56- using ( Pen pen = new Pen ( current . TreeOutlineColor ) )
45+ g . FillRectangle ( Theme . BackgroundBrush , x - 1 , y - 1 , 12 , 12 ) ;
46+ g . DrawRectangle ( Theme . ForegroundPen , x , y , size , size ) ;
47+ if ( isChecked )
5748 {
58- g . DrawRectangle ( pen , x , y , size , size ) ;
59- if ( isChecked )
60- {
61- x += 3 ;
62- y += 3 ;
63- g . DrawLine ( pen , x , y + 3 , x + 2 , y + 5 ) ;
64- g . DrawLine ( pen , x + 2 , y + 5 , x + 6 , y + 1 ) ;
65- g . DrawLine ( pen , x , y + 4 , x + 2 , y + 6 ) ;
66- g . DrawLine ( pen , x + 2 , y + 6 , x + 6 , y + 2 ) ;
67- }
49+ x += 3 ;
50+ y += 3 ;
51+ g . DrawLine ( Theme . ForegroundPen , x , y + 3 , x + 2 , y + 5 ) ;
52+ g . DrawLine ( Theme . ForegroundPen , x + 2 , y + 5 , x + 6 , y + 1 ) ;
53+ g . DrawLine ( Theme . ForegroundPen , x , y + 4 , x + 2 , y + 6 ) ;
54+ g . DrawLine ( Theme . ForegroundPen , x + 2 , y + 6 , x + 6 , y + 2 ) ;
6855 }
6956 } ;
7057
7158 TreeViewAdv . CustomColumnBackgroundRenderFunc = ( g , rect , isPressed , isHot ) =>
7259 {
73- using ( Brush brush = new SolidBrush ( current . TreeBackgroundColor ) )
74- {
75- g . FillRectangle ( brush , rect ) ;
76- }
77- using ( Pen pen = new Pen ( current . TreeRowSeparatorColor ) )
78- {
79- g . DrawLine ( pen , rect . Left , rect . Top , rect . Right , rect . Top ) ;
80- g . DrawLine ( pen , rect . Left , rect . Top + 1 , rect . Right , rect . Top + 1 ) ;
81- }
60+ g . FillRectangle ( Theme . BackgroundBrush , rect ) ;
61+ g . DrawLine ( Theme . LinePen , rect . Left , rect . Top , rect . Right , rect . Top ) ;
62+ g . DrawLine ( Theme . LinePen , rect . Left , rect . Top + 1 , rect . Right , rect . Top + 1 ) ;
8263 } ;
8364
8465 TreeViewAdv . CustomColumnTextRenderFunc = ( g , rect , font , text ) =>
8566 {
86- TextRenderer . DrawText ( g , text , font , rect , current . TreeTextColor , TextFormatFlags . Left ) ;
67+ TextRenderer . DrawText ( g , text , font , rect , Theme . Current . ForegroundColor , TextFormatFlags . Left ) ;
8768 } ;
8869
89- TreeViewAdv . CustomHorizontalLinePen = new Pen ( current . TreeRowSeparatorColor ) ;
90- TreeViewAdv . CustomSelectedRowBrush = new SolidBrush ( current . TreeSelectedBackgroundColor ) ;
91- TreeViewAdv . CustomSelectedTextColor = current . TreeSelectedTextColor ;
70+ TreeViewAdv . CustomHorizontalLinePen = Theme . LinePen ;
71+ TreeViewAdv . CustomSelectedRowBrush = Theme . SelectedBackBrush ;
72+ TreeViewAdv . CustomSelectedTextColor = Theme . Current . SelectedForegroundColor ;
9273 }
9374 }
9475}
0 commit comments