Updating group raise SaveCommand can execute

No need to click twice on history menu
Skipped first history entry as it is the same as the current entry
Stored SaveException innerexception as it is read more than once
This commit is contained in:
Geoffroy BONNEVILLE
2020-04-16 19:43:17 +02:00
parent f950564000
commit 2fb5b14085
7 changed files with 41 additions and 28 deletions

View File

@@ -4,6 +4,8 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewModels="using:ModernKeePass.ViewModels"
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
x:Class="ModernKeePass.Views.SaveDatabasePage"
mc:Ignorable="d">
<Page.DataContext>
@@ -11,11 +13,11 @@
</Page.DataContext>
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<HyperlinkButton x:Uid="SaveButton" Click="SaveButton_OnClick" Foreground="{StaticResource MainColor}" Style="{StaticResource MainColorHyperlinkButton}" />
<HyperlinkButton x:Uid="SaveButton" Command="{Binding SaveCommand}" Foreground="{StaticResource MainColor}" Style="{StaticResource MainColorHyperlinkButton}" />
<TextBlock x:Uid="SaveDesc" Style="{StaticResource BodyTextBlockStyle}" Margin="15,0,0,30" />
<HyperlinkButton x:Uid="SaveAsButton" Click="SaveAsButton_OnClick" Foreground="{StaticResource MainColor}" Style="{StaticResource MainColorHyperlinkButton}" />
<TextBlock x:Uid="SaveAsDesc" Style="{StaticResource BodyTextBlockStyle}" Margin="15,0,0,30" />
<HyperlinkButton x:Uid="CloseButton" Click="CloseButton_OnClick" Foreground="{StaticResource MainColor}" Style="{StaticResource MainColorHyperlinkButton}" />
<HyperlinkButton x:Uid="CloseButton" Command="{Binding CloseCommand}" Foreground="{StaticResource MainColor}" Style="{StaticResource MainColorHyperlinkButton}" />
<TextBlock x:Uid="CloseDesc" Style="{StaticResource BodyTextBlockStyle}" Margin="15,0,0,30" />
</StackPanel>
</Page>

View File

@@ -15,7 +15,6 @@ namespace ModernKeePass.Views
/// </summary>
public sealed partial class SaveDatabasePage
{
private Frame _mainFrame;
public SaveVm Model => (SaveVm)DataContext;
public SaveDatabasePage()
{
@@ -25,15 +24,9 @@ namespace ModernKeePass.Views
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
_mainFrame = e.Parameter as Frame;
Model.Frame = e.Parameter as Frame;
}
private async void SaveButton_OnClick(object sender, RoutedEventArgs e)
{
await Model.Save();
_mainFrame.Navigate(typeof(MainPage));
}
private async void SaveAsButton_OnClick(object sender, RoutedEventArgs e)
{
var savePicker = new FileSavePicker
@@ -46,14 +39,6 @@ namespace ModernKeePass.Views
var file = await savePicker.PickSaveFileAsync().AsTask();
if (file == null) return;
await Model.Save(file);
_mainFrame.Navigate(typeof(MainPage));
}
private async void CloseButton_OnClick(object sender, RoutedEventArgs e)
{
await Model.Close();
_mainFrame.Navigate(typeof(MainPage));
}
}
}