Updated Settings page

Added new settings (history and clipboard)
Renamed and moved Settings Vms
This commit is contained in:
Geoffroy BONNEVILLE
2020-05-13 13:50:33 +02:00
parent 7ac1595aaa
commit d38d6461bd
42 changed files with 777 additions and 164 deletions

View File

@@ -108,6 +108,7 @@
<Compile Include="Parameters\Commands\SetHasRecycleBin\SetHasRecycleBinCommand.cs" /> <Compile Include="Parameters\Commands\SetHasRecycleBin\SetHasRecycleBinCommand.cs" />
<Compile Include="Parameters\Commands\SetMaxHistoryCount\SetHistoryCountCommand.cs" /> <Compile Include="Parameters\Commands\SetMaxHistoryCount\SetHistoryCountCommand.cs" />
<Compile Include="Parameters\Commands\SetKeyDerivation\SetKeyDerivationCommand.cs" /> <Compile Include="Parameters\Commands\SetKeyDerivation\SetKeyDerivationCommand.cs" />
<Compile Include="Parameters\Commands\SetMaxHistorySize\SetMaxHistorySizeCommand.cs" />
<Compile Include="Parameters\Commands\SetRecycleBin\SetRecycleBinCommand.cs" /> <Compile Include="Parameters\Commands\SetRecycleBin\SetRecycleBinCommand.cs" />
<Compile Include="Parameters\Models\CipherVm.cs" /> <Compile Include="Parameters\Models\CipherVm.cs" />
<Compile Include="Parameters\Models\KeyDerivationVm.cs" /> <Compile Include="Parameters\Models\KeyDerivationVm.cs" />

View File

@@ -23,6 +23,7 @@ namespace ModernKeePass.Application.Common.Interfaces
int Size { get; set; } int Size { get; set; }
bool IsDirty { get; set; } bool IsDirty { get; set; }
int MaxHistoryCount { get; set; } int MaxHistoryCount { get; set; }
long MaxHistorySize { get; set; }
Task Open(byte[] file, Credentials credentials); Task Open(byte[] file, Credentials credentials);
Task ReOpen(byte[] file); Task ReOpen(byte[] file);

View File

@@ -64,17 +64,17 @@ namespace ModernKeePass.Application.Database.Commands.CreateDatabase
_database.UpdateGroup(internetGroup); _database.UpdateGroup(internetGroup);
var sample1 = _database.CreateEntry(_database.RootGroupId); var sample1 = _database.CreateEntry(_database.RootGroupId);
_database.UpdateEntry(sample1.Id, EntryFieldName.Title, "Sample Entry", true); _database.UpdateEntry(sample1.Id, EntryFieldName.Title, "Sample Entry", false);
_database.UpdateEntry(sample1.Id, EntryFieldName.UserName, "Username", true); _database.UpdateEntry(sample1.Id, EntryFieldName.UserName, "Username", false);
_database.UpdateEntry(sample1.Id, EntryFieldName.Password, "Password", true); _database.UpdateEntry(sample1.Id, EntryFieldName.Password, "Password", true);
_database.UpdateEntry(sample1.Id, EntryFieldName.Url, "https://keepass.info/", true); _database.UpdateEntry(sample1.Id, EntryFieldName.Url, "https://keepass.info/", false);
_database.UpdateEntry(sample1.Id, EntryFieldName.Notes, "You may safely delete this sample", true); _database.UpdateEntry(sample1.Id, EntryFieldName.Notes, "You may safely delete this sample", false);
var sample2 = _database.CreateEntry(_database.RootGroupId); var sample2 = _database.CreateEntry(_database.RootGroupId);
_database.UpdateEntry(sample2.Id, EntryFieldName.Title, "Sample Entry #2", true); _database.UpdateEntry(sample2.Id, EntryFieldName.Title, "Sample Entry #2", false);
_database.UpdateEntry(sample2.Id, EntryFieldName.UserName, "Michael321", true); _database.UpdateEntry(sample2.Id, EntryFieldName.UserName, "Michael321", false);
_database.UpdateEntry(sample2.Id, EntryFieldName.Password, "12345", true); _database.UpdateEntry(sample2.Id, EntryFieldName.Password, "12345", true);
_database.UpdateEntry(sample2.Id, EntryFieldName.Url, "https://keepass.info/help/kb/testform.html", true); _database.UpdateEntry(sample2.Id, EntryFieldName.Url, "https://keepass.info/help/kb/testform.html", false);
} }
} }
} }

View File

@@ -13,5 +13,6 @@
public int Size { get; internal set; } public int Size { get; internal set; }
public bool IsDirty { get; internal set; } public bool IsDirty { get; internal set; }
public int MaxHistoryCount { get; set; } public int MaxHistoryCount { get; set; }
public long MaxHistorySize { get; set; }
} }
} }

View File

@@ -34,6 +34,7 @@ namespace ModernKeePass.Application.Database.Queries.GetDatabase
database.Size = _databaseProxy.Size; database.Size = _databaseProxy.Size;
database.IsDirty = _databaseProxy.IsDirty; database.IsDirty = _databaseProxy.IsDirty;
database.MaxHistoryCount = _databaseProxy.MaxHistoryCount; database.MaxHistoryCount = _databaseProxy.MaxHistoryCount;
database.MaxHistorySize = _databaseProxy.MaxHistorySize;
} }
return database; return database;
} }

View File

@@ -0,0 +1,28 @@
using MediatR;
using ModernKeePass.Application.Common.Interfaces;
using ModernKeePass.Domain.Exceptions;
namespace ModernKeePass.Application.Parameters.Commands.SetMaxHistorySize
{
public class SetMaxHistorySizeCommand : IRequest
{
public long MaxHistorySize { get; set; }
public class SetMaxHistorySizeCommandHandler : IRequestHandler<SetMaxHistorySizeCommand>
{
private readonly IDatabaseProxy _database;
public SetMaxHistorySizeCommandHandler(IDatabaseProxy database)
{
_database = database;
}
public void Handle(SetMaxHistorySizeCommand message)
{
if (_database.IsOpen) _database.MaxHistorySize = message.MaxHistorySize;
else throw new DatabaseClosedException();
}
}
}
}

View File

