@@ -19,7 +19,13 @@ public UpgradeWindow(string currentVersion, string projectPath, string commandLi
19
19
{
20
20
InitializeComponent ( ) ;
21
21
txtCurrentVersion . Text = currentVersion ;
22
- gridAvailableVersions . ItemsSource = MainWindow . unityInstalledVersions ;
22
+ txtCurrentPlatform . Text = Tools . GetTargetPlatform ( projectPath ) ;
23
+
24
+ if ( gridAvailableVersions . ItemsSource == null )
25
+ {
26
+ gridAvailableVersions . ItemsSource = MainWindow . unityInstallationsSource ;
27
+ }
28
+
23
29
gridAvailableVersions . SelectedItem = null ;
24
30
25
31
// we have current version info in project
@@ -40,17 +46,15 @@ public UpgradeWindow(string currentVersion, string projectPath, string commandLi
40
46
string nearestVersion = Tools . FindNearestVersion ( currentVersion , MainWindow . unityInstalledVersions . Keys . ToList ( ) ) ;
41
47
if ( nearestVersion != null )
42
48
{
43
- // get correct row for nearest version
44
- var obj = Tools . GetEntry ( MainWindow . unityInstalledVersions , nearestVersion ) ;
45
- int index = gridAvailableVersions . Items . IndexOf ( obj ) ;
46
- if ( index > - 1 )
49
+ // select nearest version
50
+ for ( int i = 0 ; i < MainWindow . unityInstallationsSource . Count ; i ++ )
47
51
{
48
- gridAvailableVersions . SelectedIndex = index ;
49
- }
50
- else
51
- {
52
- // just select first item then
53
- gridAvailableVersions . SelectedIndex = 0 ;
52
+ if ( MainWindow . unityInstallationsSource [ i ] . Version == nearestVersion )
53
+ {
54
+ gridAvailableVersions . SelectedIndex = i ;
55
+ gridAvailableVersions . ScrollIntoView ( gridAvailableVersions . SelectedItem ) ;
56
+ break ;
57
+ }
54
58
}
55
59
}
56
60
}
@@ -83,7 +87,6 @@ public UpgradeWindow(string currentVersion, string projectPath, string commandLi
83
87
}
84
88
85
89
}
86
-
87
90
gridAvailableVersions . Focus ( ) ;
88
91
}
89
92
@@ -183,8 +186,8 @@ private void GridAvailableVersions_PreviewMouseDoubleClick(object sender, MouseB
183
186
184
187
void Upgrade ( )
185
188
{
186
- var k = ( gridAvailableVersions . SelectedItem ) as KeyValuePair < string , string > ? ;
187
- upgradeVersion = k . Value . Key ;
189
+ var k = ( UnityInstallation ) gridAvailableVersions . SelectedItem ;
190
+ upgradeVersion = k . Version ;
188
191
DialogResult = true ;
189
192
}
190
193
0 commit comments