@@ -731,12 +731,24 @@ public void RefreshRecentProjects()
731731 // take currently selected project row
732732 lastSelectedProjectIndex = gridRecent . SelectedIndex ;
733733 // rescan recent projects
734- // projectsSource = GetProjects.Scan(getGitBranch: (bool)chkShowGitBranchColumn.IsChecked, getPlasticBranch: (bool)chkCheckPlasticBranch.IsChecked, getArguments: (bool)chkShowLauncherArgumentsColumn.IsChecked, showMissingFolders: (bool)chkShowMissingFolderProjects.IsChecked, showTargetPlatform: (bool)chkShowPlatform.IsChecked);
735734 projectsSource = GetProjects . Scan ( getGitBranch : ( bool ) chkShowGitBranchColumn . IsChecked , getPlasticBranch : ( bool ) chkCheckPlasticBranch . IsChecked , getArguments : ( bool ) chkShowLauncherArgumentsColumn . IsChecked , showMissingFolders : ( bool ) chkShowMissingFolderProjects . IsChecked , showTargetPlatform : ( bool ) chkShowPlatform . IsChecked , AllProjectPaths : Properties . Settings . Default . projectPaths ) ;
736735 gridRecent . ItemsSource = projectsSource ;
736+
737+ // fix sorting on refresh
738+ foreach ( DataGridColumn column in gridRecent . Columns )
739+ {
740+ if ( column . Header . ToString ( ) == Settings . Default . currentSortColumn )
741+ {
742+ // TODO FIXME, hack for correct direction on refresh only
743+ Settings . Default . currentSortDirectionAscending = ! Settings . Default . currentSortDirectionAscending ;
744+ var g = new DataGridSortingEventArgs ( column ) ;
745+ SortHandlerRecentProjects ( gridRecent , g ) ;
746+ break ;
747+ }
748+ }
749+
737750 // focus back
738751 Tools . SetFocusToGrid ( gridRecent , lastSelectedProjectIndex ) ;
739- //Console.WriteLine("RefreshRecentProjects: " + projectsSource.Count);
740752 SetStatus ( "Ready (" + projectsSource . Count + " projects)" ) ;
741753 }
742754
@@ -1094,7 +1106,11 @@ private void GridRecent_Loaded(object sender, RoutedEventArgs e)
10941106 Tools . SetFocusToGrid ( gridRecent ) ;
10951107 // if coming from explorer launch, and missing unity version, projectsource is still null?
10961108 if ( projectsSource != null ) SetStatus ( "Ready (" + projectsSource . Count + " projects)" ) ;
1109+ RefreshSorting ( ) ;
1110+ }
10971111
1112+ void RefreshSorting ( )
1113+ {
10981114 // use saved sort columns
10991115 if ( string . IsNullOrEmpty ( Settings . Default . currentSortColumn ) == false )
11001116 {
@@ -1103,9 +1119,13 @@ private void GridRecent_Loaded(object sender, RoutedEventArgs e)
11031119 {
11041120 if ( column . Header . ToString ( ) == Settings . Default . currentSortColumn )
11051121 {
1106- // TODO Project binding is to Title, not project
1122+ // TODO FIXME Project binding is to Title, not projects
11071123 Settings . Default . currentSortColumn = Settings . Default . currentSortColumn . Replace ( "Project" , "Title" ) ;
1108- gridRecent . Items . SortDescriptions . Add ( new SortDescription ( Settings . Default . currentSortColumn , Settings . Default . currentSortDirectionAscending ? ListSortDirection . Ascending : ListSortDirection . Descending ) ) ;
1124+
1125+ // TODO FIXME, hack for correct direction on this refresh
1126+ Settings . Default . currentSortDirectionAscending = ! Settings . Default . currentSortDirectionAscending ;
1127+ var g = new DataGridSortingEventArgs ( column ) ;
1128+ SortHandlerRecentProjects ( gridRecent , g ) ;
11091129 break ;
11101130 }
11111131 }
@@ -1140,8 +1160,6 @@ private void BtnUpdateUnity_Click(object sender, RoutedEventArgs e)
11401160 GoLookForUpdatesForThisUnity ( ) ;
11411161 }
11421162
1143-
1144-
11451163 // if press up/down in search box, move to first item in results
11461164 private void TxtSearchBox_PreviewKeyDown ( object sender , KeyEventArgs e )
11471165 {
@@ -2994,8 +3012,6 @@ void SortHandlerRecentProjects(object sender, DataGridSortingEventArgs e)
29943012 {
29953013 DataGridColumn column = e . Column ;
29963014
2997- //Console.WriteLine("Sorted by " + column.Header);
2998-
29993015 // save current sort to prefs
30003016 Settings . Default . currentSortColumn = column . Header . ToString ( ) ;
30013017
@@ -3010,7 +3026,7 @@ void SortHandlerRecentProjects(object sender, DataGridSortingEventArgs e)
30103026 ListSortDirection direction = ( column . SortDirection != ListSortDirection . Ascending ) ? ListSortDirection . Ascending : ListSortDirection . Descending ;
30113027
30123028 // save
3013- Settings . Default . currentSortDirectionAscending = direction == ListSortDirection . Ascending ;
3029+ Settings . Default . currentSortDirectionAscending = ( direction == ListSortDirection . Ascending ) ;
30143030
30153031 //set the sort order on the column
30163032 column . SortDirection = direction ;
0 commit comments