From 73670e8689868a06353c7d954a14c7e3b6fbe244 Mon Sep 17 00:00:00 2001 From: Geoffroy BONNEVILLE Date: Fri, 17 Apr 2020 16:56:07 +0200 Subject: [PATCH] Create a shared project with all Win App common files (8.1 and 10) Finally use the dependency injected Resource Service --- .../DependencyInjection.cs | 1 + .../UWP/UwpResourceClient.cs | 3 +- ModernKeePass.sln | 12 +- ModernKeePass/Common/ResourceHelper.cs | 16 - ModernKeePass/ViewModels/CompositeKeyVm.cs | 12 +- ModernKeePass/ViewModels/MainVm.cs | 13 +- ModernKeePass/ViewModels/SettingsVm.cs | 7 +- ModernKeePass/Views/EntryDetailPage.xaml.cs | 28 +- ModernKeePass/Views/GroupDetailPage.xaml.cs | 25 +- .../MainPageFrames/NewDatabasePage.xaml.cs | 11 +- .../CompositeKeyUserControl.xaml.cs | 10 +- ModernKeePass/Win81App.csproj | 31 +- ModernKeePass10/Actions/ClipboardAction.cs | 27 -- ModernKeePass10/Actions/DeleteEntityAction.cs | 65 --- .../Actions/NavigateToUrlAction.cs | 33 -- ModernKeePass10/Actions/SetupFocusAction.cs | 27 -- ModernKeePass10/Actions/ToastAction.cs | 33 -- ModernKeePass10/Common/MessageDialogHelper.cs | 56 --- ModernKeePass10/Common/NavigationHelper.cs | 433 ------------------ .../Common/ObservableDictionary.cs | 141 ------ ModernKeePass10/Common/RelayCommand.cs | 78 ---- ModernKeePass10/Common/ResourceHelper.cs | 16 - ModernKeePass10/Common/SuspensionManager.cs | 260 ----------- .../Common/ToastNotificationHelper.cs | 53 --- .../Controls/ListViewWithDisable.cs | 20 - ModernKeePass10/Controls/TextBoxWithButton.cs | 56 --- .../BooleanToVisibilityConverter.cs | 29 -- .../Converters/ColorToBrushConverter.cs | 22 - .../DiscreteIntToSolidColorBrushConverter.cs | 27 -- .../DoubleToSolidColorBrushConverter.cs | 31 -- .../EmptyStringToVisibilityConverter.cs | 20 - .../Converters/IconToSymbolConverter.cs | 122 ----- .../InverseBooleanToVisibilityConverter.cs | 28 -- .../Converters/NullToBooleanConverter.cs | 18 - .../Converters/PluralizationConverter.cs | 24 - .../ProgressBarLegalValuesConverter.cs | 27 -- .../Converters/TextToWidthConverter.cs | 20 - ModernKeePass10/Events/PasswordEventArgs.cs | 15 - .../Extensions/DispatcherTaskExtensions.cs | 32 -- .../FirstItemDataTemplateSelector.cs | 18 - .../SelectableDataTemplateSelector.cs | 18 - ModernKeePass10/Win10App.csproj | 30 +- .../Actions/ClipboardAction.cs | 0 .../Actions/NavigateToUrlAction.cs | 0 .../Actions/SetupFocusAction.cs | 0 .../Actions/ToastAction.cs | 0 .../Common/Constants.cs | 0 .../Common/MessageDialogHelper.cs | 0 .../Common/NavigationHelper.cs | 0 .../Common/ObservableDictionary.cs | 0 .../Common/RelayCommand.cs | 0 .../Common/SuspensionManager.cs | 0 .../Common/ToastNotificationHelper.cs | 0 .../Controls/ListViewWithDisable.cs | 0 .../Controls/TextBoxWithButton.cs | 0 .../BooleanToVisibilityConverter.cs | 0 .../Converters/ColorToBrushConverter.cs | 0 .../DiscreteIntToSolidColorBrushConverter.cs | 0 .../DoubleToSolidColorBrushConverter.cs | 0 .../EmptyStringToVisibilityConverter.cs | 0 .../Converters/IconToSymbolConverter.cs | 0 .../InverseBooleanToVisibilityConverter.cs | 0 .../Converters/NullToBooleanConverter.cs | 0 .../Converters/PluralizationConverter.cs | 0 .../ProgressBarLegalValuesConverter.cs | 0 .../Converters/TextToWidthConverter.cs | 0 .../Events/PasswordEventArgs.cs | 0 .../Extensions/ColorExtensions.cs | 0 .../Extensions/DispatcherTaskExtensions.cs | 0 .../FirstItemDataTemplateSelector.cs | 0 .../SelectableDataTemplateSelector.cs | 0 WinAppCommon/WinAppCommon.projitems | 42 ++ WinAppCommon/WinAppCommon.shproj | 13 + 73 files changed, 131 insertions(+), 1872 deletions(-) delete mode 100644 ModernKeePass/Common/ResourceHelper.cs delete mode 100644 ModernKeePass10/Actions/ClipboardAction.cs delete mode 100644 ModernKeePass10/Actions/DeleteEntityAction.cs delete mode 100644 ModernKeePass10/Actions/NavigateToUrlAction.cs delete mode 100644 ModernKeePass10/Actions/SetupFocusAction.cs delete mode 100644 ModernKeePass10/Actions/ToastAction.cs delete mode 100644 ModernKeePass10/Common/MessageDialogHelper.cs delete mode 100644 ModernKeePass10/Common/NavigationHelper.cs delete mode 100644 ModernKeePass10/Common/ObservableDictionary.cs delete mode 100644 ModernKeePass10/Common/RelayCommand.cs delete mode 100644 ModernKeePass10/Common/ResourceHelper.cs delete mode 100644 ModernKeePass10/Common/SuspensionManager.cs delete mode 100644 ModernKeePass10/Common/ToastNotificationHelper.cs delete mode 100644 ModernKeePass10/Controls/ListViewWithDisable.cs delete mode 100644 ModernKeePass10/Controls/TextBoxWithButton.cs delete mode 100644 ModernKeePass10/Converters/BooleanToVisibilityConverter.cs delete mode 100644 ModernKeePass10/Converters/ColorToBrushConverter.cs delete mode 100644 ModernKeePass10/Converters/DiscreteIntToSolidColorBrushConverter.cs delete mode 100644 ModernKeePass10/Converters/DoubleToSolidColorBrushConverter.cs delete mode 100644 ModernKeePass10/Converters/EmptyStringToVisibilityConverter.cs delete mode 100644 ModernKeePass10/Converters/IconToSymbolConverter.cs delete mode 100644 ModernKeePass10/Converters/InverseBooleanToVisibilityConverter.cs delete mode 100644 ModernKeePass10/Converters/NullToBooleanConverter.cs delete mode 100644 ModernKeePass10/Converters/PluralizationConverter.cs delete mode 100644 ModernKeePass10/Converters/ProgressBarLegalValuesConverter.cs delete mode 100644 ModernKeePass10/Converters/TextToWidthConverter.cs delete mode 100644 ModernKeePass10/Events/PasswordEventArgs.cs delete mode 100644 ModernKeePass10/Extensions/DispatcherTaskExtensions.cs delete mode 100644 ModernKeePass10/TemplateSelectors/FirstItemDataTemplateSelector.cs delete mode 100644 ModernKeePass10/TemplateSelectors/SelectableDataTemplateSelector.cs rename {ModernKeePass => WinAppCommon}/Actions/ClipboardAction.cs (100%) rename {ModernKeePass => WinAppCommon}/Actions/NavigateToUrlAction.cs (100%) rename {ModernKeePass => WinAppCommon}/Actions/SetupFocusAction.cs (100%) rename {ModernKeePass => WinAppCommon}/Actions/ToastAction.cs (100%) rename {ModernKeePass => WinAppCommon}/Common/Constants.cs (100%) rename {ModernKeePass => WinAppCommon}/Common/MessageDialogHelper.cs (100%) rename {ModernKeePass => WinAppCommon}/Common/NavigationHelper.cs (100%) rename {ModernKeePass => WinAppCommon}/Common/ObservableDictionary.cs (100%) rename {ModernKeePass => WinAppCommon}/Common/RelayCommand.cs (100%) rename {ModernKeePass => WinAppCommon}/Common/SuspensionManager.cs (100%) rename {ModernKeePass => WinAppCommon}/Common/ToastNotificationHelper.cs (100%) rename {ModernKeePass => WinAppCommon}/Controls/ListViewWithDisable.cs (100%) rename {ModernKeePass => WinAppCommon}/Controls/TextBoxWithButton.cs (100%) rename {ModernKeePass => WinAppCommon}/Converters/BooleanToVisibilityConverter.cs (100%) rename {ModernKeePass => WinAppCommon}/Converters/ColorToBrushConverter.cs (100%) rename {ModernKeePass => WinAppCommon}/Converters/DiscreteIntToSolidColorBrushConverter.cs (100%) rename {ModernKeePass => WinAppCommon}/Converters/DoubleToSolidColorBrushConverter.cs (100%) rename {ModernKeePass => WinAppCommon}/Converters/EmptyStringToVisibilityConverter.cs (100%) rename {ModernKeePass => WinAppCommon}/Converters/IconToSymbolConverter.cs (100%) rename {ModernKeePass => WinAppCommon}/Converters/InverseBooleanToVisibilityConverter.cs (100%) rename {ModernKeePass => WinAppCommon}/Converters/NullToBooleanConverter.cs (100%) rename {ModernKeePass => WinAppCommon}/Converters/PluralizationConverter.cs (100%) rename {ModernKeePass => WinAppCommon}/Converters/ProgressBarLegalValuesConverter.cs (100%) rename {ModernKeePass => WinAppCommon}/Converters/TextToWidthConverter.cs (100%) rename {ModernKeePass => WinAppCommon}/Events/PasswordEventArgs.cs (100%) rename {ModernKeePass => WinAppCommon}/Extensions/ColorExtensions.cs (100%) rename {ModernKeePass => WinAppCommon}/Extensions/DispatcherTaskExtensions.cs (100%) rename {ModernKeePass => WinAppCommon}/TemplateSelectors/FirstItemDataTemplateSelector.cs (100%) rename {ModernKeePass => WinAppCommon}/TemplateSelectors/SelectableDataTemplateSelector.cs (100%) create mode 100644 WinAppCommon/WinAppCommon.projitems create mode 100644 WinAppCommon/WinAppCommon.shproj diff --git a/ModernKeePass.Infrastructure/DependencyInjection.cs b/ModernKeePass.Infrastructure/DependencyInjection.cs index 6751248..01f7884 100644 --- a/ModernKeePass.Infrastructure/DependencyInjection.cs +++ b/ModernKeePass.Infrastructure/DependencyInjection.cs @@ -28,6 +28,7 @@ namespace ModernKeePass.Infrastructure services.AddScoped(typeof(IFileProxy), typeof(StorageFileClient)); services.AddTransient(typeof(ISettingsProxy), typeof(UwpSettingsClient)); services.AddTransient(typeof(IRecentProxy), typeof(UwpRecentFilesClient)); + services.AddTransient(typeof(IResourceProxy), typeof(UwpResourceClient)); return services; } } diff --git a/ModernKeePass.Infrastructure/UWP/UwpResourceClient.cs b/ModernKeePass.Infrastructure/UWP/UwpResourceClient.cs index 6ddf960..339419b 100644 --- a/ModernKeePass.Infrastructure/UWP/UwpResourceClient.cs +++ b/ModernKeePass.Infrastructure/UWP/UwpResourceClient.cs @@ -6,10 +6,11 @@ namespace ModernKeePass.Infrastructure.UWP public class UwpResourceClient: IResourceProxy { private const string ResourceFileName = "CodeBehind"; - private readonly ResourceLoader _resourceLoader = ResourceLoader.GetForCurrentView(); + private ResourceLoader _resourceLoader; public string GetResourceValue(string key) { + if (_resourceLoader == null) _resourceLoader = ResourceLoader.GetForCurrentView(); var resource = _resourceLoader.GetString($"/{ResourceFileName}/{key}"); return resource; } diff --git a/ModernKeePass.sln b/ModernKeePass.sln index 9360d36..ac51e9a 100644 --- a/ModernKeePass.sln +++ b/ModernKeePass.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30011.22 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Win81App", "ModernKeePass\Win81App.csproj", "{A0CFC681-769B-405A-8482-0CDEE595A91F}" EndProject @@ -34,7 +34,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Win10App", "ModernKeePass10 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ModernKeePassApp.ViewModelTest", "ModernKeePass.ViewModelTest\ModernKeePassApp.ViewModelTest.csproj", "{D978E25B-028C-446C-8143-D85563ECA914}" EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "WinAppCommon", "WinAppCommon\WinAppCommon.shproj", "{A66B7A53-1D8F-41E2-A8AB-840C81B1AA92}" +EndProject Global + GlobalSection(SharedMSBuildProjectFiles) = preSolution + WinAppCommon\WinAppCommon.projitems*{a0cfc681-769b-405a-8482-0cdee595a91f}*SharedItemsImports = 4 + WinAppCommon\WinAppCommon.projitems*{a66b7a53-1d8f-41e2-a8ab-840c81b1aa92}*SharedItemsImports = 13 + WinAppCommon\WinAppCommon.projitems*{d16caff7-4187-45a8-a69e-d0658b7ac5bf}*SharedItemsImports = 4 + EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Debug|ARM = Debug|ARM @@ -204,6 +211,7 @@ Global {52FEA1EE-2FA7-4862-85FE-CB05893D439E} = {107C7C00-56F4-41B0-A8CC-0156C46A3650} {D16CAFF7-4187-45A8-A69E-D0658B7AC5BF} = {C7DB9A6F-77A8-4FE5-83CB-9C11F7100647} {D978E25B-028C-446C-8143-D85563ECA914} = {107C7C00-56F4-41B0-A8CC-0156C46A3650} + {A66B7A53-1D8F-41E2-A8AB-840C81B1AA92} = {C7DB9A6F-77A8-4FE5-83CB-9C11F7100647} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {0ADC1BC6-B1CA-427D-A97C-3CA40AAB0428} diff --git a/ModernKeePass/Common/ResourceHelper.cs b/ModernKeePass/Common/ResourceHelper.cs deleted file mode 100644 index 14d6800..0000000 --- a/ModernKeePass/Common/ResourceHelper.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Windows.ApplicationModel.Resources; - -namespace ModernKeePass.Common -{ - public class ResourceHelper - { - private const string ResourceFileName = "CodeBehind"; - private readonly ResourceLoader _resourceLoader = ResourceLoader.GetForCurrentView(); - - public string GetResourceValue(string key) - { - var resource = _resourceLoader.GetString($"/{ResourceFileName}/{key}"); - return resource; - } - } -} \ No newline at end of file diff --git a/ModernKeePass/ViewModels/CompositeKeyVm.cs b/ModernKeePass/ViewModels/CompositeKeyVm.cs index 9aa887f..e2ac2bd 100644 --- a/ModernKeePass/ViewModels/CompositeKeyVm.cs +++ b/ModernKeePass/ViewModels/CompositeKeyVm.cs @@ -12,7 +12,6 @@ using ModernKeePass.Application.Security.Commands.GenerateKeyFile; using ModernKeePass.Application.Security.Queries.EstimatePasswordComplexity; using ModernKeePass.Domain.AOP; using ModernKeePass.Domain.Dtos; -using ModernKeePass.Common; namespace ModernKeePass.ViewModels { @@ -113,15 +112,18 @@ namespace ModernKeePass.ViewModels private string _keyFileText; private readonly IMediator _mediator; private readonly ISettingsProxy _settings; - private readonly ResourceHelper _resource; + private readonly IResourceProxy _resource; - public CompositeKeyVm() : this(App.Services.GetRequiredService(), App.Services.GetRequiredService()) { } + public CompositeKeyVm() : this( + App.Services.GetRequiredService(), + App.Services.GetRequiredService(), + App.Services.GetRequiredService()) { } - public CompositeKeyVm(IMediator mediator, ISettingsProxy settings) + public CompositeKeyVm(IMediator mediator, ISettingsProxy settings, IResourceProxy resource) { _mediator = mediator; _settings = settings; - _resource = new ResourceHelper(); + _resource = resource; _keyFileText = _resource.GetResourceValue("CompositeKeyDefaultKeyFile"); } diff --git a/ModernKeePass/ViewModels/MainVm.cs b/ModernKeePass/ViewModels/MainVm.cs index 8457527..b391bf9 100644 --- a/ModernKeePass/ViewModels/MainVm.cs +++ b/ModernKeePass/ViewModels/MainVm.cs @@ -6,7 +6,6 @@ using MediatR; using Microsoft.Extensions.DependencyInjection; using ModernKeePass.Application.Common.Interfaces; using ModernKeePass.Application.Database.Queries.GetDatabase; -using ModernKeePass.Common; using ModernKeePass.Domain.AOP; using ModernKeePass.Domain.Dtos; using ModernKeePass.Domain.Interfaces; @@ -50,13 +49,17 @@ namespace ModernKeePass.ViewModels public MainVm() {} - internal MainVm(Frame referenceFrame, Frame destinationFrame, FileInfo databaseFile = null) : this(referenceFrame, destinationFrame, - App.Services.GetRequiredService(), App.Services.GetRequiredService(), databaseFile) + internal MainVm(Frame referenceFrame, Frame destinationFrame, FileInfo databaseFile = null) : this( + referenceFrame, + destinationFrame, + App.Services.GetRequiredService(), + App.Services.GetRequiredService(), + App.Services.GetRequiredService(), + databaseFile) { } - public MainVm(Frame referenceFrame, Frame destinationFrame, IMediator mediator, IRecentProxy recent, FileInfo databaseFile = null) + public MainVm(Frame referenceFrame, Frame destinationFrame, IMediator mediator, IRecentProxy recent, IResourceProxy resource, FileInfo databaseFile = null) { - var resource = new ResourceHelper(); var database = mediator.Send(new GetDatabaseQuery()).GetAwaiter().GetResult(); var mainMenuItems = new ObservableCollection diff --git a/ModernKeePass/ViewModels/SettingsVm.cs b/ModernKeePass/ViewModels/SettingsVm.cs index c5c1340..d773373 100644 --- a/ModernKeePass/ViewModels/SettingsVm.cs +++ b/ModernKeePass/ViewModels/SettingsVm.cs @@ -3,8 +3,8 @@ using System.Linq; using Windows.UI.Xaml.Controls; using MediatR; using Microsoft.Extensions.DependencyInjection; +using ModernKeePass.Application.Common.Interfaces; using ModernKeePass.Application.Database.Queries.GetDatabase; -using ModernKeePass.Common; using ModernKeePass.Domain.AOP; using ModernKeePass.Domain.Interfaces; using ModernKeePass.Views; @@ -43,11 +43,10 @@ namespace ModernKeePass.ViewModels } } - public SettingsVm() : this(App.Services.GetRequiredService()) { } + public SettingsVm() : this(App.Services.GetRequiredService(), App.Services.GetRequiredService()) { } - public SettingsVm(IMediator mediator) + public SettingsVm(IMediator mediator, IResourceProxy resource) { - var resource = new ResourceHelper(); var database = mediator.Send(new GetDatabaseQuery()).GetAwaiter().GetResult(); var menuItems = new ObservableCollection { diff --git a/ModernKeePass/Views/EntryDetailPage.xaml.cs b/ModernKeePass/Views/EntryDetailPage.xaml.cs index 0139688..402e054 100644 --- a/ModernKeePass/Views/EntryDetailPage.xaml.cs +++ b/ModernKeePass/Views/EntryDetailPage.xaml.cs @@ -1,5 +1,7 @@ using Windows.UI.Xaml; using Windows.UI.Xaml.Navigation; +using Microsoft.Extensions.DependencyInjection; +using ModernKeePass.Application.Common.Interfaces; using ModernKeePass.Common; using ModernKeePass.Models; using ModernKeePass.ViewModels; @@ -14,6 +16,7 @@ namespace ModernKeePass.Views /// public sealed partial class EntryDetailPage { + private readonly IResourceProxy _resource; public EntryDetailVm Model => (EntryDetailVm) DataContext; /// @@ -22,9 +25,11 @@ namespace ModernKeePass.Views /// public NavigationHelper NavigationHelper { get; } - public EntryDetailPage() + public EntryDetailPage(): this(App.Services.GetRequiredService()) { } + public EntryDetailPage(IResourceProxy resource) { InitializeComponent(); + _resource = resource; NavigationHelper = new NavigationHelper(this); } @@ -66,29 +71,28 @@ namespace ModernKeePass.Views private async void TopMenu_OnDeleteButtonClick(object sender, RoutedEventArgs e) { - var resource = new ResourceHelper(); if (Model.IsCurrentEntry) { var isRecycleOnDelete = Model.IsRecycleOnDelete; var message = isRecycleOnDelete - ? resource.GetResourceValue("EntryRecyclingConfirmation") - : resource.GetResourceValue("EntryDeletingConfirmation"); - await MessageDialogHelper.ShowActionDialog(resource.GetResourceValue("EntityDeleteTitle"), message, - resource.GetResourceValue("EntityDeleteActionButton"), - resource.GetResourceValue("EntityDeleteCancelButton"), async a => + ? _resource.GetResourceValue("EntryRecyclingConfirmation") + : _resource.GetResourceValue("EntryDeletingConfirmation"); + await MessageDialogHelper.ShowActionDialog(_resource.GetResourceValue("EntityDeleteTitle"), message, + _resource.GetResourceValue("EntityDeleteActionButton"), + _resource.GetResourceValue("EntityDeleteCancelButton"), async a => { - var text = isRecycleOnDelete ? resource.GetResourceValue("EntryRecycled") : resource.GetResourceValue("EntryDeleted"); + var text = isRecycleOnDelete ? _resource.GetResourceValue("EntryRecycled") : _resource.GetResourceValue("EntryDeleted"); //ToastNotificationHelper.ShowMovedToast(Entity, _resource.GetResourceValue("EntityDeleting"), text); - await Model.MarkForDelete(resource.GetResourceValue("RecycleBinTitle")); + await Model.MarkForDelete(_resource.GetResourceValue("RecycleBinTitle")); NavigationHelper.GoBack(); }, null); } else { - await MessageDialogHelper.ShowActionDialog(resource.GetResourceValue("HistoryDeleteTitle"), resource.GetResourceValue("HistoryDeleteDescription"), - resource.GetResourceValue("EntityDeleteActionButton"), - resource.GetResourceValue("EntityDeleteCancelButton"), async a => + await MessageDialogHelper.ShowActionDialog(_resource.GetResourceValue("HistoryDeleteTitle"), _resource.GetResourceValue("HistoryDeleteDescription"), + _resource.GetResourceValue("EntityDeleteActionButton"), + _resource.GetResourceValue("EntityDeleteCancelButton"), async a => { //ToastNotificationHelper.ShowMovedToast(Entity, _resource.GetResourceValue("EntityDeleting"), text); await Model.DeleteHistory(); diff --git a/ModernKeePass/Views/GroupDetailPage.xaml.cs b/ModernKeePass/Views/GroupDetailPage.xaml.cs index 95044f8..7710eeb 100644 --- a/ModernKeePass/Views/GroupDetailPage.xaml.cs +++ b/ModernKeePass/Views/GroupDetailPage.xaml.cs @@ -5,11 +5,13 @@ using Windows.Storage.Streams; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Navigation; +using Microsoft.Extensions.DependencyInjection; +using ModernKeePass.Application.Common.Interfaces; +using ModernKeePass.Application.Entry.Models; using ModernKeePass.Common; using ModernKeePass.Events; using ModernKeePass.Models; using ModernKeePass.ViewModels; -using EntryVm = ModernKeePass.Application.Entry.Models.EntryVm; // The Group Detail Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234229 @@ -21,6 +23,8 @@ namespace ModernKeePass.Views /// public sealed partial class GroupDetailPage { + private readonly IResourceProxy _resource; + /// /// NavigationHelper is used on each page to aid in navigation and /// process lifetime management @@ -28,9 +32,11 @@ namespace ModernKeePass.Views public NavigationHelper NavigationHelper { get; } public GroupDetailVm Model => (GroupDetailVm)DataContext; - public GroupDetailPage() + public GroupDetailPage(): this (App.Services.GetRequiredService()) { } + public GroupDetailPage(IResourceProxy resource) { InitializeComponent(); + _resource = resource; NavigationHelper = new NavigationHelper(this); } @@ -150,19 +156,18 @@ namespace ModernKeePass.Views private async void TopMenu_OnDeleteButtonClick(object sender, RoutedEventArgs e) { - var resource = new ResourceHelper(); var isRecycleOnDelete = Model.IsRecycleOnDelete; var message = isRecycleOnDelete - ? resource.GetResourceValue("GroupRecyclingConfirmation") - : resource.GetResourceValue("GroupDeletingConfirmation"); - var text = isRecycleOnDelete ? resource.GetResourceValue("GroupRecycled") : resource.GetResourceValue("GroupDeleted"); - await MessageDialogHelper.ShowActionDialog(resource.GetResourceValue("EntityDeleteTitle"), message, - resource.GetResourceValue("EntityDeleteActionButton"), - resource.GetResourceValue("EntityDeleteCancelButton"), async a => + ? _resource.GetResourceValue("GroupRecyclingConfirmation") + : _resource.GetResourceValue("GroupDeletingConfirmation"); + var text = isRecycleOnDelete ? _resource.GetResourceValue("GroupRecycled") : _resource.GetResourceValue("GroupDeleted"); + await MessageDialogHelper.ShowActionDialog(_resource.GetResourceValue("EntityDeleteTitle"), message, + _resource.GetResourceValue("EntityDeleteActionButton"), + _resource.GetResourceValue("EntityDeleteCancelButton"), async a => { //ToastNotificationHelper.ShowMovedToast(Entity, resource.GetResourceValue("EntityDeleting"), text); - await Model.MarkForDelete(resource.GetResourceValue("RecycleBinTitle")); + await Model.MarkForDelete(_resource.GetResourceValue("RecycleBinTitle")); NavigationHelper.GoBack(); }, null); } diff --git a/ModernKeePass/Views/MainPageFrames/NewDatabasePage.xaml.cs b/ModernKeePass/Views/MainPageFrames/NewDatabasePage.xaml.cs index c03790c..bb49628 100644 --- a/ModernKeePass/Views/MainPageFrames/NewDatabasePage.xaml.cs +++ b/ModernKeePass/Views/MainPageFrames/NewDatabasePage.xaml.cs @@ -4,7 +4,8 @@ using Windows.Storage.AccessCache; using Windows.Storage.Pickers; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; -using ModernKeePass.Common; +using Microsoft.Extensions.DependencyInjection; +using ModernKeePass.Application.Common.Interfaces; using ModernKeePass.Domain.Dtos; using ModernKeePass.Infrastructure.File; using ModernKeePass.ViewModels; @@ -18,10 +19,13 @@ namespace ModernKeePass.Views /// public sealed partial class NewDatabasePage { + private readonly IResourceProxy _resource; public NewVm Model => (NewVm)DataContext; - public NewDatabasePage() + public NewDatabasePage(): this(App.Services.GetRequiredService()) { } + public NewDatabasePage(IResourceProxy resource) { + _resource = resource; InitializeComponent(); } @@ -49,14 +53,13 @@ namespace ModernKeePass.Views private void ImportFormatComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) { - var resource = new ResourceHelper(); var comboBox = sender as ComboBox; switch (comboBox?.SelectedIndex) { case 0: Model.ImportFormat = new CsvImportFormat(); Model.ImportFileExtensionFilter = ".csv"; - Model.ImportFormatHelp = resource.GetResourceValue("NewImportFormatHelpCSV"); + Model.ImportFormatHelp = _resource.GetResourceValue("NewImportFormatHelpCSV"); break; } } diff --git a/ModernKeePass/Views/UserControls/CompositeKeyUserControl.xaml.cs b/ModernKeePass/Views/UserControls/CompositeKeyUserControl.xaml.cs index 8cd8cc0..9065d35 100644 --- a/ModernKeePass/Views/UserControls/CompositeKeyUserControl.xaml.cs +++ b/ModernKeePass/Views/UserControls/CompositeKeyUserControl.xaml.cs @@ -8,6 +8,7 @@ using Windows.UI.Xaml; using Windows.UI.Xaml.Input; using MediatR; using Microsoft.Extensions.DependencyInjection; +using ModernKeePass.Application.Common.Interfaces; using ModernKeePass.Application.Database.Commands.CloseDatabase; using ModernKeePass.Application.Database.Commands.SaveDatabase; using ModernKeePass.Application.Database.Queries.GetDatabase; @@ -24,7 +25,7 @@ namespace ModernKeePass.Views.UserControls public sealed partial class CompositeKeyUserControl { private readonly IMediator _mediator; - private readonly ResourceHelper _resource; + private readonly IResourceProxy _resource; public CompositeKeyVm Model => Grid.DataContext as CompositeKeyVm; public bool CreateNew @@ -77,13 +78,12 @@ namespace ModernKeePass.Views.UserControls public bool ShowComplexityIndicator => CreateNew || UpdateKey; - public CompositeKeyUserControl(): this(App.Services.GetRequiredService()) - { } + public CompositeKeyUserControl(): this(App.Services.GetRequiredService(), App.Services.GetRequiredService()) { } - public CompositeKeyUserControl(IMediator mediator) + public CompositeKeyUserControl(IMediator mediator, IResourceProxy resource) { _mediator = mediator; - _resource = new ResourceHelper(); + _resource = resource; InitializeComponent(); } diff --git a/ModernKeePass/Win81App.csproj b/ModernKeePass/Win81App.csproj index b9c6a1c..69aa337 100644 --- a/ModernKeePass/Win81App.csproj +++ b/ModernKeePass/Win81App.csproj @@ -89,34 +89,15 @@ true - - - - App.xaml - - - - - DonatePage.xaml - - - - - - - - - - ImportExportPage.xaml @@ -136,8 +117,6 @@ SettingsWelcomePage.xaml - - BreadCrumbUserControl.xaml @@ -147,15 +126,6 @@ CompositeKeyUserControl.xaml - - - - - - - - - MainPage.xaml @@ -557,6 +527,7 @@ + 12.0 diff --git a/ModernKeePass10/Actions/ClipboardAction.cs b/ModernKeePass10/Actions/ClipboardAction.cs deleted file mode 100644 index 6f758f0..0000000 --- a/ModernKeePass10/Actions/ClipboardAction.cs +++ /dev/null @@ -1,27 +0,0 @@ -using Windows.ApplicationModel.DataTransfer; -using Windows.UI.Xaml; -using Microsoft.Xaml.Interactivity; - -namespace ModernKeePass.Actions -{ - public class ClipboardAction : DependencyObject, IAction - { - public string Text - { - get => (string)GetValue(TextProperty); - set => SetValue(TextProperty, value); - } - - public static readonly DependencyProperty TextProperty = - DependencyProperty.Register("Text", typeof(string), typeof(ClipboardAction), new PropertyMetadata(string.Empty)); - - public object Execute(object sender, object parameter) - { - if (string.IsNullOrEmpty(Text)) return null; - var dataPackage = new DataPackage { RequestedOperation = DataPackageOperation.Copy }; - dataPackage.SetText(Text); - Clipboard.SetContent(dataPackage); - return null; - } - } -} diff --git a/ModernKeePass10/Actions/DeleteEntityAction.cs b/ModernKeePass10/Actions/DeleteEntityAction.cs deleted file mode 100644 index d72c1df..0000000 --- a/ModernKeePass10/Actions/DeleteEntityAction.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System.Windows.Input; -using Windows.UI.Xaml; -using Autofac; -using Microsoft.Xaml.Interactivity; -using ModernKeePass.Common; -using ModernKeePass.Domain.Entities; -using ModernKeePass.Domain.Interfaces; - -namespace ModernKeePass.Actions -{ - public class DeleteEntityAction : DependencyObject, IAction - { - private readonly IResourceService _resourceService; - private readonly IDatabaseService _databaseService; - - public Entity Entity - { - get => (Entity)GetValue(EntityProperty); - set => SetValue(EntityProperty, value); - } - - public static readonly DependencyProperty EntityProperty = - DependencyProperty.Register("Entity", typeof(Entity), typeof(DeleteEntityAction), - new PropertyMetadata(null)); - - public ICommand Command - { - get => (ICommand)GetValue(CommandProperty); - set => SetValue(CommandProperty, value); - } - - public static readonly DependencyProperty CommandProperty = - DependencyProperty.Register("Command", typeof(ICommand), typeof(DeleteEntityAction), - new PropertyMetadata(null)); - - public DeleteEntityAction(): this(App.Container.Resolve(), App.Container.Resolve()) - { } - - public DeleteEntityAction(IResourceService resourceService, IDatabaseService databaseService) - { - _resourceService = resourceService; - _databaseService = databaseService; - } - - public object Execute(object sender, object parameter) - { - var type = Entity is GroupEntity ? "Group" : "Entry"; - - var message = _databaseService.IsRecycleBinEnabled - ? _resourceService.GetResourceValue($"{type}RecyclingConfirmation") - : _resourceService.GetResourceValue($"{type}DeletingConfirmation"); - var text = _databaseService.IsRecycleBinEnabled ? _resourceService.GetResourceValue($"{type}Recycled") : _resourceService.GetResourceValue($"{type}Deleted"); - MessageDialogHelper.ShowActionDialog(_resourceService.GetResourceValue("EntityDeleteTitle"), message, - _resourceService.GetResourceValue("EntityDeleteActionButton"), - _resourceService.GetResourceValue("EntityDeleteCancelButton"), a => - { - ToastNotificationHelper.ShowMovedToast(Entity, _resourceService.GetResourceValue("EntityDeleting"), text); - //Entity.MarkForDelete(_resourceService.GetResourceValue("RecycleBinTitle")); - Command.Execute(null); - }, null).GetAwaiter(); - - return null; - } - } -} \ No newline at end of file diff --git a/ModernKeePass10/Actions/NavigateToUrlAction.cs b/ModernKeePass10/Actions/NavigateToUrlAction.cs deleted file mode 100644 index 2bdbc54..0000000 --- a/ModernKeePass10/Actions/NavigateToUrlAction.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using Windows.UI.Xaml; -using Microsoft.Xaml.Interactivity; -using ModernKeePass.Common; - -namespace ModernKeePass.Actions -{ - public class NavigateToUrlAction : DependencyObject, IAction - { - public string Url - { - get => (string)GetValue(UrlProperty); - set => SetValue(UrlProperty, value); - } - - public static readonly DependencyProperty UrlProperty = - DependencyProperty.Register("Url", typeof(string), typeof(NavigateToUrlAction), new PropertyMetadata(string.Empty)); - - public object Execute(object sender, object parameter) - { - try - { - var uri = new Uri(Url); - return Windows.System.Launcher.LaunchUriAsync(uri).GetAwaiter().GetResult(); - } - catch (Exception ex) - { - MessageDialogHelper.ShowErrorDialog(ex).GetAwaiter(); - return false; - } - } - } -} diff --git a/ModernKeePass10/Actions/SetupFocusAction.cs b/ModernKeePass10/Actions/SetupFocusAction.cs deleted file mode 100644 index e704277..0000000 --- a/ModernKeePass10/Actions/SetupFocusAction.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Threading.Tasks; -using Windows.UI.Core; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Microsoft.Xaml.Interactivity; - -namespace ModernKeePass.Actions -{ - public class SetupFocusAction : DependencyObject, IAction - { - public Control TargetObject - { - get => (Control)GetValue(TargetObjectProperty); - set => SetValue(TargetObjectProperty, value); - } - - public static readonly DependencyProperty TargetObjectProperty = - DependencyProperty.Register("TargetObject", typeof(Control), typeof(SetupFocusAction), new PropertyMetadata(null)); - - public object Execute(object sender, object parameter) - { - return Task.Factory.StartNew( - () => Dispatcher.RunAsync(CoreDispatcherPriority.Low, - () => TargetObject?.Focus(FocusState.Programmatic))); - } - } -} \ No newline at end of file diff --git a/ModernKeePass10/Actions/ToastAction.cs b/ModernKeePass10/Actions/ToastAction.cs deleted file mode 100644 index 0a00fda..0000000 --- a/ModernKeePass10/Actions/ToastAction.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Windows.UI.Xaml; -using Microsoft.Xaml.Interactivity; -using ModernKeePass.Common; - -namespace ModernKeePass.Actions -{ - public class ToastAction : DependencyObject, IAction - { - public string Title - { - get => (string)GetValue(TitleProperty); - set => SetValue(TitleProperty, value); - } - - public static readonly DependencyProperty TitleProperty = - DependencyProperty.Register("Title", typeof(string), typeof(ToastAction), new PropertyMetadata(string.Empty)); - - public string Message - { - get => (string)GetValue(MessageProperty); - set => SetValue(MessageProperty, value); - } - - public static readonly DependencyProperty MessageProperty = - DependencyProperty.Register("Message", typeof(string), typeof(ToastAction), new PropertyMetadata(string.Empty)); - - public object Execute(object sender, object parameter) - { - ToastNotificationHelper.ShowGenericToast(Title, Message); - return null; - } - } -} \ No newline at end of file diff --git a/ModernKeePass10/Common/MessageDialogHelper.cs b/ModernKeePass10/Common/MessageDialogHelper.cs deleted file mode 100644 index 385ef4d..0000000 --- a/ModernKeePass10/Common/MessageDialogHelper.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using System.Threading.Tasks; -using Windows.UI.Popups; - -namespace ModernKeePass.Common -{ - public static class MessageDialogHelper - { - public static async Task ShowActionDialog(string title, string contentText, string actionButtonText, string cancelButtonText, UICommandInvokedHandler actionCommand, UICommandInvokedHandler cancelCommand) - { - // Create the message dialog and set its content - var messageDialog = CreateBasicDialog(title, contentText, cancelButtonText, cancelCommand); - - // Add commands and set their callbacks; both buttons use the same callback function instead of inline event handlers - messageDialog.Commands.Add(new UICommand(actionButtonText, actionCommand)); - - // Show the message dialog - await messageDialog.ShowAsync(); - } - - public static async Task ShowErrorDialog(Exception exception) - { - if (exception == null) return; - // Create the message dialog and set its content - var messageDialog = CreateBasicDialog(exception.Message, exception.StackTrace, "OK"); - - // Show the message dialog - await messageDialog.ShowAsync(); - } - - public static async Task ShowNotificationDialog(string title, string message) - { - var dialog = CreateBasicDialog(title, message, "OK"); - - // Show the message dialog - await dialog.ShowAsync(); - } - - private static MessageDialog CreateBasicDialog(string title, string message, string dismissActionText, UICommandInvokedHandler cancelCommand = null) - { - // Create the message dialog and set its content - var messageDialog = new MessageDialog(message, title); - - // Add commands and set their callbacks - messageDialog.Commands.Add(new UICommand(dismissActionText, cancelCommand)); - - // Set the command that will be invoked by default - messageDialog.DefaultCommandIndex = 1; - - // Set the command to be invoked when escape is pressed - messageDialog.CancelCommandIndex = 1; - - return messageDialog; - } - } -} diff --git a/ModernKeePass10/Common/NavigationHelper.cs b/ModernKeePass10/Common/NavigationHelper.cs deleted file mode 100644 index bf6552f..0000000 --- a/ModernKeePass10/Common/NavigationHelper.cs +++ /dev/null @@ -1,433 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Input; -using Windows.System; -using Windows.UI.Core; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Navigation; - -namespace ModernKeePass.Common -{ - /// - /// NavigationHelper aids in navigation between pages. It provides commands used to - /// navigate back and forward as well as registers for standard mouse and keyboard - /// shortcuts used to go back and forward in Windows and the hardware back button in - /// Windows Phone. In addition it integrates SuspensionManger to handle process lifetime - /// management and state management when navigating between pages. - /// - /// - /// To make use of NavigationHelper, follow these two steps or - /// start with a BasicPage or any other Page item template other than BlankPage. - /// - /// 1) Create an instance of the NavigationHelper somewhere such as in the - /// constructor for the page and register a callback for the LoadState and - /// SaveState events. - /// - /// public MyPage() - /// { - /// this.InitializeComponent(); - /// var navigationHelper = new NavigationHelper(this); - /// this.navigationHelper.LoadState += navigationHelper_LoadState; - /// this.navigationHelper.SaveState += navigationHelper_SaveState; - /// } - /// - /// private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e) - /// { } - /// private async void navigationHelper_SaveState(object sender, LoadStateEventArgs e) - /// { } - /// - /// - /// 2) Register the page to call into the NavigationHelper whenever the page participates - /// in navigation by overriding the - /// and events. - /// - /// protected override void OnNavigatedTo(NavigationEventArgs e) - /// { - /// navigationHelper.OnNavigatedTo(e); - /// } - /// - /// protected override void OnNavigatedFrom(NavigationEventArgs e) - /// { - /// navigationHelper.OnNavigatedFrom(e); - /// } - /// - /// - [Windows.Foundation.Metadata.WebHostHidden] - public class NavigationHelper : DependencyObject - { - private Page Page { get; set; } - private Frame Frame => this.Page.Frame; - - /// - /// Initializes a new instance of the class. - /// - /// A reference to the current page used for navigation. - /// This reference allows for frame manipulation and to ensure that keyboard - /// navigation requests only occur when the page is occupying the entire window. - public NavigationHelper(Page page) - { - this.Page = page; - - // When this page is part of the visual tree make two changes: - // 1) Map application view state to visual state for the page - // 2) Handle hardware navigation requests - this.Page.Loaded += (sender, e) => - { -#if WINDOWS_PHONE_APP - Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed; -#else - // Keyboard and mouse navigation only apply when occupying the entire window - if (this.Page.ActualHeight == Window.Current.Bounds.Height && - this.Page.ActualWidth == Window.Current.Bounds.Width) - { - // Listen to the window directly so focus isn't required - Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated += - CoreDispatcher_AcceleratorKeyActivated; - Window.Current.CoreWindow.PointerPressed += - this.CoreWindow_PointerPressed; - } -#endif - }; - - // Undo the same changes when the page is no longer visible - this.Page.Unloaded += (sender, e) => - { -#if WINDOWS_PHONE_APP - Windows.Phone.UI.Input.HardwareButtons.BackPressed -= HardwareButtons_BackPressed; -#else - Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated -= - CoreDispatcher_AcceleratorKeyActivated; - Window.Current.CoreWindow.PointerPressed -= - this.CoreWindow_PointerPressed; -#endif - }; - } - - #region Navigation support - - RelayCommand _goBackCommand; - RelayCommand _goForwardCommand; - - /// - /// used to bind to the back Button's Command property - /// for navigating to the most recent item in back navigation history, if a Frame - /// manages its own navigation history. - /// - /// The is set up to use the virtual method - /// as the Execute Action and for CanExecute. - /// - public RelayCommand GoBackCommand - { - get - { - if (_goBackCommand == null) - { - _goBackCommand = new RelayCommand( - () => this.GoBack(), - () => this.CanGoBack()); - } - return _goBackCommand; - } - set => _goBackCommand = value; - } - /// - /// used for navigating to the most recent item in - /// the forward navigation history, if a Frame manages its own navigation history. - /// - /// The is set up to use the virtual method - /// as the Execute Action and for CanExecute. - /// - public RelayCommand GoForwardCommand - { - get - { - if (_goForwardCommand == null) - { - _goForwardCommand = new RelayCommand( - () => this.GoForward(), - () => this.CanGoForward()); - } - return _goForwardCommand; - } - } - - /// - /// Virtual method used by the property - /// to determine if the can go back. - /// - /// - /// true if the has at least one entry - /// in the back navigation history. - /// - public virtual bool CanGoBack() - { - return this.Frame != null && this.Frame.CanGoBack; - } - /// - /// Virtual method used by the property - /// to determine if the can go forward. - /// - /// - /// true if the has at least one entry - /// in the forward navigation history. - /// - public virtual bool CanGoForward() - { - return this.Frame != null && this.Frame.CanGoForward; - } - - /// - /// Virtual method used by the property - /// to invoke the method. - /// - public virtual void GoBack() - { - if (this.Frame != null && this.Frame.CanGoBack) this.Frame.GoBack(); - } - /// - /// Virtual method used by the property - /// to invoke the method. - /// - public virtual void GoForward() - { - if (this.Frame != null && this.Frame.CanGoForward) this.Frame.GoForward(); - } - -#if WINDOWS_PHONE_APP - /// - /// Invoked when the hardware back button is pressed. For Windows Phone only. - /// - /// Instance that triggered the event. - /// Event data describing the conditions that led to the event. - private void HardwareButtons_BackPressed(object sender, Windows.Phone.UI.Input.BackPressedEventArgs e) - { - if (this.GoBackCommand.CanExecute(null)) - { - e.Handled = true; - this.GoBackCommand.Execute(null); - } - } -#else - /// - /// Invoked on every keystroke, including system keys such as Alt key combinations, when - /// this page is active and occupies the entire window. Used to detect keyboard navigation - /// between pages even when the page itself doesn't have focus. - /// - /// Instance that triggered the event. - /// Event data describing the conditions that led to the event. - private void CoreDispatcher_AcceleratorKeyActivated(CoreDispatcher sender, - AcceleratorKeyEventArgs e) - { - var virtualKey = e.VirtualKey; - - // Only investigate further when Left, Right, or the dedicated Previous or Next keys - // are pressed - if ((e.EventType == CoreAcceleratorKeyEventType.SystemKeyDown || - e.EventType == CoreAcceleratorKeyEventType.KeyDown) && - (virtualKey == VirtualKey.Left || virtualKey == VirtualKey.Right || - (int)virtualKey == 166 || (int)virtualKey == 167)) - { - var coreWindow = Window.Current.CoreWindow; - var downState = CoreVirtualKeyStates.Down; - bool menuKey = (coreWindow.GetKeyState(VirtualKey.Menu) & downState) == downState; - bool controlKey = (coreWindow.GetKeyState(VirtualKey.Control) & downState) == downState; - bool shiftKey = (coreWindow.GetKeyState(VirtualKey.Shift) & downState) == downState; - bool noModifiers = !menuKey && !controlKey && !shiftKey; - bool onlyAlt = menuKey && !controlKey && !shiftKey; - - if (((int)virtualKey == 166 && noModifiers) || - (virtualKey == VirtualKey.Left && onlyAlt)) - { - // When the previous key or Alt+Left are pressed navigate back - e.Handled = true; - this.GoBackCommand.Execute(null); - } - else if (((int)virtualKey == 167 && noModifiers) || - (virtualKey == VirtualKey.Right && onlyAlt)) - { - // When the next key or Alt+Right are pressed navigate forward - e.Handled = true; - this.GoForwardCommand.Execute(null); - } - } - } - - /// - /// Invoked on every mouse click, touch screen tap, or equivalent interaction when this - /// page is active and occupies the entire window. Used to detect browser-style next and - /// previous mouse button clicks to navigate between pages. - /// - /// Instance that triggered the event. - /// Event data describing the conditions that led to the event. - private void CoreWindow_PointerPressed(CoreWindow sender, - PointerEventArgs e) - { - var properties = e.CurrentPoint.Properties; - - // Ignore button chords with the left, right, and middle buttons - if (properties.IsLeftButtonPressed || properties.IsRightButtonPressed || - properties.IsMiddleButtonPressed) return; - - // If back or foward are pressed (but not both) navigate appropriately - bool backPressed = properties.IsXButton1Pressed; - bool forwardPressed = properties.IsXButton2Pressed; - if (backPressed ^ forwardPressed) - { - e.Handled = true; - if (backPressed) this.GoBackCommand.Execute(null); - if (forwardPressed) this.GoForwardCommand.Execute(null); - } - } -#endif - - #endregion - - #region Process lifetime management - - private String _pageKey; - - /// - /// Register this event on the current page to populate the page - /// with content passed during navigation as well as any saved - /// state provided when recreating a page from a prior session. - /// - public event LoadStateEventHandler LoadState; - /// - /// Register this event on the current page to preserve - /// state associated with the current page in case the - /// application is suspended or the page is discarded from - /// the navigaqtion cache. - /// - public event SaveStateEventHandler SaveState; - - /// - /// Invoked when this page is about to be displayed in a Frame. - /// This method calls , where all page specific - /// navigation and process lifetime management logic should be placed. - /// - /// Event data that describes how this page was reached. The Parameter - /// property provides the group to be displayed. - public void OnNavigatedTo(NavigationEventArgs e) - { - var frameState = SuspensionManager.SessionStateForFrame(this.Frame); - this._pageKey = "Page-" + this.Frame.BackStackDepth; - - if (e.NavigationMode == NavigationMode.New) - { - // Clear existing state for forward navigation when adding a new page to the - // navigation stack - var nextPageKey = this._pageKey; - int nextPageIndex = this.Frame.BackStackDepth; - while (frameState.Remove(nextPageKey)) - { - nextPageIndex++; - nextPageKey = "Page-" + nextPageIndex; - } - - // Pass the navigation parameter to the new page - if (this.LoadState != null) - { - this.LoadState(this, new LoadStateEventArgs(e.Parameter, null)); - } - } - else - { - // Pass the navigation parameter and preserved page state to the page, using - // the same strategy for loading suspended state and recreating pages discarded - // from cache - if (this.LoadState != null) - { - this.LoadState(this, new LoadStateEventArgs(e.Parameter, (Dictionary)frameState[this._pageKey])); - } - } - } - - /// - /// Invoked when this page will no longer be displayed in a Frame. - /// This method calls , where all page specific - /// navigation and process lifetime management logic should be placed. - /// - /// Event data that describes how this page was reached. The Parameter - /// property provides the group to be displayed. - public void OnNavigatedFrom(NavigationEventArgs e) - { - var frameState = SuspensionManager.SessionStateForFrame(this.Frame); - var pageState = new Dictionary(); - if (this.SaveState != null) - { - this.SaveState(this, new SaveStateEventArgs(pageState)); - } - frameState[_pageKey] = pageState; - } - - #endregion - } - - /// - /// Represents the method that will handle the event - /// - public delegate void LoadStateEventHandler(object sender, LoadStateEventArgs e); - /// - /// Represents the method that will handle the event - /// - public delegate void SaveStateEventHandler(object sender, SaveStateEventArgs e); - - /// - /// Class used to hold the event data required when a page attempts to load state. - /// - public class LoadStateEventArgs : EventArgs - { - /// - /// The parameter value passed to - /// when this page was initially requested. - /// - public Object NavigationParameter { get; private set; } - /// - /// A dictionary of state preserved by this page during an earlier - /// session. This will be null the first time a page is visited. - /// - public Dictionary PageState { get; private set; } - - /// - /// Initializes a new instance of the class. - /// - /// - /// The parameter value passed to - /// when this page was initially requested. - /// - /// - /// A dictionary of state preserved by this page during an earlier - /// session. This will be null the first time a page is visited. - /// - public LoadStateEventArgs(Object navigationParameter, Dictionary pageState) - : base() - { - this.NavigationParameter = navigationParameter; - this.PageState = pageState; - } - } - /// - /// Class used to hold the event data required when a page attempts to save state. - /// - public class SaveStateEventArgs : EventArgs - { - /// - /// An empty dictionary to be populated with serializable state. - /// - public Dictionary PageState { get; private set; } - - /// - /// Initializes a new instance of the class. - /// - /// An empty dictionary to be populated with serializable state. - public SaveStateEventArgs(Dictionary pageState) - : base() - { - this.PageState = pageState; - } - } -} diff --git a/ModernKeePass10/Common/ObservableDictionary.cs b/ModernKeePass10/Common/ObservableDictionary.cs deleted file mode 100644 index af10715..0000000 --- a/ModernKeePass10/Common/ObservableDictionary.cs +++ /dev/null @@ -1,141 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using Windows.Foundation.Collections; - -namespace ModernKeePass.Common -{ - /// - /// Implementation of IObservableMap that supports reentrancy for use as a default view - /// model. - /// - public class ObservableDictionary : IObservableMap - { - private class ObservableDictionaryChangedEventArgs : IMapChangedEventArgs - { - public ObservableDictionaryChangedEventArgs(CollectionChange change, string key) - { - CollectionChange = change; - Key = key; - } - - public CollectionChange CollectionChange { get; private set; } - public string Key { get; private set; } - } - - private readonly Dictionary _dictionary = new Dictionary(); - public event MapChangedEventHandler MapChanged; - - private void InvokeMapChanged(CollectionChange change, string key) - { - var eventHandler = MapChanged; - if (eventHandler != null) - { - eventHandler(this, new ObservableDictionaryChangedEventArgs(change, key)); - } - } - - public void Add(string key, object value) - { - _dictionary.Add(key, value); - InvokeMapChanged(CollectionChange.ItemInserted, key); - } - - public void Add(KeyValuePair item) - { - Add(item.Key, item.Value); - } - - public void AddRange(IEnumerable> values) - { - foreach (var value in values) - { - Add(value); - } - } - - public bool Remove(string key) - { - if (_dictionary.Remove(key)) - { - InvokeMapChanged(CollectionChange.ItemRemoved, key); - return true; - } - return false; - } - - public bool Remove(KeyValuePair item) - { - object currentValue; - if (_dictionary.TryGetValue(item.Key, out currentValue) && - Equals(item.Value, currentValue) && _dictionary.Remove(item.Key)) - { - InvokeMapChanged(CollectionChange.ItemRemoved, item.Key); - return true; - } - return false; - } - - public object this[string key] - { - get => _dictionary[key]; - set - { - _dictionary[key] = value; - InvokeMapChanged(CollectionChange.ItemChanged, key); - } - } - - public void Clear() - { - var priorKeys = _dictionary.Keys.ToArray(); - _dictionary.Clear(); - foreach (var key in priorKeys) - { - InvokeMapChanged(CollectionChange.ItemRemoved, key); - } - } - - public ICollection Keys => _dictionary.Keys; - - public bool ContainsKey(string key) - { - return _dictionary.ContainsKey(key); - } - - public bool TryGetValue(string key, out object value) - { - return _dictionary.TryGetValue(key, out value); - } - - public ICollection Values => _dictionary.Values; - - public bool Contains(KeyValuePair item) - { - return _dictionary.Contains(item); - } - - public int Count => _dictionary.Count; - - public bool IsReadOnly => false; - - public IEnumerator> GetEnumerator() - { - return _dictionary.GetEnumerator(); - } - - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() - { - return _dictionary.GetEnumerator(); - } - - public void CopyTo(KeyValuePair[] array, int arrayIndex) - { - int arraySize = array.Length; - foreach (var pair in _dictionary) - { - if (arrayIndex >= arraySize) break; - array[arrayIndex++] = pair; - } - } - } -} diff --git a/ModernKeePass10/Common/RelayCommand.cs b/ModernKeePass10/Common/RelayCommand.cs deleted file mode 100644 index b651858..0000000 --- a/ModernKeePass10/Common/RelayCommand.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System; -using System.Windows.Input; - -namespace ModernKeePass.Common -{ - /// - /// A command whose sole purpose is to relay its functionality - /// to other objects by invoking delegates. - /// The default return value for the CanExecute method is 'true'. - /// needs to be called whenever - /// is expected to return a different value. - /// - public class RelayCommand : ICommand - { - private readonly Action _execute; - private readonly Func _canExecute; - - /// - /// Raised when RaiseCanExecuteChanged is called. - /// - public event EventHandler CanExecuteChanged; - - /// - /// Creates a new command that can always execute. - /// - /// The execution logic. - public RelayCommand(Action execute) - : this(execute, null) - { - } - - /// - /// Creates a new command. - /// - /// The execution logic. - /// The execution status logic. - public RelayCommand(Action execute, Func canExecute) - { - if (execute == null) - throw new ArgumentNullException(nameof(execute)); - _execute = execute; - _canExecute = canExecute; - } - - /// - /// Determines whether this can execute in its current state. - /// - /// - /// Data used by the command. If the command does not require data to be passed, this object can be set to null. - /// - /// true if this command can be executed; otherwise, false. - public bool CanExecute(object parameter) - { - return _canExecute?.Invoke() ?? true; - } - - /// - /// Executes the on the current command target. - /// - /// - /// Data used by the command. If the command does not require data to be passed, this object can be set to null. - /// - public void Execute(object parameter) - { - _execute(); - } - - /// - /// Method used to raise the event - /// to indicate that the return value of the - /// method has changed. - /// - public void RaiseCanExecuteChanged() - { - CanExecuteChanged?.Invoke(this, EventArgs.Empty); - } - } -} \ No newline at end of file diff --git a/ModernKeePass10/Common/ResourceHelper.cs b/ModernKeePass10/Common/ResourceHelper.cs deleted file mode 100644 index 14d6800..0000000 --- a/ModernKeePass10/Common/ResourceHelper.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Windows.ApplicationModel.Resources; - -namespace ModernKeePass.Common -{ - public class ResourceHelper - { - private const string ResourceFileName = "CodeBehind"; - private readonly ResourceLoader _resourceLoader = ResourceLoader.GetForCurrentView(); - - public string GetResourceValue(string key) - { - var resource = _resourceLoader.GetString($"/{ResourceFileName}/{key}"); - return resource; - } - } -} \ No newline at end of file diff --git a/ModernKeePass10/Common/SuspensionManager.cs b/ModernKeePass10/Common/SuspensionManager.cs deleted file mode 100644 index 3b00613..0000000 --- a/ModernKeePass10/Common/SuspensionManager.cs +++ /dev/null @@ -1,260 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Runtime.Serialization; -using System.Threading.Tasks; -using Windows.Storage; -using Windows.Storage.Streams; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; - -namespace ModernKeePass.Common -{ - /// - /// SuspensionManager captures global session state to simplify process lifetime management - /// for an application. Note that session state will be automatically cleared under a variety - /// of conditions and should only be used to store information that would be convenient to - /// carry across sessions, but that should be discarded when an application crashes or is - /// upgraded. - /// - internal static class SuspensionManager - { - private static Dictionary _sessionState = new Dictionary(); - private static readonly List _knownTypes = new List(); - private const string sessionStateFilename = "_sessionState.xml"; - - /// - /// Provides access to global session state for the current session. This state is - /// serialized by and restored by - /// , so values must be serializable by - /// and should be as compact as possible. Strings - /// and other self-contained data types are strongly recommended. - /// - public static Dictionary SessionState => _sessionState; - - /// - /// List of custom types provided to the when - /// reading and writing session state. Initially empty, additional types may be - /// added to customize the serialization process. - /// - public static List KnownTypes => _knownTypes; - - /// - /// Save the current . Any instances - /// registered with will also preserve their current - /// navigation stack, which in turn gives their active an opportunity - /// to save its state. - /// - /// An asynchronous task that reflects when session state has been saved. - public static async Task SaveAsync() - { - try - { - // Save the navigation state for all registered frames - foreach (var weakFrameReference in _registeredFrames) - { - Frame frame; - if (weakFrameReference.TryGetTarget(out frame)) - { - SaveFrameNavigationState(frame); - } - } - - // Serialize the session state synchronously to avoid asynchronous access to shared - // state - MemoryStream sessionData = new MemoryStream(); - DataContractSerializer serializer = new DataContractSerializer(typeof(Dictionary), _knownTypes); - serializer.WriteObject(sessionData, _sessionState); - - // Get an output stream for the SessionState file and write the state asynchronously - StorageFile file = await ApplicationData.Current.LocalFolder.CreateFileAsync(sessionStateFilename, CreationCollisionOption.ReplaceExisting); - using (Stream fileStream = await file.OpenStreamForWriteAsync()) - { - sessionData.Seek(0, SeekOrigin.Begin); - await sessionData.CopyToAsync(fileStream); - } - } - catch (Exception e) - { - throw new SuspensionManagerException(e); - } - } - - /// - /// Restores previously saved . Any instances - /// registered with will also restore their prior navigation - /// state, which in turn gives their active an opportunity restore its - /// state. - /// - /// An optional key that identifies the type of session. - /// This can be used to distinguish between multiple application launch scenarios. - /// An asynchronous task that reflects when session state has been read. The - /// content of should not be relied upon until this task - /// completes. - public static async Task RestoreAsync(String sessionBaseKey = null) - { - _sessionState = new Dictionary(); - - try - { - // Get the input stream for the SessionState file - StorageFile file = await ApplicationData.Current.LocalFolder.GetFileAsync(sessionStateFilename); - using (IInputStream inStream = await file.OpenSequentialReadAsync()) - { - // Deserialize the Session State - DataContractSerializer serializer = new DataContractSerializer(typeof(Dictionary), _knownTypes); - _sessionState = (Dictionary)serializer.ReadObject(inStream.AsStreamForRead()); - } - - // Restore any registered frames to their saved state - foreach (var weakFrameReference in _registeredFrames) - { - Frame frame; - if (weakFrameReference.TryGetTarget(out frame) && (string)frame.GetValue(FrameSessionBaseKeyProperty) == sessionBaseKey) - { - frame.ClearValue(FrameSessionStateProperty); - RestoreFrameNavigationState(frame); - } - } - } - catch (Exception e) - { - throw new SuspensionManagerException(e); - } - } - - private static DependencyProperty FrameSessionStateKeyProperty = - DependencyProperty.RegisterAttached("_FrameSessionStateKey", typeof(String), typeof(SuspensionManager), null); - private static DependencyProperty FrameSessionBaseKeyProperty = - DependencyProperty.RegisterAttached("_FrameSessionBaseKeyParams", typeof(String), typeof(SuspensionManager), null); - private static DependencyProperty FrameSessionStateProperty = - DependencyProperty.RegisterAttached("_FrameSessionState", typeof(Dictionary), typeof(SuspensionManager), null); - private static List> _registeredFrames = new List>(); - - /// - /// Registers a instance to allow its navigation history to be saved to - /// and restored from . Frames should be registered once - /// immediately after creation if they will participate in session state management. Upon - /// registration if state has already been restored for the specified key - /// the navigation history will immediately be restored. Subsequent invocations of - /// will also restore navigation history. - /// - /// An instance whose navigation history should be managed by - /// - /// A unique key into used to - /// store navigation-related information. - /// An optional key that identifies the type of session. - /// This can be used to distinguish between multiple application launch scenarios. - public static void RegisterFrame(Frame frame, String sessionStateKey, String sessionBaseKey = null) - { - if (frame.GetValue(FrameSessionStateKeyProperty) != null) - { - throw new InvalidOperationException("Frames can only be registered to one session state key"); - } - - if (frame.GetValue(FrameSessionStateProperty) != null) - { - throw new InvalidOperationException("Frames must be either be registered before accessing frame session state, or not registered at all"); - } - - if (!string.IsNullOrEmpty(sessionBaseKey)) - { - frame.SetValue(FrameSessionBaseKeyProperty, sessionBaseKey); - sessionStateKey = sessionBaseKey + "_" + sessionStateKey; - } - - // Use a dependency property to associate the session key with a frame, and keep a list of frames whose - // navigation state should be managed - frame.SetValue(FrameSessionStateKeyProperty, sessionStateKey); - _registeredFrames.Add(new WeakReference(frame)); - - // Check to see if navigation state can be restored - RestoreFrameNavigationState(frame); - } - - /// - /// Disassociates a previously registered by - /// from . Any navigation state previously captured will be - /// removed. - /// - /// An instance whose navigation history should no longer be - /// managed. - public static void UnregisterFrame(Frame frame) - { - // Remove session state and remove the frame from the list of frames whose navigation - // state will be saved (along with any weak references that are no longer reachable) - SessionState.Remove((String)frame.GetValue(FrameSessionStateKeyProperty)); - _registeredFrames.RemoveAll((weakFrameReference) => - { - Frame testFrame; - return !weakFrameReference.TryGetTarget(out testFrame) || testFrame == frame; - }); - } - - /// - /// Provides storage for session state associated with the specified . - /// Frames that have been previously registered with have - /// their session state saved and restored automatically as a part of the global - /// . Frames that are not registered have transient state - /// that can still be useful when restoring pages that have been discarded from the - /// navigation cache. - /// - /// Apps may choose to rely on to manage - /// page-specific state instead of working with frame session state directly. - /// The instance for which session state is desired. - /// A collection of state subject to the same serialization mechanism as - /// . - public static Dictionary SessionStateForFrame(Frame frame) - { - var frameState = (Dictionary)frame.GetValue(FrameSessionStateProperty); - - if (frameState == null) - { - var frameSessionKey = (String)frame.GetValue(FrameSessionStateKeyProperty); - if (frameSessionKey != null) - { - // Registered frames reflect the corresponding session state - if (!_sessionState.ContainsKey(frameSessionKey)) - { - _sessionState[frameSessionKey] = new Dictionary(); - } - frameState = (Dictionary)_sessionState[frameSessionKey]; - } - else - { - // Frames that aren't registered have transient state - frameState = new Dictionary(); - } - frame.SetValue(FrameSessionStateProperty, frameState); - } - return frameState; - } - - private static void RestoreFrameNavigationState(Frame frame) - { - var frameState = SessionStateForFrame(frame); - if (frameState.ContainsKey("Navigation")) - { - frame.SetNavigationState((String)frameState["Navigation"]); - } - } - - private static void SaveFrameNavigationState(Frame frame) - { - var frameState = SessionStateForFrame(frame); - frameState["Navigation"] = frame.GetNavigationState(); - } - } - public class SuspensionManagerException : Exception - { - public SuspensionManagerException() - { - } - - public SuspensionManagerException(Exception e) - : base("SuspensionManager failed", e) - { - - } - } -} diff --git a/ModernKeePass10/Common/ToastNotificationHelper.cs b/ModernKeePass10/Common/ToastNotificationHelper.cs deleted file mode 100644 index fb2d7c7..0000000 --- a/ModernKeePass10/Common/ToastNotificationHelper.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System; -using Windows.Data.Json; -using Windows.Data.Xml.Dom; -using Windows.UI.Notifications; -using ModernKeePass.Domain.Entities; - -namespace ModernKeePass.Common -{ - public static class ToastNotificationHelper - { - public static void ShowMovedToast(Entity entity, string action, string text) - { - var notificationXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02); - var toastElements = notificationXml.GetElementsByTagName("text"); - toastElements[0].AppendChild(notificationXml.CreateTextNode($"{action} {entity.Name}")); - toastElements[1].AppendChild(notificationXml.CreateTextNode(text)); - var toastNode = notificationXml.SelectSingleNode("/toast"); - - // This is useful only for Windows 10 UWP - var launch = new JsonObject - { - {"entityType", JsonValue.CreateStringValue(entity.GetType().Name)}, - {"entityId", JsonValue.CreateStringValue(entity.Id)} - }; - ((XmlElement)toastNode)?.SetAttribute("launch", launch.Stringify()); - - var toast = new ToastNotification(notificationXml) - { - ExpirationTime = DateTime.Now.AddSeconds(5) - }; - ToastNotificationManager.CreateToastNotifier().Show(toast); - } - - public static void ShowGenericToast(string title, string text) - { - var notificationXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02); - var toastElements = notificationXml.GetElementsByTagName("text"); - toastElements[0].AppendChild(notificationXml.CreateTextNode(title)); - toastElements[1].AppendChild(notificationXml.CreateTextNode(text)); - - var toast = new ToastNotification(notificationXml) - { - ExpirationTime = DateTime.Now.AddSeconds(5) - }; - ToastNotificationManager.CreateToastNotifier().Show(toast); - } - - public static void ShowErrorToast(Exception exception) - { - ShowGenericToast(exception.Source, exception.Message); - } - } -} diff --git a/ModernKeePass10/Controls/ListViewWithDisable.cs b/ModernKeePass10/Controls/ListViewWithDisable.cs deleted file mode 100644 index 4b395bc..0000000 --- a/ModernKeePass10/Controls/ListViewWithDisable.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using ModernKeePass.Application.Common.Interfaces; -using ModernKeePass.Domain.Interfaces; - -namespace ModernKeePass.Controls -{ - public class ListViewWithDisable: ListView - { - protected override void PrepareContainerForItemOverride(DependencyObject element, object item) - { - base.PrepareContainerForItemOverride(element, item); - - var binaryItem = item as IIsEnabled; - if (!(element is ListViewItem container) || binaryItem == null) return; - container.IsEnabled = binaryItem.IsEnabled; - container.IsHitTestVisible = binaryItem.IsEnabled; - } - } -} diff --git a/ModernKeePass10/Controls/TextBoxWithButton.cs b/ModernKeePass10/Controls/TextBoxWithButton.cs deleted file mode 100644 index c041b1f..0000000 --- a/ModernKeePass10/Controls/TextBoxWithButton.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; - -namespace ModernKeePass.Controls -{ - public class TextBoxWithButton : TextBox - { - public event EventHandler ButtonClick; - - public string ButtonSymbol - { - get => (string)GetValue(ButtonSymbolProperty); - set => SetValue(ButtonSymbolProperty, value); - } - public static readonly DependencyProperty ButtonSymbolProperty = - DependencyProperty.Register( - "ButtonSymbol", - typeof(string), - typeof(TextBoxWithButton), - new PropertyMetadata("", (o, args) => { })); - - public string ButtonTooltip - { - get => (string)GetValue(ButtonTooltipProperty); - set => SetValue(ButtonTooltipProperty, value); - } - public static readonly DependencyProperty ButtonTooltipProperty = - DependencyProperty.Register( - "ButtonTooltip", - typeof(string), - typeof(TextBoxWithButton), - new PropertyMetadata(string.Empty, (o, args) => { })); - - public bool IsButtonEnabled - { - get => (bool)GetValue(IsButtonEnabledProperty); - set => SetValue(IsButtonEnabledProperty, value); - } - public static readonly DependencyProperty IsButtonEnabledProperty = - DependencyProperty.Register( - "IsButtonEnabled", - typeof(bool), - typeof(TextBoxWithButton), - new PropertyMetadata(true, (o, args) => { })); - - protected override void OnApplyTemplate() - { - base.OnApplyTemplate(); - if (GetTemplateChild("ActionButton") is Button actionButton) - { - actionButton.Click += (sender, e) => ButtonClick?.Invoke(sender, e); - } - } - } -} \ No newline at end of file diff --git a/ModernKeePass10/Converters/BooleanToVisibilityConverter.cs b/ModernKeePass10/Converters/BooleanToVisibilityConverter.cs deleted file mode 100644 index a4145eb..0000000 --- a/ModernKeePass10/Converters/BooleanToVisibilityConverter.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Data; - -namespace ModernKeePass.Converters -{ - [Obsolete] - public class BooleanToVisibilityConverter : IValueConverter - { - public object Convert(object value, Type targetType, object parameter, string language) - { - var boolean = value as bool? ?? false; - return boolean ? Visibility.Visible : Visibility.Collapsed; - } - - // No need to implement this - public object ConvertBack(object value, Type targetType, object parameter, string language) - { - var visibility = value as Visibility? ?? Visibility.Visible; - switch (visibility) - { - case Visibility.Visible: return true; - case Visibility.Collapsed: return false; - default: - throw new ArgumentOutOfRangeException(nameof(value)); - } - } - } -} diff --git a/ModernKeePass10/Converters/ColorToBrushConverter.cs b/ModernKeePass10/Converters/ColorToBrushConverter.cs deleted file mode 100644 index c0c2a10..0000000 --- a/ModernKeePass10/Converters/ColorToBrushConverter.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using Windows.UI; -using Windows.UI.Xaml.Data; -using Windows.UI.Xaml.Media; - -namespace ModernKeePass.Converters -{ - public class ColorToBrushConverter : IValueConverter - { - public object Convert(object value, Type targetType, object parameter, string language) - { - var color = value is Color color1 ? color1 : default(Color); - if (color == default(Color) && parameter is SolidColorBrush) return (SolidColorBrush) parameter; - return new SolidColorBrush(color); - } - - public object ConvertBack(object value, Type targetType, object parameter, string language) - { - return (value as SolidColorBrush)?.Color ?? new Color(); - } - } -} \ No newline at end of file diff --git a/ModernKeePass10/Converters/DiscreteIntToSolidColorBrushConverter.cs b/ModernKeePass10/Converters/DiscreteIntToSolidColorBrushConverter.cs deleted file mode 100644 index 9a4f4ba..0000000 --- a/ModernKeePass10/Converters/DiscreteIntToSolidColorBrushConverter.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using Windows.UI; -using Windows.UI.Xaml.Data; -using Windows.UI.Xaml.Media; - -namespace ModernKeePass.Converters -{ - public class DiscreteIntToSolidColorBrushConverter : IValueConverter - { - public object Convert(object value, Type targetType, object parameter, string language) - { - var status = System.Convert.ToInt32(value); - switch (status) - { - case 1: return new SolidColorBrush(Colors.Red); - case 3: return new SolidColorBrush(Colors.Yellow); - case 5: return new SolidColorBrush(Colors.Green); - default: return new SolidColorBrush(Colors.Black); - } - } - - public object ConvertBack(object value, Type targetType, object parameter, string language) - { - throw new NotImplementedException(); - } - } -} diff --git a/ModernKeePass10/Converters/DoubleToSolidColorBrushConverter.cs b/ModernKeePass10/Converters/DoubleToSolidColorBrushConverter.cs deleted file mode 100644 index d841805..0000000 --- a/ModernKeePass10/Converters/DoubleToSolidColorBrushConverter.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using Windows.UI; -using Windows.UI.Xaml.Data; -using Windows.UI.Xaml.Media; - -namespace ModernKeePass.Converters -{ - public class DoubleToSolidColorBrushConverter : IValueConverter - { - public object Convert(object value, Type targetType, object parameter, string language) - { - try - { - var currentValue = (double) value; - var maxValue = double.Parse(parameter as string); - var green = System.Convert.ToByte(currentValue / maxValue * byte.MaxValue); - var red = (byte) (byte.MaxValue - green); - return new SolidColorBrush(Color.FromArgb(255, red, green, 0)); - } - catch (OverflowException) - { - return new SolidColorBrush(Color.FromArgb(255, 0, byte.MaxValue, 0)); - } - } - - public object ConvertBack(object value, Type targetType, object parameter, string language) - { - throw new NotImplementedException(); - } - } -} diff --git a/ModernKeePass10/Converters/EmptyStringToVisibilityConverter.cs b/ModernKeePass10/Converters/EmptyStringToVisibilityConverter.cs deleted file mode 100644 index dc73ae4..0000000 --- a/ModernKeePass10/Converters/EmptyStringToVisibilityConverter.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Data; - -namespace ModernKeePass.Converters -{ - class EmptyStringToVisibilityConverter: IValueConverter - { - public object Convert(object value, Type targetType, object parameter, string language) - { - var text = value is string ? value.ToString() : string.Empty; - return string.IsNullOrEmpty(text) ? Visibility.Collapsed : Visibility.Visible; - } - - public object ConvertBack(object value, Type targetType, object parameter, string language) - { - throw new NotImplementedException(); - } - } -} diff --git a/ModernKeePass10/Converters/IconToSymbolConverter.cs b/ModernKeePass10/Converters/IconToSymbolConverter.cs deleted file mode 100644 index 6946405..0000000 --- a/ModernKeePass10/Converters/IconToSymbolConverter.cs +++ /dev/null @@ -1,122 +0,0 @@ -using System; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Data; -using ModernKeePass.Domain.Enums; - -namespace ModernKeePass.Converters -{ - public class IconToSymbolConverter : IValueConverter - { - public object Convert(object value, Type targetType, object parameter, string language) - { - var icon = (Icon) value; - switch (icon) - { - case Icon.Delete: return Symbol.Delete; - case Icon.Edit: return Symbol.Edit; - case Icon.Save: return Symbol.Save; - case Icon.Cancel: return Symbol.Cancel; - case Icon.Accept: return Symbol.Accept; - case Icon.Home: return Symbol.Home; - case Icon.Camera: return Symbol.Camera; - case Icon.Setting: return Symbol.Setting; - case Icon.Mail: return Symbol.Mail; - case Icon.Find: return Symbol.Find; - case Icon.Help: return Symbol.Help; - case Icon.Clock: return Symbol.Clock; - case Icon.Crop: return Symbol.Crop; - case Icon.World: return Symbol.World; - case Icon.Flag: return Symbol.Flag; - case Icon.PreviewLink: return Symbol.PreviewLink; - case Icon.Document: return Symbol.Document; - case Icon.ProtectedDocument: return Symbol.ProtectedDocument; - case Icon.ContactInfo: return Symbol.ContactInfo; - case Icon.ViewAll: return Symbol.ViewAll; - case Icon.Rotate: return Symbol.Rotate; - case Icon.List: return Symbol.List; - case Icon.Shop: return Symbol.Shop; - case Icon.BrowsePhotos: return Symbol.BrowsePhotos; - case Icon.Caption: return Symbol.Caption; - case Icon.Repair: return Symbol.Repair; - case Icon.Page: return Symbol.Page2; - case Icon.Paste: return Symbol.Paste; - case Icon.Important: return Symbol.Important; - case Icon.SlideShow: return Symbol.SlideShow; - case Icon.MapDrive: return Symbol.MapDrive; - case Icon.ContactPresence: return Symbol.ContactPresence; - case Icon.Contact: return Symbol.Contact2; - case Icon.Folder: return Symbol.Folder; - case Icon.View: return Symbol.View; - case Icon.Permissions: return Symbol.Permissions; - case Icon.Map: return Symbol.Map; - case Icon.CellPhone: return Symbol.CellPhone; - case Icon.OutlineStar: return Symbol.OutlineStar; - case Icon.Calculator: return Symbol.Calculator; - case Icon.Library: return Symbol.Library; - case Icon.SyncFolder: return Symbol.SyncFolder; - case Icon.GoToStart: return Symbol.GoToStart; - case Icon.ZeroBars: return Symbol.ZeroBars; - case Icon.FourBars: return Symbol.FourBars; - case Icon.Scan: return Symbol.Scan; - case Icon.ReportHacked: return Symbol.ReportHacked; - default: return Symbol.Stop; - } - } - - public object ConvertBack(object value, Type targetType, object parameter, string language) - { - var symbol = (Symbol) value; - switch (symbol) - { - case Symbol.Delete: return Icon.Delete; - case Symbol.Edit: return Icon.Edit; - case Symbol.Save: return Icon.Save; - case Symbol.Cancel: return Icon.Cancel; - case Symbol.Accept: return Icon.Accept; - case Symbol.Home: return Icon.Home; - case Symbol.Camera: return Icon.Camera; - case Symbol.Setting: return Icon.Setting; - case Symbol.Mail: return Icon.Mail; - case Symbol.Find: return Icon.Find; - case Symbol.Help: return Icon.Help; - case Symbol.Clock: return Icon.Clock; - case Symbol.Crop: return Icon.Crop; - case Symbol.World: return Icon.World; - case Symbol.Flag: return Icon.Flag; - case Symbol.PreviewLink: return Icon.PreviewLink; - case Symbol.Document: return Icon.Document; - case Symbol.ProtectedDocument: return Icon.ProtectedDocument; - case Symbol.ContactInfo: return Icon.ContactInfo; - case Symbol.ViewAll: return Icon.ViewAll; - case Symbol.Rotate: return Icon.Rotate; - case Symbol.List: return Icon.List; - case Symbol.Shop: return Icon.Shop; - case Symbol.BrowsePhotos: return Icon.BrowsePhotos; - case Symbol.Caption: return Icon.Caption; - case Symbol.Repair: return Icon.Repair; - case Symbol.Page2: return Icon.Page; - case Symbol.Paste: return Icon.Paste; - case Symbol.Important: return Icon.Important; - case Symbol.SlideShow: return Icon.SlideShow; - case Symbol.MapDrive: return Icon.MapDrive; - case Symbol.ContactPresence: return Icon.ContactPresence; - case Symbol.Contact2: return Icon.Contact; - case Symbol.Folder: return Icon.Folder; - case Symbol.View: return Icon.View; - case Symbol.Permissions: return Icon.Permissions; - case Symbol.Map: return Icon.Map; - case Symbol.CellPhone: return Icon.CellPhone; - case Symbol.OutlineStar: return Icon.OutlineStar; - case Symbol.Calculator: return Icon.Calculator; - case Symbol.Library: return Icon.Library; - case Symbol.SyncFolder: return Icon.SyncFolder; - case Symbol.GoToStart: return Icon.GoToStart; - case Symbol.ZeroBars: return Icon.ZeroBars; - case Symbol.FourBars: return Icon.FourBars; - case Symbol.Scan: return Icon.Scan; - case Symbol.ReportHacked: return Icon.ReportHacked; - default: return Icon.Stop; - } - } - } -} \ No newline at end of file diff --git a/ModernKeePass10/Converters/InverseBooleanToVisibilityConverter.cs b/ModernKeePass10/Converters/InverseBooleanToVisibilityConverter.cs deleted file mode 100644 index e354271..0000000 --- a/ModernKeePass10/Converters/InverseBooleanToVisibilityConverter.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Data; - -namespace ModernKeePass.Converters -{ - public class InverseBooleanToVisibilityConverter : IValueConverter - { - public object Convert(object value, Type targetType, object parameter, string language) - { - var boolean = value as bool? ?? false; - return boolean ? Visibility.Collapsed : Visibility.Visible; - } - - // No need to implement this - public object ConvertBack(object value, Type targetType, object parameter, string language) - { - var visibility = value as Visibility? ?? Visibility.Visible; - switch (visibility) - { - case Visibility.Visible: return false; - case Visibility.Collapsed: return true; - default: - throw new ArgumentOutOfRangeException(nameof(value)); - } - } - } -} \ No newline at end of file diff --git a/ModernKeePass10/Converters/NullToBooleanConverter.cs b/ModernKeePass10/Converters/NullToBooleanConverter.cs deleted file mode 100644 index 667980f..0000000 --- a/ModernKeePass10/Converters/NullToBooleanConverter.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using Windows.UI.Xaml.Data; - -namespace ModernKeePass.Converters -{ - public class NullToBooleanConverter : IValueConverter - { - public object Convert(object value, Type targetType, object parameter, string language) - { - return value != null; - } - - public object ConvertBack(object value, Type targetType, object parameter, string language) - { - throw new NotImplementedException(); - } - } -} diff --git a/ModernKeePass10/Converters/PluralizationConverter.cs b/ModernKeePass10/Converters/PluralizationConverter.cs deleted file mode 100644 index e870363..0000000 --- a/ModernKeePass10/Converters/PluralizationConverter.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using Windows.UI.Xaml.Data; - -namespace ModernKeePass.Converters -{ - public class PluralizationConverter : IValueConverter - { - public object Convert(object value, Type targetType, object parameter, string language) - { - var pluralizationOptionString = parameter as string; - var pluralizationOptions = pluralizationOptionString?.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries); - if (pluralizationOptions == null || pluralizationOptions.Length != 2) return string.Empty; - var count = value is int ? (int) value : 0; - var text = count == 1 ? pluralizationOptions[0] : pluralizationOptions[1]; - return $"{count} {text}"; - } - - // No need to implement this - public object ConvertBack(object value, Type targetType, object parameter, string language) - { - throw new NotImplementedException(); - } - } -} diff --git a/ModernKeePass10/Converters/ProgressBarLegalValuesConverter.cs b/ModernKeePass10/Converters/ProgressBarLegalValuesConverter.cs deleted file mode 100644 index b6b84f4..0000000 --- a/ModernKeePass10/Converters/ProgressBarLegalValuesConverter.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using Windows.UI.Xaml.Data; - -namespace ModernKeePass.Converters -{ - public class ProgressBarLegalValuesConverter : IValueConverter - { - public object Convert(object value, Type targetType, object parameter, string language) - { - var legalValuesOptionString = parameter as string; - var legalValuesOptions = legalValuesOptionString?.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries); - if (legalValuesOptions == null || legalValuesOptions.Length != 2) return 0; - - var minValue = double.Parse(legalValuesOptions[0]); - var maxValue = double.Parse(legalValuesOptions[1]); - var count = value is double ? (double)value : 0; - if (count > maxValue) return maxValue; - if (count < minValue) return minValue; - return count; - } - - public object ConvertBack(object value, Type targetType, object parameter, string language) - { - throw new NotImplementedException(); - } - } -} diff --git a/ModernKeePass10/Converters/TextToWidthConverter.cs b/ModernKeePass10/Converters/TextToWidthConverter.cs deleted file mode 100644 index c3f1b24..0000000 --- a/ModernKeePass10/Converters/TextToWidthConverter.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using Windows.UI.Xaml.Data; - -namespace ModernKeePass.Converters -{ - public class TextToWidthConverter : IValueConverter - { - public object Convert(object value, Type targetType, object parameter, string language) - { - var fontSize = double.Parse(parameter as string); - var text = value as string; - return text?.Length * fontSize ?? 0; - } - - public object ConvertBack(object value, Type targetType, object parameter, string language) - { - throw new NotImplementedException(); - } - } -} diff --git a/ModernKeePass10/Events/PasswordEventArgs.cs b/ModernKeePass10/Events/PasswordEventArgs.cs deleted file mode 100644 index 51b97a4..0000000 --- a/ModernKeePass10/Events/PasswordEventArgs.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using ModernKeePass.Domain.Entities; - -namespace ModernKeePass.Events -{ - public class PasswordEventArgs: EventArgs - { - public GroupEntity RootGroupEntity { get; set; } - - public PasswordEventArgs(GroupEntity groupEntity) - { - RootGroupEntity = groupEntity; - } - } -} \ No newline at end of file diff --git a/ModernKeePass10/Extensions/DispatcherTaskExtensions.cs b/ModernKeePass10/Extensions/DispatcherTaskExtensions.cs deleted file mode 100644 index c0ecb9e..0000000 --- a/ModernKeePass10/Extensions/DispatcherTaskExtensions.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using System.Threading.Tasks; -using Windows.UI.Core; - -namespace ModernKeePass.Extensions -{ - public static class DispatcherTaskExtensions - { - public static async Task RunTaskAsync(this CoreDispatcher dispatcher, - Func> func, CoreDispatcherPriority priority = CoreDispatcherPriority.Normal) - { - var taskCompletionSource = new TaskCompletionSource(); - await dispatcher.RunAsync(priority, async () => - { - try - { - taskCompletionSource.SetResult(await func()); - } - catch (Exception ex) - { - taskCompletionSource.SetException(ex); - } - }); - return await taskCompletionSource.Task; - } - - // There is no TaskCompletionSource so we use a bool that we throw away. - public static async Task RunTaskAsync(this CoreDispatcher dispatcher, - Func func, CoreDispatcherPriority priority = CoreDispatcherPriority.Normal) => - await RunTaskAsync(dispatcher, async () => { await func(); return false; }, priority); - } -} \ No newline at end of file diff --git a/ModernKeePass10/TemplateSelectors/FirstItemDataTemplateSelector.cs b/ModernKeePass10/TemplateSelectors/FirstItemDataTemplateSelector.cs deleted file mode 100644 index e363d22..0000000 --- a/ModernKeePass10/TemplateSelectors/FirstItemDataTemplateSelector.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; - -namespace ModernKeePass.TemplateSelectors -{ - public class FirstItemDataTemplateSelector: DataTemplateSelector - { - public DataTemplate FirstItem { get; set; } - public DataTemplate OtherItem { get; set; } - - protected override DataTemplate SelectTemplateCore(object item, DependencyObject container) - { - var itemsControl = ItemsControl.ItemsControlFromItemContainer(container); - var returnTemplate = itemsControl?.IndexFromContainer(container) == 0 ? FirstItem : OtherItem; - return returnTemplate; - } - } -} \ No newline at end of file diff --git a/ModernKeePass10/TemplateSelectors/SelectableDataTemplateSelector.cs b/ModernKeePass10/TemplateSelectors/SelectableDataTemplateSelector.cs deleted file mode 100644 index 115beb5..0000000 --- a/ModernKeePass10/TemplateSelectors/SelectableDataTemplateSelector.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using ModernKeePass.Application.Common.Interfaces; -using ModernKeePass.Domain.Interfaces; - -namespace ModernKeePass.TemplateSelectors -{ - public class SelectableDataTemplateSelector: DataTemplateSelector - { - public DataTemplate TrueItem { get; set; } - public DataTemplate FalseItem { get; set; } - - protected override DataTemplate SelectTemplateCore(object item, DependencyObject container) - { - return item is ISelectableModel isSelectableItem && isSelectableItem.IsSelected ? TrueItem : FalseItem; - } - } -} diff --git a/ModernKeePass10/Win10App.csproj b/ModernKeePass10/Win10App.csproj index d4ca446..df4d083 100644 --- a/ModernKeePass10/Win10App.csproj +++ b/ModernKeePass10/Win10App.csproj @@ -94,16 +94,9 @@ true - - - - - App.xaml - - UpdateCredentialsUserControl.xaml @@ -114,7 +107,6 @@ - @@ -133,16 +125,6 @@ DonatePage.xaml - - - - - - - - - - ImportExportPage.xaml @@ -165,8 +147,6 @@ SettingsWelcomePage.xaml - - BreadCrumbUserControl.xaml @@ -176,15 +156,6 @@ CredentialsUserControl.xaml - - - - - - - - - MainPage.xaml @@ -513,6 +484,7 @@ Infrastructure + 14.0 diff --git a/ModernKeePass/Actions/ClipboardAction.cs b/WinAppCommon/Actions/ClipboardAction.cs similarity index 100% rename from ModernKeePass/Actions/ClipboardAction.cs rename to WinAppCommon/Actions/ClipboardAction.cs diff --git a/ModernKeePass/Actions/NavigateToUrlAction.cs b/WinAppCommon/Actions/NavigateToUrlAction.cs similarity index 100% rename from ModernKeePass/Actions/NavigateToUrlAction.cs rename to WinAppCommon/Actions/NavigateToUrlAction.cs diff --git a/ModernKeePass/Actions/SetupFocusAction.cs b/WinAppCommon/Actions/SetupFocusAction.cs similarity index 100% rename from ModernKeePass/Actions/SetupFocusAction.cs rename to WinAppCommon/Actions/SetupFocusAction.cs diff --git a/ModernKeePass/Actions/ToastAction.cs b/WinAppCommon/Actions/ToastAction.cs similarity index 100% rename from ModernKeePass/Actions/ToastAction.cs rename to WinAppCommon/Actions/ToastAction.cs diff --git a/ModernKeePass/Common/Constants.cs b/WinAppCommon/Common/Constants.cs similarity index 100% rename from ModernKeePass/Common/Constants.cs rename to WinAppCommon/Common/Constants.cs diff --git a/ModernKeePass/Common/MessageDialogHelper.cs b/WinAppCommon/Common/MessageDialogHelper.cs similarity index 100% rename from ModernKeePass/Common/MessageDialogHelper.cs rename to WinAppCommon/Common/MessageDialogHelper.cs diff --git a/ModernKeePass/Common/NavigationHelper.cs b/WinAppCommon/Common/NavigationHelper.cs similarity index 100% rename from ModernKeePass/Common/NavigationHelper.cs rename to WinAppCommon/Common/NavigationHelper.cs diff --git a/ModernKeePass/Common/ObservableDictionary.cs b/WinAppCommon/Common/ObservableDictionary.cs similarity index 100% rename from ModernKeePass/Common/ObservableDictionary.cs rename to WinAppCommon/Common/ObservableDictionary.cs diff --git a/ModernKeePass/Common/RelayCommand.cs b/WinAppCommon/Common/RelayCommand.cs similarity index 100% rename from ModernKeePass/Common/RelayCommand.cs rename to WinAppCommon/Common/RelayCommand.cs diff --git a/ModernKeePass/Common/SuspensionManager.cs b/WinAppCommon/Common/SuspensionManager.cs similarity index 100% rename from ModernKeePass/Common/SuspensionManager.cs rename to WinAppCommon/Common/SuspensionManager.cs diff --git a/ModernKeePass/Common/ToastNotificationHelper.cs b/WinAppCommon/Common/ToastNotificationHelper.cs similarity index 100% rename from ModernKeePass/Common/ToastNotificationHelper.cs rename to WinAppCommon/Common/ToastNotificationHelper.cs diff --git a/ModernKeePass/Controls/ListViewWithDisable.cs b/WinAppCommon/Controls/ListViewWithDisable.cs similarity index 100% rename from ModernKeePass/Controls/ListViewWithDisable.cs rename to WinAppCommon/Controls/ListViewWithDisable.cs diff --git a/ModernKeePass/Controls/TextBoxWithButton.cs b/WinAppCommon/Controls/TextBoxWithButton.cs similarity index 100% rename from ModernKeePass/Controls/TextBoxWithButton.cs rename to WinAppCommon/Controls/TextBoxWithButton.cs diff --git a/ModernKeePass/Converters/BooleanToVisibilityConverter.cs b/WinAppCommon/Converters/BooleanToVisibilityConverter.cs similarity index 100% rename from ModernKeePass/Converters/BooleanToVisibilityConverter.cs rename to WinAppCommon/Converters/BooleanToVisibilityConverter.cs diff --git a/ModernKeePass/Converters/ColorToBrushConverter.cs b/WinAppCommon/Converters/ColorToBrushConverter.cs similarity index 100% rename from ModernKeePass/Converters/ColorToBrushConverter.cs rename to WinAppCommon/Converters/ColorToBrushConverter.cs diff --git a/ModernKeePass/Converters/DiscreteIntToSolidColorBrushConverter.cs b/WinAppCommon/Converters/DiscreteIntToSolidColorBrushConverter.cs similarity index 100% rename from ModernKeePass/Converters/DiscreteIntToSolidColorBrushConverter.cs rename to WinAppCommon/Converters/DiscreteIntToSolidColorBrushConverter.cs diff --git a/ModernKeePass/Converters/DoubleToSolidColorBrushConverter.cs b/WinAppCommon/Converters/DoubleToSolidColorBrushConverter.cs similarity index 100% rename from ModernKeePass/Converters/DoubleToSolidColorBrushConverter.cs rename to WinAppCommon/Converters/DoubleToSolidColorBrushConverter.cs diff --git a/ModernKeePass/Converters/EmptyStringToVisibilityConverter.cs b/WinAppCommon/Converters/EmptyStringToVisibilityConverter.cs similarity index 100% rename from ModernKeePass/Converters/EmptyStringToVisibilityConverter.cs rename to WinAppCommon/Converters/EmptyStringToVisibilityConverter.cs diff --git a/ModernKeePass/Converters/IconToSymbolConverter.cs b/WinAppCommon/Converters/IconToSymbolConverter.cs similarity index 100% rename from ModernKeePass/Converters/IconToSymbolConverter.cs rename to WinAppCommon/Converters/IconToSymbolConverter.cs diff --git a/ModernKeePass/Converters/InverseBooleanToVisibilityConverter.cs b/WinAppCommon/Converters/InverseBooleanToVisibilityConverter.cs similarity index 100% rename from ModernKeePass/Converters/InverseBooleanToVisibilityConverter.cs rename to WinAppCommon/Converters/InverseBooleanToVisibilityConverter.cs diff --git a/ModernKeePass/Converters/NullToBooleanConverter.cs b/WinAppCommon/Converters/NullToBooleanConverter.cs similarity index 100% rename from ModernKeePass/Converters/NullToBooleanConverter.cs rename to WinAppCommon/Converters/NullToBooleanConverter.cs diff --git a/ModernKeePass/Converters/PluralizationConverter.cs b/WinAppCommon/Converters/PluralizationConverter.cs similarity index 100% rename from ModernKeePass/Converters/PluralizationConverter.cs rename to WinAppCommon/Converters/PluralizationConverter.cs diff --git a/ModernKeePass/Converters/ProgressBarLegalValuesConverter.cs b/WinAppCommon/Converters/ProgressBarLegalValuesConverter.cs similarity index 100% rename from ModernKeePass/Converters/ProgressBarLegalValuesConverter.cs rename to WinAppCommon/Converters/ProgressBarLegalValuesConverter.cs diff --git a/ModernKeePass/Converters/TextToWidthConverter.cs b/WinAppCommon/Converters/TextToWidthConverter.cs similarity index 100% rename from ModernKeePass/Converters/TextToWidthConverter.cs rename to WinAppCommon/Converters/TextToWidthConverter.cs diff --git a/ModernKeePass/Events/PasswordEventArgs.cs b/WinAppCommon/Events/PasswordEventArgs.cs similarity index 100% rename from ModernKeePass/Events/PasswordEventArgs.cs rename to WinAppCommon/Events/PasswordEventArgs.cs diff --git a/ModernKeePass/Extensions/ColorExtensions.cs b/WinAppCommon/Extensions/ColorExtensions.cs similarity index 100% rename from ModernKeePass/Extensions/ColorExtensions.cs rename to WinAppCommon/Extensions/ColorExtensions.cs diff --git a/ModernKeePass/Extensions/DispatcherTaskExtensions.cs b/WinAppCommon/Extensions/DispatcherTaskExtensions.cs similarity index 100% rename from ModernKeePass/Extensions/DispatcherTaskExtensions.cs rename to WinAppCommon/Extensions/DispatcherTaskExtensions.cs diff --git a/ModernKeePass/TemplateSelectors/FirstItemDataTemplateSelector.cs b/WinAppCommon/TemplateSelectors/FirstItemDataTemplateSelector.cs similarity index 100% rename from ModernKeePass/TemplateSelectors/FirstItemDataTemplateSelector.cs rename to WinAppCommon/TemplateSelectors/FirstItemDataTemplateSelector.cs diff --git a/ModernKeePass/TemplateSelectors/SelectableDataTemplateSelector.cs b/WinAppCommon/TemplateSelectors/SelectableDataTemplateSelector.cs similarity index 100% rename from ModernKeePass/TemplateSelectors/SelectableDataTemplateSelector.cs rename to WinAppCommon/TemplateSelectors/SelectableDataTemplateSelector.cs diff --git a/WinAppCommon/WinAppCommon.projitems b/WinAppCommon/WinAppCommon.projitems new file mode 100644 index 0000000..94343b7 --- /dev/null +++ b/WinAppCommon/WinAppCommon.projitems @@ -0,0 +1,42 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + a66b7a53-1d8f-41e2-a8ab-840c81b1aa92 + + + ModernKeePass + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/WinAppCommon/WinAppCommon.shproj b/WinAppCommon/WinAppCommon.shproj new file mode 100644 index 0000000..439a911 --- /dev/null +++ b/WinAppCommon/WinAppCommon.shproj @@ -0,0 +1,13 @@ + + + + a66b7a53-1d8f-41e2-a8ab-840c81b1aa92 + 14.0 + + + + + + + +