diff --git a/ModernKeePass/App.xaml b/ModernKeePass/App.xaml
index 1e96ea1..175a021 100644
--- a/ModernKeePass/App.xaml
+++ b/ModernKeePass/App.xaml
@@ -1,18 +1,21 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ModernKeePass/App.xaml.cs b/ModernKeePass/App.xaml.cs
index 240f2a2..9cf0302 100644
--- a/ModernKeePass/App.xaml.cs
+++ b/ModernKeePass/App.xaml.cs
@@ -10,6 +10,7 @@ using Windows.Storage.Pickers;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
+using GalaSoft.MvvmLight.Views;
using MediatR;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.HockeyApp;
@@ -37,6 +38,7 @@ namespace ModernKeePass
private readonly IResourceProxy _resource;
private readonly IMediator _mediator;
private readonly ISettingsProxy _settings;
+ private readonly INavigationService _navigation;
public static IServiceProvider Services { get; private set; }
@@ -62,12 +64,13 @@ namespace ModernKeePass
serviceCollection.AddInfrastructureCommon();
serviceCollection.AddInfrastructureKeePass();
serviceCollection.AddInfrastructureUwp();
- serviceCollection.AddAppAutomapper();
+ serviceCollection.AddWin81App();
Services = serviceCollection.BuildServiceProvider();
_mediator = Services.GetService();
_resource = Services.GetService();
_settings = Services.GetService();
+ _navigation = Services.GetService();
}
#region Event Handlers
@@ -157,7 +160,8 @@ namespace ModernKeePass
var launchActivatedEventArgs = e as LaunchActivatedEventArgs;
if (launchActivatedEventArgs != null && rootFrame.Content == null)
- rootFrame.Navigate(typeof(MainPage), launchActivatedEventArgs.Arguments);
+ //rootFrame.Navigate(typeof(MainPage), launchActivatedEventArgs.Arguments);
+ _navigation.NavigateTo(Constants.Navigation.MainPage, launchActivatedEventArgs.Arguments);
// Ensure the current window is active
Window.Current.Activate();
@@ -247,11 +251,13 @@ namespace ModernKeePass
Name = file.DisplayName,
Path = file.Path
};
- rootFrame.Navigate(typeof(MainPage), fileInfo);
+ //rootFrame.Navigate(typeof(MainPage), fileInfo);
+ _navigation.NavigateTo(Constants.Navigation.MainPage, fileInfo);
}
else
{
- rootFrame.Navigate(typeof(MainPage));
+ //rootFrame.Navigate(typeof(MainPage));
+ _navigation.NavigateTo(Constants.Navigation.MainPage);
}
Window.Current.Content = rootFrame;
diff --git a/ModernKeePass/DependencyInjection.cs b/ModernKeePass/DependencyInjection.cs
index 9c18c87..2be2630 100644
--- a/ModernKeePass/DependencyInjection.cs
+++ b/ModernKeePass/DependencyInjection.cs
@@ -1,17 +1,29 @@
using System.Reflection;
using AutoMapper;
+using GalaSoft.MvvmLight.Views;
using Microsoft.Extensions.DependencyInjection;
+using ModernKeePass.Common;
+using ModernKeePass.Views;
namespace ModernKeePass
{
public static class DependencyInjection
{
- public static IServiceCollection AddAppAutomapper(this IServiceCollection services)
+ public static IServiceCollection AddWin81App(this IServiceCollection services)
{
var applicationAssembly = typeof(Application.DependencyInjection).GetTypeInfo().Assembly;
var infrastructureAssembly = typeof(Infrastructure.DependencyInjection).GetTypeInfo().Assembly;
services.AddAutoMapper(applicationAssembly, infrastructureAssembly);
+ services.AddSingleton(provider =>
+ {
+ var nav = new NavigationService();
+ nav.Configure(Constants.Navigation.MainPage, typeof(MainPage));
+ nav.Configure(Constants.Navigation.EntryPage, typeof(EntryDetailPage));
+ nav.Configure(Constants.Navigation.GroupPage, typeof(GroupDetailPage));
+ return nav;
+ });
+
return services;
}
}
diff --git a/ModernKeePass/ViewModel/MainViewModel.cs b/ModernKeePass/ViewModel/MainViewModel.cs
new file mode 100644
index 0000000..5d6d57d
--- /dev/null
+++ b/ModernKeePass/ViewModel/MainViewModel.cs
@@ -0,0 +1,34 @@
+using GalaSoft.MvvmLight;
+
+namespace ModernKeePass.ViewModel
+{
+ ///
+ /// This class contains properties that the main View can data bind to.
+ ///
+ /// Use the mvvminpc snippet to add bindable properties to this ViewModel.
+ ///
+ ///
+ /// You can also use Blend to data bind with the tool's support.
+ ///
+ ///
+ /// See http://www.galasoft.ch/mvvm
+ ///
+ ///
+ public class MainViewModel : ViewModelBase
+ {
+ ///
+ /// Initializes a new instance of the MainViewModel class.
+ ///
+ public MainViewModel()
+ {
+ ////if (IsInDesignMode)
+ ////{
+ //// // Code runs in Blend --> create design time data.
+ ////}
+ ////else
+ ////{
+ //// // Code runs "for real"
+ ////}
+ }
+ }
+}
\ No newline at end of file
diff --git a/ModernKeePass/ViewModel/ViewModelLocator.cs b/ModernKeePass/ViewModel/ViewModelLocator.cs
new file mode 100644
index 0000000..dbbd121
--- /dev/null
+++ b/ModernKeePass/ViewModel/ViewModelLocator.cs
@@ -0,0 +1,55 @@
+/*
+ In App.xaml:
+
+
+
+
+ In the View:
+ DataContext="{Binding Source={StaticResource Locator}, Path=ViewModelName}"
+
+ You can also use Blend to do all this with the tool's support.
+ See http://www.galasoft.ch/mvvm
+*/
+
+using CommonServiceLocator;
+using GalaSoft.MvvmLight;
+using GalaSoft.MvvmLight.Ioc;
+
+namespace ModernKeePass.ViewModel
+{
+ ///
+ /// This class contains static references to all the view models in the
+ /// application and provides an entry point for the bindings.
+ ///
+ public class ViewModelLocator
+ {
+ ///
+ /// Initializes a new instance of the ViewModelLocator class.
+ ///
+ public ViewModelLocator()
+ {
+ ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
+
+ ////if (ViewModelBase.IsInDesignModeStatic)
+ ////{
+ //// // Create design time view services and models
+ //// SimpleIoc.Default.Register();
+ ////}
+ ////else
+ ////{
+ //// // Create run time view services and models
+ //// SimpleIoc.Default.Register();
+ ////}
+
+ SimpleIoc.Default.Register();
+ }
+
+ public MainViewModel Main => ServiceLocator.Current.GetInstance();
+
+ public static void Cleanup()
+ {
+ // TODO Clear the ViewModels
+ }
+ }
+}
\ No newline at end of file
diff --git a/ModernKeePass/ViewModels/EntryDetailVm.cs b/ModernKeePass/ViewModels/EntryDetailVm.cs
index d15e68d..ad53837 100644
--- a/ModernKeePass/ViewModels/EntryDetailVm.cs
+++ b/ModernKeePass/ViewModels/EntryDetailVm.cs
@@ -5,6 +5,7 @@ using System.Linq;
using System.Threading.Tasks;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media;
+using GalaSoft.MvvmLight.Command;
using MediatR;
using Microsoft.Extensions.DependencyInjection;
using ModernKeePass.Application.Database.Commands.SaveDatabase;
@@ -22,7 +23,6 @@ using ModernKeePass.Application.Group.Commands.RemoveEntry;
using ModernKeePass.Application.Group.Queries.GetGroup;
using ModernKeePass.Application.Security.Commands.GeneratePassword;
using ModernKeePass.Application.Security.Queries.EstimatePasswordComplexity;
-using ModernKeePass.Common;
using ModernKeePass.Domain.Enums;
using ModernKeePass.Interfaces;
using ModernKeePass.Application.Group.Models;
diff --git a/ModernKeePass/ViewModels/GroupDetailVm.cs b/ModernKeePass/ViewModels/GroupDetailVm.cs
index 825d583..0684829 100644
--- a/ModernKeePass/ViewModels/GroupDetailVm.cs
+++ b/ModernKeePass/ViewModels/GroupDetailVm.cs
@@ -5,6 +5,7 @@ using System.Collections.Specialized;
using System.Linq;
using System.Threading.Tasks;
using Windows.UI.Xaml.Controls;
+using GalaSoft.MvvmLight.Command;
using MediatR;
using Microsoft.Extensions.DependencyInjection;
using ModernKeePass.Application.Database.Commands.SaveDatabase;
@@ -24,7 +25,6 @@ using ModernKeePass.Application.Group.Commands.UpdateGroup;
using ModernKeePass.Application.Group.Models;
using ModernKeePass.Application.Group.Queries.GetGroup;
using ModernKeePass.Application.Group.Queries.SearchEntries;
-using ModernKeePass.Common;
using ModernKeePass.Domain.AOP;
using ModernKeePass.Domain.Enums;
using ModernKeePass.Interfaces;
diff --git a/ModernKeePass/ViewModels/RecentVm.cs b/ModernKeePass/ViewModels/RecentVm.cs
index ba05d04..1b5e287 100644
--- a/ModernKeePass/ViewModels/RecentVm.cs
+++ b/ModernKeePass/ViewModels/RecentVm.cs
@@ -1,9 +1,9 @@
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows.Input;
+using GalaSoft.MvvmLight.Command;
using Microsoft.Extensions.DependencyInjection;
using ModernKeePass.Application.Common.Interfaces;
-using ModernKeePass.Common;
using ModernKeePass.Domain.AOP;
using ModernKeePass.Domain.Interfaces;
using ModernKeePass.ViewModels.ListItems;
diff --git a/ModernKeePass/ViewModels/SaveVm.cs b/ModernKeePass/ViewModels/SaveVm.cs
index e2b2695..15f48e2 100644
--- a/ModernKeePass/ViewModels/SaveVm.cs
+++ b/ModernKeePass/ViewModels/SaveVm.cs
@@ -2,12 +2,12 @@
using Windows.Storage;
using Windows.Storage.AccessCache;
using Windows.UI.Xaml.Controls;
+using GalaSoft.MvvmLight.Command;
using MediatR;
using Microsoft.Extensions.DependencyInjection;
using ModernKeePass.Application.Database.Commands.CloseDatabase;
using ModernKeePass.Application.Database.Commands.SaveDatabase;
using ModernKeePass.Application.Database.Queries.GetDatabase;
-using ModernKeePass.Common;
using ModernKeePass.Views;
namespace ModernKeePass.ViewModels
diff --git a/ModernKeePass/Views/UserControls/UpdateCredentialsUserControl.xaml b/ModernKeePass/Views/UserControls/UpdateCredentialsUserControl.xaml
index 62dde4b..7f4e119 100644
--- a/ModernKeePass/Views/UserControls/UpdateCredentialsUserControl.xaml
+++ b/ModernKeePass/Views/UserControls/UpdateCredentialsUserControl.xaml
@@ -1,14 +1,14 @@
-
+
@@ -18,7 +18,7 @@
-
+
@@ -60,7 +60,7 @@
diff --git a/ModernKeePass/Views/UserControls/UpdateCredentialsUserControl.xaml.cs b/ModernKeePass/Views/UserControls/UpdateCredentialsUserControl.xaml.cs
index 0825ad3..8d66a80 100644
--- a/ModernKeePass/Views/UserControls/UpdateCredentialsUserControl.xaml.cs
+++ b/ModernKeePass/Views/UserControls/UpdateCredentialsUserControl.xaml.cs
@@ -13,7 +13,7 @@ namespace ModernKeePass.Views.UserControls
{
public sealed partial class UpdateCredentialsUserControl
{
- public UpdateCredentialsViewModel ViewModel => Grid.DataContext as UpdateCredentialsViewModel;
+ public SetCredentialsViewModel ViewModel => Grid.DataContext as SetCredentialsViewModel;
public string ButtonLabel
{
diff --git a/ModernKeePass/Win81App.csproj b/ModernKeePass/Win81App.csproj
index f5d42ef..9bef338 100644
--- a/ModernKeePass/Win81App.csproj
+++ b/ModernKeePass/Win81App.csproj
@@ -94,6 +94,8 @@
+
+
DonatePage.xaml
@@ -348,10 +350,26 @@
..\packages\Portable.BouncyCastle.1.8.5\lib\netstandard1.0\BouncyCastle.Crypto.dll
True
+
+ ..\packages\CommonServiceLocator.2.0.5\lib\netstandard1.0\CommonServiceLocator.dll
+ True
+
..\packages\FluentValidation.8.6.2\lib\netstandard1.1\FluentValidation.dll
True
+
+ ..\packages\MvvmLightLibs.5.4.1.1\lib\windows81\GalaSoft.MvvmLight.dll
+ True
+
+
+ ..\packages\MvvmLightLibs.5.4.1.1\lib\windows81\GalaSoft.MvvmLight.Extras.dll
+ True
+
+
+ ..\packages\MvvmLightLibs.5.4.1.1\lib\windows81\GalaSoft.MvvmLight.Platform.dll
+ True
+
..\packages\MediatR.3.0.1\lib\netstandard1.1\MediatR.dll
True
@@ -401,11 +419,11 @@
True
- ..\packages\System.Buffers.4.5.0\lib\netstandard1.1\System.Buffers.dll
+ ..\packages\System.Buffers.4.5.1\lib\netstandard1.1\System.Buffers.dll
True
-
- ..\packages\System.Collections.Immutable.1.5.0\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll
+
+ ..\packages\System.Collections.Immutable.1.7.0\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll
True
@@ -420,20 +438,20 @@
..\packages\System.Drawing.Primitives.4.3.0\lib\netstandard1.1\System.Drawing.Primitives.dll
True
-
- ..\packages\System.Memory.4.5.1\lib\netstandard1.1\System.Memory.dll
+
+ ..\packages\System.Memory.4.5.4\lib\netstandard1.1\System.Memory.dll
True
-
- ..\packages\System.Numerics.Vectors.4.4.0\lib\portable-net45+win8+wp8+wpa81\System.Numerics.Vectors.dll
+
+ ..\packages\System.Numerics.Vectors.4.5.0\lib\portable-net45+win8+wp8+wpa81\System.Numerics.Vectors.dll
True
-
- ..\packages\System.Reflection.Metadata.1.6.0\lib\portable-net45+win8\System.Reflection.Metadata.dll
+
+ ..\packages\System.Reflection.Metadata.1.8.0\lib\portable-net45+win8\System.Reflection.Metadata.dll
True
-
- ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.1\lib\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll
+
+ ..\packages\System.Runtime.CompilerServices.Unsafe.4.7.1\lib\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll
True
diff --git a/ModernKeePass/packages.config b/ModernKeePass/packages.config
index c2fd7a0..fbea0f8 100644
--- a/ModernKeePass/packages.config
+++ b/ModernKeePass/packages.config
@@ -2,12 +2,13 @@
+
-
+
@@ -15,15 +16,17 @@
+
+
-
+
-
+
@@ -37,21 +40,21 @@
-
+
-
+
-
+
-
-
-
+
+
+
-
+
-
+
diff --git a/WinAppCommon/Common/Constants.cs b/WinAppCommon/Common/Constants.cs
index 8e4a232..ccebcf7 100644
--- a/WinAppCommon/Common/Constants.cs
+++ b/WinAppCommon/Common/Constants.cs
@@ -2,6 +2,13 @@
{
public class Constants
{
+ public class Navigation
+ {
+ public static string MainPage => nameof(MainPage);
+ public static string EntryPage => nameof(EntryPage);
+ public static string GroupPage => nameof(GroupPage);
+ }
+
public class File
{
public static int OneMegaByte => 1048576;
diff --git a/WinAppCommon/ViewModels/UserControls/UpdateCredentialsViewModel.cs b/WinAppCommon/ViewModels/UserControls/SetCredentialsViewModel.cs
similarity index 81%
rename from WinAppCommon/ViewModels/UserControls/UpdateCredentialsViewModel.cs
rename to WinAppCommon/ViewModels/UserControls/SetCredentialsViewModel.cs
index 6874430..6f1171b 100644
--- a/WinAppCommon/ViewModels/UserControls/UpdateCredentialsViewModel.cs
+++ b/WinAppCommon/ViewModels/UserControls/SetCredentialsViewModel.cs
@@ -7,7 +7,7 @@ using ModernKeePass.Domain.Dtos;
namespace ModernKeePass.ViewModels
{
- public class UpdateCredentialsViewModel : OpenDatabaseControlVm
+ public class SetCredentialsViewModel : OpenDatabaseControlVm
{
private readonly ICredentialsProxy _credentials;
private readonly ISettingsProxy _settings;
@@ -24,9 +24,9 @@ namespace ModernKeePass.ViewModels
public new bool IsValid => HasPassword && Password == ConfirmPassword || HasKeyFile && KeyFilePath != string.Empty;
- public UpdateCredentialsViewModel(): this(App.Services.GetRequiredService(), App.Services.GetRequiredService()) { }
+ public SetCredentialsViewModel(): this(App.Services.GetRequiredService(), App.Services.GetRequiredService()) { }
- public UpdateCredentialsViewModel(ICredentialsProxy credentials, ISettingsProxy settings)
+ public SetCredentialsViewModel(ICredentialsProxy credentials, ISettingsProxy settings)
{
_credentials = credentials;
_settings = settings;
diff --git a/WinAppCommon/WinAppCommon.projitems b/WinAppCommon/WinAppCommon.projitems
index 6796d64..08c35c0 100644
--- a/WinAppCommon/WinAppCommon.projitems
+++ b/WinAppCommon/WinAppCommon.projitems
@@ -45,6 +45,6 @@
-
+
\ No newline at end of file