@@ -46,6 +46,12 @@ namespace ModernKeePass.Infrastructure.KeePass
set { _pwDatabase.HistoryMaxItems = value; } set { _pwDatabase.HistoryMaxItems = value; }
} }
public long MaxHistorySize
{
get { return _pwDatabase.HistoryMaxSize; }
set { _pwDatabase.HistoryMaxSize = value; }
}
// Settings // Settings
public bool IsRecycleBinEnabled public bool IsRecycleBinEnabled
{ {

View File

@@ -216,8 +216,8 @@
<data name="CompositeKeyErrorUserAccount" xml:space="preserve"> <data name="CompositeKeyErrorUserAccount" xml:space="preserve">
<value>- user account</value> <value>- user account</value>
</data> </data>
<data name="SettingsMenuItemSave" xml:space="preserve"> <data name="SettingsMenuItemCredentials" xml:space="preserve">
<value>Saving</value> <value>Credentials</value>
</data> </data>
<data name="RecycleBinTitle" xml:space="preserve"> <data name="RecycleBinTitle" xml:space="preserve">
<value>Recycle Bin</value> <value>Recycle Bin</value>
@@ -282,4 +282,10 @@
<data name="DatabaseTooBigTitle" xml:space="preserve"> <data name="DatabaseTooBigTitle" xml:space="preserve">
<value>Attention</value> <value>Attention</value>
</data> </data>
<data name="SettingsMenuItemHistory" xml:space="preserve">
<value>History</value>
</data>
<data name="SettingsMenuItemRecycleBin" xml:space="preserve">
<value>Recycle Bin</value>
</data>
</root> </root>

View File

@@ -297,9 +297,6 @@
<data name="SettingsDatabaseKdf.Text" xml:space="preserve"> <data name="SettingsDatabaseKdf.Text" xml:space="preserve">
<value>Key Derivation Algorithm</value> <value>Key Derivation Algorithm</value>
</data> </data>
<data name="SettingsDatabaseRecycleBin.Header" xml:space="preserve">
<value>Recycle bin</value>
</data>
<data name="SettingsDatabaseRecycleBin.OffContent" xml:space="preserve"> <data name="SettingsDatabaseRecycleBin.OffContent" xml:space="preserve">
<value>Disabled</value> <value>Disabled</value>
</data> </data>
@@ -558,4 +555,13 @@
<data name="TopMenuRestoreButton.Content" xml:space="preserve"> <data name="TopMenuRestoreButton.Content" xml:space="preserve">
<value>Restore</value> <value>Restore</value>
</data> </data>
<data name="SettingsHistoryMaxCount.Text" xml:space="preserve">
<value>Max history items</value>
</data>
<data name="SettingsHistoryMaxSize.Text" xml:space="preserve">
<value>Max history size (MB)</value>
</data>
<data name="SettingsCopyExpiration.Text" xml:space="preserve">
<value>Delete copied value from clipboard after how many seconds ?</value>
</data>
</root> </root>

View File

@@ -204,9 +204,6 @@
<data name="SettingsMenuGroupDatabase" xml:space="preserve"> <data name="SettingsMenuGroupDatabase" xml:space="preserve">
<value>Base de données</value> <value>Base de données</value>
</data> </data>
<data name="SettingsMenuItemGeneral" xml:space="preserve">
<value>Général</value>
</data>
<data name="SettingsMenuItemNew" xml:space="preserve"> <data name="SettingsMenuItemNew" xml:space="preserve">
<value>Nouveau</value> <value>Nouveau</value>
</data> </data>
@@ -216,9 +213,6 @@
<data name="CompositeKeyErrorUserAccount" xml:space="preserve"> <data name="CompositeKeyErrorUserAccount" xml:space="preserve">
<value>- compte utilisateur</value> <value>- compte utilisateur</value>
</data> </data>
<data name="SettingsMenuItemSave" xml:space="preserve">
<value>Sauvegardes</value>
</data>
<data name="RecycleBinTitle" xml:space="preserve"> <data name="RecycleBinTitle" xml:space="preserve">
<value>Corbeille</value> <value>Corbeille</value>
</data> </data>
@@ -285,4 +279,16 @@
<data name="DatabaseTooBigTitle" xml:space="preserve"> <data name="DatabaseTooBigTitle" xml:space="preserve">
<value>Attention</value> <value>Attention</value>
</data> </data>
<data name="SettingsMenuItemCredentials" xml:space="preserve">
<value>Identifiants</value>
</data>
<data name="SettingsMenuItemHistory" xml:space="preserve">
<value>Historique</value>
</data>
<data name="SettingsMenuItemRecycleBin" xml:space="preserve">
<value>Corbeille</value>
</data>
<data name="SettingsMenuItemGeneral" xml:space="preserve">
<value>Général</value>
</data>
</root> </root>

View File

@@ -297,9 +297,6 @@
<data name="SettingsDatabaseKdf.Text" xml:space="preserve"> <data name="SettingsDatabaseKdf.Text" xml:space="preserve">
<value>Algorithme de dérivation de clé</value> <value>Algorithme de dérivation de clé</value>
</data> </data>
<data name="SettingsDatabaseRecycleBin.Header" xml:space="preserve">
<value>Corbeille</value>
</data>
<data name="SettingsDatabaseRecycleBin.OffContent" xml:space="preserve"> <data name="SettingsDatabaseRecycleBin.OffContent" xml:space="preserve">
<value>Désactivé</value> <value>Désactivé</value>
</data> </data>
@@ -555,4 +552,13 @@
<data name="TopMenuRestoreButton.Content" xml:space="preserve"> <data name="TopMenuRestoreButton.Content" xml:space="preserve">
<value>Restaurer</value> <value>Restaurer</value>
</data> </data>
<data name="SettingsHistoryMaxCount.Text" xml:space="preserve">
<value>Nombre d'éléments d'historique max</value>
</data>
<data name="SettingsHistoryMaxSize.Text" xml:space="preserve">
<value>Taille de l'historique (MO)</value>
</data>
<data name="SettingsCopyExpiration.Text" xml:space="preserve">
<value>Supprimer la valeur copiée dans le presse papier après combien de secondes ?</value>
</data>
</root> </root>

View File

@@ -135,7 +135,7 @@ namespace ModernKeePass.ViewModels
set set
{ {
SelectedItem.Title.Value = value; SelectedItem.Title.Value = value;
SetFieldValue(nameof(Title), value, true).Wait(); SetFieldValue(nameof(Title), value, false).Wait();
} }
} }
@@ -145,7 +145,7 @@ namespace ModernKeePass.ViewModels
set set
{ {
SelectedItem.Username.Value = value; SelectedItem.Username.Value = value;
SetFieldValue(nameof(UserName), value, true).Wait(); SetFieldValue(nameof(UserName), value, false).Wait();
RaisePropertyChanged(nameof(UserName)); RaisePropertyChanged(nameof(UserName));
} }
} }
@@ -168,7 +168,7 @@ namespace ModernKeePass.ViewModels
set set
{ {
SelectedItem.Url.Value = value; SelectedItem.Url.Value = value;
SetFieldValue(nameof(Url), value, true).Wait(); SetFieldValue(nameof(Url), value, false).Wait();
RaisePropertyChanged(nameof(Url)); RaisePropertyChanged(nameof(Url));
} }
} }
@@ -179,7 +179,7 @@ namespace ModernKeePass.ViewModels
set set
{ {
SelectedItem.Notes.Value = value; SelectedItem.Notes.Value = value;
SetFieldValue(nameof(Notes), value, true).Wait(); SetFieldValue(nameof(Notes), value, false).Wait();
} }
} }
@@ -189,7 +189,7 @@ namespace ModernKeePass.ViewModels
set set
{ {
SelectedItem.Icon = (Icon)Enum.Parse(typeof(Icon), value.ToString()); SelectedItem.Icon = (Icon)Enum.Parse(typeof(Icon), value.ToString());
SetFieldValue(nameof(Icon), SelectedItem.Icon, true).Wait(); SetFieldValue(nameof(Icon), SelectedItem.Icon, false).Wait();
} }
} }
@@ -201,7 +201,7 @@ namespace ModernKeePass.ViewModels
if (!HasExpirationDate) return; if (!HasExpirationDate) return;
SelectedItem.ExpirationDate = value.Date; SelectedItem.ExpirationDate = value.Date;
SetFieldValue("ExpirationDate", SelectedItem.ExpirationDate, true).Wait(); SetFieldValue("ExpirationDate", SelectedItem.ExpirationDate, false).Wait();
} }
} }
@@ -213,7 +213,7 @@ namespace ModernKeePass.ViewModels
if (!HasExpirationDate) return; if (!HasExpirationDate) return;
SelectedItem.ExpirationDate = SelectedItem.ExpirationDate.Date.Add(value); SelectedItem.ExpirationDate = SelectedItem.ExpirationDate.Date.Add(value);
SetFieldValue("ExpirationDate", SelectedItem.ExpirationDate, true).Wait(); SetFieldValue("ExpirationDate", SelectedItem.ExpirationDate, false).Wait();
} }
} }
@@ -223,7 +223,7 @@ namespace ModernKeePass.ViewModels
set set
{ {
SelectedItem.HasExpirationDate = value; SelectedItem.HasExpirationDate = value;
SetFieldValue(nameof(HasExpirationDate), value, true).Wait(); SetFieldValue(nameof(HasExpirationDate), value, false).Wait();
RaisePropertyChanged(nameof(HasExpirationDate)); RaisePropertyChanged(nameof(HasExpirationDate));
} }
} }
@@ -234,7 +234,7 @@ namespace ModernKeePass.ViewModels
set set
{ {
SelectedItem.BackgroundColor = value.ToColor(); SelectedItem.BackgroundColor = value.ToColor();
SetFieldValue(nameof(BackgroundColor), SelectedItem.BackgroundColor, true).Wait(); SetFieldValue(nameof(BackgroundColor), SelectedItem.BackgroundColor, false).Wait();
} }
} }
@@ -244,7 +244,7 @@ namespace ModernKeePass.ViewModels
set set
{ {
SelectedItem.ForegroundColor = value.ToColor(); SelectedItem.ForegroundColor = value.ToColor();
SetFieldValue(nameof(ForegroundColor), SelectedItem.ForegroundColor, true).Wait(); SetFieldValue(nameof(ForegroundColor), SelectedItem.ForegroundColor, false).Wait();
} }
} }

