diff --git a/ModernKeePass.Application/Application.csproj b/ModernKeePass.Application/Application.csproj index 9df5904..dcc8af3 100644 --- a/ModernKeePass.Application/Application.csproj +++ b/ModernKeePass.Application/Application.csproj @@ -108,6 +108,7 @@ + diff --git a/ModernKeePass.Application/Common/Interfaces/IDatabaseProxy.cs b/ModernKeePass.Application/Common/Interfaces/IDatabaseProxy.cs index 1e1494d..d16dfe7 100644 --- a/ModernKeePass.Application/Common/Interfaces/IDatabaseProxy.cs +++ b/ModernKeePass.Application/Common/Interfaces/IDatabaseProxy.cs @@ -23,6 +23,7 @@ namespace ModernKeePass.Application.Common.Interfaces int Size { get; set; } bool IsDirty { get; set; } int MaxHistoryCount { get; set; } + long MaxHistorySize { get; set; } Task Open(byte[] file, Credentials credentials); Task ReOpen(byte[] file); diff --git a/ModernKeePass.Application/Database/Commands/CreateDatabase/CreateDatabaseCommand.cs b/ModernKeePass.Application/Database/Commands/CreateDatabase/CreateDatabaseCommand.cs index c8cd341..3037ace 100644 --- a/ModernKeePass.Application/Database/Commands/CreateDatabase/CreateDatabaseCommand.cs +++ b/ModernKeePass.Application/Database/Commands/CreateDatabase/CreateDatabaseCommand.cs @@ -64,17 +64,17 @@ namespace ModernKeePass.Application.Database.Commands.CreateDatabase _database.UpdateGroup(internetGroup); var sample1 = _database.CreateEntry(_database.RootGroupId); - _database.UpdateEntry(sample1.Id, EntryFieldName.Title, "Sample Entry", true); - _database.UpdateEntry(sample1.Id, EntryFieldName.UserName, "Username", true); + _database.UpdateEntry(sample1.Id, EntryFieldName.Title, "Sample Entry", false); + _database.UpdateEntry(sample1.Id, EntryFieldName.UserName, "Username", false); _database.UpdateEntry(sample1.Id, EntryFieldName.Password, "Password", true); - _database.UpdateEntry(sample1.Id, EntryFieldName.Url, "https://keepass.info/", true); - _database.UpdateEntry(sample1.Id, EntryFieldName.Notes, "You may safely delete this sample", true); + _database.UpdateEntry(sample1.Id, EntryFieldName.Url, "https://keepass.info/", false); + _database.UpdateEntry(sample1.Id, EntryFieldName.Notes, "You may safely delete this sample", false); var sample2 = _database.CreateEntry(_database.RootGroupId); - _database.UpdateEntry(sample2.Id, EntryFieldName.Title, "Sample Entry #2", true); - _database.UpdateEntry(sample2.Id, EntryFieldName.UserName, "Michael321", true); + _database.UpdateEntry(sample2.Id, EntryFieldName.Title, "Sample Entry #2", false); + _database.UpdateEntry(sample2.Id, EntryFieldName.UserName, "Michael321", false); _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); } } } diff --git a/ModernKeePass.Application/Database/Models/DatabaseVm.cs b/ModernKeePass.Application/Database/Models/DatabaseVm.cs index 831b621..c791c73 100644 --- a/ModernKeePass.Application/Database/Models/DatabaseVm.cs +++ b/ModernKeePass.Application/Database/Models/DatabaseVm.cs @@ -13,5 +13,6 @@ public int Size { get; internal set; } public bool IsDirty { get; internal set; } public int MaxHistoryCount { get; set; } + public long MaxHistorySize { get; set; } } } \ No newline at end of file diff --git a/ModernKeePass.Application/Database/Queries/GetDatabase/GetDatabaseQuery.cs b/ModernKeePass.Application/Database/Queries/GetDatabase/GetDatabaseQuery.cs index 93ebe5b..ddf867a 100644 --- a/ModernKeePass.Application/Database/Queries/GetDatabase/GetDatabaseQuery.cs +++ b/ModernKeePass.Application/Database/Queries/GetDatabase/GetDatabaseQuery.cs @@ -34,6 +34,7 @@ namespace ModernKeePass.Application.Database.Queries.GetDatabase database.Size = _databaseProxy.Size; database.IsDirty = _databaseProxy.IsDirty; database.MaxHistoryCount = _databaseProxy.MaxHistoryCount; + database.MaxHistorySize = _databaseProxy.MaxHistorySize; } return database; } diff --git a/ModernKeePass.Application/Parameters/Commands/SetMaxHistorySize/SetMaxHistorySizeCommand.cs b/ModernKeePass.Application/Parameters/Commands/SetMaxHistorySize/SetMaxHistorySizeCommand.cs new file mode 100644 index 0000000..5618a92 --- /dev/null +++ b/ModernKeePass.Application/Parameters/Commands/SetMaxHistorySize/SetMaxHistorySizeCommand.cs @@ -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 + { + 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(); + } + } + + } +} \ No newline at end of file diff --git a/ModernKeePass.Infrastructure/KeePass/KeePassDatabaseClient.cs b/ModernKeePass.Infrastructure/KeePass/KeePassDatabaseClient.cs index 5e269b8..d8276d9 100644 --- a/ModernKeePass.Infrastructure/KeePass/KeePassDatabaseClient.cs +++ b/ModernKeePass.Infrastructure/KeePass/KeePassDatabaseClient.cs @@ -46,6 +46,12 @@ namespace ModernKeePass.Infrastructure.KeePass set { _pwDatabase.HistoryMaxItems = value; } } + public long MaxHistorySize + { + get { return _pwDatabase.HistoryMaxSize; } + set { _pwDatabase.HistoryMaxSize = value; } + } + // Settings public bool IsRecycleBinEnabled { diff --git a/ModernKeePass/Strings/en-US/CodeBehind.resw b/ModernKeePass/Strings/en-US/CodeBehind.resw index 3b04d80..c965b0e 100644 --- a/ModernKeePass/Strings/en-US/CodeBehind.resw +++ b/ModernKeePass/Strings/en-US/CodeBehind.resw @@ -216,8 +216,8 @@ - user account - - Saving + + Credentials Recycle Bin @@ -282,4 +282,10 @@ Attention + + History + + + Recycle Bin + \ No newline at end of file diff --git a/ModernKeePass/Strings/en-US/Resources.resw b/ModernKeePass/Strings/en-US/Resources.resw index 715bc93..72ed5a2 100644 --- a/ModernKeePass/Strings/en-US/Resources.resw +++ b/ModernKeePass/Strings/en-US/Resources.resw @@ -297,9 +297,6 @@ Key Derivation Algorithm - - Recycle bin - Disabled @@ -558,4 +555,13 @@ Restore + + Max history items + + + Max history size (MB) + + + Delete copied value from clipboard after how many seconds ? + \ No newline at end of file diff --git a/ModernKeePass/Strings/fr-FR/CodeBehind.resw b/ModernKeePass/Strings/fr-FR/CodeBehind.resw index 41e78b6..10a05c7 100644 --- a/ModernKeePass/Strings/fr-FR/CodeBehind.resw +++ b/ModernKeePass/Strings/fr-FR/CodeBehind.resw @@ -204,9 +204,6 @@ Base de données - - Général - Nouveau @@ -216,9 +213,6 @@ - compte utilisateur - - Sauvegardes - Corbeille @@ -285,4 +279,16 @@ Attention + + Identifiants + + + Historique + + + Corbeille + + + Général + \ No newline at end of file diff --git a/ModernKeePass/Strings/fr-FR/Resources.resw b/ModernKeePass/Strings/fr-FR/Resources.resw index d38b04e..53fbadf 100644 --- a/ModernKeePass/Strings/fr-FR/Resources.resw +++ b/ModernKeePass/Strings/fr-FR/Resources.resw @@ -297,9 +297,6 @@ Algorithme de dérivation de clé - - Corbeille - Désactivé @@ -555,4 +552,13 @@ Restaurer + + Nombre d'éléments d'historique max + + + Taille de l'historique (MO) + + + Supprimer la valeur copiée dans le presse papier après combien de secondes ? + \ No newline at end of file diff --git a/ModernKeePass/ViewModels/EntryDetailVm.cs b/ModernKeePass/ViewModels/EntryDetailVm.cs index 18a320c..d70a302 100644 --- a/ModernKeePass/ViewModels/EntryDetailVm.cs +++ b/ModernKeePass/ViewModels/EntryDetailVm.cs @@ -135,7 +135,7 @@ namespace ModernKeePass.ViewModels set { SelectedItem.Title.Value = value; - SetFieldValue(nameof(Title), value, true).Wait(); + SetFieldValue(nameof(Title), value, false).Wait(); } } @@ -145,7 +145,7 @@ namespace ModernKeePass.ViewModels set { SelectedItem.Username.Value = value; - SetFieldValue(nameof(UserName), value, true).Wait(); + SetFieldValue(nameof(UserName), value, false).Wait(); RaisePropertyChanged(nameof(UserName)); } } @@ -168,7 +168,7 @@ namespace ModernKeePass.ViewModels set { SelectedItem.Url.Value = value; - SetFieldValue(nameof(Url), value, true).Wait(); + SetFieldValue(nameof(Url), value, false).Wait(); RaisePropertyChanged(nameof(Url)); } } @@ -179,7 +179,7 @@ namespace ModernKeePass.ViewModels set { SelectedItem.Notes.Value = value; - SetFieldValue(nameof(Notes), value, true).Wait(); + SetFieldValue(nameof(Notes), value, false).Wait(); } } @@ -189,7 +189,7 @@ namespace ModernKeePass.ViewModels set { 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; 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; 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 { SelectedItem.HasExpirationDate = value; - SetFieldValue(nameof(HasExpirationDate), value, true).Wait(); + SetFieldValue(nameof(HasExpirationDate), value, false).Wait(); RaisePropertyChanged(nameof(HasExpirationDate)); } } @@ -234,7 +234,7 @@ namespace ModernKeePass.ViewModels set { 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 { SelectedItem.ForegroundColor = value.ToColor(); - SetFieldValue(nameof(ForegroundColor), SelectedItem.ForegroundColor, true).Wait(); + SetFieldValue(nameof(ForegroundColor), SelectedItem.ForegroundColor, false).Wait(); } } diff --git a/ModernKeePass/ViewModels/SettingsVm.cs b/ModernKeePass/ViewModels/SettingsVm.cs index f1b72e8..77e089b 100644 --- a/ModernKeePass/ViewModels/SettingsVm.cs +++ b/ModernKeePass/ViewModels/SettingsVm.cs @@ -8,6 +8,7 @@ using ModernKeePass.Application.Database.Queries.GetDatabase; using ModernKeePass.Domain.Interfaces; using ModernKeePass.ViewModels.ListItems; using ModernKeePass.Views; +using ModernKeePass.Views.SettingsPageFrames; namespace ModernKeePass.ViewModels { @@ -57,19 +58,11 @@ namespace ModernKeePass.ViewModels IsSelected = true }, new ListMenuItemVm - { - Title = resource.GetResourceValue("SettingsMenuItemSave"), - Group = resource.GetResourceValue("SettingsMenuGroupApplication"), - SymbolIcon = Symbol.Save, - PageType = typeof(SettingsSavePage) - }, - new ListMenuItemVm { Title = resource.GetResourceValue("SettingsMenuItemGeneral"), - Group = resource.GetResourceValue("SettingsMenuGroupDatabase"), + Group = resource.GetResourceValue("SettingsMenuGroupApplication"), SymbolIcon = Symbol.Setting, - PageType = typeof(SettingsDatabasePage), - IsEnabled = database.IsOpen + PageType = typeof(SettingsGeneralPage) }, new ListMenuItemVm { @@ -78,6 +71,30 @@ namespace ModernKeePass.ViewModels SymbolIcon = Symbol.Permissions, PageType = typeof(SettingsSecurityPage), 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); diff --git a/ModernKeePass/Views/SettingsPageFrames/SettingsCredentialsPage.xaml b/ModernKeePass/Views/SettingsPageFrames/SettingsCredentialsPage.xaml new file mode 100644 index 0000000..1fdf1b4 --- /dev/null +++ b/ModernKeePass/Views/SettingsPageFrames/SettingsCredentialsPage.xaml @@ -0,0 +1,20 @@ + + + + + + + + + + + + diff --git a/ModernKeePass/Views/SettingsPageFrames/SettingsDatabasePage.xaml.cs b/ModernKeePass/Views/SettingsPageFrames/SettingsCredentialsPage.xaml.cs similarity index 76% rename from ModernKeePass/Views/SettingsPageFrames/SettingsDatabasePage.xaml.cs rename to ModernKeePass/Views/SettingsPageFrames/SettingsCredentialsPage.xaml.cs index b612334..6977756 100644 --- a/ModernKeePass/Views/SettingsPageFrames/SettingsDatabasePage.xaml.cs +++ b/ModernKeePass/Views/SettingsPageFrames/SettingsCredentialsPage.xaml.cs @@ -5,9 +5,9 @@ namespace ModernKeePass.Views /// /// An empty page that can be used on its own or navigated to within a Frame. /// - public sealed partial class SettingsDatabasePage + public sealed partial class SettingsCredentialsPage { - public SettingsDatabasePage() + public SettingsCredentialsPage() { InitializeComponent(); } diff --git a/ModernKeePass/Views/SettingsPageFrames/SettingsSavePage.xaml b/ModernKeePass/Views/SettingsPageFrames/SettingsGeneralPage.xaml similarity index 72% rename from ModernKeePass/Views/SettingsPageFrames/SettingsSavePage.xaml rename to ModernKeePass/Views/SettingsPageFrames/SettingsGeneralPage.xaml index cddeb5e..e73354f 100644 --- a/ModernKeePass/Views/SettingsPageFrames/SettingsSavePage.xaml +++ b/ModernKeePass/Views/SettingsPageFrames/SettingsGeneralPage.xaml @@ -1,15 +1,17 @@  + DataContext="{Binding Source={StaticResource Locator}, Path=General}"> + + diff --git a/ModernKeePass/Views/SettingsPageFrames/SettingsGeneralPage.xaml.cs b/ModernKeePass/Views/SettingsPageFrames/SettingsGeneralPage.xaml.cs new file mode 100644 index 0000000..2a8432b --- /dev/null +++ b/ModernKeePass/Views/SettingsPageFrames/SettingsGeneralPage.xaml.cs @@ -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 +{ + /// + /// An empty page that can be used on its own or navigated to within a Frame. + /// + 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; + } + } + } +} diff --git a/ModernKeePass/Views/SettingsPageFrames/SettingsHistoryPage.xaml b/ModernKeePass/Views/SettingsPageFrames/SettingsHistoryPage.xaml new file mode 100644 index 0000000..435379a --- /dev/null +++ b/ModernKeePass/Views/SettingsPageFrames/SettingsHistoryPage.xaml @@ -0,0 +1,16 @@ + + + + + + + + + diff --git a/ModernKeePass/Views/SettingsPageFrames/SettingsHistoryPage.xaml.cs b/ModernKeePass/Views/SettingsPageFrames/SettingsHistoryPage.xaml.cs new file mode 100644 index 0000000..5a3987b --- /dev/null +++ b/ModernKeePass/Views/SettingsPageFrames/SettingsHistoryPage.xaml.cs @@ -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 +{ + /// + /// An empty page that can be used on its own or navigated to within a Frame. + /// + 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; + } + } + } +} diff --git a/ModernKeePass/Views/SettingsPageFrames/SettingsDatabasePage.xaml b/ModernKeePass/Views/SettingsPageFrames/SettingsRecycleBinPage.xaml similarity index 58% rename from ModernKeePass/Views/SettingsPageFrames/SettingsDatabasePage.xaml rename to ModernKeePass/Views/SettingsPageFrames/SettingsRecycleBinPage.xaml index 37d9ac9..4117314 100644 --- a/ModernKeePass/Views/SettingsPageFrames/SettingsDatabasePage.xaml +++ b/ModernKeePass/Views/SettingsPageFrames/SettingsRecycleBinPage.xaml @@ -1,12 +1,12 @@  + DataContext="{Binding Source={StaticResource Locator}, Path=RecycleBin}"> @@ -15,9 +15,6 @@ - - - @@ -25,11 +22,5 @@ - - - - - - diff --git a/ModernKeePass/Views/SettingsPageFrames/SettingsRecycleBinPage.xaml.cs b/ModernKeePass/Views/SettingsPageFrames/SettingsRecycleBinPage.xaml.cs new file mode 100644 index 0000000..a24fafe --- /dev/null +++ b/ModernKeePass/Views/SettingsPageFrames/SettingsRecycleBinPage.xaml.cs @@ -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 +{ + /// + /// An empty page that can be used on its own or navigated to within a Frame. + /// + public sealed partial class SettingsRecycleBinPage : Page + { + public SettingsRecycleBinPage() + { + this.InitializeComponent(); + } + } +} diff --git a/ModernKeePass/Views/SettingsPageFrames/SettingsSavePage.xaml.cs b/ModernKeePass/Views/SettingsPageFrames/SettingsSavePage.xaml.cs deleted file mode 100644 index 444c34b..0000000 --- a/ModernKeePass/Views/SettingsPageFrames/SettingsSavePage.xaml.cs +++ /dev/null @@ -1,15 +0,0 @@ -// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238 - -namespace ModernKeePass.Views -{ - /// - /// An empty page that can be used on its own or navigated to within a Frame. - /// - public sealed partial class SettingsSavePage - { - public SettingsSavePage() - { - InitializeComponent(); - } - } -} diff --git a/ModernKeePass/Views/SettingsPageFrames/SettingsSecurityPage.xaml b/ModernKeePass/Views/SettingsPageFrames/SettingsSecurityPage.xaml index e74ea3d..7a01ab8 100644 --- a/ModernKeePass/Views/SettingsPageFrames/SettingsSecurityPage.xaml +++ b/ModernKeePass/Views/SettingsPageFrames/SettingsSecurityPage.xaml @@ -4,17 +4,20 @@ 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=SettingsSecurity}"> + DataContext="{Binding Source={StaticResource Locator}, Path=Security}"> - - - - - - - + + + + + + + + + + + diff --git a/ModernKeePass/Win81App.csproj b/ModernKeePass/Win81App.csproj index 7056d04..8778d8c 100644 --- a/ModernKeePass/Win81App.csproj +++ b/ModernKeePass/Win81App.csproj @@ -102,17 +102,23 @@ ImportExportPage.xaml - - SettingsDatabasePage.xaml + + SettingsHistoryPage.xaml + + + SettingsRecycleBinPage.xaml + + + SettingsSecurityPage.xaml SettingsNewDatabasePage.xaml - - SettingsSavePage.xaml + + SettingsGeneralPage.xaml - - SettingsSecurityPage.xaml + + SettingsCredentialsPage.xaml SettingsWelcomePage.xaml @@ -201,7 +207,15 @@ Designer MSBuild:Compile - + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + Designer MSBuild:Compile @@ -253,7 +267,7 @@ Designer MSBuild:Compile - + Designer MSBuild:Compile @@ -261,7 +275,7 @@ Designer MSBuild:Compile - + Designer MSBuild:Compile diff --git a/ModernKeePass/appMetadata/en-us/baselisting/releaseNotes.txt b/ModernKeePass/appMetadata/en-us/baselisting/releaseNotes.txt index e8aaf35..9e891f6 100644 --- a/ModernKeePass/appMetadata/en-us/baselisting/releaseNotes.txt +++ b/ModernKeePass/appMetadata/en-us/baselisting/releaseNotes.txt @@ -2,6 +2,6 @@ Support for additional fields Support for attachments Add an expiration timer for clipboard data Ability to manually reorder groups -Ability to set max history count +Ability to set max history count and size Design changes Update to KeePassLib version 2.45 \ No newline at end of file diff --git a/ModernKeePass/appMetadata/fr-fr/baselisting/releaseNotes.txt b/ModernKeePass/appMetadata/fr-fr/baselisting/releaseNotes.txt index 313b341..5a6d3b8 100644 --- a/ModernKeePass/appMetadata/fr-fr/baselisting/releaseNotes.txt +++ b/ModernKeePass/appMetadata/fr-fr/baselisting/releaseNotes.txt @@ -2,6 +2,6 @@ Ajout des champs additionnels Ajout des pièces-jointes Ajout d'une expiration du presse papier 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 Mise a jour de la KeePassLib version 2.45 \ No newline at end of file diff --git a/WinAppCommon/ViewModels/Items/SettingsCredentialsVm.cs b/WinAppCommon/ViewModels/Items/SettingsCredentialsVm.cs new file mode 100644 index 0000000..d2ed043 --- /dev/null +++ b/WinAppCommon/ViewModels/Items/SettingsCredentialsVm.cs @@ -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(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")); + } + } +} \ No newline at end of file diff --git a/WinAppCommon/ViewModels/Items/SettingsHistoryVm.cs b/WinAppCommon/ViewModels/Items/SettingsHistoryVm.cs new file mode 100644 index 0000000..761f329 --- /dev/null +++ b/WinAppCommon/ViewModels/Items/SettingsHistoryVm.cs @@ -0,0 +1,7 @@ +namespace ModernKeePass.ViewModels.ListItems +{ + public class SettingsHistoryVm + { + + } +} \ No newline at end of file diff --git a/WinAppCommon/ViewModels/Items/SettingsRecycleBinVm.cs b/WinAppCommon/ViewModels/Items/SettingsRecycleBinVm.cs new file mode 100644 index 0000000..0c28420 --- /dev/null +++ b/WinAppCommon/ViewModels/Items/SettingsRecycleBinVm.cs @@ -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 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(rootGroup.SubGroups); + } + } +} \ No newline at end of file diff --git a/WinAppCommon/ViewModels/Items/SettingsSecurityVm.cs b/WinAppCommon/ViewModels/Items/SettingsSecurityVm.cs index 121b8ab..1664f72 100644 --- a/WinAppCommon/ViewModels/Items/SettingsSecurityVm.cs +++ b/WinAppCommon/ViewModels/Items/SettingsSecurityVm.cs @@ -1,37 +1,57 @@ -using System.Threading.Tasks; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; using GalaSoft.MvvmLight; using MediatR; -using Messages; -using ModernKeePass.Application.Common.Interfaces; -using ModernKeePass.Application.Database.Commands.UpdateCredentials; +using ModernKeePass.Application.Database.Models; 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 { - public class SettingsSecurityVm: ViewModelBase + // TODO: implement Kdf settings + public class SettingsSecurityVm: ObservableObject { private readonly IMediator _mediator; - private readonly IResourceProxy _resource; - private readonly INotificationService _notification; + private readonly DatabaseVm _database; + - public SettingsSecurityVm(IMediator mediator, IResourceProxy resource, INotificationService notification) + public ObservableCollection Ciphers { get; } + public IEnumerable Compressions => _mediator.Send(new GetCompressionsQuery()).GetAwaiter().GetResult(); + public ObservableCollection 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; - _resource = resource; - _notification = notification; - - MessengerInstance.Register(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")); + _database = _mediator.Send(new GetDatabaseQuery()).GetAwaiter().GetResult(); + var ciphers = _mediator.Send(new GetCiphersQuery()).GetAwaiter().GetResult(); + Ciphers = new ObservableCollection(ciphers); + var keyDerivations = _mediator.Send(new GetKeyDerivationsQuery()).GetAwaiter().GetResult(); + KeyDerivations = new ObservableCollection(keyDerivations); } } -} \ No newline at end of file +} diff --git a/WinAppCommon/ViewModels/Settings/CredentialsVm.cs b/WinAppCommon/ViewModels/Settings/CredentialsVm.cs new file mode 100644 index 0000000..48efe4d --- /dev/null +++ b/WinAppCommon/ViewModels/Settings/CredentialsVm.cs @@ -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(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")); + } + } +} \ No newline at end of file diff --git a/WinAppCommon/ViewModels/Settings/GeneralVm.cs b/WinAppCommon/ViewModels/Settings/GeneralVm.cs new file mode 100644 index 0000000..ceba6c8 --- /dev/null +++ b/WinAppCommon/ViewModels/Settings/GeneralVm.cs @@ -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; + } + + } +} \ No newline at end of file diff --git a/WinAppCommon/ViewModels/Settings/HistoryVm.cs b/WinAppCommon/ViewModels/Settings/HistoryVm.cs new file mode 100644 index 0000000..79b678a --- /dev/null +++ b/WinAppCommon/ViewModels/Settings/HistoryVm.cs @@ -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(); + } + } +} \ No newline at end of file diff --git a/WinAppCommon/ViewModels/Settings/RecycleBinVm.cs b/WinAppCommon/ViewModels/Settings/RecycleBinVm.cs new file mode 100644 index 0000000..34f7979 --- /dev/null +++ b/WinAppCommon/ViewModels/Settings/RecycleBinVm.cs @@ -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 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(rootGroup.SubGroups); + } + } +} \ No newline at end of file diff --git a/WinAppCommon/ViewModels/Items/SettingsDatabaseVm.cs b/WinAppCommon/ViewModels/Settings/SecurityVm.cs similarity index 60% rename from WinAppCommon/ViewModels/Items/SettingsDatabaseVm.cs rename to WinAppCommon/ViewModels/Settings/SecurityVm.cs index 9a06afd..b5b3822 100644 --- a/WinAppCommon/ViewModels/Items/SettingsDatabaseVm.cs +++ b/WinAppCommon/ViewModels/Settings/SecurityVm.cs @@ -3,48 +3,24 @@ 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.SetCipher; using ModernKeePass.Application.Parameters.Commands.SetCompression; -using ModernKeePass.Application.Parameters.Commands.SetHasRecycleBin; using ModernKeePass.Application.Parameters.Commands.SetKeyDerivation; -using ModernKeePass.Application.Parameters.Commands.SetRecycleBin; 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.Settings { // TODO: implement Kdf settings - public class SettingsDatabaseVm: ObservableObject + public class SecurityVm: 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 Groups { get; } public ObservableCollection Ciphers { get; } public IEnumerable Compressions => _mediator.Send(new GetCompressionsQuery()).GetAwaiter().GetResult(); public ObservableCollection KeyDerivations { get; } @@ -67,21 +43,10 @@ namespace ModernKeePass.ViewModels.ListItems set { _mediator.Send(new SetKeyDerivationCommand {KeyDerivationId = value.Id}).Wait(); } } - public IEntityVm SelectedRecycleBin - { - get { return Groups.FirstOrDefault(g => g.Id == _database.RecycleBinId); } - set - { - if (!IsNewRecycleBin) _mediator.Send(new SetRecycleBinCommand { RecycleBinId = value.Id}).Wait(); - } - } - - public SettingsDatabaseVm(IMediator mediator) + public SecurityVm(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(rootGroup.SubGroups); var ciphers = _mediator.Send(new GetCiphersQuery()).GetAwaiter().GetResult(); Ciphers = new ObservableCollection(ciphers); var keyDerivations = _mediator.Send(new GetKeyDerivationsQuery()).GetAwaiter().GetResult(); diff --git a/WinAppCommon/ViewModels/Settings/SettingsCredentialsVm.cs b/WinAppCommon/ViewModels/Settings/SettingsCredentialsVm.cs new file mode 100644 index 0000000..d62acd1 --- /dev/null +++ b/WinAppCommon/ViewModels/Settings/SettingsCredentialsVm.cs @@ -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(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")); + } + } +} \ No newline at end of file diff --git a/WinAppCommon/ViewModels/Settings/SettingsHistoryVm.cs b/WinAppCommon/ViewModels/Settings/SettingsHistoryVm.cs new file mode 100644 index 0000000..cf7523a --- /dev/null +++ b/WinAppCommon/ViewModels/Settings/SettingsHistoryVm.cs @@ -0,0 +1,7 @@ +namespace ModernKeePass.ViewModels.Settings +{ + public class SettingsHistoryVm + { + + } +} \ No newline at end of file diff --git a/WinAppCommon/ViewModels/Settings/SettingsNewVm.cs b/WinAppCommon/ViewModels/Settings/SettingsNewVm.cs new file mode 100644 index 0000000..0762df9 --- /dev/null +++ b/WinAppCommon/ViewModels/Settings/SettingsNewVm.cs @@ -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 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; } + } +} diff --git a/WinAppCommon/ViewModels/Settings/SettingsRecycleBinVm.cs b/WinAppCommon/ViewModels/Settings/SettingsRecycleBinVm.cs new file mode 100644 index 0000000..869309e --- /dev/null +++ b/WinAppCommon/ViewModels/Settings/SettingsRecycleBinVm.cs @@ -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 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(rootGroup.SubGroups); + } + } +} \ No newline at end of file diff --git a/WinAppCommon/ViewModels/Settings/SettingsSaveVm.cs b/WinAppCommon/ViewModels/Settings/SettingsSaveVm.cs new file mode 100644 index 0000000..bf34828 --- /dev/null +++ b/WinAppCommon/ViewModels/Settings/SettingsSaveVm.cs @@ -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); } + } + } +} \ No newline at end of file diff --git a/WinAppCommon/ViewModels/ViewModelLocatorCommon.cs b/WinAppCommon/ViewModels/ViewModelLocatorCommon.cs index 791f4a5..5a22044 100644 --- a/WinAppCommon/ViewModels/ViewModelLocatorCommon.cs +++ b/WinAppCommon/ViewModels/ViewModelLocatorCommon.cs @@ -20,7 +20,7 @@ using GalaSoft.MvvmLight.Views; using MediatR; using Microsoft.Extensions.DependencyInjection; using ModernKeePass.Application.Common.Interfaces; -using ModernKeePass.ViewModels.ListItems; +using ModernKeePass.ViewModels.Settings; namespace ModernKeePass.ViewModels { @@ -57,10 +57,12 @@ namespace ModernKeePass.ViewModels SimpleIoc.Default.Register(() => App.Services.GetRequiredService()); } - SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); - SimpleIoc.Default.Register(); - SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); @@ -70,10 +72,12 @@ namespace ModernKeePass.ViewModels SimpleIoc.Default.Register(); } - public SettingsDatabaseVm SettingsDatabase => ServiceLocator.Current.GetInstance(Guid.NewGuid().ToString()); + public SecurityVm Security => ServiceLocator.Current.GetInstance(Guid.NewGuid().ToString()); public SettingsNewVm SettingsNew => ServiceLocator.Current.GetInstance(Guid.NewGuid().ToString()); - public SettingsSaveVm SettingsSave => ServiceLocator.Current.GetInstance(Guid.NewGuid().ToString()); - public SettingsSecurityVm SettingsSecurity => ServiceLocator.Current.GetInstance(Guid.NewGuid().ToString()); + public GeneralVm General => ServiceLocator.Current.GetInstance(Guid.NewGuid().ToString()); + public CredentialsVm Credentials => ServiceLocator.Current.GetInstance(Guid.NewGuid().ToString()); + public RecycleBinVm RecycleBin => ServiceLocator.Current.GetInstance(Guid.NewGuid().ToString()); + public HistoryVm History => ServiceLocator.Current.GetInstance(Guid.NewGuid().ToString()); public OpenDatabaseControlVm OpenDatabaseControl => ServiceLocator.Current.GetInstance(Guid.NewGuid().ToString()); public SetCredentialsVm SetCredentials => ServiceLocator.Current.GetInstance(Guid.NewGuid().ToString()); public TopMenuVm TopMenu => ServiceLocator.Current.GetInstance(Guid.NewGuid().ToString()); diff --git a/WinAppCommon/WinAppCommon.projitems b/WinAppCommon/WinAppCommon.projitems index a8bc241..db0c6e2 100644 --- a/WinAppCommon/WinAppCommon.projitems +++ b/WinAppCommon/WinAppCommon.projitems @@ -43,14 +43,16 @@ + + + + + + - - - -