1
1
using System ;
2
2
using System . Collections . Generic ;
3
3
using System . Collections . ObjectModel ;
4
+ using System . Diagnostics . CodeAnalysis ;
4
5
using System . Globalization ;
5
6
using System . Linq ;
6
7
using NLog ;
21
22
using System . Windows ;
22
23
23
24
// ReSharper disable CanBeReplacedWithTryCastAndCheckForNull
25
+ // ReSharper disable ExplicitCallerInfoArgument
24
26
25
27
namespace Rubberduck . Navigation . CodeExplorer
26
28
{
@@ -99,54 +101,45 @@ public CodeExplorerViewModel(FolderHelper folderHelper, RubberduckParserState st
99
101
100
102
SetNameSortCommand = new DelegateCommand ( LogManager . GetCurrentClassLogger ( ) , param =>
101
103
{
102
- if ( ( bool ) param == true )
104
+ if ( ( bool ) param )
103
105
{
104
106
SortByName = ( bool ) param ;
105
107
SortByCodeOrder = ! ( bool ) param ;
106
108
}
107
- } , param =>
108
- {
109
- return SortByName ? false : true ;
110
- } ) ;
109
+ } , param => ! SortByName ) ;
111
110
112
111
SetCodeOrderSortCommand = new DelegateCommand ( LogManager . GetCurrentClassLogger ( ) , param =>
113
112
{
114
- if ( ( bool ) param == true )
113
+ if ( ( bool ) param )
115
114
{
116
115
SortByCodeOrder = ( bool ) param ;
117
116
SortByName = ! ( bool ) param ;
118
- } ;
119
- } , param =>
120
- {
121
- return SortByCodeOrder ? false : true ;
122
- } ) ;
117
+ }
118
+ } , param => ! SortByCodeOrder ) ;
123
119
}
124
120
125
121
private CodeExplorerItemViewModel _selectedItem ;
126
122
public CodeExplorerItemViewModel SelectedItem
127
123
{
128
- get { return _selectedItem ; }
124
+ get => _selectedItem ;
129
125
set
130
126
{
131
127
_selectedItem = value ;
132
128
OnPropertyChanged ( ) ;
133
129
134
- // ReSharper disable ExplicitCallerInfoArgument
135
130
OnPropertyChanged ( "CanExecuteIndenterCommand" ) ;
136
131
OnPropertyChanged ( "CanExecuteRenameCommand" ) ;
137
132
OnPropertyChanged ( "CanExecuteFindAllReferencesCommand" ) ;
138
133
OnPropertyChanged ( "ExportVisibility" ) ;
139
134
OnPropertyChanged ( "ExportAllVisibility" ) ;
140
135
OnPropertyChanged ( "PanelTitle" ) ;
141
136
OnPropertyChanged ( "Description" ) ;
142
-
143
- // ReSharper restore ExplicitCallerInfoArgument
144
137
}
145
138
}
146
139
147
140
public bool SortByName
148
141
{
149
- get { return _windowSettings . CodeExplorer_SortByName ; }
142
+ get => _windowSettings . CodeExplorer_SortByName ;
150
143
set
151
144
{
152
145
if ( _windowSettings . CodeExplorer_SortByName == value )
@@ -166,7 +159,7 @@ public bool SortByName
166
159
167
160
public bool SortByCodeOrder
168
161
{
169
- get { return _windowSettings . CodeExplorer_SortByCodeOrder ; }
162
+ get => _windowSettings . CodeExplorer_SortByCodeOrder ;
170
163
set
171
164
{
172
165
if ( _windowSettings . CodeExplorer_SortByCodeOrder == value )
@@ -192,7 +185,7 @@ public bool SortByCodeOrder
192
185
193
186
public bool GroupByType
194
187
{
195
- get { return _windowSettings . CodeExplorer_GroupByType ; }
188
+ get => _windowSettings . CodeExplorer_GroupByType ;
196
189
set
197
190
{
198
191
if ( _windowSettings . CodeExplorer_GroupByType != value )
@@ -207,10 +200,22 @@ public bool GroupByType
207
200
}
208
201
}
209
202
203
+ private bool _canSearch ;
204
+
205
+ public bool CanSearch
206
+ {
207
+ get => _canSearch ;
208
+ set
209
+ {
210
+ _canSearch = value ;
211
+ OnPropertyChanged ( ) ;
212
+ }
213
+ }
214
+
210
215
private bool _isBusy ;
211
216
public bool IsBusy
212
217
{
213
- get { return _isBusy ; }
218
+ get => _isBusy ;
214
219
set
215
220
{
216
221
_isBusy = value ;
@@ -277,15 +282,17 @@ public string Description
277
282
private ObservableCollection < CodeExplorerItemViewModel > _projects ;
278
283
public ObservableCollection < CodeExplorerItemViewModel > Projects
279
284
{
280
- get { return _projects ; }
285
+ get => _projects ;
281
286
set
282
287
{
283
288
ReorderChildNodes ( value ) ;
284
289
_projects = new ObservableCollection < CodeExplorerItemViewModel > ( value . OrderBy ( o => o . NameWithSignature ) ) ;
285
-
290
+ CanSearch = _projects . Any ( ) ;
291
+
286
292
OnPropertyChanged ( ) ;
287
293
// Once a Project has been set, show the TreeView
288
294
OnPropertyChanged ( "TreeViewVisibility" ) ;
295
+ OnPropertyChanged ( "CanSearch" ) ;
289
296
}
290
297
}
291
298
0 commit comments