View File

@@ -8,6 +8,7 @@ using ModernKeePass.Application.Database.Queries.GetDatabase;
using ModernKeePass.Domain.Interfaces; using ModernKeePass.Domain.Interfaces;
using ModernKeePass.ViewModels.ListItems; using ModernKeePass.ViewModels.ListItems;
using ModernKeePass.Views; using ModernKeePass.Views;
using ModernKeePass.Views.SettingsPageFrames;
namespace ModernKeePass.ViewModels namespace ModernKeePass.ViewModels
{ {
@@ -57,19 +58,11 @@ namespace ModernKeePass.ViewModels
IsSelected = true IsSelected = true
}, },
new ListMenuItemVm new ListMenuItemVm
{
Title = resource.GetResourceValue("SettingsMenuItemSave"),
Group = resource.GetResourceValue("SettingsMenuGroupApplication"),
SymbolIcon = Symbol.Save,
PageType = typeof(SettingsSavePage)
},
new ListMenuItemVm
{ {
Title = resource.GetResourceValue("SettingsMenuItemGeneral"), Title = resource.GetResourceValue("SettingsMenuItemGeneral"),
Group = resource.GetResourceValue("SettingsMenuGroupDatabase"), Group = resource.GetResourceValue("SettingsMenuGroupApplication"),
SymbolIcon = Symbol.Setting, SymbolIcon = Symbol.Setting,
PageType = typeof(SettingsDatabasePage), PageType = typeof(SettingsGeneralPage)
IsEnabled = database.IsOpen
}, },
new ListMenuItemVm new ListMenuItemVm
{ {
@@ -78,6 +71,30 @@ namespace ModernKeePass.ViewModels
SymbolIcon = Symbol.Permissions, SymbolIcon = Symbol.Permissions,
PageType = typeof(SettingsSecurityPage), PageType = typeof(SettingsSecurityPage),
IsEnabled = database.IsOpen IsEnabled = database.IsOpen
},
new ListMenuItemVm
{
Title = resource.GetResourceValue("SettingsMenuItemHistory"),
Group = resource.GetResourceValue("SettingsMenuGroupDatabase"),
SymbolIcon = Symbol.Undo,
PageType = typeof(SettingsHistoryPage),
IsEnabled = database.IsOpen
},
new ListMenuItemVm
{
Title = resource.GetResourceValue("SettingsMenuItemRecycleBin"),
Group = resource.GetResourceValue("SettingsMenuGroupDatabase"),
SymbolIcon = Symbol.Delete,
PageType = typeof(SettingsRecycleBinPage),
IsEnabled = database.IsOpen
},
new ListMenuItemVm
{
Title = resource.GetResourceValue("SettingsMenuItemCredentials"),
Group = resource.GetResourceValue("SettingsMenuGroupDatabase"),
SymbolIcon = Symbol.Account,
PageType = typeof(SettingsCredentialsPage),
IsEnabled = database.IsOpen
} }
}; };
SelectedItem = menuItems.FirstOrDefault(m => m.IsSelected); SelectedItem = menuItems.FirstOrDefault(m => m.IsSelected);

View File

@@ -0,0 +1,20 @@
<Page
x:Class="ModernKeePass.Views.SettingsCredentialsPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:userControls="using:ModernKeePass.Views.UserControls"
mc:Ignorable="d"
DataContext="{Binding Source={StaticResource Locator}, Path=Credentials}">
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<TextBlock x:Uid="SettingsSecurityTitle" Style="{StaticResource TextBlockSettingsHeaderStyle}" Margin="5,0,0,0" />
<TextBlock TextWrapping="WrapWholeWords" Margin="5,0,0,0">
<Run x:Uid="SettingsSecurityDesc1" />
<Run x:Uid="SettingsSecurityDesc2" FontWeight="SemiBold" />
<Run x:Uid="SettingsSecurityDesc3" />
</TextBlock>
<userControls:SetCredentialsUserControl Margin="0,20,0,0" x:Uid="SettingsSecurityUpdateButton"/>
</StackPanel>
</Page>

View File

@@ -5,9 +5,9 @@ namespace ModernKeePass.Views
/// <summary> /// <summary>
/// An empty page that can be used on its own or navigated to within a Frame. /// An empty page that can be used on its own or navigated to within a Frame.
/// </summary> /// </summary>
public sealed partial class SettingsDatabasePage public sealed partial class SettingsCredentialsPage
{ {
public SettingsDatabasePage() public SettingsCredentialsPage()
{ {
InitializeComponent(); InitializeComponent();
} }

View File

@@ -1,15 +1,17 @@
<Page <Page
x:Class="ModernKeePass.Views.SettingsSavePage" x:Class="ModernKeePass.Views.SettingsGeneralPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" mc:Ignorable="d"
DataContext="{Binding Source={StaticResource Locator}, Path=SettingsSave}"> DataContext="{Binding Source={StaticResource Locator}, Path=General}">
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<TextBlock x:Uid="SettingsSaveDatabaseSuspendTitle" Style="{StaticResource TextBlockSettingsHeaderStyle}" Margin="5,0,0,10"/> <TextBlock x:Uid="SettingsSaveDatabaseSuspendTitle" Style="{StaticResource TextBlockSettingsHeaderStyle}" Margin="5,0,0,10"/>
<TextBlock x:Uid="SettingsSaveDatabaseSuspendDesc" TextWrapping="WrapWholeWords" Margin="5,0,0,10"/> <TextBlock x:Uid="SettingsSaveDatabaseSuspendDesc" TextWrapping="WrapWholeWords" Margin="5,0,0,10"/>
<ToggleSwitch x:Uid="SettingsSaveDatabaseSuspend" IsOn="{Binding IsSaveSuspend, Mode=TwoWay}" /> <ToggleSwitch x:Uid="SettingsSaveDatabaseSuspend" IsOn="{Binding IsSaveSuspend, Mode=TwoWay}" />
<TextBlock x:Uid="SettingsCopyExpiration" Style="{StaticResource TextBlockSettingsHeaderStyle}" Margin="5,20,0,10" />
<TextBox Text="{Binding CopyExpiration, Mode=TwoWay}" InputScope="Number" KeyDown="UIElement_OnKeyDown" />
</StackPanel> </StackPanel>
</Page> </Page>

View File

@@ -0,0 +1,26 @@
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
using Windows.System;
using Windows.UI.Xaml.Input;
namespace ModernKeePass.Views
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class SettingsGeneralPage
{
public SettingsGeneralPage()
{
InitializeComponent();
}
private void UIElement_OnKeyDown(object sender, KeyRoutedEventArgs e)
{
if ((e.Key < VirtualKey.NumberPad0 || e.Key > VirtualKey.NumberPad9) & (e.Key < VirtualKey.Number0 || e.Key > VirtualKey.Number9))
{
e.Handled = true;
}
}
}
}

View File

@@ -0,0 +1,16 @@
<Page
x:Class="ModernKeePass.Views.SettingsPageFrames.SettingsHistoryPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
DataContext="{Binding Source={StaticResource Locator}, Path=History}">
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<TextBlock x:Uid="SettingsHistoryMaxCount" Style="{StaticResource TextBlockSettingsHeaderStyle}" Margin="5,20,0,10" />
<TextBox Text="{Binding MaxCount, Mode=TwoWay}" InputScope="Number" KeyDown="UIElement_OnKeyDown" />
<TextBlock x:Uid="SettingsHistoryMaxSize" Style="{StaticResource TextBlockSettingsHeaderStyle}" Margin="5,20,0,10" />
<TextBox Text="{Binding MaxSize, Mode=TwoWay}" InputScope="Number" KeyDown="UIElement_OnKeyDown" />
</StackPanel>
</Page>

View File

@@ -0,0 +1,26 @@
using Windows.System;
using Windows.UI.Xaml.Input;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
namespace ModernKeePass.Views.SettingsPageFrames
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class SettingsHistoryPage
{
public SettingsHistoryPage()
{
InitializeComponent();
}
private void UIElement_OnKeyDown(object sender, KeyRoutedEventArgs e)
{
if ((e.Key < VirtualKey.NumberPad0 || e.Key > VirtualKey.NumberPad9) & (e.Key < VirtualKey.Number0 || e.Key > VirtualKey.Number9))
{
e.Handled = true;
}
}
}
}

