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

@@ -1,9 +1,15 @@
using GalaSoft.MvvmLight;
using System.Threading.Tasks;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using ModernKeePass.Application.Common.Interfaces;
using ModernKeePass.Domain.Common;
using ModernKeePass.Domain.Dtos;
namespace ModernKeePass.ViewModels
{
public class OpenVm: ViewModelBase
{
private readonly IFileProxy _file;
private string _name;
private string _path;
private string _token;
@@ -30,5 +36,27 @@ namespace ModernKeePass.ViewModels
get { return _path; }
set { Set(() => Path, ref _path, value); }
}
public RelayCommand OpenDatabaseFileCommand { get; }
public OpenVm(IFileProxy file)
{
_file = file;
OpenDatabaseFileCommand = new RelayCommand(async () => await OpenDatabaseFile());
}
public void SetFileInformation(FileInfo file)
{
if (file == null) return;
Token = file.Id;
Path = file.Path;
Name = file.Name;
}
private async Task OpenDatabaseFile()
{
var file = await _file.OpenFile(string.Empty, Constants.Extensions.Kdbx, true);
SetFileInformation(file);
}
}
}