@@ -297,19 +297,42 @@ private bool ProjectFilter(object item)
297297 private bool UpdatesFilter ( object item )
298298 {
299299 Updates unity = item as Updates ;
300+
300301 bool haveSearchString = string . IsNullOrEmpty ( _filterString ) == false ;
301- bool matchString = unity . Version . IndexOf ( _filterString , 0 , StringComparison . CurrentCultureIgnoreCase ) > - 1 ;
302+ bool matchString = haveSearchString && unity . Version . IndexOf ( _filterString , 0 , StringComparison . CurrentCultureIgnoreCase ) > - 1 ;
303+
304+ bool checkedAlls = ( bool ) rdoAll . IsChecked ;
305+ bool checkedLTSs = ( bool ) rdoLTS . IsChecked ;
306+ bool checkedAlphas = ( bool ) rdoAlphas . IsChecked ;
307+ bool checkedBetas = ( bool ) rdoBetas . IsChecked ;
302308
303- bool checkedAlphas = ( bool ) chkAlphas . IsChecked ;
304- bool checkedBetas = ( bool ) chkBetas . IsChecked ;
309+ bool matchLTS = false ;
310+ if ( checkedLTSs )
311+ {
312+ var version = unity . Version . Split ( '.' ) ;
313+ var versionInt = int . Parse ( version [ 0 ] ) ;
314+ var versionMinor = int . Parse ( version [ 1 ] ) ;
315+ // https://unity3d.com/unity/qa/lts-releases
316+ matchLTS = ( versionInt >= 2017 && versionMinor == 4 ) || ( versionInt > 2019 && versionMinor == 3 ) ;
317+ }
305318
306319 bool matchAlphas = checkedAlphas && unity . Version . IndexOf ( "a" , 0 , StringComparison . CurrentCultureIgnoreCase ) > - 1 ;
307320 bool matchBetas = checkedBetas && unity . Version . IndexOf ( "b" , 0 , StringComparison . CurrentCultureIgnoreCase ) > - 1 ;
308321
309- // TODO there must be simpler way : D
310- if ( checkedAlphas && checkedBetas ) return haveSearchString ? ( matchString && ( matchAlphas || matchBetas ) ) : ( matchAlphas || matchBetas ) ;
311- if ( checkedAlphas ) return haveSearchString ? matchString && matchAlphas : matchAlphas ;
312- if ( checkedBetas ) return haveSearchString ? matchString && matchBetas : matchBetas ;
322+ // match search string and some radiobutton
323+ if ( haveSearchString )
324+ {
325+ if ( checkedAlls ) return matchString ;
326+ if ( checkedLTSs ) return matchString && matchLTS ;
327+ if ( checkedAlphas ) return matchString && matchAlphas ;
328+ if ( checkedBetas ) return matchString && matchBetas ;
329+ }
330+ else // no search text, filter by radiobuttons
331+ {
332+ if ( checkedAlls || matchLTS || matchAlphas || matchBetas ) return true ;
333+ }
334+
335+ // fallback
313336 return matchString ;
314337 }
315338
@@ -621,9 +644,6 @@ async Task CallGetUnityUpdates()
621644 if ( items == null ) return ;
622645 updatesSource = GetUnityUpdates . Parse ( items ) ;
623646 if ( updatesSource == null ) return ;
624-
625-
626-
627647 dataGridUpdates . ItemsSource = updatesSource ;
628648 }
629649
@@ -2816,8 +2836,6 @@ void SortHandlerUpdates(object sender, DataGridSortingEventArgs e)
28162836 //use a ListCollectionView to do the sort.
28172837 ListCollectionView lcv = ( ListCollectionView ) CollectionViewSource . GetDefaultView ( dataGridUpdates . ItemsSource ) ;
28182838
2819- Console . WriteLine ( "Sorted by " + column . Header + " " + direction ) ;
2820-
28212839 comparer = new CustomUpdatesSort ( direction , column . Header . ToString ( ) ) ;
28222840
28232841 //apply the sort
@@ -3178,8 +3196,9 @@ private void txtMaxProjectCount_TextChanged(object sender, TextChangedEventArgs
31783196 }
31793197 }
31803198
3181- private void chkAlphas_Checked ( object sender , RoutedEventArgs e )
3199+ private void rdoAll_Checked ( object sender , RoutedEventArgs e )
31823200 {
3201+ if ( this . IsActive == false ) return ; // dont run code on window init
31833202 FilterUpdates ( ) ;
31843203 }
31853204
0 commit comments