View File

@@ -1,12 +1,12 @@
<Page <Page
x:Class="ModernKeePass.Views.SettingsDatabasePage" x:Class="ModernKeePass.Views.SettingsPageFrames.SettingsRecycleBinPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:converters="using:ModernKeePass.Converters" xmlns:converters="using:ModernKeePass.Converters"
mc:Ignorable="d" mc:Ignorable="d"
DataContext="{Binding Source={StaticResource Locator}, Path=SettingsDatabase}"> DataContext="{Binding Source={StaticResource Locator}, Path=RecycleBin}">
<Page.Resources> <Page.Resources>
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/> <converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
<converters:NullToBooleanConverter x:Key="NullToBooleanConverter"/> <converters:NullToBooleanConverter x:Key="NullToBooleanConverter"/>
@@ -15,9 +15,6 @@
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<StackPanel.Resources> <StackPanel.Resources>
<CollectionViewSource x:Name="RecycleBinGroups" Source="{Binding Groups}" /> <CollectionViewSource x:Name="RecycleBinGroups" Source="{Binding Groups}" />
<CollectionViewSource x:Name="Ciphers" Source="{Binding Ciphers}" />
<CollectionViewSource x:Name="Compressions" Source="{Binding Compressions}" />
<CollectionViewSource x:Name="KeyDerivations" Source="{Binding KeyDerivations}" />
</StackPanel.Resources> </StackPanel.Resources>
<ToggleSwitch x:Uid="SettingsDatabaseRecycleBin" IsOn="{Binding HasRecycleBin, Mode=TwoWay}" /> <ToggleSwitch x:Uid="SettingsDatabaseRecycleBin" IsOn="{Binding HasRecycleBin, Mode=TwoWay}" />
<StackPanel Visibility="{Binding HasRecycleBin, Converter={StaticResource BooleanToVisibilityConverter}}"> <StackPanel Visibility="{Binding HasRecycleBin, Converter={StaticResource BooleanToVisibilityConverter}}">
@@ -25,11 +22,5 @@
<RadioButton x:Name="RadioButton" x:Uid="SettingsDatabaseRecycleBinExisting" GroupName="Recycle" IsChecked="{Binding SelectedRecycleBin, Converter={StaticResource NullToBooleanConverter}}" /> <RadioButton x:Name="RadioButton" x:Uid="SettingsDatabaseRecycleBinExisting" GroupName="Recycle" IsChecked="{Binding SelectedRecycleBin, Converter={StaticResource NullToBooleanConverter}}" />
<ComboBox ItemsSource="{Binding Source={StaticResource RecycleBinGroups}}" SelectedItem="{Binding SelectedRecycleBin, Mode=TwoWay}" IsEnabled="{Binding IsChecked, ElementName=RadioButton}" /> <ComboBox ItemsSource="{Binding Source={StaticResource RecycleBinGroups}}" SelectedItem="{Binding SelectedRecycleBin, Mode=TwoWay}" IsEnabled="{Binding IsChecked, ElementName=RadioButton}" />
</StackPanel> </StackPanel>
<TextBlock x:Uid="SettingsDatabaseEncryption" Style="{StaticResource TextBlockSettingsHeaderStyle}" Margin="5,20,0,10" />
<ComboBox ItemsSource="{Binding Source={StaticResource Ciphers}}" DisplayMemberPath="Name" SelectedItem="{Binding SelectedCipher, Mode=TwoWay}" />
<TextBlock x:Uid="SettingsDatabaseCompression" Style="{StaticResource TextBlockSettingsHeaderStyle}" Margin="5,20,0,10" />
<ComboBox ItemsSource="{Binding Source={StaticResource Compressions}}" SelectedItem="{Binding SelectedCompression, Mode=TwoWay}" />
<TextBlock x:Uid="SettingsDatabaseKdf" Style="{StaticResource TextBlockSettingsHeaderStyle}" Margin="5,20,0,10" />
<ComboBox ItemsSource="{Binding Source={StaticResource KeyDerivations}}" DisplayMemberPath="Name" SelectedItem="{Binding SelectedKeyDerivation, Mode=TwoWay}" />
</StackPanel> </StackPanel>
</Page> </Page>

View File

@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
namespace ModernKeePass.Views.SettingsPageFrames
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class SettingsRecycleBinPage : Page
{
public SettingsRecycleBinPage()
{
this.InitializeComponent();
}
}
}

View File

@@ -1,15 +0,0 @@
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
namespace ModernKeePass.Views
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class SettingsSavePage
{
public SettingsSavePage()
{
InitializeComponent();
}
}
}

View File

@@ -4,17 +4,20 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:userControls="using:ModernKeePass.Views.UserControls"
mc:Ignorable="d" mc:Ignorable="d"
DataContext="{Binding Source={StaticResource Locator}, Path=SettingsSecurity}"> DataContext="{Binding Source={StaticResource Locator}, Path=Security}">
<StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<TextBlock x:Uid="SettingsSecurityTitle" Style="{StaticResource TextBlockSettingsHeaderStyle}" Margin="5,0,0,0" /> <StackPanel.Resources>
<TextBlock TextWrapping="WrapWholeWords" Margin="5,0,0,0"> <CollectionViewSource x:Name="Ciphers" Source="{Binding Ciphers}" />
<Run x:Uid="SettingsSecurityDesc1" /> <CollectionViewSource x:Name="Compressions" Source="{Binding Compressions}" />
<Run x:Uid="SettingsSecurityDesc2" FontWeight="SemiBold" /> <CollectionViewSource x:Name="KeyDerivations" Source="{Binding KeyDerivations}" />
<Run x:Uid="SettingsSecurityDesc3" /> </StackPanel.Resources>
</TextBlock> <TextBlock x:Uid="SettingsDatabaseEncryption" Style="{StaticResource TextBlockSettingsHeaderStyle}" Margin="5,20,0,10" />
<userControls:SetCredentialsUserControl Margin="0,20,0,0" x:Uid="SettingsSecurityUpdateButton"/> <ComboBox ItemsSource="{Binding Source={StaticResource Ciphers}}" DisplayMemberPath="Name" SelectedItem="{Binding SelectedCipher, Mode=TwoWay}" />
<TextBlock x:Uid="SettingsDatabaseCompression" Style="{StaticResource TextBlockSettingsHeaderStyle}" Margin="5,20,0,10" />
<ComboBox ItemsSource="{Binding Source={StaticResource Compressions}}" SelectedItem="{Binding SelectedCompression, Mode=TwoWay}" />
<TextBlock x:Uid="SettingsDatabaseKdf" Style="{StaticResource TextBlockSettingsHeaderStyle}" Margin="5,20,0,10" />
<ComboBox ItemsSource="{Binding Source={StaticResource KeyDerivations}}" DisplayMemberPath="Name" SelectedItem="{Binding SelectedKeyDerivation, Mode=TwoWay}" />
</StackPanel> </StackPanel>
</Page> </Page>

View File

