@@ -598,19 +598,12 @@ private void ShowForm()
598
598
599
599
void LaunchSelectedProject ( bool openProject = true )
600
600
{
601
- if ( gridRecent . CurrentCell == null )
602
- {
603
- if ( gridRecent . SelectedRows . Count != 0 )
604
- {
605
- DataGridViewRow row = gridRecent . SelectedRows [ 0 ] ;
606
- gridRecent . CurrentCell = row . Cells [ 0 ] ;
607
- }
608
- }
609
- var selected = gridRecent . CurrentCell . RowIndex ;
601
+ FixSelectedRow ( ) ;
602
+ var selected = gridRecent ? . CurrentCell ? . RowIndex ;
610
603
611
- if ( selected > - 1 )
604
+ if ( selected . HasValue && selected > - 1 )
612
605
{
613
- var projectPath = gridRecent . Rows [ selected ] . Cells [ "_path" ] . Value . ToString ( ) ;
606
+ var projectPath = gridRecent . Rows [ ( int ) selected ] . Cells [ "_path" ] . Value . ToString ( ) ;
614
607
var version = Tools . GetProjectVersion ( projectPath ) ;
615
608
LaunchProject ( projectPath , version , openProject ) ;
616
609
SetStatus ( "Ready" ) ;
@@ -621,11 +614,12 @@ void LaunchSelectedProject(bool openProject = true)
621
614
622
615
void LaunchSelectedUnity ( )
623
616
{
624
- var selected = gridUnityList . CurrentCell . RowIndex ;
625
- if ( selected > - 1 )
617
+ FixSelectedRow ( ) ;
618
+ var selected = gridRecent ? . CurrentCell ? . RowIndex ;
619
+ if ( selected . HasValue && selected > - 1 )
626
620
{
627
621
SetStatus ( "Launching Unity.." ) ;
628
- var version = gridUnityList . Rows [ selected ] . Cells [ "_unityVersion" ] . Value . ToString ( ) ;
622
+ var version = gridUnityList . Rows [ ( int ) selected ] . Cells [ "_unityVersion" ] . Value . ToString ( ) ;
629
623
try
630
624
{
631
625
Process myProcess = new Process ( ) ;
@@ -686,10 +680,11 @@ private void btnRemovePackFolder_Click(object sender, EventArgs e)
686
680
687
681
private void btnOpenReleasePage_Click ( object sender , EventArgs e )
688
682
{
689
- var selected = gridUnityList . CurrentCell . RowIndex ;
690
- if ( selected > - 1 )
683
+ FixSelectedRow ( ) ;
684
+ var selected = gridRecent ? . CurrentCell ? . RowIndex ;
685
+ if ( selected . HasValue && selected > - 1 )
691
686
{
692
- var version = gridUnityList . Rows [ selected ] . Cells [ "_unityVersion" ] . Value . ToString ( ) ;
687
+ var version = gridUnityList . Rows [ ( int ) selected ] . Cells [ "_unityVersion" ] . Value . ToString ( ) ;
693
688
if ( Tools . OpenReleaseNotes ( version ) == true )
694
689
{
695
690
SetStatus ( "Opening release notes for version " + version ) ;
@@ -708,10 +703,11 @@ private void btnLaunchUnity_Click(object sender, EventArgs e)
708
703
709
704
private void btnExploreUnity_Click ( object sender , EventArgs e )
710
705
{
711
- var selected = gridUnityList . CurrentCell . RowIndex ;
712
- if ( selected > - 1 )
706
+ FixSelectedRow ( ) ;
707
+ var selected = gridRecent ? . CurrentCell ? . RowIndex ;
708
+ if ( selected . HasValue && selected > - 1 )
713
709
{
714
- var unityPath = Path . GetDirectoryName ( gridUnityList . Rows [ selected ] . Cells [ "_unityPath" ] . Value . ToString ( ) ) ;
710
+ var unityPath = Path . GetDirectoryName ( gridUnityList . Rows [ ( int ) selected ] . Cells [ "_unityPath" ] . Value . ToString ( ) ) ;
715
711
if ( Tools . LaunchExplorer ( unityPath ) == false )
716
712
{
717
713
SetStatus ( "Error> Directory not found: " + unityPath ) ;
@@ -873,10 +869,11 @@ private void notifyIcon_MouseClick(object sender, MouseEventArgs e)
873
869
874
870
private void btn_openFolder_Click ( object sender , EventArgs e )
875
871
{
876
- var selected = gridRecent . CurrentCell . RowIndex ;
877
- if ( selected > - 1 )
872
+ FixSelectedRow ( ) ;
873
+ var selected = gridRecent ? . CurrentCell ? . RowIndex ;
874
+ if ( selected . HasValue && selected > - 1 )
878
875
{
879
- string folder = gridRecent . Rows [ selected ] . Cells [ "_path" ] . Value . ToString ( ) ;
876
+ string folder = gridRecent . Rows [ ( int ) selected ] . Cells [ "_path" ] . Value . ToString ( ) ;
880
877
if ( Tools . LaunchExplorer ( folder ) == false )
881
878
{
882
879
SetStatus ( "Error> Directory not found: " + folder ) ;
@@ -959,8 +956,9 @@ private void btnOpenLogFolder_Click(object sender, EventArgs e)
959
956
960
957
private void btnOpenUpdateWebsite_Click ( object sender , EventArgs e )
961
958
{
959
+ FixSelectedRow ( ) ;
962
960
var selected = gridUnityUpdates ? . CurrentCell ? . RowIndex ;
963
- if ( selected != null && selected > - 1 )
961
+ if ( selected . HasValue && selected > - 1 )
964
962
{
965
963
var version = gridUnityUpdates . Rows [ ( int ) selected ] . Cells [ "_UnityUpdateVersion" ] . Value . ToString ( ) ;
966
964
Tools . OpenReleaseNotes ( version ) ;
@@ -1079,12 +1077,13 @@ private void Form1_FormClosing(object sender, FormClosingEventArgs e)
1079
1077
// displays version selector to upgrade project
1080
1078
void UpgradeProject ( )
1081
1079
{
1082
- var selected = gridRecent . CurrentCell . RowIndex ;
1083
- if ( selected > - 1 )
1080
+ FixSelectedRow ( ) ;
1081
+ var selected = gridRecent ? . CurrentCell ? . RowIndex ;
1082
+ if ( selected . HasValue && selected > - 1 )
1084
1083
{
1085
1084
SetStatus ( "Upgrading project ..." ) ;
1086
1085
1087
- var projectPath = gridRecent . Rows [ selected ] . Cells [ "_path" ] . Value . ToString ( ) ;
1086
+ var projectPath = gridRecent . Rows [ ( int ) selected ] . Cells [ "_path" ] . Value . ToString ( ) ;
1088
1087
var currentVersion = Tools . GetProjectVersion ( projectPath ) ;
1089
1088
1090
1089
if ( string . IsNullOrEmpty ( currentVersion ) == true )
@@ -1183,10 +1182,11 @@ private void UnityVersionsListDownloaded(object sender, DownloadStringCompletedE
1183
1182
string GetSelectedRowData ( string key )
1184
1183
{
1185
1184
string path = null ;
1185
+ FixSelectedRow ( ) ;
1186
1186
var selected = gridRecent ? . CurrentCell ? . RowIndex ;
1187
1187
if ( selected . HasValue && selected > - 1 )
1188
1188
{
1189
- path = gridRecent . Rows [ selected . Value ] . Cells [ key ] . Value ? . ToString ( ) ;
1189
+ path = gridRecent . Rows [ ( int ) selected ] . Cells [ key ] . Value ? . ToString ( ) ;
1190
1190
}
1191
1191
return path ;
1192
1192
}
@@ -1318,5 +1318,17 @@ private void SaveSettingsOnExit()
1318
1318
Properties . Settings . Default . Save ( ) ;
1319
1319
}
1320
1320
1321
+ void FixSelectedRow ( )
1322
+ {
1323
+ if ( gridRecent . CurrentCell == null )
1324
+ {
1325
+ if ( gridRecent . SelectedRows . Count != 0 )
1326
+ {
1327
+ DataGridViewRow row = gridRecent . SelectedRows [ 0 ] ;
1328
+ gridRecent . CurrentCell = row . Cells [ 0 ] ;
1329
+ }
1330
+ }
1331
+ }
1332
+
1321
1333
} // class Form
1322
1334
} // namespace
0 commit comments