diff --git a/ModernKeePass/ModernKeePassApp.csproj b/ModernKeePass/ModernKeePassApp.csproj
index f8911a8..1c0ce08 100644
--- a/ModernKeePass/ModernKeePassApp.csproj
+++ b/ModernKeePass/ModernKeePassApp.csproj
@@ -133,6 +133,9 @@
SettingsDatabasePage.xaml
+
+ SettingsNewDatabasePage.xaml
+
SettingsSecurityPage.xaml
@@ -195,6 +198,7 @@
+
@@ -268,6 +272,10 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
diff --git a/ModernKeePass/Pages/SettingsPageFrames/SettingsNewDatabasePage.xaml b/ModernKeePass/Pages/SettingsPageFrames/SettingsNewDatabasePage.xaml
new file mode 100644
index 0000000..e12f6b3
--- /dev/null
+++ b/ModernKeePass/Pages/SettingsPageFrames/SettingsNewDatabasePage.xaml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ModernKeePass/Pages/SettingsPageFrames/SettingsNewDatabasePage.xaml.cs b/ModernKeePass/Pages/SettingsPageFrames/SettingsNewDatabasePage.xaml.cs
new file mode 100644
index 0000000..4074169
--- /dev/null
+++ b/ModernKeePass/Pages/SettingsPageFrames/SettingsNewDatabasePage.xaml.cs
@@ -0,0 +1,15 @@
+// Pour en savoir plus sur le modèle d'élément Page vierge, consultez la page http://go.microsoft.com/fwlink/?LinkId=234238
+
+namespace ModernKeePass.Pages.SettingsPageFrames
+{
+ ///
+ /// Une page vide peut être utilisée seule ou constituer une page de destination au sein d'un frame.
+ ///
+ public sealed partial class SettingsNewDatabasePage
+ {
+ public SettingsNewDatabasePage()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/ModernKeePass/Strings/en-US/Resources.resw b/ModernKeePass/Strings/en-US/Resources.resw
index 557aada..f73e323 100644
--- a/ModernKeePass/Strings/en-US/Resources.resw
+++ b/ModernKeePass/Strings/en-US/Resources.resw
@@ -249,6 +249,21 @@
Enabled
+
+ Here, you can change some default options when creating a database.
+
+
+ Default Key Derivation algorithm
+
+
+ Create sample data
+
+
+ No
+
+
+ Yes
+
Here, you may change your database password, key file, or both. Just click on on
diff --git a/ModernKeePass/ViewModels/GroupVm.cs b/ModernKeePass/ViewModels/GroupVm.cs
index 6349f18..a80dcef 100644
--- a/ModernKeePass/ViewModels/GroupVm.cs
+++ b/ModernKeePass/ViewModels/GroupVm.cs
@@ -34,7 +34,7 @@ namespace ModernKeePass.ViewModels
///
public bool IsSelected
{
- get { return _database.RecycleBinEnabled && _database.RecycleBin?.Id == Id; }
+ get { return _database != null && _database.RecycleBinEnabled && _database.RecycleBin?.Id == Id; }
set
{
if (value && _pwGroup != null) _database.RecycleBin = this;
diff --git a/ModernKeePass/ViewModels/Items/SettingsDatabaseVm.cs b/ModernKeePass/ViewModels/Items/SettingsDatabaseVm.cs
index 5967172..40d8af8 100644
--- a/ModernKeePass/ViewModels/Items/SettingsDatabaseVm.cs
+++ b/ModernKeePass/ViewModels/Items/SettingsDatabaseVm.cs
@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
-using Windows.Storage;
using Windows.UI.Xaml;
using ModernKeePass.Common;
using ModernKeePass.Interfaces;
@@ -15,7 +14,6 @@ namespace ModernKeePass.ViewModels
public class SettingsDatabaseVm: NotifyPropertyChangedBase, IHasSelectableObject
{
private readonly IDatabase _database;
- private readonly ApplicationDataContainer _localSettings = ApplicationData.Current.LocalSettings;
private GroupVm _selectedItem;
public bool HasRecycleBin
@@ -96,18 +94,5 @@ namespace ModernKeePass.ViewModels
_database = database;
Groups = _database.RootGroup.Groups;
}
-
- // TODO: Move to another setting class (or a static class)
- private T GetSetting(string property)
- {
- try
- {
- return (T) Convert.ChangeType(_localSettings.Values[property], typeof(T));
- }
- catch (InvalidCastException)
- {
- return default(T);
- }
- }
}
}
diff --git a/ModernKeePass/ViewModels/Items/SettingsNewVm.cs b/ModernKeePass/ViewModels/Items/SettingsNewVm.cs
new file mode 100644
index 0000000..8c44868
--- /dev/null
+++ b/ModernKeePass/ViewModels/Items/SettingsNewVm.cs
@@ -0,0 +1,47 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Windows.Storage;
+using ModernKeePassLib.Cryptography.KeyDerivation;
+
+namespace ModernKeePass.ViewModels
+{
+ public class SettingsNewVm
+ {
+ private readonly ApplicationDataContainer _localSettings = ApplicationData.Current.LocalSettings;
+
+ public bool IsCreateSample
+ {
+ get { return GetSetting("Sample"); }
+ set { PutSetting("Sample", value); }
+ }
+
+ public IEnumerable KeyDerivations => KdfPool.Engines.Select(e => e.Name);
+
+ public string KeyDerivationName
+ {
+ get { return GetSetting("KeyDerivation"); }
+ set { PutSetting("KeyDerivation", value); }
+ }
+
+ // TODO: Move this to a common class
+ private T GetSetting(string property)
+ {
+ try
+ {
+ return (T)Convert.ChangeType(_localSettings.Values[property], typeof(T));
+ }
+ catch (InvalidCastException)
+ {
+ return default(T);
+ }
+ }
+
+ private void PutSetting(string property, T value)
+ {
+ if (_localSettings.Values.ContainsKey(property))
+ _localSettings.Values[property] = value;
+ else _localSettings.Values.Add(property, value);
+ }
+ }
+}
diff --git a/ModernKeePass/ViewModels/MainVm.cs b/ModernKeePass/ViewModels/MainVm.cs
index 8962e0a..9dc0000 100644
--- a/ModernKeePass/ViewModels/MainVm.cs
+++ b/ModernKeePass/ViewModels/MainVm.cs
@@ -73,6 +73,10 @@ namespace ModernKeePass.ViewModels
IsSelected = (database == null || database.Status == (int) DatabaseHelper.DatabaseStatus.Closed) && mru.Entries.Count > 0, IsEnabled = mru.Entries.Count > 0
},
new MainMenuItemVm
+ {
+ Title = "Settings" , PageType = typeof(SettingsPage), Destination = referenceFrame, SymbolIcon = Symbol.Setting
+ },
+ new MainMenuItemVm
{
Title = "About" , PageType = typeof(AboutPage), Destination = destinationFrame, SymbolIcon = Symbol.Help
}
diff --git a/ModernKeePass/ViewModels/SettingsVm.cs b/ModernKeePass/ViewModels/SettingsVm.cs
index 3d71496..edcc9b1 100644
--- a/ModernKeePass/ViewModels/SettingsVm.cs
+++ b/ModernKeePass/ViewModels/SettingsVm.cs
@@ -1,17 +1,18 @@
using System.Collections.ObjectModel;
using System.Linq;
+using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using ModernKeePass.Common;
using ModernKeePass.Interfaces;
using ModernKeePass.Pages;
+using ModernKeePass.Pages.SettingsPageFrames;
namespace ModernKeePass.ViewModels
{
public class SettingsVm : NotifyPropertyChangedBase, IHasSelectableObject
{
private ListMenuItemVm _selectedItem;
-
- //public ObservableCollection MenuItems { get; set; }
+
private IOrderedEnumerable> _menuItems;
public IOrderedEnumerable> MenuItems
@@ -40,14 +41,33 @@ namespace ModernKeePass.ViewModels
}
}
- public SettingsVm()
+ public SettingsVm() : this((Application.Current as App)?.Database) { }
+
+ public SettingsVm(IDatabase database)
{
var menuItems = new ObservableCollection
{
- new ListMenuItemVm { Title = "General", Group = "Database", SymbolIcon = Symbol.Setting, PageType = typeof(SettingsDatabasePage), IsSelected = true },
- new ListMenuItemVm { Title = "Security", Group = "Database", SymbolIcon = Symbol.Permissions, PageType = typeof(SettingsSecurityPage) },
- //new ListMenuItemVm { Title = "General", SymbolIcon = Symbol.Edit, PageType = typeof(SettingsGeneralPage) }
+ new ListMenuItemVm { Title = "New", Group = "Application", SymbolIcon = Symbol.Add, PageType = typeof(SettingsNewDatabasePage) }
};
+ if (database?.Status == 2)
+ {
+ menuItems.Add(new ListMenuItemVm
+ {
+ Title = "General",
+ Group = "Database",
+ SymbolIcon = Symbol.Setting,
+ PageType = typeof(SettingsDatabasePage),
+ IsSelected = true
+ });
+ menuItems.Add(new ListMenuItemVm
+ {
+ Title = "Security",
+ Group = "Database",
+ SymbolIcon = Symbol.Permissions,
+ PageType = typeof(SettingsSecurityPage)
+ });
+
+ }
SelectedItem = menuItems.FirstOrDefault(m => m.IsSelected);
MenuItems = from item in menuItems group item by item.Group into grp orderby grp.Key select grp;
diff --git a/ModernKeePassApp.Test/ViewModelsTests.cs b/ModernKeePassApp.Test/ViewModelsTests.cs
index 4146660..5df57fa 100644
--- a/ModernKeePassApp.Test/ViewModelsTests.cs
+++ b/ModernKeePassApp.Test/ViewModelsTests.cs
@@ -25,7 +25,7 @@ namespace ModernKeePassApp.Test
var mainVm = new MainVm(null, null, database);
Assert.AreEqual(1, mainVm.MainMenuItems.Count());
var firstGroup = mainVm.MainMenuItems.FirstOrDefault();
- Assert.AreEqual(5, firstGroup.Count());
+ Assert.AreEqual(6, firstGroup.Count());
database.Status = 1;
mainVm = new MainVm(null, null, database);
@@ -94,7 +94,7 @@ namespace ModernKeePassApp.Test
var settingsVm = new SettingsVm();
Assert.AreEqual(1, settingsVm.MenuItems.Count());
var firstGroup = settingsVm.MenuItems.FirstOrDefault();
- Assert.AreEqual(2, firstGroup.Count());
+ Assert.AreEqual(1, firstGroup.Count());
Assert.IsNotNull(settingsVm.SelectedItem);
var selectedItem = (ListMenuItemVm) settingsVm.SelectedItem;
Assert.AreEqual("General", selectedItem.Title);