mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-04 16:10:16 -04:00
WIP New database (and open and recent...)
This commit is contained in:
23
ModernKeePass/Pages/NewDatabasePage.xaml
Normal file
23
ModernKeePass/Pages/NewDatabasePage.xaml
Normal file
@@ -0,0 +1,23 @@
|
||||
<Page
|
||||
x:Class="ModernKeePass.Pages.NewDatabasePage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:controls="using:ModernKeePass.Controls"
|
||||
xmlns:converters="using:ModernKeePass.Converters"
|
||||
xmlns:viewModels="using:ModernKeePass.ViewModels"
|
||||
mc:Ignorable="d">
|
||||
<Page.Resources>
|
||||
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
|
||||
</Page.Resources>
|
||||
<Page.DataContext>
|
||||
<viewModels:OpenVm />
|
||||
</Page.DataContext>
|
||||
|
||||
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
<HyperlinkButton Content="Create new..." Click="ButtonBase_OnClick" />
|
||||
<TextBlock TextWrapping="Wrap" Text="{Binding Name}" Height="auto" Width="auto" FontSize="16" Margin="10,7,0,6" />
|
||||
<controls:OpenDatabaseUserControl CreateNew="True" Visibility="{Binding ShowPasswordBox, Converter={StaticResource BooleanToVisibilityConverter}}" ValidationChecked="PasswordUserControl_PasswordChecked" />
|
||||
</StackPanel>
|
||||
</Page>
|
52
ModernKeePass/Pages/NewDatabasePage.xaml.cs
Normal file
52
ModernKeePass/Pages/NewDatabasePage.xaml.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Windows.Storage.Pickers;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
using ModernKeePass.Events;
|
||||
using ModernKeePass.ViewModels;
|
||||
|
||||
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
|
||||
|
||||
namespace ModernKeePass.Pages
|
||||
{
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
public sealed partial class NewDatabasePage : Page
|
||||
{
|
||||
private Frame _mainFrame;
|
||||
|
||||
public NewDatabasePage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
base.OnNavigatedTo(e);
|
||||
_mainFrame = e.Parameter as Frame;
|
||||
}
|
||||
|
||||
private async void ButtonBase_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();
|
||||
if (file == null) return;
|
||||
var viewModel = DataContext as OpenVm;
|
||||
viewModel.OpenFile(file);
|
||||
}
|
||||
|
||||
private void PasswordUserControl_PasswordChecked(object sender, PasswordEventArgs e)
|
||||
{
|
||||
_mainFrame.Navigate(typeof(GroupDetailPage), e.RootGroup);
|
||||
}
|
||||
}
|
||||
}
|
@@ -19,6 +19,6 @@
|
||||
<HyperlinkButton Content="Browse files..." Click="ButtonBase_OnClick" />
|
||||
<HyperlinkButton Content="From Url..." IsEnabled="False" />
|
||||
<TextBlock TextWrapping="Wrap" Text="{Binding Name}" Height="auto" Width="auto" FontSize="16" Margin="10,7,0,6" />
|
||||
<local:OpenDatabaseUserControl DatabaseFile="{Binding File}" Visibility="{Binding ShowPasswordBox, Converter={StaticResource BooleanToVisibilityConverter}}" ValidationChecked="PasswordUserControl_PasswordChecked" />
|
||||
<local:OpenDatabaseUserControl Visibility="{Binding ShowPasswordBox, Converter={StaticResource BooleanToVisibilityConverter}}" ValidationChecked="PasswordUserControl_PasswordChecked" />
|
||||
</StackPanel>
|
||||
</Page>
|
@@ -23,7 +23,7 @@
|
||||
<DataTemplate>
|
||||
<StackPanel Margin="10,0,10,0">
|
||||
<TextBlock Text="{Binding Name}" Width="350" Padding="5" />
|
||||
<local:OpenDatabaseUserControl DatabaseFile="{Binding File}" Visibility="{Binding IsSelected, Converter={StaticResource BooleanToVisibilityConverter}}" ValidationChecked="PasswordUserControl_PasswordChecked" />
|
||||
<local:OpenDatabaseUserControl Visibility="{Binding IsSelected, Converter={StaticResource BooleanToVisibilityConverter}}" ValidationChecked="PasswordUserControl_PasswordChecked" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
|
Reference in New Issue
Block a user