diff --git a/src/Views/Checkout.axaml b/src/Views/Checkout.axaml index eaf2e79e..eb1c9de0 100644 --- a/src/Views/Checkout.axaml +++ b/src/Views/Checkout.axaml @@ -32,22 +32,21 @@ HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,8,0" Text="{DynamicResource Text.Checkout.LocalChanges}"/> - - - - - + + IsCheckedChanged="OnLocalChangeActionIsCheckedChanged"/> + IsCheckedChanged="OnLocalChangeActionIsCheckedChanged"/> + IsCheckedChanged="OnLocalChangeActionIsCheckedChanged"/> diff --git a/src/Views/Checkout.axaml.cs b/src/Views/Checkout.axaml.cs index f8398a1d..da6e6b31 100644 --- a/src/Views/Checkout.axaml.cs +++ b/src/Views/Checkout.axaml.cs @@ -1,4 +1,5 @@ using Avalonia.Controls; +using Avalonia.Interactivity; namespace SourceGit.Views { @@ -8,5 +9,51 @@ namespace SourceGit.Views { InitializeComponent(); } + + protected override void OnLoaded(RoutedEventArgs e) + { + base.OnLoaded(e); + + var vm = DataContext as ViewModels.Checkout; + if (vm == null) + return; + + switch (vm.PreAction) + { + case Models.DealWithLocalChanges.DoNothing: + RadioDoNothing.IsChecked = true; + break; + case Models.DealWithLocalChanges.StashAndReaply: + RadioStashAndReply.IsChecked = true; + break; + default: + RadioDiscard.IsChecked = true; + break; + } + } + + private void OnLocalChangeActionIsCheckedChanged(object sender, RoutedEventArgs e) + { + var vm = DataContext as ViewModels.Checkout; + if (vm == null) + return; + + if (RadioDoNothing.IsChecked == true) + { + if (vm.PreAction != Models.DealWithLocalChanges.DoNothing) + vm.PreAction = Models.DealWithLocalChanges.DoNothing; + return; + } + + if (RadioStashAndReply.IsChecked == true) + { + if (vm.PreAction != Models.DealWithLocalChanges.StashAndReaply) + vm.PreAction = Models.DealWithLocalChanges.StashAndReaply; + return; + } + + if (vm.PreAction != Models.DealWithLocalChanges.Discard) + vm.PreAction = Models.DealWithLocalChanges.Discard; + } } } diff --git a/src/Views/CreateBranch.axaml b/src/Views/CreateBranch.axaml index 3516c317..caea0be4 100644 --- a/src/Views/CreateBranch.axaml +++ b/src/Views/CreateBranch.axaml @@ -69,21 +69,20 @@ Margin="0,0,8,0" Text="{DynamicResource Text.CreateBranch.LocalChanges}"/> - - - - + IsCheckedChanged="OnLocalChangeActionIsCheckedChanged"/> + IsCheckedChanged="OnLocalChangeActionIsCheckedChanged"/> + IsCheckedChanged="OnLocalChangeActionIsCheckedChanged"/> - - - - + IsCheckedChanged="OnLocalChangeActionIsCheckedChanged"/> + IsCheckedChanged="OnLocalChangeActionIsCheckedChanged"/> + IsCheckedChanged="OnLocalChangeActionIsCheckedChanged"/>