Created a Settings Service

Created a Recent Service
Created a Resources Service
Code refactor
Updated tests
This commit is contained in:
BONNEVILLE Geoffroy
2017-12-01 17:59:38 +01:00
parent f172e31250
commit 744858df81
35 changed files with 552 additions and 141 deletions

View File

@@ -1,24 +1,15 @@
using System;
using Windows.Storage;
using Windows.Storage;
using ModernKeePass.Common;
using Windows.Storage.AccessCache;
using Windows.UI.Xaml;
using ModernKeePass.Interfaces;
using ModernKeePass.Services;
namespace ModernKeePass.ViewModels
{
public class RecentItemVm: NotifyPropertyChangedBase, ISelectableModel
public class RecentItemVm: NotifyPropertyChangedBase, ISelectableModel, IRecentItem
{
private bool _isSelected;
public RecentItemVm() {}
public RecentItemVm(AccessListEntry entry, StorageFile file)
{
Token = entry.Token;
Name = entry.Metadata;
DatabaseFile = file;
}
public StorageFile DatabaseFile { get; }
public string Token { get; }
public string Name { get; }
@@ -30,6 +21,14 @@ namespace ModernKeePass.ViewModels
set { SetProperty(ref _isSelected, value); }
}
public RecentItemVm() {}
public RecentItemVm(string token, string metadata, IStorageItem file)
{
Token = token;
Name = metadata;
DatabaseFile = file as StorageFile;
}
public void OpenDatabaseFile()
{
OpenDatabaseFile((Application.Current as App)?.Database);
@@ -40,10 +39,14 @@ namespace ModernKeePass.ViewModels
database.DatabaseFile = DatabaseFile;
}
public async void UpdateAccessTime()
public void UpdateAccessTime()
{
var mru = StorageApplicationPermissions.MostRecentlyUsedList;
await mru.GetFileAsync(Token);
UpdateAccessTime(new RecentService());
}
public async void UpdateAccessTime(IRecent recent)
{
await recent.GetFileAsync(Token);
}
}
}

View File

@@ -11,6 +11,7 @@ using ModernKeePassLib.Cryptography.KeyDerivation;
namespace ModernKeePass.ViewModels
{
// TODO: implement Kdf settings
public class SettingsDatabaseVm: NotifyPropertyChangedBase, IHasSelectableObject
{
private readonly IDatabase _database;

View File

@@ -1,23 +1,33 @@
using System.Collections.Generic;
using ModernKeePass.Interfaces;
using ModernKeePass.Services;
namespace ModernKeePass.ViewModels
{
public class SettingsNewVm
{
private ISettings _settings;
public SettingsNewVm() : this(new SettingsService())
{ }
public SettingsNewVm(ISettings settings)
{
_settings = settings;
}
public bool IsCreateSample
{
get { return SettingsService.GetSetting<bool>("Sample"); }
set { SettingsService.PutSetting("Sample", value); }
get { return _settings.GetSetting<bool>("Sample"); }
set { _settings.PutSetting("Sample", value); }
}
public IEnumerable<string> FileFormats => new []{"2", "4"};
public string FileFormatVersion
{
get { return SettingsService.GetSetting<string>("DefaultFileFormat"); }
set { SettingsService.PutSetting("DefaultFileFormat", value); }
get { return _settings.GetSetting<string>("DefaultFileFormat"); }
set { _settings.PutSetting("DefaultFileFormat", value); }
}
}
}