@@ -123,80 +123,85 @@ private void autoUpdateGameCheckbox_Changed(object sender, RoutedEventArgs e)
123123 return ;
124124 _configService . AutoUpdateGame = autoUpdateGameCheckbox . IsChecked ?? false ;
125125 SetAllInteractionEnabled ( true ) ;
126+
127+ if ( _configService . AutoUpdateGame )
128+ {
129+ InstallLatestBuildFromVersionDropdown ( ) ;
130+ }
126131 }
127132
128- private async void DownloadBuild ( Build build )
133+ private void downloadButton_Click ( object sender , RoutedEventArgs e )
134+ {
135+ InstallLatestBuildFromVersionDropdown ( ) ;
136+ }
137+
138+ private async void InstallLatestBuildFromVersionDropdown ( )
129139 {
130140 if ( _selectedMenuItem == null )
131141 return ;
132-
133- var currentVersion = await _selectedMenuItem . InstallService . GetCurrentVersionAsync ( ) ;
134- if ( build . Version == currentVersion )
135- return ;
136142
137- try
143+ var selectedItem = versionDropdown . SelectedItem as ComboBoxItem ;
144+ if ( selectedItem ? . Tag is Build build )
138145 {
139- downloadProgress . IsVisible = true ;
140- SetAllInteractionEnabled ( false ) ;
141-
142- var assets = build . Assets
143- . Where ( x => x . IsPortable )
144- . Where ( x => x . IsApplicableForCurrentPlatform ( ) )
145- . OrderBy ( x => x , BuildAssetComparer . Default )
146- . ToArray ( ) ;
147-
148- var asset = assets . FirstOrDefault ( ) ;
149- if ( asset == null )
150- {
146+ var currentVersion = await _selectedMenuItem . InstallService . GetCurrentVersionAsync ( ) ;
147+ if ( build . Version == currentVersion )
151148 return ;
152- }
153-
154- var progress = new Progress < DownloadProgressReport > ( ) ;
155- progress . ProgressChanged += ( s , report ) =>
149+
150+ try
156151 {
157- Dispatcher . UIThread . Post ( ( ) =>
152+ downloadProgress . IsVisible = true ;
153+ SetAllInteractionEnabled ( false ) ;
154+
155+ var assets = build . Assets
156+ . Where ( x => x . IsPortable )
157+ . Where ( x => x . IsApplicableForCurrentPlatform ( ) )
158+ . OrderBy ( x => x , BuildAssetComparer . Default )
159+ . ToArray ( ) ;
160+
161+ var asset = assets . FirstOrDefault ( ) ;
162+ if ( asset == null )
158163 {
159- downloadButton . Content = report . Status ;
160- if ( report . Value is float value )
161- {
162- downloadProgress . IsIndeterminate = false ;
163- downloadProgress . Value = value ;
164- }
165- else
164+ return ;
165+ }
166+
167+ var progress = new Progress < DownloadProgressReport > ( ) ;
168+ progress . ProgressChanged += ( s , report ) =>
169+ {
170+ Dispatcher . UIThread . Post ( ( ) =>
166171 {
167- downloadProgress . IsIndeterminate = true ;
168- }
169- } ) ;
170- } ;
171-
172- var cts = new CancellationTokenSource ( ) ;
173- await _selectedMenuItem . InstallService . DownloadVersion (
174- new DownloadService ( ) ,
175- new Shell ( ) ,
176- build . Version ,
177- asset . Uri ,
178- progress ,
179- cts . Token ) ;
180- await RefreshInstalledVersionAsync ( ) ;
181- }
182- catch ( Exception ex )
183- {
184- ShowError ( StringResources . DownloadBuildFailedTitle , ex ) ;
185- }
186- finally
187- {
188- downloadButton . Content = StringResources . Download ;
189- downloadProgress . IsVisible = false ;
190- SetAllInteractionEnabled ( true ) ;
191- }
192- }
193-
194- private void downloadButton_Click ( object sender , RoutedEventArgs e )
195- {
196- var selectedItem = versionDropdown . SelectedItem as ComboBoxItem ;
197- if ( selectedItem ? . Tag is Build build )
198- {
199- DownloadBuild ( build ) ;
172+ downloadButton . Content = report . Status ;
173+ if ( report . Value is float value )
174+ {
175+ downloadProgress . IsIndeterminate = false ;
176+ downloadProgress . Value = value ;
177+ }
178+ else
179+ {
180+ downloadProgress . IsIndeterminate = true ;
181+ }
182+ } ) ;
183+ } ;
184+
185+ var cts = new CancellationTokenSource ( ) ;
186+ await _selectedMenuItem . InstallService . DownloadVersion (
187+ new DownloadService ( ) ,
188+ new Shell ( ) ,
189+ build . Version ,
190+ asset . Uri ,
191+ progress ,
192+ cts . Token ) ;
193+ await RefreshInstalledVersionAsync ( ) ;
194+ }
195+ catch ( Exception ex )
196+ {
197+ ShowError ( StringResources . DownloadBuildFailedTitle , ex ) ;
198+ }
199+ finally
200+ {
201+ downloadButton . Content = StringResources . Download ;
202+ downloadProgress . IsVisible = false ;
203+ SetAllInteractionEnabled ( true ) ;
204+ }
200205 }
201206 }
202207
@@ -288,9 +293,9 @@ private async Task RefreshAvailableVersionsAsync()
288293 {
289294 downloadButton . IsEnabled = ! _configService . AutoUpdateGame ;
290295 versionDropdown . IsHitTestVisible = true ;
291- if ( _configService . AutoUpdateGame && builds . Length > 0 )
296+ if ( _configService . AutoUpdateGame )
292297 {
293- DownloadBuild ( builds [ 0 ] ) ;
298+ InstallLatestBuildFromVersionDropdown ( ) ;
294299 }
295300 }
296301 }
0 commit comments