Files
modernkeepass/ModernKeePass/Views/MainPageFrames/NewDatabasePage.xaml.cs
Geoffroy BONNEVILLE 8e06bf4bb0 Removed half-baked import feature for now
No views depend on services anymore
Dirty status fully handled by behavior
2020-04-27 11:14:29 +02:00

48 lines
1.5 KiB
C#

using System;
using System.Collections.Generic;
using Windows.Storage.AccessCache;
using Windows.Storage.Pickers;
using Windows.UI.Xaml;
using ModernKeePass.Domain.Dtos;
using ModernKeePass.ViewModels;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
namespace ModernKeePass.Views
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class NewDatabasePage
{
private NewVm Model => (NewVm)DataContext;
public NewDatabasePage()
{
InitializeComponent();
}
private async void CreateDatabaseButton_OnClick(object sender, RoutedEventArgs e)
{
var savePicker = new FileSavePicker
{
SuggestedStartLocation = PickerLocationId.DocumentsLibrary,
SuggestedFileName = "New Database"
};
savePicker.FileTypeChoices.Add("KeePass 2.x database", new List<string> { ".kdbx" });
var file = await savePicker.PickSaveFileAsync().AsTask();
if (file == null) return;
var token = StorageApplicationPermissions.FutureAccessList.Add(file, file.Name);
var fileInfo = new FileInfo
{
Id = token,
Path = file.Path,
Name = file.DisplayName
};
Model.OpenFile(fileInfo);
}
}
}