mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Finished Password User Control
Recent and Open now use this control
This commit is contained in:

committed by
BONNEVILLE Geoffroy

parent
324553c58c
commit
6d69dd4d15
@@ -6,7 +6,7 @@
|
|||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DesignHeight="60"
|
d:DesignHeight="65"
|
||||||
d:DesignWidth="400">
|
d:DesignWidth="400">
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
@@ -15,6 +15,6 @@
|
|||||||
<SymbolIcon Symbol="Forward" />
|
<SymbolIcon Symbol="Forward" />
|
||||||
</Button>
|
</Button>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<TextBlock x:Name="StatusTextBlock" Height="auto" Width="auto" Foreground="#FF9E1B1B" FontSize="16" />
|
<TextBlock x:Name="StatusTextBlock" Height="auto" Width="auto" Foreground="#FF9E1B1B" FontSize="16" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
@@ -1,17 +1,8 @@
|
|||||||
using System;
|
using Windows.System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices.WindowsRuntime;
|
|
||||||
using Windows.Foundation;
|
|
||||||
using Windows.Foundation.Collections;
|
|
||||||
using Windows.UI.Xaml;
|
using Windows.UI.Xaml;
|
||||||
using Windows.UI.Xaml.Controls;
|
using Windows.UI.Xaml.Controls;
|
||||||
using Windows.UI.Xaml.Controls.Primitives;
|
|
||||||
using Windows.UI.Xaml.Data;
|
|
||||||
using Windows.UI.Xaml.Input;
|
using Windows.UI.Xaml.Input;
|
||||||
using Windows.UI.Xaml.Media;
|
using ModernKeePass.Events;
|
||||||
using Windows.UI.Xaml.Navigation;
|
|
||||||
|
|
||||||
// Pour en savoir plus sur le modèle d'élément Contrôle utilisateur, consultez la page http://go.microsoft.com/fwlink/?LinkId=234236
|
// Pour en savoir plus sur le modèle d'élément Contrôle utilisateur, consultez la page http://go.microsoft.com/fwlink/?LinkId=234236
|
||||||
|
|
||||||
@@ -21,7 +12,23 @@ namespace ModernKeePass.Controls
|
|||||||
{
|
{
|
||||||
public PasswordUserControl()
|
public PasswordUserControl()
|
||||||
{
|
{
|
||||||
this.InitializeComponent();
|
InitializeComponent();
|
||||||
|
PasswordBox.Focus(FocusState.Programmatic);
|
||||||
|
}
|
||||||
|
|
||||||
|
public delegate void PasswordCheckedEventHandler(object sender, DatabaseEventArgs e);
|
||||||
|
public event PasswordCheckedEventHandler PasswordChecked;
|
||||||
|
|
||||||
|
private void OpenButton_OnClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
var app = (App)Application.Current;
|
||||||
|
StatusTextBlock.Text = app.Database.Open(PasswordBox.Password);
|
||||||
|
PasswordChecked(this, new DatabaseEventArgs { IsOpen = app.Database.IsOpen });
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PasswordBox_KeyDown(object sender, KeyRoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Key == VirtualKey.Enter) OpenButton_OnClick(null, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
9
ModernKeePass/Events/DatabaseEventArgs.cs
Normal file
9
ModernKeePass/Events/DatabaseEventArgs.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace ModernKeePass.Events
|
||||||
|
{
|
||||||
|
public class DatabaseEventArgs: EventArgs
|
||||||
|
{
|
||||||
|
public bool IsOpen { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@@ -1,8 +1,19 @@
|
|||||||
namespace ModernKeePass.Models
|
using System.ComponentModel;
|
||||||
|
using Windows.UI.Xaml;
|
||||||
|
|
||||||
|
namespace ModernKeePass.Models
|
||||||
{
|
{
|
||||||
public class RecentItem
|
public class RecentItem: INotifyPropertyChanged
|
||||||
{
|
{
|
||||||
public string Token { get; set; }
|
public string Token { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
public Visibility PasswordVisibility { get; set; } = Visibility.Collapsed;
|
||||||
|
|
||||||
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
|
||||||
|
public void NotifyPropertyChanged(string propertyName)
|
||||||
|
{
|
||||||
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -120,6 +120,7 @@
|
|||||||
<DependentUpon>PasswordUserControl.xaml</DependentUpon>
|
<DependentUpon>PasswordUserControl.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Converters\PluralizationConverter.cs" />
|
<Compile Include="Converters\PluralizationConverter.cs" />
|
||||||
|
<Compile Include="Events\DatabaseEventArgs.cs" />
|
||||||
<Compile Include="Interfaces\IIsEnabled.cs" />
|
<Compile Include="Interfaces\IIsEnabled.cs" />
|
||||||
<Compile Include="MainPage.xaml.cs">
|
<Compile Include="MainPage.xaml.cs">
|
||||||
<DependentUpon>MainPage.xaml</DependentUpon>
|
<DependentUpon>MainPage.xaml</DependentUpon>
|
||||||
|
@@ -4,36 +4,17 @@
|
|||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:viewModels="using:ModernKeePass.ViewModels"
|
xmlns:viewModels="using:ModernKeePass.ViewModels"
|
||||||
|
xmlns:local="using:ModernKeePass.Controls"
|
||||||
x:Class="ModernKeePass.Pages.OpenDatabasePage"
|
x:Class="ModernKeePass.Pages.OpenDatabasePage"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
<Page.DataContext>
|
<Page.DataContext>
|
||||||
<viewModels:DatabaseVm/>
|
<viewModels:DatabaseVm/>
|
||||||
</Page.DataContext>
|
</Page.DataContext>
|
||||||
|
|
||||||
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||||
<Grid.ChildrenTransitions>
|
<HyperlinkButton Content="Browse files..." Click="ButtonBase_OnClick" />
|
||||||
<TransitionCollection>
|
<HyperlinkButton Content="From Url..." IsEnabled="False" />
|
||||||
<EntranceThemeTransition/>
|
<TextBlock TextWrapping="Wrap" Text="{Binding Name}" Height="auto" Width="auto" FontSize="16" Margin="10,7,0,6" />
|
||||||
</TransitionCollection>
|
<local:PasswordUserControl Visibility="{Binding SelectedVisibility}" PasswordChecked="PasswordUserControl_PasswordChecked" />
|
||||||
</Grid.ChildrenTransitions>
|
</StackPanel>
|
||||||
<Grid.ColumnDefinitions>
|
|
||||||
<ColumnDefinition Width="150" />
|
|
||||||
<ColumnDefinition Width="*" />
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition Height="*" />
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<HyperlinkButton Grid.Row="0" Grid.ColumnSpan="2" Content="Browse files..." Click="ButtonBase_OnClick" />
|
|
||||||
<HyperlinkButton Grid.Row="1" Grid.ColumnSpan="2" Content="From Url..." IsEnabled="False" />
|
|
||||||
<TextBlock Grid.Row="0" Grid.Column="1" HorizontalAlignment="Left" Visibility="{Binding SelectedVisibility}" TextWrapping="Wrap" Text="{Binding Name}" VerticalAlignment="Center" Height="auto" Width="auto" FontSize="16" Margin="10,7,0,6" />
|
|
||||||
<TextBlock Grid.Row="3" Grid.Column="0" HorizontalAlignment="Left" Visibility="{Binding SelectedVisibility}" TextWrapping="Wrap" Text="Password" VerticalAlignment="Center" Height="auto" Width="auto" FontSize="16" Margin="10,7,0,6" />
|
|
||||||
<PasswordBox Grid.Row="3" Grid.Column="1" x:Name="PasswordBox" Visibility="{Binding SelectedVisibility}" Width="500" IsPasswordRevealButtonEnabled="True" Margin="0,0,10,0" KeyDown="PasswordBox_KeyDown" PlaceholderText="Password"/>
|
|
||||||
<TextBlock Grid.Row="4" Grid.Column="1" x:Name="StatusTextBlock" Visibility="{Binding SelectedVisibility}" Height="auto" Width="auto" Foreground="#FF9E1B1B" FontSize="16" />
|
|
||||||
<Button Grid.Row="5" Grid.Column="1" Content="OK" Visibility="{Binding SelectedVisibility}" HorizontalAlignment="Right" VerticalAlignment="Top" Click="OpenButton_OnClick" Margin="0,0,7,0" Width="auto"/>
|
|
||||||
</Grid>
|
|
||||||
</Page>
|
</Page>
|
||||||
|
@@ -71,19 +71,12 @@ namespace ModernKeePass.Pages
|
|||||||
databaseVm.Name = file.Name;
|
databaseVm.Name = file.Name;
|
||||||
databaseVm.NotifyPropertyChanged("SelectedVisibility");
|
databaseVm.NotifyPropertyChanged("SelectedVisibility");
|
||||||
databaseVm.NotifyPropertyChanged("Name");
|
databaseVm.NotifyPropertyChanged("Name");
|
||||||
PasswordBox.Focus(FocusState.Programmatic);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OpenButton_OnClick(object sender, RoutedEventArgs e)
|
private void PasswordUserControl_PasswordChecked(object sender, Events.DatabaseEventArgs e)
|
||||||
{
|
{
|
||||||
var app = (App)Application.Current;
|
var app = (App)Application.Current;
|
||||||
StatusTextBlock.Text = app.Database.Open(PasswordBox.Password);
|
if (e.IsOpen) _mainFrame.Navigate(typeof(GroupDetailPage), app.Database.RootGroup);
|
||||||
if (string.IsNullOrEmpty(StatusTextBlock.Text)) _mainFrame.Navigate(typeof(GroupDetailPage), app.Database.RootGroup);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void PasswordBox_KeyDown(object sender, KeyRoutedEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.Key == VirtualKey.Enter) OpenButton_OnClick(null, null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
<Page
|
<Page
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:local="using:ModernKeePass.Pages"
|
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:viewModels="using:ModernKeePass.ViewModels"
|
xmlns:viewModels="using:ModernKeePass.ViewModels"
|
||||||
|
xmlns:local="using:ModernKeePass.Controls"
|
||||||
x:Class="ModernKeePass.Pages.RecentDatabasesPage"
|
x:Class="ModernKeePass.Pages.RecentDatabasesPage"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
<Page.DataContext>
|
<Page.DataContext>
|
||||||
@@ -23,7 +23,10 @@
|
|||||||
IsSynchronizedWithCurrentItem="False">
|
IsSynchronizedWithCurrentItem="False">
|
||||||
<ListView.ItemTemplate>
|
<ListView.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<TextBlock Text="{Binding Name}" Width="350" Padding="5" />
|
<StackPanel>
|
||||||
|
<TextBlock Text="{Binding Name}" Width="350" Padding="5" />
|
||||||
|
<local:PasswordUserControl Visibility="{Binding PasswordVisibility}" PasswordChecked="PasswordUserControl_PasswordChecked" />
|
||||||
|
</StackPanel>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ListView.ItemTemplate>
|
</ListView.ItemTemplate>
|
||||||
<ListView.ItemContainerStyle>
|
<ListView.ItemContainerStyle>
|
||||||
|
@@ -1,14 +1,14 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using ModernKeePass.Common;
|
|
||||||
using ModernKeePass.Models;
|
|
||||||
using ModernKeePass.ViewModels;
|
|
||||||
using Windows.Storage;
|
using Windows.Storage;
|
||||||
using Windows.Storage.AccessCache;
|
using Windows.Storage.AccessCache;
|
||||||
using Windows.UI.Xaml;
|
using Windows.UI.Xaml;
|
||||||
using Windows.UI.Xaml.Controls;
|
using Windows.UI.Xaml.Controls;
|
||||||
using Windows.UI.Xaml.Navigation;
|
using Windows.UI.Xaml.Navigation;
|
||||||
|
using ModernKeePass.Common;
|
||||||
|
using ModernKeePass.Models;
|
||||||
|
using ModernKeePass.ViewModels;
|
||||||
|
|
||||||
// Pour en savoir plus sur le modèle d'élément Page vierge, consultez la page http://go.microsoft.com/fwlink/?LinkId=234238
|
// Pour en savoir plus sur le modèle d'élément Page vierge, consultez la page http://go.microsoft.com/fwlink/?LinkId=234238
|
||||||
|
|
||||||
@@ -30,7 +30,6 @@ namespace ModernKeePass.Pages
|
|||||||
{
|
{
|
||||||
base.OnNavigatedTo(e);
|
base.OnNavigatedTo(e);
|
||||||
_mainFrame = e.Parameter as Frame;
|
_mainFrame = e.Parameter as Frame;
|
||||||
//RecentListView.SelectedIndex = -1;
|
|
||||||
var mru = StorageApplicationPermissions.MostRecentlyUsedList;
|
var mru = StorageApplicationPermissions.MostRecentlyUsedList;
|
||||||
var recentVm = DataContext as RecentVm;
|
var recentVm = DataContext as RecentVm;
|
||||||
recentVm.RecentItems = new ObservableCollection<RecentItem>(
|
recentVm.RecentItems = new ObservableCollection<RecentItem>(
|
||||||
@@ -41,15 +40,20 @@ namespace ModernKeePass.Pages
|
|||||||
|
|
||||||
private async void RecentListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
private async void RecentListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
//if (RecentListView == null || e.RemovedItems.Count > 0) return;
|
|
||||||
var recentItem = e.AddedItems[0] as RecentItem;
|
var recentItem = e.AddedItems[0] as RecentItem;
|
||||||
var mru = StorageApplicationPermissions.MostRecentlyUsedList;
|
var mru = StorageApplicationPermissions.MostRecentlyUsedList;
|
||||||
var file = await mru.GetFileAsync(recentItem.Token) as StorageFile;
|
var file = await mru.GetFileAsync(recentItem.Token) as StorageFile;
|
||||||
|
|
||||||
var app = (App)Application.Current;
|
var app = (App)Application.Current;
|
||||||
app.Database = new DatabaseHelper(file);
|
app.Database = new DatabaseHelper(file);
|
||||||
app.Database.Open("test");
|
recentItem.PasswordVisibility = Visibility.Visible;
|
||||||
_mainFrame.Navigate(typeof(GroupDetailPage), app.Database.RootGroup);
|
recentItem.NotifyPropertyChanged("PasswordVisibility");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PasswordUserControl_PasswordChecked(object sender, Events.DatabaseEventArgs e)
|
||||||
|
{
|
||||||
|
var app = (App)Application.Current;
|
||||||
|
if (e.IsOpen) _mainFrame.Navigate(typeof(GroupDetailPage), app.Database.RootGroup);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user