@@ -102,17 +102,23 @@
<Compile Include="Views\MainPageFrames\ImportExportPage.xaml.cs"> <Compile Include="Views\MainPageFrames\ImportExportPage.xaml.cs">
<DependentUpon>ImportExportPage.xaml</DependentUpon> <DependentUpon>ImportExportPage.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Views\SettingsPageFrames\SettingsDatabasePage.xaml.cs"> <Compile Include="Views\SettingsPageFrames\SettingsHistoryPage.xaml.cs">
<DependentUpon>SettingsDatabasePage.xaml</DependentUpon> <DependentUpon>SettingsHistoryPage.xaml</DependentUpon>
</Compile>
<Compile Include="Views\SettingsPageFrames\SettingsRecycleBinPage.xaml.cs">
<DependentUpon>SettingsRecycleBinPage.xaml</DependentUpon>
</Compile>
<Compile Include="Views\SettingsPageFrames\SettingsSecurityPage.xaml.cs">
<DependentUpon>SettingsSecurityPage.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Views\SettingsPageFrames\SettingsNewDatabasePage.xaml.cs"> <Compile Include="Views\SettingsPageFrames\SettingsNewDatabasePage.xaml.cs">
<DependentUpon>SettingsNewDatabasePage.xaml</DependentUpon> <DependentUpon>SettingsNewDatabasePage.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Views\SettingsPageFrames\SettingsSavePage.xaml.cs"> <Compile Include="Views\SettingsPageFrames\SettingsGeneralPage.xaml.cs">
<DependentUpon>SettingsSavePage.xaml</DependentUpon> <DependentUpon>SettingsGeneralPage.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Views\SettingsPageFrames\SettingsSecurityPage.xaml.cs"> <Compile Include="Views\SettingsPageFrames\SettingsCredentialsPage.xaml.cs">
<DependentUpon>SettingsSecurityPage.xaml</DependentUpon> <DependentUpon>SettingsCredentialsPage.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Views\SettingsPageFrames\SettingsWelcomePage.xaml.cs"> <Compile Include="Views\SettingsPageFrames\SettingsWelcomePage.xaml.cs">
<DependentUpon>SettingsWelcomePage.xaml</DependentUpon> <DependentUpon>SettingsWelcomePage.xaml</DependentUpon>
@@ -201,7 +207,15 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Views\SettingsPageFrames\SettingsSavePage.xaml"> <Page Include="Views\SettingsPageFrames\SettingsHistoryPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\SettingsPageFrames\SettingsRecycleBinPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\SettingsPageFrames\SettingsGeneralPage.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
@@ -253,7 +267,7 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Views\SettingsPageFrames\SettingsDatabasePage.xaml"> <Page Include="Views\SettingsPageFrames\SettingsSecurityPage.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
@@ -261,7 +275,7 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Views\SettingsPageFrames\SettingsSecurityPage.xaml"> <Page Include="Views\SettingsPageFrames\SettingsCredentialsPage.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>

View File

@@ -2,6 +2,6 @@ Support for additional fields
Support for attachments Support for attachments
Add an expiration timer for clipboard data Add an expiration timer for clipboard data
Ability to manually reorder groups Ability to manually reorder groups
Ability to set max history count Ability to set max history count and size
Design changes Design changes
Update to KeePassLib version 2.45 Update to KeePassLib version 2.45

View File

@@ -2,6 +2,6 @@ Ajout des champs additionnels
Ajout des pi<70>ces-jointes Ajout des pi<70>ces-jointes
Ajout d'une expiration du presse papier Ajout d'une expiration du presse papier
Possibilite de reorganiser les groupes manuellement Possibilite de reorganiser les groupes manuellement
Possibilite de parametrer le nombre max d'historique Possibilite de parametrer le nombre max et la taille de l'historique
Quelques changements de design Quelques changements de design
Mise a jour de la KeePassLib version 2.45 Mise a jour de la KeePassLib version 2.45

View File

@@ -0,0 +1,37 @@
using System.Threading.Tasks;
using GalaSoft.MvvmLight;
using MediatR;
using Messages;
using ModernKeePass.Application.Common.Interfaces;
using ModernKeePass.Application.Database.Commands.UpdateCredentials;
using ModernKeePass.Application.Database.Queries.GetDatabase;
namespace ModernKeePass.ViewModels.ListItems
{
public class SettingsCredentialsVm: ViewModelBase
{
private readonly IMediator _mediator;
private readonly IResourceProxy _resource;
private readonly INotificationService _notification;
public SettingsCredentialsVm(IMediator mediator, IResourceProxy resource, INotificationService notification)
{
_mediator = mediator;
_resource = resource;
_notification = notification;
MessengerInstance.Register<CredentialsSetMessage>(this, async message => await UpdateDatabaseCredentials(message));
}
public async Task UpdateDatabaseCredentials(CredentialsSetMessage message)
{
await _mediator.Send(new UpdateCredentialsCommand
{
KeyFilePath = message.KeyFilePath,
Password = message.Password
});
var database = await _mediator.Send(new GetDatabaseQuery());
_notification.Show(database.Name, _resource.GetResourceValue("CompositeKeyUpdated"));
}
}
}

View File

@@ -0,0 +1,7 @@
namespace ModernKeePass.ViewModels.ListItems
{
public class SettingsHistoryVm
{
}
}

View File

@@ -0,0 +1,57 @@
using System.Collections.ObjectModel;
using System.Linq;
using GalaSoft.MvvmLight;
using MediatR;
using ModernKeePass.Application.Common.Interfaces;
using ModernKeePass.Application.Database.Models;
using ModernKeePass.Application.Database.Queries.GetDatabase;
using ModernKeePass.Application.Group.Queries.GetGroup;
using ModernKeePass.Application.Parameters.Commands.SetHasRecycleBin;
using ModernKeePass.Application.Parameters.Commands.SetRecycleBin;
namespace ModernKeePass.ViewModels.ListItems
{
public class SettingsRecycleBinVm: ObservableObject
{
private readonly IMediator _mediator;
private readonly DatabaseVm _database;
public bool HasRecycleBin
{
get { return _database.IsRecycleBinEnabled; }
set
{
_mediator.Send(new SetHasRecycleBinCommand { HasRecycleBin = value }).Wait();
RaisePropertyChanged(nameof(HasRecycleBin));
}
}
public bool IsNewRecycleBin
{
get { return string.IsNullOrEmpty(_database.RecycleBinId); }
set
{
if (value) _mediator.Send(new SetRecycleBinCommand { RecycleBinId = null }).Wait();
}
}
public ObservableCollection<IEntityVm> Groups { get; }
public IEntityVm SelectedRecycleBin
{
get { return Groups.FirstOrDefault(g => g.Id == _database.RecycleBinId); }
set
{
if (!IsNewRecycleBin) _mediator.Send(new SetRecycleBinCommand { RecycleBinId = value.Id }).Wait();
}
}
public SettingsRecycleBinVm(IMediator mediator)
{
_mediator = mediator;
_database = _mediator.Send(new GetDatabaseQuery()).GetAwaiter().GetResult();
var rootGroup = _mediator.Send(new GetGroupQuery { Id = _database.RootGroupId }).GetAwaiter().GetResult();
Groups = new ObservableCollection<IEntityVm>(rootGroup.SubGroups);
}
}
}

View File

