@@ -32,28 +32,29 @@ public UpgradeWindow(string currentVersion, string projectPath, string commandLi
3232 btnDownload . IsEnabled = true ;
3333
3434 // if dont have exact version, show red outline
35- if ( MainWindow . unityInstalledVersions . ContainsKey ( currentVersion ) == false )
35+ if ( currentVersion == null || MainWindow . unityInstalledVersions . ContainsKey ( currentVersion ) == false )
3636 {
3737 txtCurrentVersion . BorderBrush = Brushes . Red ;
3838 txtCurrentVersion . BorderThickness = new Thickness ( 1 ) ;
3939 }
40-
41- // remove china c1 from version
42- if ( currentVersion . Contains ( 'c' ) ) currentVersion = currentVersion . Replace ( "c1" , "" ) ;
43-
44- // find nearest version
45- string nearestVersion = Tools . FindNearestVersion ( currentVersion , MainWindow . unityInstalledVersions . Keys . ToList ( ) ) ;
46-
47- if ( nearestVersion != null )
40+ else // not null
4841 {
49- // select nearest version
50- for ( int i = 0 ; i < MainWindow . unityInstallationsSource . Count ; i ++ )
42+ // remove china c1 from version
43+ if ( currentVersion . Contains ( 'c' ) ) currentVersion = currentVersion . Replace ( "c1" , "" ) ;
44+ // find nearest version
45+ string nearestVersion = Tools . FindNearestVersion ( currentVersion , MainWindow . unityInstalledVersions . Keys . ToList ( ) ) ;
46+
47+ if ( nearestVersion != null )
5148 {
52- if ( MainWindow . unityInstallationsSource [ i ] . Version == nearestVersion )
49+ // select nearest version
50+ for ( int i = 0 ; i < MainWindow . unityInstallationsSource . Count ; i ++ )
5351 {
54- gridAvailableVersions . SelectedIndex = i ;
55- gridAvailableVersions . ScrollIntoView ( gridAvailableVersions . SelectedItem ) ;
56- break ;
52+ if ( MainWindow . unityInstallationsSource [ i ] . Version == nearestVersion )
53+ {
54+ gridAvailableVersions . SelectedIndex = i ;
55+ gridAvailableVersions . ScrollIntoView ( gridAvailableVersions . SelectedItem ) ;
56+ break ;
57+ }
5758 }
5859 }
5960 }
@@ -77,7 +78,7 @@ private void BtnOpenReleasePage_Click(object sender, RoutedEventArgs e)
7778 Tools . OpenReleaseNotes ( txtCurrentVersion . Text ) ;
7879 }
7980
80-
81+
8182 private void BtnDownloadEditor_Click ( object sender , RoutedEventArgs e )
8283 {
8384 Tools . DownloadInBrowser ( txtCurrentVersion . Text ) ;
0 commit comments