From 98631956842c0df497231520e2ad34e39ecf71e6 Mon Sep 17 00:00:00 2001 From: BONNEVILLE Geoffroy Date: Tue, 24 Jul 2018 17:52:44 +0200 Subject: [PATCH] Added CodeAnalysis package Better entry history handling Changing icon now adds an history entry --- ModernKeePass/ModernKeePass.App.csproj | 56 +++++++++++++++++++ ModernKeePass/ViewModels/EntryVm.cs | 36 +++++++++--- ModernKeePass/Views/EntryDetailPage.xaml | 8 +-- ModernKeePass/Views/EntryDetailPage.xaml.cs | 2 +- .../en-us/baselisting/releaseNotes.txt | 1 + .../fr-fr/baselisting/releaseNotes.txt | 1 + ModernKeePass/packages.config | 12 ++++ 7 files changed, 101 insertions(+), 15 deletions(-) diff --git a/ModernKeePass/ModernKeePass.App.csproj b/ModernKeePass/ModernKeePass.App.csproj index 28a1fc5..dbcd994 100644 --- a/ModernKeePass/ModernKeePass.App.csproj +++ b/ModernKeePass/ModernKeePass.App.csproj @@ -391,6 +391,30 @@ ..\packages\Portable.BouncyCastle.1.8.2\lib\netstandard1.0\BouncyCastle.Crypto.dll True + + ..\packages\Microsoft.CodeAnalysis.Common.1.3.1\lib\portable-net45+win8\Microsoft.CodeAnalysis.dll + True + + + ..\packages\Microsoft.CodeAnalysis.CSharp.1.3.1\lib\portable-net45+win8\Microsoft.CodeAnalysis.CSharp.dll + True + + + ..\packages\Microsoft.CodeAnalysis.CSharp.Workspaces.1.3.1\lib\portable-net45+win8\Microsoft.CodeAnalysis.CSharp.Workspaces.dll + True + + + ..\packages\Microsoft.CodeAnalysis.VisualBasic.1.3.1\lib\portable-net45+win8\Microsoft.CodeAnalysis.VisualBasic.dll + True + + + ..\packages\Microsoft.CodeAnalysis.VisualBasic.Workspaces.1.3.1\lib\portable-net45+win8\Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll + True + + + ..\packages\Microsoft.CodeAnalysis.Workspaces.Common.1.3.1\lib\portable-net45+win8\Microsoft.CodeAnalysis.Workspaces.dll + True + ..\packages\HockeySDK.Core.4.1.6\lib\portable-net45+win8+wp8+wpa81+win81+uap10.0\Microsoft.HockeyApp.Core45.dll True @@ -411,10 +435,38 @@ ..\packages\Splat.3.0.0\lib\netstandard1.1\Splat.dll True + + ..\packages\System.Collections.Immutable.1.1.37\lib\dotnet\System.Collections.Immutable.dll + True + + + ..\packages\Microsoft.Composition.1.0.27\lib\portable-net45+win8+wp8+wpa81\System.Composition.AttributedModel.dll + True + + + ..\packages\Microsoft.Composition.1.0.27\lib\portable-net45+win8+wp8+wpa81\System.Composition.Convention.dll + True + + + ..\packages\Microsoft.Composition.1.0.27\lib\portable-net45+win8+wp8+wpa81\System.Composition.Hosting.dll + True + + + ..\packages\Microsoft.Composition.1.0.27\lib\portable-net45+win8+wp8+wpa81\System.Composition.Runtime.dll + True + + + ..\packages\Microsoft.Composition.1.0.27\lib\portable-net45+win8+wp8+wpa81\System.Composition.TypedParts.dll + True + ..\packages\System.Drawing.Primitives.4.3.0\lib\netstandard1.1\System.Drawing.Primitives.dll True + + ..\packages\System.Reflection.Metadata.1.2.0\lib\portable-net45+win8\System.Reflection.Metadata.dll + True + ..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\win8\System.Runtime.InteropServices.RuntimeInformation.dll True @@ -499,6 +551,10 @@ + + + + 12.0 diff --git a/ModernKeePass/ViewModels/EntryVm.cs b/ModernKeePass/ViewModels/EntryVm.cs index 457bf3f..63d7631 100644 --- a/ModernKeePass/ViewModels/EntryVm.cs +++ b/ModernKeePass/ViewModels/EntryVm.cs @@ -92,19 +92,33 @@ namespace ModernKeePass.ViewModels if (_pwEntry?.IconId != null) return (int) _pwEntry?.IconId; return -1; } - set { _pwEntry.IconId = (PwIcon)value; } + set + { + HandleBackup(); + _pwEntry.IconId = (PwIcon)value; + } } public DateTimeOffset ExpiryDate { get { return new DateTimeOffset(_pwEntry.ExpiryTime.Date); } - set { if (HasExpirationDate) _pwEntry.ExpiryTime = value.DateTime; } + set + { + if (!HasExpirationDate) return; + HandleBackup(); + _pwEntry.ExpiryTime = value.DateTime; + } } public TimeSpan ExpiryTime { get { return _pwEntry.ExpiryTime.TimeOfDay; } - set { if (HasExpirationDate) _pwEntry.ExpiryTime = _pwEntry.ExpiryTime.Date.Add(value); } + set + { + if (!HasExpirationDate) return; + HandleBackup(); + _pwEntry.ExpiryTime = _pwEntry.ExpiryTime.Date.Add(value); + } } public bool IsEditMode @@ -170,6 +184,7 @@ namespace ModernKeePass.ViewModels if (value != null) _pwEntry.BackgroundColor = (Color) value; } } + public Color? ForegroundColor { get { return _pwEntry?.ForegroundColor; } @@ -286,6 +301,14 @@ namespace ModernKeePass.ViewModels return IsSelected ? _resource.GetResourceValue("EntryCurrent") : _pwEntry.LastModificationTime.ToString("g"); } + private void HandleBackup() + { + if (_isDirty) return; + _pwEntry?.Touch(true); + _pwEntry?.CreateBackup(null); + _isDirty = true; + } + private string GetEntryValue(string key) { return _pwEntry?.Strings.GetSafe(key).ReadString(); @@ -293,13 +316,8 @@ namespace ModernKeePass.ViewModels private void SetEntryValue(string key, ProtectedString newValue) { - if (!_isDirty) - { - _pwEntry.Touch(true); - _pwEntry?.CreateBackup(null); - } + HandleBackup(); _pwEntry?.Strings.Set(key, newValue); - _isDirty = true; } } } diff --git a/ModernKeePass/Views/EntryDetailPage.xaml b/ModernKeePass/Views/EntryDetailPage.xaml index c07f3c3..ea7c37a 100644 --- a/ModernKeePass/Views/EntryDetailPage.xaml +++ b/ModernKeePass/Views/EntryDetailPage.xaml @@ -453,11 +453,11 @@ - + - + @@ -481,7 +481,7 @@ Style="{StaticResource NoBorderButtonStyle}"> - + @@ -497,13 +497,11 @@ + + + + + + + + + @@ -12,6 +21,7 @@ + @@ -21,6 +31,8 @@ + +