2017-09-12 18:20:32 +02:00
|
|
|
|
using System;
|
2017-09-18 18:40:43 +02:00
|
|
|
|
using Windows.UI.Xaml;
|
2017-09-10 13:49:11 -04:00
|
|
|
|
using Windows.UI.Xaml.Controls;
|
|
|
|
|
|
2017-09-12 18:20:32 +02:00
|
|
|
|
using ModernKeePass.Pages;
|
2017-09-13 18:37:44 +02:00
|
|
|
|
using ModernKeePass.ViewModels;
|
2017-09-12 18:20:32 +02:00
|
|
|
|
|
2017-09-11 15:13:04 +02:00
|
|
|
|
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
|
2017-09-10 13:49:11 -04:00
|
|
|
|
|
|
|
|
|
namespace ModernKeePass
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2017-09-11 15:13:04 +02:00
|
|
|
|
/// An empty page that can be used on its own or navigated to within a Frame.
|
2017-09-10 13:49:11 -04:00
|
|
|
|
/// </summary>
|
|
|
|
|
public sealed partial class MainPage : Page
|
|
|
|
|
{
|
|
|
|
|
public MainPage()
|
|
|
|
|
{
|
|
|
|
|
this.InitializeComponent();
|
|
|
|
|
}
|
2017-09-11 18:25:00 +02:00
|
|
|
|
|
2017-09-18 18:40:43 +02:00
|
|
|
|
private async void Button_Click(object sender, RoutedEventArgs e)
|
2017-09-11 18:25:00 +02:00
|
|
|
|
{
|
|
|
|
|
var picker = new Windows.Storage.Pickers.FileOpenPicker();
|
|
|
|
|
picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.List;
|
|
|
|
|
picker.SuggestedStartLocation =
|
|
|
|
|
Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
|
|
|
|
|
picker.FileTypeFilter.Add(".kdbx");
|
|
|
|
|
|
|
|
|
|
var file = await picker.PickSingleFileAsync();
|
|
|
|
|
if (file != null)
|
|
|
|
|
{
|
|
|
|
|
// Application now has read/write access to the picked file
|
2017-09-18 18:40:43 +02:00
|
|
|
|
//DataContext = new DatabaseVm(file);
|
|
|
|
|
((App)Application.Current).Database = new Common.DatabaseHelper(file);
|
|
|
|
|
var homeVm = DataContext as HomeVm;
|
|
|
|
|
homeVm.Visibility = Visibility.Visible;
|
|
|
|
|
homeVm.NotifyPropertyChanged("Visibility");
|
2017-09-11 18:25:00 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-09-15 15:58:51 +02:00
|
|
|
|
|
2017-09-22 15:40:24 +02:00
|
|
|
|
private void openBbutton_Click(object sender, RoutedEventArgs e)
|
2017-09-15 15:58:51 +02:00
|
|
|
|
{
|
2017-09-18 18:40:43 +02:00
|
|
|
|
/*var database = DataContext as DatabaseVm;
|
2017-09-15 15:58:51 +02:00
|
|
|
|
database.Open();
|
|
|
|
|
if (database.IsOpen)
|
2017-09-18 18:40:43 +02:00
|
|
|
|
Frame.Navigate(typeof(GroupDetailPage), database.RootGroup);*/
|
|
|
|
|
var homeVm = DataContext as HomeVm;
|
|
|
|
|
var app = ((App)Application.Current);
|
2017-09-22 15:40:24 +02:00
|
|
|
|
homeVm.ErrorMessage = app.Database.Open(homeVm.Password);
|
2017-09-18 18:40:43 +02:00
|
|
|
|
if (!app.Database.IsOpen) homeVm.NotifyPropertyChanged("ErrorMessage");
|
|
|
|
|
else Frame.Navigate(typeof(GroupDetailPage), app.Database.RootGroup);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void saveBbutton_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var database = DataContext as HomeVm;
|
|
|
|
|
((App)Application.Current).Database.Save();
|
2017-09-15 15:58:51 +02:00
|
|
|
|
}
|
2017-09-20 18:19:00 +02:00
|
|
|
|
|
|
|
|
|
private void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.AddedItems.Contains(SelectItem) || e.AddedItems.Contains(NewItem))
|
|
|
|
|
{
|
|
|
|
|
SelectGrid.Visibility = Visibility.Visible;
|
|
|
|
|
SaveButton.Visibility = Visibility.Collapsed;
|
|
|
|
|
}
|
|
|
|
|
else if (e.AddedItems.Contains(SaveItem))
|
|
|
|
|
{
|
|
|
|
|
SaveButton.Visibility = Visibility.Visible;
|
|
|
|
|
SelectGrid.Visibility = Visibility.Collapsed;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-09-10 13:49:11 -04:00
|
|
|
|
}
|
|
|
|
|
}
|