11using System ;
22using System . Collections . Generic ;
33using System . Collections . ObjectModel ;
4+ using System . Diagnostics . CodeAnalysis ;
45using System . Globalization ;
56using System . Linq ;
67using NLog ;
2122using System . Windows ;
2223
2324// ReSharper disable CanBeReplacedWithTryCastAndCheckForNull
25+ // ReSharper disable ExplicitCallerInfoArgument
2426
2527namespace Rubberduck . Navigation . CodeExplorer
2628{
@@ -99,54 +101,45 @@ public CodeExplorerViewModel(FolderHelper folderHelper, RubberduckParserState st
99101
100102 SetNameSortCommand = new DelegateCommand ( LogManager . GetCurrentClassLogger ( ) , param =>
101103 {
102- if ( ( bool ) param == true )
104+ if ( ( bool ) param )
103105 {
104106 SortByName = ( bool ) param ;
105107 SortByCodeOrder = ! ( bool ) param ;
106108 }
107- } , param =>
108- {
109- return SortByName ? false : true ;
110- } ) ;
109+ } , param => ! SortByName ) ;
111110
112111 SetCodeOrderSortCommand = new DelegateCommand ( LogManager . GetCurrentClassLogger ( ) , param =>
113112 {
114- if ( ( bool ) param == true )
113+ if ( ( bool ) param )
115114 {
116115 SortByCodeOrder = ( bool ) param ;
117116 SortByName = ! ( bool ) param ;
118- } ;
119- } , param =>
120- {
121- return SortByCodeOrder ? false : true ;
122- } ) ;
117+ }
118+ } , param => ! SortByCodeOrder ) ;
123119 }
124120
125121 private CodeExplorerItemViewModel _selectedItem ;
126122 public CodeExplorerItemViewModel SelectedItem
127123 {
128- get { return _selectedItem ; }
124+ get => _selectedItem ;
129125 set
130126 {
131127 _selectedItem = value ;
132128 OnPropertyChanged ( ) ;
133129
134- // ReSharper disable ExplicitCallerInfoArgument
135130 OnPropertyChanged ( "CanExecuteIndenterCommand" ) ;
136131 OnPropertyChanged ( "CanExecuteRenameCommand" ) ;
137132 OnPropertyChanged ( "CanExecuteFindAllReferencesCommand" ) ;
138133 OnPropertyChanged ( "ExportVisibility" ) ;
139134 OnPropertyChanged ( "ExportAllVisibility" ) ;
140135 OnPropertyChanged ( "PanelTitle" ) ;
141136 OnPropertyChanged ( "Description" ) ;
142-
143- // ReSharper restore ExplicitCallerInfoArgument
144137 }
145138 }
146139
147140 public bool SortByName
148141 {
149- get { return _windowSettings . CodeExplorer_SortByName ; }
142+ get => _windowSettings . CodeExplorer_SortByName ;
150143 set
151144 {
152145 if ( _windowSettings . CodeExplorer_SortByName == value )
@@ -166,7 +159,7 @@ public bool SortByName
166159
167160 public bool SortByCodeOrder
168161 {
169- get { return _windowSettings . CodeExplorer_SortByCodeOrder ; }
162+ get => _windowSettings . CodeExplorer_SortByCodeOrder ;
170163 set
171164 {
172165 if ( _windowSettings . CodeExplorer_SortByCodeOrder == value )
@@ -192,7 +185,7 @@ public bool SortByCodeOrder
192185
193186 public bool GroupByType
194187 {
195- get { return _windowSettings . CodeExplorer_GroupByType ; }
188+ get => _windowSettings . CodeExplorer_GroupByType ;
196189 set
197190 {
198191 if ( _windowSettings . CodeExplorer_GroupByType != value )
@@ -207,10 +200,22 @@ public bool GroupByType
207200 }
208201 }
209202
203+ private bool _canSearch ;
204+
205+ public bool CanSearch
206+ {
207+ get => _canSearch ;
208+ set
209+ {
210+ _canSearch = value ;
211+ OnPropertyChanged ( ) ;
212+ }
213+ }
214+
210215 private bool _isBusy ;
211216 public bool IsBusy
212217 {
213- get { return _isBusy ; }
218+ get => _isBusy ;
214219 set
215220 {
216221 _isBusy = value ;
@@ -277,15 +282,17 @@ public string Description
277282 private ObservableCollection < CodeExplorerItemViewModel > _projects ;
278283 public ObservableCollection < CodeExplorerItemViewModel > Projects
279284 {
280- get { return _projects ; }
285+ get => _projects ;
281286 set
282287 {
283288 ReorderChildNodes ( value ) ;
284289 _projects = new ObservableCollection < CodeExplorerItemViewModel > ( value . OrderBy ( o => o . NameWithSignature ) ) ;
285-
290+ CanSearch = _projects . Any ( ) ;
291+
286292 OnPropertyChanged ( ) ;
287293 // Once a Project has been set, show the TreeView
288294 OnPropertyChanged ( "TreeViewVisibility" ) ;
295+ OnPropertyChanged ( "CanSearch" ) ;
289296 }
290297 }
291298
0 commit comments