1111using Microsoft . Win32 ;
1212using SDV . App . Logging ;
1313using Serilog . Events ;
14- using SDV . DependenciesAnalyzer . Interfaces ;
1514using SDV . GraphGenerator . Interfaces ;
1615
1716namespace SDV . App
@@ -36,10 +35,10 @@ public MainWindow(ILogger<MainWindow> logger, WindowLogSink logSink, IGraphBuild
3635 {
3736 Filter = "solution files (*.sln)|*.sln"
3837 } ;
39- PackagePrefixes . Text = "Microsoft.*, System.*" ;
38+ PackageFiltersExclude . Text = "Microsoft.*, System.*" ;
4039 IncludeDependentProjects . IsChecked = true ;
4140 ClearSelectionButton . IsEnabled = false ;
42- SetupModeComboBox ( ) ;
41+ Labels . Text = "IsNuget= \ud83d \udce6 " ;
4342 logSink . OnLogEmitted = OnLogEmitted ;
4443 }
4544
@@ -69,19 +68,25 @@ private async void btnBuild_Click(object sender, RoutedEventArgs e)
6968 _logger . LogError ( "Please, select sln file to proceed" ) ;
7069 return ;
7170 }
72-
71+
7372 ToggleControlsAs ( false ) ;
7473
7574 try
7675 {
7776 var request = new GraphBuilderRequest ( _slnFilePaths )
7877 {
79- Mode = ( PackageFilterMode ) Mode . SelectedValue ,
80- PackageFilters = PackagePrefixes . Text . Split ( "," ) . Select ( t => t . Trim ( ) ) . Where ( t => ! string . IsNullOrEmpty ( t ) ) . ToArray ( ) ,
78+ FiltersInclude = GetCommaSeparatedValues ( PackageFiltersInclude . Text ) . ToArray ( ) ,
79+ FiltersExclude = GetCommaSeparatedValues ( PackageFiltersExclude . Text ) . ToArray ( ) ,
80+ Labels = GetCommaSeparatedValues ( Labels . Text ) . Select ( s => s . Split ( '=' ) ) . Where ( a => a . Length == 2 )
81+ . GroupBy ( s => s [ 0 ] . Trim ( ) )
82+ . ToDictionary (
83+ g => g . Key ,
84+ g => g . SelectMany ( v => v ) . Select ( s => s . Trim ( ) )
85+ . Where ( s => ! string . IsNullOrEmpty ( s ) && s != g . Key ) . ToArray ( ) ) ,
8186 IncludeDependentProjects = IncludeDependentProjects . IsChecked ?? false ,
8287 MergeProjects = MergeProjects . IsChecked ?? false
8388 } ;
84-
89+
8590 var path = await BuildGraphAndGetFilePathAsync ( request ) ;
8691
8792 OpenUrl ( path ) ;
@@ -97,12 +102,17 @@ private async void btnBuild_Click(object sender, RoutedEventArgs e)
97102 }
98103 }
99104
100- private Task < string > BuildGraphAndGetFilePathAsync ( GraphBuilderRequest graphBuilderRequest ) =>
105+ private static IEnumerable < string > GetCommaSeparatedValues ( string str )
106+ {
107+ return str . Split ( "," ) . Select ( t => t . Trim ( ) ) . Where ( t => ! string . IsNullOrEmpty ( t ) ) ;
108+ }
109+
110+ private Task < string > BuildGraphAndGetFilePathAsync ( GraphBuilderRequest graphBuilderRequest ) =>
101111 Task . Run ( ( ) => _builder . BuildGraphAndGetFilePath ( graphBuilderRequest ) ) ;
102112
103113 private void btnClearSelection_Click ( object sender , RoutedEventArgs e )
104114 {
105- _slnFilePaths = new HashSet < string > ( ) ;
115+ _slnFilePaths = [ ] ;
106116 Log . Text = string . Empty ;
107117 _logger . LogInformation ( "Selection cleared" ) ;
108118 ClearSelectionButton . IsEnabled = false ;
@@ -136,27 +146,17 @@ private static void OpenUrl(string url)
136146 }
137147 }
138148
139- private void SetupModeComboBox ( )
140- {
141- var item = Tuple . Create ( "Disabled" , PackageFilterMode . None ) ;
142- Mode . DisplayMemberPath = nameof ( item . Item1 ) ;
143- Mode . SelectedValuePath = nameof ( item . Item2 ) ;
144- Mode . SelectedValue = PackageFilterMode . Exclude ;
145- Mode . Items . Add ( item ) ;
146- Mode . Items . Add ( Tuple . Create ( "Include listed packages" , PackageFilterMode . Include ) ) ;
147- Mode . Items . Add ( Tuple . Create ( "Exclude listed packages" , PackageFilterMode . Exclude ) ) ;
148- }
149-
150149 private void ToggleControlsAs ( bool state )
151150 {
152151 SlnFileSelectorButton . IsEnabled = state ;
153- Mode . IsEnabled = state ;
154- PackagePrefixes . IsEnabled = state ;
152+ PackageFiltersInclude . IsEnabled = state ;
153+ PackageFiltersExclude . IsEnabled = state ;
154+ Labels . IsEnabled = state ;
155155 IncludeDependentProjects . IsEnabled = state ;
156156 MergeProjects . IsEnabled = state ;
157157 BuildGraphButton . IsEnabled = state ;
158158 }
159-
159+
160160 private void OnLogEmitted ( LogEventLevel level , string log )
161161 {
162162 Log . Dispatcher . Invoke ( DispatcherPriority . Background , ( ) =>
@@ -167,7 +167,7 @@ private void OnLogEmitted(LogEventLevel level, string log)
167167 } ) ;
168168 }
169169
170- private static Brush GetBrushForLevel ( LogEventLevel level )
170+ private static SolidColorBrush GetBrushForLevel ( LogEventLevel level )
171171 {
172172 return level switch
173173 {
0 commit comments