Save error is now handled via Messenger instead of unhandled exception handler (which didn't work)

Save as actually works now
WIP Styles
Code cleanup
This commit is contained in:
Geoffroy BONNEVILLE
2020-05-04 12:48:27 +02:00
parent 97b10baedc
commit 1e7662def7
33 changed files with 268 additions and 268 deletions

View File

@@ -40,7 +40,7 @@
<HyperlinkButton Grid.Row="1" Grid.Column="1" Margin="-15,0,0,0"
x:Name="HyperlinkButton"
Content="{Binding KeyFileText}"
Click="KeyFileButton_Click" />
Command="{Binding OpenKeyFileCommand}" />
<Button Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="2"
x:Uid="OpenDatabaseControlButton"

View File

@@ -1,7 +1,4 @@
using System;
using Windows.Storage.AccessCache;
using Windows.Storage.Pickers;
using Windows.System;
using Windows.System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Input;
using ModernKeePass.ViewModels;
@@ -38,24 +35,5 @@ namespace ModernKeePass.Views.UserControls
// Stop the event from triggering twice
e.Handled = true;
}
private async void KeyFileButton_Click(object sender, RoutedEventArgs e)
{
var picker = new FileOpenPicker
{
ViewMode = PickerViewMode.List,
SuggestedStartLocation = PickerLocationId.DocumentsLibrary
};
picker.FileTypeFilter.Add("*");
// Application now has read/write access to the picked file
var file = await picker.PickSingleFileAsync();
if (file == null) return;
var token = StorageApplicationPermissions.FutureAccessList.Add(file, file.Name);
Model.KeyFilePath = token;
Model.KeyFileText = file.Name;
Model.HasKeyFile = true;
}
}
}

View File

@@ -13,7 +13,7 @@
<converters:DoubleToSolidColorBrushConverter x:Key="DoubleToSolidColorBrushConverter"/>
<converters:InverseBooleanToVisibilityConverter x:Key="InverseBooleanToVisibilityConverter"/>
</UserControl.Resources>
<Grid x:Name="Grid" DataContext="{Binding Source={StaticResource Locator}, Path=SetCredentials}">
<Grid DataContext="{Binding Source={StaticResource Locator}, Path=SetCredentials}">
<Grid.Resources>
<SolidColorBrush x:Key="ErrorBrush" Color="Red" />
<SolidColorBrush x:Key="ValidBrush" Color="Green" />
@@ -57,11 +57,9 @@
<HyperlinkButton Grid.Row="3" Grid.Column="1" Margin="-15,0,0,0"
x:Name="HyperlinkButton"
Content="{Binding KeyFileText}"
IsEnabled="{Binding HasKeyFile}"
Click="KeyFileButton_Click" />
Command="{Binding OpenKeyFileCommand}" />
<HyperlinkButton Grid.Row="3" Grid.Column="1" HorizontalAlignment="Right"
IsEnabled="{Binding HasKeyFile}"
Click="CreateKeyFileButton_Click">
Command="{Binding CreateKeyFileCommand}">
<SymbolIcon Symbol="Add">
<ToolTipService.ToolTip>
<ToolTip x:Uid="CompositeKeyNewKeyFileTooltip" />

View File

@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using Windows.Storage.AccessCache;
using Windows.Storage.Pickers;
using Windows.UI.Xaml;
using ModernKeePass.ViewModels;
using Windows.UI.Xaml;
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
@@ -11,8 +6,6 @@ namespace ModernKeePass.Views.UserControls
{
public sealed partial class SetCredentialsUserControl
{
private SetCredentialsVm Model => (SetCredentialsVm)Grid.DataContext;
public string ButtonLabel
{
get { return (string)GetValue(ButtonLabelProperty); }
@@ -29,40 +22,5 @@ namespace ModernKeePass.Views.UserControls
{
InitializeComponent();
}
private async void KeyFileButton_Click(object sender, RoutedEventArgs e)
{
var picker =
new FileOpenPicker
{
ViewMode = PickerViewMode.List,
SuggestedStartLocation = PickerLocationId.DocumentsLibrary
};
picker.FileTypeFilter.Add("*");
// Application now has read/write access to the picked file
var file = await picker.PickSingleFileAsync();
if (file == null) return;
Model.KeyFilePath = StorageApplicationPermissions.FutureAccessList.Add(file, file.Name);
Model.KeyFileText = file.Name;
}
private async void CreateKeyFileButton_Click(object sender, RoutedEventArgs e)
{
var savePicker = new FileSavePicker
{
SuggestedStartLocation = PickerLocationId.DocumentsLibrary,
SuggestedFileName = "Key"
};
savePicker.FileTypeChoices.Add("Key file", new List<string> { ".key" });
var file = await savePicker.PickSaveFileAsync();
if (file == null) return;
Model.KeyFilePath = StorageApplicationPermissions.FutureAccessList.Add(file, file.Name);
Model.KeyFileText = file.Name;
await Model.GenerateKeyFile();
}
}
}