@@ -1,37 +1,57 @@
using System.Threading.Tasks; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using GalaSoft.MvvmLight; using GalaSoft.MvvmLight;
using MediatR; using MediatR;
using Messages; using ModernKeePass.Application.Database.Models;
using ModernKeePass.Application.Common.Interfaces;
using ModernKeePass.Application.Database.Commands.UpdateCredentials;
using ModernKeePass.Application.Database.Queries.GetDatabase; using ModernKeePass.Application.Database.Queries.GetDatabase;
using ModernKeePass.Application.Parameters.Commands.SetCipher;
using ModernKeePass.Application.Parameters.Commands.SetCompression;
using ModernKeePass.Application.Parameters.Commands.SetKeyDerivation;
using ModernKeePass.Application.Parameters.Models;
using ModernKeePass.Application.Parameters.Queries.GetCiphers;
using ModernKeePass.Application.Parameters.Queries.GetCompressions;
using ModernKeePass.Application.Parameters.Queries.GetKeyDerivations;
namespace ModernKeePass.ViewModels.ListItems namespace ModernKeePass.ViewModels.ListItems
{ {
public class SettingsSecurityVm: ViewModelBase // TODO: implement Kdf settings
public class SettingsSecurityVm: ObservableObject
{ {
private readonly IMediator _mediator; private readonly IMediator _mediator;
private readonly IResourceProxy _resource; private readonly DatabaseVm _database;
private readonly INotificationService _notification;
public SettingsSecurityVm(IMediator mediator, IResourceProxy resource, INotificationService notification) public ObservableCollection<CipherVm> Ciphers { get; }
public IEnumerable<string> Compressions => _mediator.Send(new GetCompressionsQuery()).GetAwaiter().GetResult();
public ObservableCollection<KeyDerivationVm> KeyDerivations { get; }
public CipherVm SelectedCipher
{
get { return Ciphers.FirstOrDefault(c => c.Id == _database.CipherId); }
set { _mediator.Send(new SetCipherCommand {CipherId = value.Id}).Wait(); }
}
public string SelectedCompression
{
get { return Compressions.FirstOrDefault(c => c == _database.Compression); }
set { _mediator.Send(new SetCompressionCommand {Compression = value}).Wait(); }
}
public KeyDerivationVm SelectedKeyDerivation
{
get { return KeyDerivations.FirstOrDefault(c => c.Id == _database.KeyDerivationId); }
set { _mediator.Send(new SetKeyDerivationCommand {KeyDerivationId = value.Id}).Wait(); }
}
public SettingsSecurityVm(IMediator mediator)
{ {
_mediator = mediator; _mediator = mediator;
_resource = resource; _database = _mediator.Send(new GetDatabaseQuery()).GetAwaiter().GetResult();
_notification = notification; var ciphers = _mediator.Send(new GetCiphersQuery()).GetAwaiter().GetResult();
Ciphers = new ObservableCollection<CipherVm>(ciphers);
MessengerInstance.Register<CredentialsSetMessage>(this, async message => await UpdateDatabaseCredentials(message)); var keyDerivations = _mediator.Send(new GetKeyDerivationsQuery()).GetAwaiter().GetResult();
} KeyDerivations = new ObservableCollection<KeyDerivationVm>(keyDerivations);
public async Task UpdateDatabaseCredentials(CredentialsSetMessage message)
{
await _mediator.Send(new UpdateCredentialsCommand
{
KeyFilePath = message.KeyFilePath,
Password = message.Password
});
var database = await _mediator.Send(new GetDatabaseQuery());
_notification.Show(database.Name, _resource.GetResourceValue("CompositeKeyUpdated"));
} }
} }
} }

View File

@@ -0,0 +1,37 @@
using System.Threading.Tasks;
using GalaSoft.MvvmLight;
using MediatR;
using Messages;
using ModernKeePass.Application.Common.Interfaces;
using ModernKeePass.Application.Database.Commands.UpdateCredentials;
using ModernKeePass.Application.Database.Queries.GetDatabase;
namespace ModernKeePass.ViewModels.Settings
{
public class CredentialsVm: ViewModelBase
{
private readonly IMediator _mediator;
private readonly IResourceProxy _resource;
private readonly INotificationService _notification;
public CredentialsVm(IMediator mediator, IResourceProxy resource, INotificationService notification)
{
_mediator = mediator;
_resource = resource;
_notification = notification;
MessengerInstance.Register<CredentialsSetMessage>(this, async message => await UpdateDatabaseCredentials(message));
}
public async Task UpdateDatabaseCredentials(CredentialsSetMessage message)
{
await _mediator.Send(new UpdateCredentialsCommand
{
KeyFilePath = message.KeyFilePath,
Password = message.Password
});
var database = await _mediator.Send(new GetDatabaseQuery());
_notification.Show(database.Name, _resource.GetResourceValue("CompositeKeyUpdated"));
}
}
}

View File

@@ -0,0 +1,28 @@
using ModernKeePass.Application.Common.Interfaces;
using ModernKeePass.Common;
namespace ModernKeePass.ViewModels.Settings
{
public class GeneralVm
{
private readonly ISettingsProxy _settings;
public bool IsSaveSuspend
{
get { return _settings.GetSetting(Constants.Settings.SaveSuspend, true); }
set { _settings.PutSetting(Constants.Settings.SaveSuspend, value); }
}
public int CopyExpiration
{
get { return _settings.GetSetting(Constants.Settings.ClipboardTimeout, 10); }
set { _settings.PutSetting(Constants.Settings.ClipboardTimeout, value); }
}
public GeneralVm(ISettingsProxy settings)
{
_settings = settings;
}
}
}

View File

@@ -0,0 +1,32 @@
using MediatR;
using ModernKeePass.Application.Database.Models;
using ModernKeePass.Application.Database.Queries.GetDatabase;
using ModernKeePass.Application.Parameters.Commands.SetMaxHistoryCount;
using ModernKeePass.Application.Parameters.Commands.SetMaxHistorySize;
namespace ModernKeePass.ViewModels.Settings
{
public class HistoryVm
{
private readonly IMediator _mediator;
private readonly DatabaseVm _database;
public int MaxCount
{
get { return _database.MaxHistoryCount; }
set { _mediator.Send(new SetMaxHistoryCountCommand { MaxHistoryCount = value }).Wait(); }
}
public long MaxSize
{
get { return _database.MaxHistorySize / 1024 / 1024; }
set { _mediator.Send(new SetMaxHistorySizeCommand { MaxHistorySize = value * 1024 * 1024 }).Wait(); }
}
public HistoryVm(IMediator mediator)
{
_mediator = mediator;
_database = _mediator.Send(new GetDatabaseQuery()).GetAwaiter().GetResult();
}
}
}

View File

@@ -0,0 +1,57 @@
using System.Collections.ObjectModel;
using System.Linq;
using GalaSoft.MvvmLight;
using MediatR;
using ModernKeePass.Application.Common.Interfaces;
using ModernKeePass.Application.Database.Models;
using ModernKeePass.Application.Database.Queries.GetDatabase;
using ModernKeePass.Application.Group.Queries.GetGroup;
using ModernKeePass.Application.Parameters.Commands.SetHasRecycleBin;
using ModernKeePass.Application.Parameters.Commands.SetRecycleBin;
namespace ModernKeePass.ViewModels.Settings
{
public class RecycleBinVm: ObservableObject
{
private readonly IMediator _mediator;
private readonly DatabaseVm _database;
public bool HasRecycleBin
{
get { return _database.IsRecycleBinEnabled; }
set
{
_mediator.Send(new SetHasRecycleBinCommand { HasRecycleBin = value }).Wait();
RaisePropertyChanged(nameof(HasRecycleBin));
}
}
public bool IsNewRecycleBin
{
get { return string.IsNullOrEmpty(_database.RecycleBinId); }
set
{
if (value) _mediator.Send(new SetRecycleBinCommand { RecycleBinId = null }).Wait();
}
}
public ObservableCollection<IEntityVm> Groups { get; }
public IEntityVm SelectedRecycleBin
{
get { return Groups.FirstOrDefault(g => g.Id == _database.RecycleBinId); }
set
{
if (!IsNewRecycleBin) _mediator.Send(new SetRecycleBinCommand { RecycleBinId = value.Id }).Wait();
}
}
public RecycleBinVm(IMediator mediator)
{
_mediator = mediator;
_database = _mediator.Send(new GetDatabaseQuery()).GetAwaiter().GetResult();
var rootGroup = _mediator.Send(new GetGroupQuery { Id = _database.RootGroupId }).GetAwaiter().GetResult();
Groups = new ObservableCollection<IEntityVm>(rootGroup.SubGroups);
}
}
}

View File

