2017-09-27 18:01:21 +02:00
|
|
|
|
using System;
|
2020-04-06 20:20:45 +02:00
|
|
|
|
using Windows.Storage.AccessCache;
|
2017-09-27 18:01:21 +02:00
|
|
|
|
using Windows.Storage.Pickers;
|
|
|
|
|
using Windows.UI.Xaml;
|
|
|
|
|
using Windows.UI.Xaml.Navigation;
|
2020-04-06 20:20:45 +02:00
|
|
|
|
using ModernKeePass.Domain.Dtos;
|
2017-09-27 18:01:21 +02:00
|
|
|
|
using ModernKeePass.ViewModels;
|
|
|
|
|
|
|
|
|
|
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
|
|
|
|
|
|
2017-12-08 19:38:33 +01:00
|
|
|
|
namespace ModernKeePass.Views
|
2017-09-27 18:01:21 +02:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// An empty page that can be used on its own or navigated to within a Frame.
|
|
|
|
|
/// </summary>
|
2017-10-12 17:45:37 +02:00
|
|
|
|
public sealed partial class OpenDatabasePage
|
2017-09-27 18:01:21 +02:00
|
|
|
|
{
|
2017-10-12 18:37:49 +02:00
|
|
|
|
public OpenVm Model => (OpenVm)DataContext;
|
|
|
|
|
|
2017-09-27 18:01:21 +02:00
|
|
|
|
public OpenDatabasePage()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-06 20:20:45 +02:00
|
|
|
|
protected override async void OnNavigatedTo(NavigationEventArgs e)
|
2017-09-27 18:01:21 +02:00
|
|
|
|
{
|
|
|
|
|
base.OnNavigatedTo(e);
|
2020-04-06 20:20:45 +02:00
|
|
|
|
var file = e.Parameter as FileInfo;
|
2018-06-19 18:47:37 +02:00
|
|
|
|
if (file != null)
|
|
|
|
|
{
|
2020-04-06 20:20:45 +02:00
|
|
|
|
await Model.OpenFile(file);
|
2018-06-19 18:47:37 +02:00
|
|
|
|
}
|
2017-09-27 18:01:21 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async void ButtonBase_OnClick(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
2020-03-30 19:43:04 +02:00
|
|
|
|
var picker = new FileOpenPicker
|
|
|
|
|
{
|
|
|
|
|
ViewMode = PickerViewMode.List,
|
|
|
|
|
SuggestedStartLocation = PickerLocationId.DocumentsLibrary
|
|
|
|
|
};
|
2017-09-27 18:01:21 +02:00
|
|
|
|
picker.FileTypeFilter.Add(".kdbx");
|
2017-10-10 15:00:31 +02:00
|
|
|
|
|
2017-09-27 18:01:21 +02:00
|
|
|
|
// Application now has read/write access to the picked file
|
2017-10-16 10:57:39 +02:00
|
|
|
|
var file = await picker.PickSingleFileAsync();
|
|
|
|
|
if (file == null) return;
|
2020-04-06 20:20:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var token = StorageApplicationPermissions.FutureAccessList.Add(file);
|
|
|
|
|
var fileInfo = new FileInfo
|
|
|
|
|
{
|
|
|
|
|
Path = token,
|
|
|
|
|
Name = file.DisplayName
|
|
|
|
|
};
|
|
|
|
|
await Model.OpenFile(fileInfo);
|
2017-09-27 18:01:21 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|