mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 23:50:18 -04:00
New database setting page
(Database) Settings available from Main menu
This commit is contained in:
@@ -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<T>(string property)
|
||||
{
|
||||
try
|
||||
{
|
||||
return (T) Convert.ChangeType(_localSettings.Values[property], typeof(T));
|
||||
}
|
||||
catch (InvalidCastException)
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
47
ModernKeePass/ViewModels/Items/SettingsNewVm.cs
Normal file
47
ModernKeePass/ViewModels/Items/SettingsNewVm.cs
Normal file
@@ -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<bool>("Sample"); }
|
||||
set { PutSetting("Sample", value); }
|
||||
}
|
||||
|
||||
public IEnumerable<string> KeyDerivations => KdfPool.Engines.Select(e => e.Name);
|
||||
|
||||
public string KeyDerivationName
|
||||
{
|
||||
get { return GetSetting<string>("KeyDerivation"); }
|
||||
set { PutSetting("KeyDerivation", value); }
|
||||
}
|
||||
|
||||
// TODO: Move this to a common class
|
||||
private T GetSetting<T>(string property)
|
||||
{
|
||||
try
|
||||
{
|
||||
return (T)Convert.ChangeType(_localSettings.Values[property], typeof(T));
|
||||
}
|
||||
catch (InvalidCastException)
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
}
|
||||
|
||||
private void PutSetting<T>(string property, T value)
|
||||
{
|
||||
if (_localSettings.Values.ContainsKey(property))
|
||||
_localSettings.Values[property] = value;
|
||||
else _localSettings.Values.Add(property, value);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user