From 310bd777b2df695395b74c73428cb9edf6edd413 Mon Sep 17 00:00:00 2001 From: Geoffroy BONNEVILLE Date: Mon, 20 Apr 2020 20:02:43 +0200 Subject: [PATCH] WIP Split composite key user control Some refactoring --- ModernKeePass.Application/Application.csproj | 2 +- ...IPasswordProxy.cs => ICredentialsProxy.cs} | 4 +- .../Entry/Models/EntryVm.cs | 3 +- .../GenerateKeyFile/GenerateKeyFileCommand.cs | 4 +- .../GeneratePasswordCommand.cs | 4 +- .../EstimatePasswordComplexityQuery.cs | 10 +- ModernKeePass.Domain/Entities/EntryEntity.cs | 2 +- .../DependencyInjection.cs | 2 +- .../Infrastructure.csproj | 2 +- .../KeePass/EntryMappingProfile.cs | 8 +- ...dClient.cs => KeePassCredentialsClient.cs} | 6 +- ModernKeePass/Interfaces/IVmEntity.cs | 11 +- ModernKeePass/ViewModels/CompositeKeyVm.cs | 20 +- ModernKeePass/ViewModels/EntryDetailVm.cs | 21 +- ModernKeePass/ViewModels/GroupDetailVm.cs | 25 +- ModernKeePass/ViewModels/MainVm.cs | 1 + ModernKeePass/ViewModels/RecentVm.cs | 1 + ModernKeePass/ViewModels/SettingsVm.cs | 1 + ModernKeePass/Views/GroupDetailPage.xaml | 3 +- ModernKeePass/Views/MainPage.xaml.cs | 1 + .../MainPageFrames/OpenDatabasePage.xaml | 6 +- .../MainPageFrames/RecentDatabasesPage.xaml | 8 +- ModernKeePass/Views/SettingsPage.xaml.cs | 1 + .../SettingsDatabasePage.xaml | 4 +- .../SettingsNewDatabasePage.xaml | 4 +- .../SettingsPageFrames/SettingsSavePage.xaml | 4 +- .../UserControls/OpenDatabaseUserControl.xaml | 55 +++ .../OpenDatabaseUserControl.xaml.cs | 134 ++++++++ .../UpdateCredentialsUserControl.xaml | 72 ++++ .../UpdateCredentialsUserControl.xaml.cs | 88 +++++ ModernKeePass/Win81App.csproj | 20 +- ModernKeePass10/Package.appxmanifest | 43 ++- .../ListItems/ListMenuItemViewModel.cs | 31 -- .../ListItems/MainMenuItemViewModel.cs | 10 - .../ListItems/RecentItemViewModel.cs | 36 -- .../ListItems/SettingsDatabaseViewModel.cs | 101 ------ .../ListItems/SettingsNewViewModel.cs | 33 -- .../ListItems/SettingsSaveViewModel.cs | 24 -- ModernKeePass10/ViewModels/Old/EntryVm.cs | 322 ------------------ ModernKeePass10/ViewModels/Old/GroupVm.cs | 257 -------------- .../UserControls/CredentialsViewModel.cs | 149 -------- .../UpdateCredentialsViewModel.cs | 93 ----- ModernKeePass10/Win10App.csproj | 17 +- WinAppCommon/Common/Constants.cs | 2 + .../ViewModels/Items/ListMenuItemVm.cs | 2 +- .../ViewModels/Items/MainMenuItemVm.cs | 2 +- .../ViewModels/Items/RecentItemVm.cs | 2 +- .../ViewModels/Items/SettingsDatabaseVm.cs | 2 +- .../ViewModels/Items/SettingsNewVm.cs | 11 +- .../ViewModels/Items/SettingsSaveVm.cs | 2 +- .../UserControls/CredentialsViewModel.cs | 175 ++++++++++ .../UserControls/OpenDatabaseControlVm.cs | 153 +++++++++ .../UpdateCredentialsViewModel.cs | 47 +++ WinAppCommon/WinAppCommon.projitems | 8 + 54 files changed, 849 insertions(+), 1200 deletions(-) rename ModernKeePass.Application/Common/Interfaces/{IPasswordProxy.cs => ICredentialsProxy.cs} (70%) rename ModernKeePass.Infrastructure/KeePass/{KeePassPasswordClient.cs => KeePassCredentialsClient.cs} (88%) create mode 100644 ModernKeePass/Views/UserControls/OpenDatabaseUserControl.xaml create mode 100644 ModernKeePass/Views/UserControls/OpenDatabaseUserControl.xaml.cs create mode 100644 ModernKeePass/Views/UserControls/UpdateCredentialsUserControl.xaml create mode 100644 ModernKeePass/Views/UserControls/UpdateCredentialsUserControl.xaml.cs delete mode 100644 ModernKeePass10/ViewModels/ListItems/ListMenuItemViewModel.cs delete mode 100644 ModernKeePass10/ViewModels/ListItems/MainMenuItemViewModel.cs delete mode 100644 ModernKeePass10/ViewModels/ListItems/RecentItemViewModel.cs delete mode 100644 ModernKeePass10/ViewModels/ListItems/SettingsDatabaseViewModel.cs delete mode 100644 ModernKeePass10/ViewModels/ListItems/SettingsNewViewModel.cs delete mode 100644 ModernKeePass10/ViewModels/ListItems/SettingsSaveViewModel.cs delete mode 100644 ModernKeePass10/ViewModels/Old/EntryVm.cs delete mode 100644 ModernKeePass10/ViewModels/Old/GroupVm.cs delete mode 100644 ModernKeePass10/ViewModels/UserControls/CredentialsViewModel.cs delete mode 100644 ModernKeePass10/ViewModels/UserControls/UpdateCredentialsViewModel.cs rename {ModernKeePass => WinAppCommon}/ViewModels/Items/ListMenuItemVm.cs (94%) rename {ModernKeePass => WinAppCommon}/ViewModels/Items/MainMenuItemVm.cs (81%) rename {ModernKeePass => WinAppCommon}/ViewModels/Items/RecentItemVm.cs (97%) rename {ModernKeePass => WinAppCommon}/ViewModels/Items/SettingsDatabaseVm.cs (98%) rename {ModernKeePass => WinAppCommon}/ViewModels/Items/SettingsNewVm.cs (60%) rename {ModernKeePass => WinAppCommon}/ViewModels/Items/SettingsSaveVm.cs (93%) create mode 100644 WinAppCommon/ViewModels/UserControls/CredentialsViewModel.cs create mode 100644 WinAppCommon/ViewModels/UserControls/OpenDatabaseControlVm.cs create mode 100644 WinAppCommon/ViewModels/UserControls/UpdateCredentialsViewModel.cs diff --git a/ModernKeePass.Application/Application.csproj b/ModernKeePass.Application/Application.csproj index 82245e8..f50d458 100644 --- a/ModernKeePass.Application/Application.csproj +++ b/ModernKeePass.Application/Application.csproj @@ -81,7 +81,7 @@ - + diff --git a/ModernKeePass.Application/Common/Interfaces/IPasswordProxy.cs b/ModernKeePass.Application/Common/Interfaces/ICredentialsProxy.cs similarity index 70% rename from ModernKeePass.Application/Common/Interfaces/IPasswordProxy.cs rename to ModernKeePass.Application/Common/Interfaces/ICredentialsProxy.cs index aec2b37..25f6cd5 100644 --- a/ModernKeePass.Application/Common/Interfaces/IPasswordProxy.cs +++ b/ModernKeePass.Application/Common/Interfaces/ICredentialsProxy.cs @@ -2,10 +2,10 @@ namespace ModernKeePass.Application.Common.Interfaces { - public interface IPasswordProxy + public interface ICredentialsProxy { string GeneratePassword(PasswordGenerationOptions options); - uint EstimatePasswordComplexity(string password); + int EstimatePasswordComplexity(string password); byte[] GenerateKeyFile(byte[] additionalEntropy); } } \ No newline at end of file diff --git a/ModernKeePass.Application/Entry/Models/EntryVm.cs b/ModernKeePass.Application/Entry/Models/EntryVm.cs index 6e245ab..5593938 100644 --- a/ModernKeePass.Application/Entry/Models/EntryVm.cs +++ b/ModernKeePass.Application/Entry/Models/EntryVm.cs @@ -19,7 +19,8 @@ namespace ModernKeePass.Application.Entry.Models public string Username { get; set; } public string Password { get; set; } public string Notes { get; set; } - public Uri Url { get; set; } + public string Url { get; set; } + public bool HasUrl => !string.IsNullOrEmpty(Url); public Dictionary AdditionalFields { get; set; } public List History { get; set; } public Icon Icon { get; set; } diff --git a/ModernKeePass.Application/Security/Commands/GenerateKeyFile/GenerateKeyFileCommand.cs b/ModernKeePass.Application/Security/Commands/GenerateKeyFile/GenerateKeyFileCommand.cs index 373d6bf..d10b692 100644 --- a/ModernKeePass.Application/Security/Commands/GenerateKeyFile/GenerateKeyFileCommand.cs +++ b/ModernKeePass.Application/Security/Commands/GenerateKeyFile/GenerateKeyFileCommand.cs @@ -12,10 +12,10 @@ namespace ModernKeePass.Application.Security.Commands.GenerateKeyFile public class GenerateKeyFileCommandHandler : IAsyncRequestHandler { - private readonly IPasswordProxy _security; + private readonly ICredentialsProxy _security; private readonly IFileProxy _file; - public GenerateKeyFileCommandHandler(IPasswordProxy security, IFileProxy file) + public GenerateKeyFileCommandHandler(ICredentialsProxy security, IFileProxy file) { _security = security; _file = file; diff --git a/ModernKeePass.Application/Security/Commands/GeneratePassword/GeneratePasswordCommand.cs b/ModernKeePass.Application/Security/Commands/GeneratePassword/GeneratePasswordCommand.cs index a7ef3e8..f68503f 100644 --- a/ModernKeePass.Application/Security/Commands/GeneratePassword/GeneratePasswordCommand.cs +++ b/ModernKeePass.Application/Security/Commands/GeneratePassword/GeneratePasswordCommand.cs @@ -19,9 +19,9 @@ namespace ModernKeePass.Application.Security.Commands.GeneratePassword public class GeneratePasswordCommandHandler: IRequestHandler { - private readonly IPasswordProxy _security; + private readonly ICredentialsProxy _security; - public GeneratePasswordCommandHandler(IPasswordProxy security) + public GeneratePasswordCommandHandler(ICredentialsProxy security) { _security = security; } diff --git a/ModernKeePass.Application/Security/Queries/EstimatePasswordComplexity/EstimatePasswordComplexityQuery.cs b/ModernKeePass.Application/Security/Queries/EstimatePasswordComplexity/EstimatePasswordComplexityQuery.cs index 96f9070..d5f7f78 100644 --- a/ModernKeePass.Application/Security/Queries/EstimatePasswordComplexity/EstimatePasswordComplexityQuery.cs +++ b/ModernKeePass.Application/Security/Queries/EstimatePasswordComplexity/EstimatePasswordComplexityQuery.cs @@ -3,20 +3,20 @@ using ModernKeePass.Application.Common.Interfaces; namespace ModernKeePass.Application.Security.Queries.EstimatePasswordComplexity { - public class EstimatePasswordComplexityQuery : IRequest + public class EstimatePasswordComplexityQuery : IRequest { public string Password { get; set; } - public class EstimatePasswordComplexityQueryHandler : IRequestHandler + public class EstimatePasswordComplexityQueryHandler : IRequestHandler { - private readonly IPasswordProxy _security; + private readonly ICredentialsProxy _security; - public EstimatePasswordComplexityQueryHandler(IPasswordProxy security) + public EstimatePasswordComplexityQueryHandler(ICredentialsProxy security) { _security = security; } - public uint Handle(EstimatePasswordComplexityQuery message) + public int Handle(EstimatePasswordComplexityQuery message) { return _security.EstimatePasswordComplexity(message.Password); } diff --git a/ModernKeePass.Domain/Entities/EntryEntity.cs b/ModernKeePass.Domain/Entities/EntryEntity.cs index 71b0261..5031390 100644 --- a/ModernKeePass.Domain/Entities/EntryEntity.cs +++ b/ModernKeePass.Domain/Entities/EntryEntity.cs @@ -9,7 +9,7 @@ namespace ModernKeePass.Domain.Entities { public string UserName { get; set; } public string Password { get; set; } - public Uri Url { get; set; } + public string Url { get; set; } public string Notes { get; set; } public DateTimeOffset ExpirationDate { get; set; } public Dictionary AdditionalFields { get; set; } = new Dictionary(); diff --git a/ModernKeePass.Infrastructure/DependencyInjection.cs b/ModernKeePass.Infrastructure/DependencyInjection.cs index 01f7884..1c9f466 100644 --- a/ModernKeePass.Infrastructure/DependencyInjection.cs +++ b/ModernKeePass.Infrastructure/DependencyInjection.cs @@ -19,7 +19,7 @@ namespace ModernKeePass.Infrastructure { services.AddSingleton(typeof(IDatabaseProxy), typeof(KeePassDatabaseClient)); services.AddTransient(typeof(ICryptographyClient), typeof(KeePassCryptographyClient)); - services.AddTransient(typeof(IPasswordProxy), typeof(KeePassPasswordClient)); + services.AddTransient(typeof(ICredentialsProxy), typeof(KeePassCredentialsClient)); return services; } diff --git a/ModernKeePass.Infrastructure/Infrastructure.csproj b/ModernKeePass.Infrastructure/Infrastructure.csproj index ad457cd..aa33c0d 100644 --- a/ModernKeePass.Infrastructure/Infrastructure.csproj +++ b/ModernKeePass.Infrastructure/Infrastructure.csproj @@ -85,7 +85,7 @@ - + diff --git a/ModernKeePass.Infrastructure/KeePass/EntryMappingProfile.cs b/ModernKeePass.Infrastructure/KeePass/EntryMappingProfile.cs index bb8e421..04a1898 100644 --- a/ModernKeePass.Infrastructure/KeePass/EntryMappingProfile.cs +++ b/ModernKeePass.Infrastructure/KeePass/EntryMappingProfile.cs @@ -10,7 +10,6 @@ namespace ModernKeePass.Infrastructure.KeePass { public EntryMappingProfile() { - Uri url; CreateMap() .ForMember(dest => dest.ParentId, opt => opt.MapFrom(src => src.ParentGroup.Uuid.ToHexString())) .ForMember(dest => dest.ParentName, opt => opt.MapFrom(src => src.ParentGroup.Name)) @@ -18,12 +17,7 @@ namespace ModernKeePass.Infrastructure.KeePass .ForMember(dest => dest.Name, opt => opt.MapFrom(src => GetEntryValue(src, PwDefs.TitleField))) .ForMember(dest => dest.UserName, opt => opt.MapFrom(src => GetEntryValue(src, PwDefs.UserNameField))) .ForMember(dest => dest.Password, opt => opt.MapFrom(src => GetEntryValue(src, PwDefs.PasswordField))) - .ForMember(dest => dest.Url, opt => - { - opt.PreCondition(src => - Uri.TryCreate(GetEntryValue(src, PwDefs.UrlField), UriKind.Absolute, out url)); - opt.MapFrom(src => new Uri(GetEntryValue(src, PwDefs.UrlField))); - }) + .ForMember(dest => dest.Url, opt => opt.MapFrom(src => GetEntryValue(src, PwDefs.UrlField))) .ForMember(dest => dest.Notes, opt => opt.MapFrom(src => GetEntryValue(src, PwDefs.NotesField))) .ForMember(dest => dest.ForegroundColor, opt => opt.MapFrom(src => src.ForegroundColor)) .ForMember(dest => dest.BackgroundColor, opt => opt.MapFrom(src => src.BackgroundColor)) diff --git a/ModernKeePass.Infrastructure/KeePass/KeePassPasswordClient.cs b/ModernKeePass.Infrastructure/KeePass/KeePassCredentialsClient.cs similarity index 88% rename from ModernKeePass.Infrastructure/KeePass/KeePassPasswordClient.cs rename to ModernKeePass.Infrastructure/KeePass/KeePassCredentialsClient.cs index 7f846c3..0582077 100644 --- a/ModernKeePass.Infrastructure/KeePass/KeePassPasswordClient.cs +++ b/ModernKeePass.Infrastructure/KeePass/KeePassCredentialsClient.cs @@ -7,7 +7,7 @@ using ModernKeePassLib.Security; namespace ModernKeePass.Infrastructure.KeePass { - public class KeePassPasswordClient: IPasswordProxy + public class KeePassCredentialsClient: ICredentialsProxy { public string GeneratePassword(PasswordGenerationOptions options) { @@ -35,9 +35,9 @@ namespace ModernKeePass.Infrastructure.KeePass return password.ReadString(); } - public uint EstimatePasswordComplexity(string password) + public int EstimatePasswordComplexity(string password) { - return QualityEstimation.EstimatePasswordBits(password?.ToCharArray()); + return (int)QualityEstimation.EstimatePasswordBits(password?.ToCharArray()); } public byte[] GenerateKeyFile(byte[] additionalEntropy) diff --git a/ModernKeePass/Interfaces/IVmEntity.cs b/ModernKeePass/Interfaces/IVmEntity.cs index 714ce18..2593463 100644 --- a/ModernKeePass/Interfaces/IVmEntity.cs +++ b/ModernKeePass/Interfaces/IVmEntity.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using System.Threading.Tasks; -using System.Windows.Input; using Windows.UI.Xaml.Controls; using ModernKeePass.Application.Group.Models; @@ -13,19 +12,11 @@ namespace ModernKeePass.Interfaces string Title { get; set; } IEnumerable BreadCrumb { get; } bool IsEditMode { get; } - - /// - /// Save changes to Model - /// - ICommand SaveCommand { get; } + /// /// Move a entity to the destination group /// /// The destination to move the entity to Task Move(GroupVm destination); - /// - /// Delete from ViewModel - /// - Task MarkForDelete(string recycleBinTitle); } } \ No newline at end of file diff --git a/ModernKeePass/ViewModels/CompositeKeyVm.cs b/ModernKeePass/ViewModels/CompositeKeyVm.cs index e2ac2bd..306e9e3 100644 --- a/ModernKeePass/ViewModels/CompositeKeyVm.cs +++ b/ModernKeePass/ViewModels/CompositeKeyVm.cs @@ -31,7 +31,7 @@ namespace ModernKeePass.ViewModels set { SetProperty(ref _hasPassword, value); - OnPropertyChanged("IsValid"); + OnPropertyChanged(nameof(IsValid)); } } @@ -41,21 +41,11 @@ namespace ModernKeePass.ViewModels set { SetProperty(ref _hasKeyFile, value); - OnPropertyChanged("IsValid"); + OnPropertyChanged(nameof(IsValid)); } } - public bool HasUserAccount - { - get { return _hasUserAccount; } - set - { - SetProperty(ref _hasUserAccount, value); - OnPropertyChanged("IsValid"); - } - } - - public bool IsValid => !_isOpening && (HasPassword || HasKeyFile && KeyFilePath != null || HasUserAccount); + public bool IsValid => !_isOpening && (HasPassword || HasKeyFile && KeyFilePath != null); public string Status { @@ -103,7 +93,6 @@ namespace ModernKeePass.ViewModels private bool _hasPassword; private bool _hasKeyFile; - private bool _hasUserAccount; private bool _isOpening; private string _password = string.Empty; private string _status; @@ -160,7 +149,6 @@ namespace ModernKeePass.ViewModels var errorMessage = new StringBuilder($"{_resource.GetResourceValue("CompositeKeyErrorOpen")}\n"); if (HasPassword) errorMessage.AppendLine(_resource.GetResourceValue("CompositeKeyErrorUserPassword")); if (HasKeyFile) errorMessage.AppendLine(_resource.GetResourceValue("CompositeKeyErrorUserKeyFile")); - if (HasUserAccount) errorMessage.AppendLine(_resource.GetResourceValue("CompositeKeyErrorUserAccount")); UpdateStatus(errorMessage.ToString(), StatusTypes.Error); } catch (Exception e) @@ -171,7 +159,7 @@ namespace ModernKeePass.ViewModels finally { _isOpening = false; - OnPropertyChanged("IsValid"); + OnPropertyChanged(nameof(IsValid)); } return false; } diff --git a/ModernKeePass/ViewModels/EntryDetailVm.cs b/ModernKeePass/ViewModels/EntryDetailVm.cs index ca03228..d15e68d 100644 --- a/ModernKeePass/ViewModels/EntryDetailVm.cs +++ b/ModernKeePass/ViewModels/EntryDetailVm.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Threading.Tasks; -using System.Windows.Input; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Media; using MediatR; @@ -120,10 +119,10 @@ namespace ModernKeePass.ViewModels public string Url { - get { return SelectedItem.Url?.ToString(); } + get { return SelectedItem.Url; } set { - SelectedItem.Url = new Uri(value); + SelectedItem.Url = value; SetFieldValue(nameof(Url), value).Wait(); } } @@ -216,10 +215,10 @@ namespace ModernKeePass.ViewModels set { SetProperty(ref _isRevealPassword, value); } } - public ICommand SaveCommand { get; } - public ICommand GeneratePasswordCommand { get; } - public ICommand MoveCommand { get; } - public ICommand RestoreCommand { get; } + public RelayCommand SaveCommand { get; } + public RelayCommand GeneratePasswordCommand { get; } + public RelayCommand MoveCommand { get; } + public RelayCommand RestoreCommand { get; } private DatabaseVm Database => _mediator.Send(new GetDatabaseQuery()).GetAwaiter().GetResult(); @@ -286,7 +285,7 @@ namespace ModernKeePass.ViewModels public async Task SetFieldValue(string fieldName, object value) { await _mediator.Send(new SetFieldValueCommand { EntryId = Id, FieldName = fieldName, FieldValue = value }); - ((RelayCommand)SaveCommand).RaiseCanExecuteChanged(); + SaveCommand.RaiseCanExecuteChanged(); _isDirty = true; } @@ -300,7 +299,7 @@ namespace ModernKeePass.ViewModels await _mediator.Send(new RestoreHistoryCommand { Entry = History[0], HistoryIndex = History.Count - SelectedIndex }); History.Insert(0, SelectedItem); SelectedIndex = 0; - ((RelayCommand)SaveCommand).RaiseCanExecuteChanged(); + SaveCommand.RaiseCanExecuteChanged(); } public async Task DeleteHistory() @@ -308,14 +307,14 @@ namespace ModernKeePass.ViewModels await _mediator.Send(new DeleteHistoryCommand { Entry = History[0], HistoryIndex = History.Count - SelectedIndex }); History.RemoveAt(SelectedIndex); SelectedIndex = 0; - ((RelayCommand)SaveCommand).RaiseCanExecuteChanged(); + SaveCommand.RaiseCanExecuteChanged(); } private async Task SaveChanges() { await AddHistory(); await _mediator.Send(new SaveDatabaseCommand()); - ((RelayCommand)SaveCommand).RaiseCanExecuteChanged(); + SaveCommand.RaiseCanExecuteChanged(); _isDirty = false; } } diff --git a/ModernKeePass/ViewModels/GroupDetailVm.cs b/ModernKeePass/ViewModels/GroupDetailVm.cs index f4033b9..825d583 100644 --- a/ModernKeePass/ViewModels/GroupDetailVm.cs +++ b/ModernKeePass/ViewModels/GroupDetailVm.cs @@ -4,7 +4,6 @@ using System.Collections.ObjectModel; using System.Collections.Specialized; using System.Linq; using System.Threading.Tasks; -using System.Windows.Input; using Windows.UI.Xaml.Controls; using MediatR; using Microsoft.Extensions.DependencyInjection; @@ -53,7 +52,7 @@ namespace ModernKeePass.ViewModels set { _mediator.Send(new UpdateGroupCommand {Group = _group, Title = value, Icon = _group.Icon}).Wait(); - ((RelayCommand)SaveCommand).RaiseCanExecuteChanged(); + SaveCommand.RaiseCanExecuteChanged(); } } @@ -63,7 +62,7 @@ namespace ModernKeePass.ViewModels set { _mediator.Send(new UpdateGroupCommand { Group = _group, Title = _group.Title, Icon = (Icon)Enum.Parse(typeof(Icon), value.ToString()) }).Wait(); - ((RelayCommand)SaveCommand).RaiseCanExecuteChanged(); + SaveCommand.RaiseCanExecuteChanged(); } } @@ -73,8 +72,8 @@ namespace ModernKeePass.ViewModels set { SetProperty(ref _isEditMode, value); - ((RelayCommand)SortEntriesCommand).RaiseCanExecuteChanged(); - ((RelayCommand)SortGroupsCommand).RaiseCanExecuteChanged(); + SortEntriesCommand.RaiseCanExecuteChanged(); + SortGroupsCommand.RaiseCanExecuteChanged(); } } @@ -89,10 +88,10 @@ namespace ModernKeePass.ViewModels public IEnumerable BreadCrumb { get; } - public ICommand SaveCommand { get; } - public ICommand SortEntriesCommand { get; } - public ICommand SortGroupsCommand { get; } - public ICommand MoveCommand { get; } + public RelayCommand SaveCommand { get; } + public RelayCommand SortEntriesCommand { get; } + public RelayCommand SortGroupsCommand { get; } + public RelayCommand MoveCommand { get; } private DatabaseVm Database => _mediator.Send(new GetDatabaseQuery()).GetAwaiter().GetResult(); @@ -156,7 +155,7 @@ namespace ModernKeePass.ViewModels private async Task SaveChanges() { await _mediator.Send(new SaveDatabaseCommand()); - ((RelayCommand)SaveCommand).RaiseCanExecuteChanged(); + SaveCommand.RaiseCanExecuteChanged(); } private async void Entries_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) @@ -179,21 +178,21 @@ namespace ModernKeePass.ViewModels } break; } - ((RelayCommand)SaveCommand).RaiseCanExecuteChanged(); + SaveCommand.RaiseCanExecuteChanged(); } private async Task SortEntriesAsync() { await _mediator.Send(new SortEntriesCommand {Group = _group}); OnPropertyChanged(nameof(Entries)); - ((RelayCommand)SaveCommand).RaiseCanExecuteChanged(); + SaveCommand.RaiseCanExecuteChanged(); } private async Task SortGroupsAsync() { await _mediator.Send(new SortGroupsCommand {Group = _group}); OnPropertyChanged(nameof(Groups)); - ((RelayCommand)SaveCommand).RaiseCanExecuteChanged(); + SaveCommand.RaiseCanExecuteChanged(); } } } diff --git a/ModernKeePass/ViewModels/MainVm.cs b/ModernKeePass/ViewModels/MainVm.cs index b391bf9..2393fdf 100644 --- a/ModernKeePass/ViewModels/MainVm.cs +++ b/ModernKeePass/ViewModels/MainVm.cs @@ -10,6 +10,7 @@ using ModernKeePass.Domain.AOP; using ModernKeePass.Domain.Dtos; using ModernKeePass.Domain.Interfaces; using ModernKeePass.Models; +using ModernKeePass.ViewModels.ListItems; using ModernKeePass.Views; namespace ModernKeePass.ViewModels diff --git a/ModernKeePass/ViewModels/RecentVm.cs b/ModernKeePass/ViewModels/RecentVm.cs index 3084bbc..ba05d04 100644 --- a/ModernKeePass/ViewModels/RecentVm.cs +++ b/ModernKeePass/ViewModels/RecentVm.cs @@ -6,6 +6,7 @@ using ModernKeePass.Application.Common.Interfaces; using ModernKeePass.Common; using ModernKeePass.Domain.AOP; using ModernKeePass.Domain.Interfaces; +using ModernKeePass.ViewModels.ListItems; namespace ModernKeePass.ViewModels { diff --git a/ModernKeePass/ViewModels/SettingsVm.cs b/ModernKeePass/ViewModels/SettingsVm.cs index d773373..998ba59 100644 --- a/ModernKeePass/ViewModels/SettingsVm.cs +++ b/ModernKeePass/ViewModels/SettingsVm.cs @@ -7,6 +7,7 @@ using ModernKeePass.Application.Common.Interfaces; using ModernKeePass.Application.Database.Queries.GetDatabase; using ModernKeePass.Domain.AOP; using ModernKeePass.Domain.Interfaces; +using ModernKeePass.ViewModels.ListItems; using ModernKeePass.Views; namespace ModernKeePass.ViewModels diff --git a/ModernKeePass/Views/GroupDetailPage.xaml b/ModernKeePass/Views/GroupDetailPage.xaml index a1e31e6..76f679b 100644 --- a/ModernKeePass/Views/GroupDetailPage.xaml +++ b/ModernKeePass/Views/GroupDetailPage.xaml @@ -133,11 +133,10 @@ - + - diff --git a/ModernKeePass/Views/MainPage.xaml.cs b/ModernKeePass/Views/MainPage.xaml.cs index 3a1e315..6b84a3e 100644 --- a/ModernKeePass/Views/MainPage.xaml.cs +++ b/ModernKeePass/Views/MainPage.xaml.cs @@ -2,6 +2,7 @@ using Windows.UI.Xaml.Navigation; using ModernKeePass.Domain.Dtos; using ModernKeePass.ViewModels; +using ModernKeePass.ViewModels.ListItems; // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238 diff --git a/ModernKeePass/Views/MainPageFrames/OpenDatabasePage.xaml b/ModernKeePass/Views/MainPageFrames/OpenDatabasePage.xaml index 84b2768..69374b2 100644 --- a/ModernKeePass/Views/MainPageFrames/OpenDatabasePage.xaml +++ b/ModernKeePass/Views/MainPageFrames/OpenDatabasePage.xaml @@ -25,13 +25,13 @@ - + - + - + diff --git a/ModernKeePass/Views/MainPageFrames/RecentDatabasesPage.xaml b/ModernKeePass/Views/MainPageFrames/RecentDatabasesPage.xaml index 338c9fb..082f575 100644 --- a/ModernKeePass/Views/MainPageFrames/RecentDatabasesPage.xaml +++ b/ModernKeePass/Views/MainPageFrames/RecentDatabasesPage.xaml @@ -43,16 +43,16 @@ - + - + - + - + diff --git a/ModernKeePass/Views/SettingsPage.xaml.cs b/ModernKeePass/Views/SettingsPage.xaml.cs index a942a57..474d0e5 100644 --- a/ModernKeePass/Views/SettingsPage.xaml.cs +++ b/ModernKeePass/Views/SettingsPage.xaml.cs @@ -1,5 +1,6 @@ using Windows.UI.Xaml.Controls; using ModernKeePass.ViewModels; +using ModernKeePass.ViewModels.ListItems; // The Split Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234234 diff --git a/ModernKeePass/Views/SettingsPageFrames/SettingsDatabasePage.xaml b/ModernKeePass/Views/SettingsPageFrames/SettingsDatabasePage.xaml index 3084b2b..9b4c540 100644 --- a/ModernKeePass/Views/SettingsPageFrames/SettingsDatabasePage.xaml +++ b/ModernKeePass/Views/SettingsPageFrames/SettingsDatabasePage.xaml @@ -4,8 +4,8 @@ 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:viewModels="using:ModernKeePass.ViewModels" xmlns:converters="using:ModernKeePass.Converters" + xmlns:listItems="using:ModernKeePass.ViewModels.ListItems" mc:Ignorable="d"> @@ -16,7 +16,7 @@ - + diff --git a/ModernKeePass/Views/SettingsPageFrames/SettingsNewDatabasePage.xaml b/ModernKeePass/Views/SettingsPageFrames/SettingsNewDatabasePage.xaml index 722681b..ca5d652 100644 --- a/ModernKeePass/Views/SettingsPageFrames/SettingsNewDatabasePage.xaml +++ b/ModernKeePass/Views/SettingsPageFrames/SettingsNewDatabasePage.xaml @@ -4,13 +4,13 @@ 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:viewModels="using:ModernKeePass.ViewModels" + xmlns:listItems="using:ModernKeePass.ViewModels.ListItems" mc:Ignorable="d"> - + diff --git a/ModernKeePass/Views/SettingsPageFrames/SettingsSavePage.xaml b/ModernKeePass/Views/SettingsPageFrames/SettingsSavePage.xaml index 824c417..ac4aa8f 100644 --- a/ModernKeePass/Views/SettingsPageFrames/SettingsSavePage.xaml +++ b/ModernKeePass/Views/SettingsPageFrames/SettingsSavePage.xaml @@ -4,10 +4,10 @@ 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:viewModels="using:ModernKeePass.ViewModels" + xmlns:listItems="using:ModernKeePass.ViewModels.ListItems" mc:Ignorable="d"> - + diff --git a/ModernKeePass/Views/UserControls/OpenDatabaseUserControl.xaml b/ModernKeePass/Views/UserControls/OpenDatabaseUserControl.xaml new file mode 100644 index 0000000..a887acb --- /dev/null +++ b/ModernKeePass/Views/UserControls/OpenDatabaseUserControl.xaml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +