@@ -15,13 +15,16 @@ public sealed partial class OpenRecentProjectsForm : Form
1515 {
1616 [ NotNull ] readonly Settings settings ;
1717 [ NotNull ] [ ItemNotNull ] readonly List < string > recentProjects = ProjectManager . PluginMain . Settings . RecentProjects . Where ( File . Exists ) . ToList ( ) ;
18+ [ NotNull ] readonly Brush defaultNodeBrush ;
19+ [ NotNull ] readonly Brush selectedNodeBrush = new SolidBrush ( SystemColors . ControlDarkDark ) ;
1820
1921 public OpenRecentProjectsForm ( [ NotNull ] Settings settings )
2022 {
2123 this . settings = settings ;
2224 Font = PluginBase . Settings . DefaultFont ;
2325 InitializeComponent ( ) ;
2426 InitializeTree ( ) ;
27+ defaultNodeBrush = new SolidBrush ( tree . BackColor ) ;
2528 if ( settings . RecentProjectsSize . Width > MinimumSize . Width ) Size = settings . RecentProjectsSize ;
2629 RefrestTree ( ) ;
2730 }
@@ -55,7 +58,11 @@ void FillTree()
5558 {
5659 var search = input . Text ;
5760 var projects = search . Length > 0 ? SearchUtil . FindAll ( recentProjects , search ) : recentProjects ;
58- if ( projects . Count > 0 ) projects . ForEach ( it => tree . Nodes . Add ( it , it , 0 ) ) ;
61+ if ( projects . Count == 0 ) return ;
62+ foreach ( var it in projects )
63+ {
64+ tree . Nodes . Add ( it , it , 0 ) ;
65+ }
5966 }
6067
6168 void Navigate ( )
@@ -121,5 +128,30 @@ void OnInputKeyDown(object sender, KeyEventArgs e)
121128 void OnTreeMouseDoubleClick ( object sender , MouseEventArgs e ) => Navigate ( ) ;
122129
123130 void OnTreeAfterSelect ( object sender , TreeViewEventArgs e ) => open . Enabled = SelectedItem != null ;
131+
132+ void OnTreeDrawNode ( object sender , DrawTreeNodeEventArgs e )
133+ {
134+ var fillBrush = defaultNodeBrush ;
135+ var textBrush = Brushes . Black ;
136+ var moduleBrush = Brushes . DimGray ;
137+ if ( ( e . State & TreeNodeStates . Selected ) > 0 )
138+ {
139+ fillBrush = selectedNodeBrush ;
140+ textBrush = Brushes . White ;
141+ moduleBrush = Brushes . LightGray ;
142+ }
143+ var bounds = e . Bounds ;
144+ var text = Path . GetFileNameWithoutExtension ( e . Node . Text ) ;
145+ float x = bounds . X ;
146+ var itemWidth = tree . Width - x ;
147+ var graphics = e . Graphics ;
148+ graphics . FillRectangle ( fillBrush , x , bounds . Y , itemWidth , tree . ItemHeight ) ;
149+ var font = tree . Font ;
150+ graphics . DrawString ( text , font , textBrush , x , bounds . Top , StringFormat . GenericDefault ) ;
151+ var path = Path . GetDirectoryName ( e . Node . Text ) ;
152+ if ( string . IsNullOrEmpty ( path ) ) return ;
153+ x += graphics . MeasureString ( text , font ) . Width ;
154+ graphics . DrawString ( $ "({ path } )", font , moduleBrush , x , bounds . Top , StringFormat . GenericDefault ) ;
155+ }
124156 }
125157}
0 commit comments