@@ -39,7 +39,7 @@ public partial class MainWindow : Window
39
39
public static readonly string launcherArgumentsFile = "LauncherArguments.txt" ;
40
40
string _filterString = null ;
41
41
const string githubURL = "https://github.com/unitycoder/UnityLauncherPro" ;
42
-
42
+ int lastSelectedProjectIndex = 0 ;
43
43
Mutex myMutex ;
44
44
45
45
public MainWindow ( )
@@ -339,14 +339,20 @@ void AddUnityInstallationRootFolder()
339
339
}
340
340
}
341
341
342
- void SetFocusToGrid ( DataGrid targetGrid )
342
+ void SetFocusToGrid ( DataGrid targetGrid , int index = 0 )
343
343
{
344
344
//e.Handled = true; // if enabled, we enter to first row initially
345
345
if ( targetGrid . Items . Count < 1 ) return ;
346
346
targetGrid . Focus ( ) ;
347
- targetGrid . SelectedIndex = 0 ;
348
- DataGridRow row = ( DataGridRow ) targetGrid . ItemContainerGenerator . ContainerFromIndex ( 0 ) ;
347
+ DataGridRow row = ( DataGridRow ) targetGrid . ItemContainerGenerator . ContainerFromIndex ( index ) ;
348
+ if ( row == null )
349
+ {
350
+ gridRecent . UpdateLayout ( ) ;
351
+ gridRecent . ScrollIntoView ( gridRecent . Items [ index ] ) ;
352
+ row = ( DataGridRow ) gridRecent . ItemContainerGenerator . ContainerFromIndex ( index ) ;
353
+ }
349
354
row . MoveFocus ( new TraversalRequest ( FocusNavigationDirection . Next ) ) ;
355
+ targetGrid . SelectedIndex = index ;
350
356
}
351
357
352
358
async void CallGetUnityUpdates ( )
@@ -490,17 +496,20 @@ private void OnWindowKeyDown(object sender, KeyEventArgs e)
490
496
491
497
switch ( e . Key )
492
498
{
493
- case Key . F5 : // refresh projects
494
- projectsSource = GetProjects . Scan ( getGitBranch : ( bool ) chkShowGitBranchColumn . IsChecked , getArguments : ( bool ) chkShowLauncherArgumentsColumn . IsChecked , showMissingFolders : ( bool ) chkShowMissingFolderProjects . IsChecked ) ;
495
- gridRecent . ItemsSource = projectsSource ;
496
- break ;
497
499
case Key . Escape : // clear project search
498
500
if ( txtSearchBox . Text == "" )
499
501
{
500
502
SetFocusToGrid ( gridRecent ) ;
501
503
}
502
504
txtSearchBox . Text = "" ;
503
505
break ;
506
+ case Key . F5 :
507
+ txtSearchBox . Text = "" ;
508
+ break ;
509
+ case Key . Up :
510
+ case Key . Left :
511
+ case Key . Right :
512
+ case Key . Down :
504
513
case Key . F2 : // edit arguments
505
514
break ;
506
515
default : // any key
@@ -563,8 +572,8 @@ private async void OnTabSelectionChanged(object sender, SelectionChangedEventArg
563
572
if ( updatesSource == null )
564
573
{
565
574
var task = GetUnityUpdates . Scan ( ) ;
575
+ if ( task . IsCompleted == false ) return ;
566
576
var items = await task ;
567
- // TODO handle errors?
568
577
if ( items == null ) return ;
569
578
updatesSource = GetUnityUpdates . Parse ( items ) ;
570
579
if ( updatesSource == null ) return ;
@@ -661,6 +670,7 @@ private void BtnUpgradeProject_Click(object sender, RoutedEventArgs e)
661
670
662
671
private void GridRecent_Loaded ( object sender , RoutedEventArgs e )
663
672
{
673
+ //Console.WriteLine("GridRecent_Loaded");
664
674
SetFocusToGrid ( gridRecent ) ;
665
675
}
666
676
@@ -763,6 +773,17 @@ private void GridRecent_PreviewKeyDown(object sender, KeyEventArgs e)
763
773
{
764
774
switch ( e . Key )
765
775
{
776
+ case Key . Up :
777
+ case Key . Down :
778
+ break ;
779
+
780
+ case Key . F5 : // refresh projects
781
+ txtSearchBox . Text = "" ;
782
+ lastSelectedProjectIndex = gridRecent . SelectedIndex ;
783
+ projectsSource = GetProjects . Scan ( getGitBranch : ( bool ) chkShowGitBranchColumn . IsChecked , getArguments : ( bool ) chkShowLauncherArgumentsColumn . IsChecked , showMissingFolders : ( bool ) chkShowMissingFolderProjects . IsChecked ) ;
784
+ gridRecent . ItemsSource = projectsSource ;
785
+ SetFocusToGrid ( gridRecent , lastSelectedProjectIndex ) ;
786
+ break ;
766
787
case Key . Tab :
767
788
if ( ( Keyboard . Modifiers & ModifierKeys . Control ) == ModifierKeys . Control )
768
789
{
0 commit comments