Lots of bug corrections

WIP - still lots left
This commit is contained in:
Geoffroy BONNEVILLE
2020-03-31 19:19:02 +02:00
parent e4bd788ed3
commit 90c592d7ee
24 changed files with 191 additions and 215 deletions

View File

@@ -16,9 +16,9 @@ using ModernKeePass.Application.Group.Commands.RemoveEntry;
using ModernKeePass.Application.Security.Commands.GeneratePassword;
using ModernKeePass.Application.Security.Queries.EstimatePasswordComplexity;
using ModernKeePass.Common;
using ModernKeePass.Domain.Enums;
using ModernKeePass.Domain.Interfaces;
using ModernKeePass.Interfaces;
using ModernKeePass.Services;
namespace ModernKeePass.ViewModels
{
@@ -38,21 +38,7 @@ namespace ModernKeePass.ViewModels
public string CustomChars { get; set; } = string.Empty;
public string Id => _entry.Id;
public IEnumerable<Application.Group.Models.GroupVm> BreadCrumb
{
get
{
var groups = new Stack<Application.Group.Models.GroupVm>();
var group = _entry.ParentGroup;
while (group.ParentGroup != null)
{
group = group.ParentGroup;
groups.Push(group);
}
return groups;
}
}
public IEnumerable<Application.Group.Models.GroupVm> BreadCrumb => _entry.Breadcrumb;
/// <summary>
/// Determines if the Entry is current or from history
@@ -72,14 +58,21 @@ namespace ModernKeePass.ViewModels
public string Title
{
get { return _entry.Title; }
set { _mediator.Send(new SetFieldValueCommand { EntryId = Id, FieldName = nameof(Title), FieldValue = value}); }
set
{
_mediator.Send(new SetFieldValueCommand { EntryId = Id, FieldName = nameof(Title), FieldValue = value}).Wait();
_entry.Title = value;
}
}
public string UserName
{
get { return _entry.Username; }
set { _mediator.Send(new SetFieldValueCommand { EntryId = Id, FieldName = nameof(UserName), FieldValue = value }); }
set
{
_mediator.Send(new SetFieldValueCommand { EntryId = Id, FieldName = nameof(UserName), FieldValue = value }).Wait();
_entry.Username = value;
}
}
public string Password
@@ -87,7 +80,8 @@ namespace ModernKeePass.ViewModels
get { return _entry.Password; }
set
{
_mediator.Send(new SetFieldValueCommand { EntryId = Id, FieldName = nameof(Password), FieldValue = value });
_mediator.Send(new SetFieldValueCommand { EntryId = Id, FieldName = nameof(Password), FieldValue = value }).Wait();
_entry.Password = value;
OnPropertyChanged();
OnPropertyChanged(nameof(PasswordComplexityIndicator));
}
@@ -95,14 +89,22 @@ namespace ModernKeePass.ViewModels
public string Url
{
get { return _entry.Url.ToString();}
set { _mediator.Send(new SetFieldValueCommand { EntryId = Id, FieldName = nameof(Url), FieldValue = value }); }
get { return _entry.Url?.ToString(); }
set
{
_mediator.Send(new SetFieldValueCommand { EntryId = Id, FieldName = nameof(Url), FieldValue = value }).Wait();
_entry.Url = new Uri(value);
}
}
public string Notes
{
get { return _entry.Notes; }
set { _mediator.Send(new SetFieldValueCommand { EntryId = Id, FieldName = nameof(Notes), FieldValue = value }); }
set
{
_mediator.Send(new SetFieldValueCommand { EntryId = Id, FieldName = nameof(Notes), FieldValue = value }).Wait();
_entry.Notes = value;
}
}
public Symbol Icon
@@ -112,7 +114,11 @@ namespace ModernKeePass.ViewModels
if (HasExpired) return Symbol.ReportHacked;
return (Symbol) _entry.Icon;
}
set { _mediator.Send(new SetFieldValueCommand { EntryId = Id, FieldName = nameof(Icon), FieldValue = value }); }
set
{
_mediator.Send(new SetFieldValueCommand { EntryId = Id, FieldName = nameof(Icon), FieldValue = value }).Wait();
_entry.Icon = (Icon)value;
}
}
public DateTimeOffset ExpiryDate
@@ -121,7 +127,8 @@ namespace ModernKeePass.ViewModels
set
{
if (!HasExpirationDate) return;
_mediator.Send(new SetFieldValueCommand { EntryId = Id, FieldName = "ExpirationDate", FieldValue = value.Date });
_mediator.Send(new SetFieldValueCommand { EntryId = Id, FieldName = "ExpirationDate", FieldValue = value.Date }).Wait();
_entry.ExpirationDate = value.Date;
}
}
@@ -131,9 +138,48 @@ namespace ModernKeePass.ViewModels
set
{
if (!HasExpirationDate) return;
_mediator.Send(new SetFieldValueCommand { EntryId = Id, FieldName = "ExpirationDate", FieldValue = ExpiryDate.Date.Add(value) });
_mediator.Send(new SetFieldValueCommand { EntryId = Id, FieldName = "ExpirationDate", FieldValue = ExpiryDate.Date.Add(value) }).Wait();
_entry.ExpirationDate = _entry.ExpirationDate.Date.Add(value);
}
}
public bool HasExpirationDate
{
get { return _entry.HasExpirationDate; }
set
{
_mediator.Send(new SetFieldValueCommand { EntryId = Id, FieldName = nameof(HasExpirationDate), FieldValue = value }).Wait();
_entry.HasExpirationDate = value;
OnPropertyChanged();
}
}
public Color? BackgroundColor
{
get { return _entry?.BackgroundColor; }
set
{
if (value != null)
{
_mediator.Send(new SetFieldValueCommand { EntryId = Id, FieldName = nameof(BackgroundColor), FieldValue = value }).Wait();
_entry.BackgroundColor = (Color)value;
}
}
}
public Color? ForegroundColor
{
get { return _entry?.ForegroundColor; }
set
{
if (value != null)
{
_mediator.Send(new SetFieldValueCommand { EntryId = Id, FieldName = nameof(ForegroundColor), FieldValue = value }).Wait();
_entry.ForegroundColor = (Color)value;
}
}
}
public IEnumerable<Application.Entry.Models.EntryVm> History => _entry.History;
public bool IsEditMode
{
@@ -164,36 +210,6 @@ namespace ModernKeePass.ViewModels
OnPropertyChanged();
}
}
public bool HasExpirationDate
{
get { return _entry.HasExpirationDate; }
set
{
_mediator.Send(new SetFieldValueCommand {EntryId = Id, FieldName = nameof(HasExpirationDate), FieldValue = value});
OnPropertyChanged();
}
}
public IEnumerable<Application.Entry.Models.EntryVm> History => _entry.History;
public Color? BackgroundColor
{
get { return _entry?.BackgroundColor; }
set
{
if (value != null) _entry.BackgroundColor = (Color) value;
}
}
public Color? ForegroundColor
{
get { return _entry?.ForegroundColor; }
set
{
if (value != null) _entry.ForegroundColor = (Color)value;
}
}
public bool CanRestore => _entry.ParentGroup == _database.RecycleBin;
@@ -203,7 +219,6 @@ namespace ModernKeePass.ViewModels
private readonly Application.Entry.Models.EntryVm _entry;
private readonly IMediator _mediator;
private readonly IResourceService _resource;
private readonly DatabaseVm _database;
private bool _isEditMode;
private bool _isRevealPassword;
@@ -212,13 +227,12 @@ namespace ModernKeePass.ViewModels
public EntryVm() { }
internal EntryVm(Application.Entry.Models.EntryVm entry, bool isNewEntry = false) : this(entry, App.Mediator, new ResourcesService(), isNewEntry) { }
internal EntryVm(Application.Entry.Models.EntryVm entry, bool isNewEntry = false) : this(entry, App.Mediator, isNewEntry) { }
public EntryVm(Application.Entry.Models.EntryVm entry, IMediator mediator, IResourceService resource, bool isNewEntry = false)
public EntryVm(Application.Entry.Models.EntryVm entry, IMediator mediator, bool isNewEntry = false)
{
_entry = entry;
_mediator = mediator;
_resource = resource;
_database = _mediator.Send(new GetDatabaseQuery()).GetAwaiter().GetResult();
_isEditMode = isNewEntry;
if (isNewEntry) GeneratePassword().GetAwaiter().GetResult();
@@ -246,7 +260,6 @@ namespace ModernKeePass.ViewModels
OnPropertyChanged(nameof(IsRevealPasswordEnabled));
}
public async Task MarkForDelete(string recycleBinTitle)
{
if (_database.IsRecycleBinEnabled && _database.RecycleBin == null)
@@ -274,12 +287,5 @@ namespace ModernKeePass.ViewModels
{
return _entry;
}
public override string ToString()
{
return IsSelected ?
_resource.GetResourceValue("EntryCurrent") :
_entry.ModificationDate.ToString("g");
}
}
}

