11using Microsoft . UI . Xaml ;
22using Microsoft . UI . Xaml . Controls ;
33using UniGetUI . Core . Language ;
4+ using UniGetUI . Core . SettingsEngine ;
45using UniGetUI . Core . SettingsEngine . SecureSettings ;
56using UniGetUI . Core . Tools ;
67using UniGetUI . PackageEngine . Enums ;
@@ -26,6 +27,7 @@ public InstallOptions_Manager(IPackageManager manager)
2627 AdminCheckBox . Content = CoreTools . Translate ( "Run as admin" ) ;
2728 InteractiveCheckBox . Content = CoreTools . Translate ( "Interactive installation" ) ;
2829 HashCheckBox . Content = CoreTools . Translate ( "Skip hash check" ) ;
30+ UninstallPreviousVerOnUpdate . Content = CoreTools . Translate ( "Uninstall previous versions when updated" ) ;
2931 PreReleaseCheckBox . Content = CoreTools . Translate ( "Allow pre-release versions" ) ;
3032 ArchLabel . Text = CoreTools . Translate ( "Architecture to install:" ) ;
3133 ScopeLabel . Text = CoreTools . Translate ( "Installation scope:" ) ;
@@ -149,6 +151,9 @@ private async Task LoadOptions()
149151 CustomParameters2 . Text = string . Join ( ' ' , options . CustomParameters_Update ) ;
150152 CustomParameters3 . Text = string . Join ( ' ' , options . CustomParameters_Uninstall ) ;
151153
154+ UninstallPreviousVerOnUpdate . IsEnabled = Manager . Capabilities . CanUninstallPreviousVersionsAfterUpdate ;
155+ UninstallPreviousVerOnUpdate . IsChecked = options . UninstallPreviousVersionsOnUpdate ;
156+
152157 ResetButton . IsEnabled = true ;
153158 ApplyButton . IsEnabled = true ;
154159 ApplyButton . Style = ( Style ) Application . Current . Resources [ "DefaultButtonStyle" ] ;
@@ -167,6 +172,7 @@ private async Task SaveOptions()
167172 options . SkipHashCheck = HashCheckBox . IsChecked ?? false ;
168173 options . InteractiveInstallation = InteractiveCheckBox . IsChecked ?? false ;
169174 options . PreRelease = PreReleaseCheckBox . IsChecked ?? false ;
175+ options . UninstallPreviousVersionsOnUpdate = UninstallPreviousVerOnUpdate . IsChecked ?? false ;
170176
171177 // Administrator
172178 options . Architecture = "" ;
@@ -216,6 +222,7 @@ private void DisableAllInput()
216222 InteractiveCheckBox . IsEnabled = false ;
217223 HashCheckBox . IsEnabled = false ;
218224 ArchitectureCombo . IsEnabled = false ;
225+ UninstallPreviousVerOnUpdate . IsEnabled = false ;
219226 ScopeCombo . IsEnabled = false ;
220227 SelectDir . IsEnabled = false ;
221228 ResetDir . IsEnabled = false ;
@@ -294,4 +301,9 @@ private void GoToSecureSettings_Click(object sender, RoutedEventArgs e)
294301 {
295302 MainApp . Instance . MainWindow . NavigationPage . OpenSettingsPage ( typeof ( Administrator ) ) ;
296303 }
304+
305+ private void ClearPreviousOnUpdate_OnClick ( object sender , RoutedEventArgs e )
306+ {
307+ ApplyButton . Style = ( Style ) Application . Current . Resources [ "AccentButtonStyle" ] ;
308+ }
297309}
0 commit comments