mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Open file from Explorer with association works
Major code refactor in Open, Save and Recent pages and VM Main page automatically opens a sub page depending on context
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using Windows.ApplicationModel;
|
||||
using Windows.ApplicationModel.Activation;
|
||||
using Windows.Storage;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
@@ -16,15 +17,15 @@ namespace ModernKeePass
|
||||
/// </summary>
|
||||
sealed partial class App : Application
|
||||
{
|
||||
public DatabaseHelper Database { get; set; }
|
||||
public DatabaseHelper Database { get; set; } = new DatabaseHelper();
|
||||
/// <summary>
|
||||
/// Initializes the singleton application object. This is the first line of authored code
|
||||
/// executed, and as such is the logical equivalent of main() or WinMain().
|
||||
/// </summary>
|
||||
public App()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
this.Suspending += OnSuspending;
|
||||
InitializeComponent();
|
||||
Suspending += OnSuspending;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -38,11 +39,11 @@ namespace ModernKeePass
|
||||
#if DEBUG
|
||||
if (System.Diagnostics.Debugger.IsAttached)
|
||||
{
|
||||
this.DebugSettings.EnableFrameRateCounter = true;
|
||||
DebugSettings.EnableFrameRateCounter = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
Frame rootFrame = Window.Current.Content as Frame;
|
||||
var rootFrame = Window.Current.Content as Frame;
|
||||
|
||||
// Do not repeat app initialization when the Window already has content,
|
||||
// just ensure that the window is active
|
||||
@@ -95,8 +96,18 @@ namespace ModernKeePass
|
||||
private void OnSuspending(object sender, SuspendingEventArgs e)
|
||||
{
|
||||
var deferral = e.SuspendingOperation.GetDeferral();
|
||||
//TODO: Save application state and stop any background activity
|
||||
Database.Save();
|
||||
deferral.Complete();
|
||||
}
|
||||
|
||||
protected override void OnFileActivated(FileActivatedEventArgs args)
|
||||
{
|
||||
base.OnFileActivated(args);
|
||||
Database.DatabaseFile = args.Files[0] as StorageFile;
|
||||
var rootFrame = new Frame();
|
||||
rootFrame.Navigate(typeof(MainPage), args);
|
||||
Window.Current.Content = rootFrame;
|
||||
Window.Current.Activate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user