2017-10-02 10:44:04 +02:00
|
|
|
|
using System;
|
2017-10-09 18:40:02 +02:00
|
|
|
|
using System.Threading.Tasks;
|
2017-10-02 10:44:04 +02:00
|
|
|
|
using Windows.System;
|
2017-10-09 18:40:02 +02:00
|
|
|
|
using Windows.UI.Core;
|
2017-09-30 09:00:32 -04:00
|
|
|
|
using Windows.UI.Xaml;
|
|
|
|
|
using Windows.UI.Xaml.Controls;
|
|
|
|
|
using Windows.UI.Xaml.Input;
|
|
|
|
|
|
|
|
|
|
// Pour en savoir plus sur le modèle d'élément Contrôle utilisateur, consultez la page http://go.microsoft.com/fwlink/?LinkId=234236
|
|
|
|
|
|
|
|
|
|
namespace ModernKeePass.Controls
|
|
|
|
|
{
|
2017-10-02 10:44:04 +02:00
|
|
|
|
public sealed partial class OpenDatabaseUserControl : UserControl
|
2017-09-30 09:00:32 -04:00
|
|
|
|
{
|
2017-10-02 10:44:04 +02:00
|
|
|
|
public OpenDatabaseUserControl()
|
2017-09-30 09:00:32 -04:00
|
|
|
|
{
|
2017-10-01 08:48:29 -04:00
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-02 10:44:04 +02:00
|
|
|
|
public event PasswordCheckedEventHandler ValidationChecked;
|
2017-10-09 18:40:02 +02:00
|
|
|
|
public delegate void PasswordCheckedEventHandler(object sender, EventArgs e);
|
2017-10-01 08:48:29 -04:00
|
|
|
|
|
|
|
|
|
private void OpenButton_OnClick(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var app = (App)Application.Current;
|
|
|
|
|
StatusTextBlock.Text = app.Database.Open(PasswordBox.Password);
|
2017-10-02 10:44:04 +02:00
|
|
|
|
ValidationChecked?.Invoke(this, new EventArgs());
|
2017-10-01 08:48:29 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PasswordBox_KeyDown(object sender, KeyRoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Key == VirtualKey.Enter) OpenButton_OnClick(null, null);
|
2017-09-30 09:00:32 -04:00
|
|
|
|
}
|
2017-10-09 18:40:02 +02:00
|
|
|
|
|
|
|
|
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Task.Factory.StartNew(
|
|
|
|
|
() => Dispatcher.RunAsync(CoreDispatcherPriority.Low,
|
|
|
|
|
() => PasswordBox.Focus(FocusState.Programmatic)));
|
|
|
|
|
}
|
2017-09-30 09:00:32 -04:00
|
|
|
|
}
|
|
|
|
|
}
|