View File

@@ -103,21 +103,7 @@ namespace ModernKeePass.ViewModels
set { SetProperty(ref _isMenuClosed, value); }
}
public IEnumerable<Application.Group.Models.GroupVm> BreadCrumb
{
get
{
var groups = new Stack<Application.Group.Models.GroupVm>();
var group = _group;
while (group.ParentGroup != null)
{
group = group.ParentGroup;
groups.Push(group);
}
return groups;
}
}
public IEnumerable<Application.Group.Models.GroupVm> BreadCrumb => _group.Breadcrumb;
public ICommand SaveCommand { get; }
public ICommand SortEntriesCommand { get; }
@@ -209,11 +195,6 @@ namespace ModernKeePass.ViewModels
{
await _mediator.Send(new DeleteGroupCommand { Group = _group });
}
public override string ToString()
{
return Title;
}
private async Task SortEntriesAsync()
{

View File

@@ -30,7 +30,7 @@ namespace ModernKeePass.ViewModels
get { return _database.IsRecycleBinEnabled; }
set
{
_mediator.Send(new SetHasRecycleBinCommand {HasRecycleBin = value}).GetAwaiter().GetResult();
_mediator.Send(new SetHasRecycleBinCommand {HasRecycleBin = value}).Wait();
OnPropertyChanged(nameof(HasRecycleBin));
}
}
@@ -40,7 +40,7 @@ namespace ModernKeePass.ViewModels
get { return _database.RecycleBin == null; }
set
{
if (value) _mediator.Send(new SetRecycleBinCommand { RecycleBin = null }).GetAwaiter().GetResult();
if (value) _mediator.Send(new SetRecycleBinCommand { RecycleBin = null }).Wait();
}
}
@@ -53,19 +53,19 @@ namespace ModernKeePass.ViewModels
public CipherVm SelectedCipher
{
get { return Ciphers.FirstOrDefault(c => c.Id == _database.CipherId); }
set { _mediator.Send(new SetCipherCommand {CipherId = value.Id}).GetAwaiter().GetResult(); }
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}).GetAwaiter().GetResult(); }
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}).GetAwaiter().GetResult(); }
set { _mediator.Send(new SetKeyDerivationCommand {KeyDerivationId = value.Id}).Wait(); }
}
/*public int CipherIndex

View File

@@ -55,7 +55,7 @@ namespace ModernKeePass.Views
{
var vm = e.Parameter as Application.Group.Models.GroupVm;
if (vm != null)
DataContext = vm;
DataContext = new GroupVm(vm);
}
}
@@ -103,13 +103,13 @@ namespace ModernKeePass.Views
e.DestinationItem.Item = e.SourceItem.Item;
}
}
private void CreateEntry_ButtonClick(object sender, RoutedEventArgs e)
private async void CreateEntry_ButtonClick(object sender, RoutedEventArgs e)
{
Frame.Navigate(typeof(EntryDetailPage), Model.AddNewEntry());
Frame.Navigate(typeof(EntryDetailPage), await Model.AddNewEntry());
}
private void CreateGroup_ButtonClick(object sender, RoutedEventArgs e)
private async void CreateGroup_ButtonClick(object sender, RoutedEventArgs e)
{
Frame.Navigate(typeof(GroupDetailPage), Model.AddNewGroup());
Frame.Navigate(typeof(GroupDetailPage), await Model.AddNewGroup());
}
private void GridView_DragItemsStarting(object sender, DragItemsStartingEventArgs e)

View File

@@ -28,9 +28,9 @@ namespace ModernKeePass.Views
_mainFrame = e.Parameter as Frame;
}
private void SaveButton_OnClick(object sender, RoutedEventArgs e)
private async void SaveButton_OnClick(object sender, RoutedEventArgs e)
{
Model.Save();
await Model.Save();
_mainFrame.Navigate(typeof(MainPage));
}
@@ -45,7 +45,7 @@ namespace ModernKeePass.Views
var file = await savePicker.PickSaveFileAsync();
if (file == null) return;
Model.Save(file);
await Model.Save(file);
_mainFrame.Navigate(typeof(MainPage));
}

View File

@@ -16,7 +16,7 @@
</ItemsControl.ItemsPanel>
<ItemsControl.Resources>
<DataTemplate x:Name="FirstItemTemplate">
<HyperlinkButton Foreground="{StaticResource MainColor}" Content="{Binding Name}" Style="{StaticResource MainColorHyperlinkButton}" FontWeight="Light" FontSize="12" Padding="0">
<HyperlinkButton Foreground="{StaticResource MainColor}" Content="{Binding Title}" Style="{StaticResource MainColorHyperlinkButton}" FontWeight="Light" FontSize="12" Padding="0">
<interactivity:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="Click">
<core:NavigateToPageAction Parameter="{Binding}" TargetPage="ModernKeePass.Views.GroupDetailPage" />
@@ -29,7 +29,7 @@
<Viewbox MaxHeight="10" Margin="0,2,0,0">
<SymbolIcon Symbol="Forward" />
</Viewbox>
<HyperlinkButton Foreground="{StaticResource MainColor}" Content="{Binding Name}" Style="{StaticResource MainColorHyperlinkButton}" FontWeight="Light" FontSize="12" Padding="0">
<HyperlinkButton Foreground="{StaticResource MainColor}" Content="{Binding Title}" Style="{StaticResource MainColorHyperlinkButton}" FontWeight="Light" FontSize="12" Padding="0">
<interactivity:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="Click">
<core:NavigateToPageAction Parameter="{Binding}" TargetPage="ModernKeePass.Views.GroupDetailPage" />

View File

@@ -1,6 +1,6 @@
using System.Collections.Generic;
using Windows.UI.Xaml;
using ModernKeePass.Interfaces;
using ModernKeePass.Application.Common.Interfaces;
// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236
@@ -13,17 +13,17 @@ namespace ModernKeePass.Views.UserControls
InitializeComponent();
}
public IEnumerable<IVmEntity> ItemsSource
public IEnumerable<IEntityVm> ItemsSource
{
get { return (IEnumerable<IVmEntity>)GetValue(ItemsSourceProperty); }
get { return (IEnumerable<IEntityVm>)GetValue(ItemsSourceProperty); }
set { SetValue(ItemsSourceProperty, value); }
}
public static readonly DependencyProperty ItemsSourceProperty =
DependencyProperty.Register(
"ItemsSource",
typeof(IEnumerable<IVmEntity>),
typeof(IEnumerable<IEntityVm>),
typeof(BreadCrumbUserControl),
new PropertyMetadata(new Stack<IVmEntity>(), (o, args) => { }));
new PropertyMetadata(new Stack<IEntityVm>(), (o, args) => { }));
}
}

View File

@@ -388,15 +388,12 @@
</Page>
</ItemGroup>
<ItemGroup>
<Reference Include="Autofac">
<HintPath>..\..\..\..\..\.nuget\packages\Autofac\4.9.4\lib\netstandard1.1\Autofac.dll</HintPath>
</Reference>
<Reference Include="AutoMapper, Version=6.0.2.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005, processorArchitecture=MSIL">
<HintPath>..\packages\AutoMapper.6.0.2\lib\netstandard1.1\AutoMapper.dll</HintPath>
<Reference Include="AutoMapper, Version=5.2.0.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005, processorArchitecture=MSIL">
<HintPath>..\packages\AutoMapper.5.2.0\lib\netstandard1.1\AutoMapper.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="AutoMapper.Extensions.Microsoft.DependencyInjection, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\AutoMapper.Extensions.Microsoft.DependencyInjection.2.0.1\lib\netstandard1.1\AutoMapper.Extensions.Microsoft.DependencyInjection.dll</HintPath>
<Reference Include="AutoMapper.Extensions.Microsoft.DependencyInjection, Version=1.2.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\AutoMapper.Extensions.Microsoft.DependencyInjection.1.2.0\lib\netstandard1.1\AutoMapper.Extensions.Microsoft.DependencyInjection.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="BouncyCastle.Crypto, Version=1.8.5.0, Culture=neutral, PublicKeyToken=0e99375e54769942, processorArchitecture=MSIL">

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AutoMapper" version="6.0.2" targetFramework="win81" />
<package id="AutoMapper.Extensions.Microsoft.DependencyInjection" version="2.0.1" targetFramework="win81" />
<package id="AutoMapper" version="5.2.0" targetFramework="win81" />
<package id="AutoMapper.Extensions.Microsoft.DependencyInjection" version="1.2.0" targetFramework="win81" />
<package id="FluentValidation" version="8.6.2" targetFramework="win81" />
<package id="HockeySDK.Core" version="4.1.6" targetFramework="win81" />
<package id="HockeySDK.WINRT" version="4.1.6" targetFramework="win81" />