@@ -3,48 +3,24 @@ using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using GalaSoft.MvvmLight; using GalaSoft.MvvmLight;
using MediatR; using MediatR;
using ModernKeePass.Application.Common.Interfaces;
using ModernKeePass.Application.Database.Models; using ModernKeePass.Application.Database.Models;
using ModernKeePass.Application.Database.Queries.GetDatabase; using ModernKeePass.Application.Database.Queries.GetDatabase;
using ModernKeePass.Application.Group.Queries.GetGroup;
using ModernKeePass.Application.Parameters.Commands.SetCipher; using ModernKeePass.Application.Parameters.Commands.SetCipher;
using ModernKeePass.Application.Parameters.Commands.SetCompression; using ModernKeePass.Application.Parameters.Commands.SetCompression;
using ModernKeePass.Application.Parameters.Commands.SetHasRecycleBin;
using ModernKeePass.Application.Parameters.Commands.SetKeyDerivation; using ModernKeePass.Application.Parameters.Commands.SetKeyDerivation;
using ModernKeePass.Application.Parameters.Commands.SetRecycleBin;
using ModernKeePass.Application.Parameters.Models; using ModernKeePass.Application.Parameters.Models;
using ModernKeePass.Application.Parameters.Queries.GetCiphers; using ModernKeePass.Application.Parameters.Queries.GetCiphers;
using ModernKeePass.Application.Parameters.Queries.GetCompressions; using ModernKeePass.Application.Parameters.Queries.GetCompressions;
using ModernKeePass.Application.Parameters.Queries.GetKeyDerivations; using ModernKeePass.Application.Parameters.Queries.GetKeyDerivations;
namespace ModernKeePass.ViewModels.ListItems namespace ModernKeePass.ViewModels.Settings
{ {
// TODO: implement Kdf settings // TODO: implement Kdf settings
public class SettingsDatabaseVm: ObservableObject public class SecurityVm: ObservableObject
{ {
private readonly IMediator _mediator; private readonly IMediator _mediator;
private readonly DatabaseVm _database; private readonly DatabaseVm _database;
public bool HasRecycleBin
{
get { return _database.IsRecycleBinEnabled; }
set
{
_mediator.Send(new SetHasRecycleBinCommand {HasRecycleBin = value}).Wait();
RaisePropertyChanged(nameof(HasRecycleBin));
}
}
public bool IsNewRecycleBin
{
get { return string.IsNullOrEmpty(_database.RecycleBinId); }
set
{
if (value) _mediator.Send(new SetRecycleBinCommand { RecycleBinId = null }).Wait();
}
}
public ObservableCollection<IEntityVm> Groups { get; }
public ObservableCollection<CipherVm> Ciphers { get; } public ObservableCollection<CipherVm> Ciphers { get; }
public IEnumerable<string> Compressions => _mediator.Send(new GetCompressionsQuery()).GetAwaiter().GetResult(); public IEnumerable<string> Compressions => _mediator.Send(new GetCompressionsQuery()).GetAwaiter().GetResult();
public ObservableCollection<KeyDerivationVm> KeyDerivations { get; } public ObservableCollection<KeyDerivationVm> KeyDerivations { get; }
@@ -67,21 +43,10 @@ namespace ModernKeePass.ViewModels.ListItems
set { _mediator.Send(new SetKeyDerivationCommand {KeyDerivationId = value.Id}).Wait(); } set { _mediator.Send(new SetKeyDerivationCommand {KeyDerivationId = value.Id}).Wait(); }
} }
public IEntityVm SelectedRecycleBin public SecurityVm(IMediator mediator)
{
get { return Groups.FirstOrDefault(g => g.Id == _database.RecycleBinId); }
set
{
if (!IsNewRecycleBin) _mediator.Send(new SetRecycleBinCommand { RecycleBinId = value.Id}).Wait();
}
}
public SettingsDatabaseVm(IMediator mediator)
{ {
_mediator = mediator; _mediator = mediator;
_database = _mediator.Send(new GetDatabaseQuery()).GetAwaiter().GetResult(); _database = _mediator.Send(new GetDatabaseQuery()).GetAwaiter().GetResult();
var rootGroup = _mediator.Send(new GetGroupQuery { Id = _database.RootGroupId }).GetAwaiter().GetResult();
Groups = new ObservableCollection<IEntityVm>(rootGroup.SubGroups);
var ciphers = _mediator.Send(new GetCiphersQuery()).GetAwaiter().GetResult(); var ciphers = _mediator.Send(new GetCiphersQuery()).GetAwaiter().GetResult();
Ciphers = new ObservableCollection<CipherVm>(ciphers); Ciphers = new ObservableCollection<CipherVm>(ciphers);
var keyDerivations = _mediator.Send(new GetKeyDerivationsQuery()).GetAwaiter().GetResult(); var keyDerivations = _mediator.Send(new GetKeyDerivationsQuery()).GetAwaiter().GetResult();

View File

@@ -0,0 +1,37 @@
using System.Threading.Tasks;
using GalaSoft.MvvmLight;
using MediatR;
using Messages;
using ModernKeePass.Application.Common.Interfaces;
using ModernKeePass.Application.Database.Commands.UpdateCredentials;
using ModernKeePass.Application.Database.Queries.GetDatabase;
namespace ModernKeePass.ViewModels.Settings
{
public class SettingsCredentialsVm: ViewModelBase
{
private readonly IMediator _mediator;
private readonly IResourceProxy _resource;
private readonly INotificationService _notification;
public SettingsCredentialsVm(IMediator mediator, IResourceProxy resource, INotificationService notification)
{
_mediator = mediator;
_resource = resource;
_notification = notification;
MessengerInstance.Register<CredentialsSetMessage>(this, async message => await UpdateDatabaseCredentials(message));
}
public async Task UpdateDatabaseCredentials(CredentialsSetMessage message)
{
await _mediator.Send(new UpdateCredentialsCommand
{
KeyFilePath = message.KeyFilePath,
Password = message.Password
});
var database = await _mediator.Send(new GetDatabaseQuery());
_notification.Show(database.Name, _resource.GetResourceValue("CompositeKeyUpdated"));
}
}
}

View File

@@ -0,0 +1,7 @@
namespace ModernKeePass.ViewModels.Settings
{
public class SettingsHistoryVm
{
}
}

View File

@@ -0,0 +1,53 @@
using System.Collections.Generic;
using System.Linq;
using ModernKeePass.Application.Common.Interfaces;
using ModernKeePass.Common;
namespace ModernKeePass.ViewModels.Settings
{
public class SettingsNewVm
{
private readonly ISettingsProxy _settings;
public SettingsNewVm(ISettingsProxy settings)
{
_settings = settings;
}
public bool IsCreateSample
{
get { return _settings.GetSetting(Constants.Settings.Sample, true); }
set { _settings.PutSetting(Constants.Settings.Sample, value); }
}
public IEnumerable<DatabaseFormat> FileFormats => new []
{
new DatabaseFormat
{
Version = "4",
DisplayText = "4 (Argon2, ChaCha20)"
},
new DatabaseFormat
{
Version = "3",
DisplayText = "3 (AES-KDF, AES/Rijndael)"
}
};
public DatabaseFormat DatabaseFormatVersion
{
get
{
var version = _settings.GetSetting(Constants.Settings.DefaultFileFormat, "4");
return FileFormats.FirstOrDefault(f => f.Version == version);
}
set { _settings.PutSetting(Constants.Settings.DefaultFileFormat, value.Version); }
}
}
public class DatabaseFormat
{
public string Version { get; set; }
public string DisplayText { get; set; }
}
}

View File

@@ -0,0 +1,57 @@
using System.Collections.ObjectModel;
using System.Linq;
using GalaSoft.MvvmLight;
using MediatR;
using ModernKeePass.Application.Common.Interfaces;
using ModernKeePass.Application.Database.Models;
using ModernKeePass.Application.Database.Queries.GetDatabase;
using ModernKeePass.Application.Group.Queries.GetGroup;
using ModernKeePass.Application.Parameters.Commands.SetHasRecycleBin;
using ModernKeePass.Application.Parameters.Commands.SetRecycleBin;
namespace ModernKeePass.ViewModels.Settings
{
public class SettingsRecycleBinVm: ObservableObject
{
private readonly IMediator _mediator;
private readonly DatabaseVm _database;
public bool HasRecycleBin
{
get { return _database.IsRecycleBinEnabled; }
set
{
_mediator.Send(new SetHasRecycleBinCommand { HasRecycleBin = value }).Wait();
RaisePropertyChanged(nameof(HasRecycleBin));
}
}
public bool IsNewRecycleBin
{
get { return string.IsNullOrEmpty(_database.RecycleBinId); }
set
{
if (value) _mediator.Send(new SetRecycleBinCommand { RecycleBinId = null }).Wait();
}
}
public ObservableCollection<IEntityVm> Groups { get; }
public IEntityVm SelectedRecycleBin
{
get { return Groups.FirstOrDefault(g => g.Id == _database.RecycleBinId); }
set
{
if (!IsNewRecycleBin) _mediator.Send(new SetRecycleBinCommand { RecycleBinId = value.Id }).Wait();
}
}
public SettingsRecycleBinVm(IMediator mediator)
{
_mediator = mediator;
_database = _mediator.Send(new GetDatabaseQuery()).GetAwaiter().GetResult();
var rootGroup = _mediator.Send(new GetGroupQuery { Id = _database.RootGroupId }).GetAwaiter().GetResult();
Groups = new ObservableCollection<IEntityVm>(rootGroup.SubGroups);
}
}
}

View File

@@ -0,0 +1,21 @@
using ModernKeePass.Application.Common.Interfaces;
using ModernKeePass.Common;
namespace ModernKeePass.ViewModels.Settings
{
public class SettingsSaveVm
{
private readonly ISettingsProxy _settings;
public SettingsSaveVm(ISettingsProxy settings)
{
_settings = settings;
}
public bool IsSaveSuspend
{
get { return _settings.GetSetting(Constants.Settings.SaveSuspend, true); }
set { _settings.PutSetting(Constants.Settings.SaveSuspend, value); }
}
}
}

View File

@@ -20,7 +20,7 @@ using GalaSoft.MvvmLight.Views;
using MediatR; using MediatR;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using ModernKeePass.Application.Common.Interfaces; using ModernKeePass.Application.Common.Interfaces;
using ModernKeePass.ViewModels.ListItems; using ModernKeePass.ViewModels.Settings;
namespace ModernKeePass.ViewModels namespace ModernKeePass.ViewModels
{ {
@@ -57,10 +57,12 @@ namespace ModernKeePass.ViewModels
SimpleIoc.Default.Register(() => App.Services.GetRequiredService<INotificationService>()); SimpleIoc.Default.Register(() => App.Services.GetRequiredService<INotificationService>());
} }
SimpleIoc.Default.Register<SettingsDatabaseVm>(); SimpleIoc.Default.Register<SecurityVm>();
SimpleIoc.Default.Register<SettingsNewVm>(); SimpleIoc.Default.Register<SettingsNewVm>();
SimpleIoc.Default.Register<SettingsSaveVm>(); SimpleIoc.Default.Register<GeneralVm>();
SimpleIoc.Default.Register<SettingsSecurityVm>(); SimpleIoc.Default.Register<CredentialsVm>();
SimpleIoc.Default.Register<RecycleBinVm>();
SimpleIoc.Default.Register<HistoryVm>();
SimpleIoc.Default.Register<OpenDatabaseControlVm>(); SimpleIoc.Default.Register<OpenDatabaseControlVm>();
SimpleIoc.Default.Register<SetCredentialsVm>(); SimpleIoc.Default.Register<SetCredentialsVm>();
SimpleIoc.Default.Register<TopMenuVm>(); SimpleIoc.Default.Register<TopMenuVm>();
@@ -70,10 +72,12 @@ namespace ModernKeePass.ViewModels
SimpleIoc.Default.Register<SaveVm>(); SimpleIoc.Default.Register<SaveVm>();
} }
public SettingsDatabaseVm SettingsDatabase => ServiceLocator.Current.GetInstance<SettingsDatabaseVm>(Guid.NewGuid().ToString()); public SecurityVm Security => ServiceLocator.Current.GetInstance<SecurityVm>(Guid.NewGuid().ToString());
public SettingsNewVm SettingsNew => ServiceLocator.Current.GetInstance<SettingsNewVm>(Guid.NewGuid().ToString()); public SettingsNewVm SettingsNew => ServiceLocator.Current.GetInstance<SettingsNewVm>(Guid.NewGuid().ToString());
public SettingsSaveVm SettingsSave => ServiceLocator.Current.GetInstance<SettingsSaveVm>(Guid.NewGuid().ToString()); public GeneralVm General => ServiceLocator.Current.GetInstance<GeneralVm>(Guid.NewGuid().ToString());
public SettingsSecurityVm SettingsSecurity => ServiceLocator.Current.GetInstance<SettingsSecurityVm>(Guid.NewGuid().ToString()); public CredentialsVm Credentials => ServiceLocator.Current.GetInstance<CredentialsVm>(Guid.NewGuid().ToString());
public RecycleBinVm RecycleBin => ServiceLocator.Current.GetInstance<RecycleBinVm>(Guid.NewGuid().ToString());
public HistoryVm History => ServiceLocator.Current.GetInstance<HistoryVm>(Guid.NewGuid().ToString());
public OpenDatabaseControlVm OpenDatabaseControl => ServiceLocator.Current.GetInstance<OpenDatabaseControlVm>(Guid.NewGuid().ToString()); public OpenDatabaseControlVm OpenDatabaseControl => ServiceLocator.Current.GetInstance<OpenDatabaseControlVm>(Guid.NewGuid().ToString());
public SetCredentialsVm SetCredentials => ServiceLocator.Current.GetInstance<SetCredentialsVm>(Guid.NewGuid().ToString()); public SetCredentialsVm SetCredentials => ServiceLocator.Current.GetInstance<SetCredentialsVm>(Guid.NewGuid().ToString());
public TopMenuVm TopMenu => ServiceLocator.Current.GetInstance<TopMenuVm>(Guid.NewGuid().ToString()); public TopMenuVm TopMenu => ServiceLocator.Current.GetInstance<TopMenuVm>(Guid.NewGuid().ToString());

View File

@@ -43,14 +43,16 @@
<Compile Include="$(MSBuildThisFileDirectory)Messages\SaveErrorMessage.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Messages\SaveErrorMessage.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\AboutVm.cs" /> <Compile Include="$(MSBuildThisFileDirectory)ViewModels\AboutVm.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\Items\EntryFieldVm.cs" /> <Compile Include="$(MSBuildThisFileDirectory)ViewModels\Items\EntryFieldVm.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\Settings\CredentialsVm.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\Settings\HistoryVm.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\Settings\SettingsNewVm.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\Settings\RecycleBinVm.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\Settings\GeneralVm.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\Settings\SecurityVm.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\ViewModelLocatorCommon.cs" /> <Compile Include="$(MSBuildThisFileDirectory)ViewModels\ViewModelLocatorCommon.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\Items\ListMenuItemVm.cs" /> <Compile Include="$(MSBuildThisFileDirectory)ViewModels\Items\ListMenuItemVm.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\Items\MainMenuItemVm.cs" /> <Compile Include="$(MSBuildThisFileDirectory)ViewModels\Items\MainMenuItemVm.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\Items\RecentItemVm.cs" /> <Compile Include="$(MSBuildThisFileDirectory)ViewModels\Items\RecentItemVm.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\Items\SettingsDatabaseVm.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\Items\SettingsNewVm.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\Items\SettingsSaveVm.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\Items\SettingsSecurityVm.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\NewVm.cs" /> <Compile Include="$(MSBuildThisFileDirectory)ViewModels\NewVm.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\OpenVm.cs" /> <Compile Include="$(MSBuildThisFileDirectory)ViewModels\OpenVm.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\RecentVm.cs" /> <Compile Include="$(MSBuildThisFileDirectory)ViewModels\RecentVm.cs" />