From 6ffa53f6eed834de8765ee5dbe9911ef5ed3c7bb Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Wed, 7 Apr 2021 16:39:35 +0200 Subject: [PATCH 1/5] Added Utilities to change DPIAwareness --- src/Artemis.UI/Bootstrapper.cs | 5 +++- src/Artemis.UI/Properties/AssemblyInfo.cs | 4 ++- src/Artemis.UI/Utilities/DPIAwareness.cs | 36 +++++++++++++++++++++++ 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 src/Artemis.UI/Utilities/DPIAwareness.cs diff --git a/src/Artemis.UI/Bootstrapper.cs b/src/Artemis.UI/Bootstrapper.cs index 471d56412..11d1f56c9 100644 --- a/src/Artemis.UI/Bootstrapper.cs +++ b/src/Artemis.UI/Bootstrapper.cs @@ -14,6 +14,7 @@ using Artemis.UI.Services; using Artemis.UI.Shared; using Artemis.UI.Shared.Services; using Artemis.UI.Stylet; +using Artemis.UI.Utilities; using Ninject; using Serilog; using Stylet; @@ -47,6 +48,8 @@ namespace Artemis.UI return; } + try { DPIAwareness.Initalize(); } catch (Exception ex) { logger.Error($"Failed to set DPI-Awareness: {ex.Message}"); } + IViewManager viewManager = Kernel.Get(); StartupArguments = Args.ToList(); @@ -68,7 +71,7 @@ namespace Artemis.UI Execute.OnUIThreadSync(() => { UIElement view = viewManager.CreateAndBindViewForModelIfNecessary(RootViewModel); - ((TrayViewModel) RootViewModel).SetTaskbarIcon(view); + ((TrayViewModel)RootViewModel).SetTaskbarIcon(view); }); // Initialize the core async so the UI can show the progress diff --git a/src/Artemis.UI/Properties/AssemblyInfo.cs b/src/Artemis.UI/Properties/AssemblyInfo.cs index 412a20daf..aee89dd05 100644 --- a/src/Artemis.UI/Properties/AssemblyInfo.cs +++ b/src/Artemis.UI/Properties/AssemblyInfo.cs @@ -1,11 +1,14 @@ using System.Runtime.InteropServices; using System.Windows; +using System.Windows.Media; // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] +[assembly: DisableDpiAwareness] + //In order to begin building localizable applications, set //CultureYouAreCodingWith in your .csproj file //inside a . For example, if you are using US english @@ -15,7 +18,6 @@ using System.Windows; //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] - [assembly: ThemeInfo( ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located //(used if a resource is not found in the page, diff --git a/src/Artemis.UI/Utilities/DPIAwareness.cs b/src/Artemis.UI/Utilities/DPIAwareness.cs new file mode 100644 index 000000000..1a89562a2 --- /dev/null +++ b/src/Artemis.UI/Utilities/DPIAwareness.cs @@ -0,0 +1,36 @@ +using System.Runtime.InteropServices; + +namespace Artemis.UI.Utilities +{ + public static class DPIAwareness + { + [DllImport("user32.dll", SetLastError = true)] + internal static extern bool SetProcessDpiAwarenessContext(int dpiFlag); + + [DllImport("SHCore.dll", SetLastError = true)] + internal static extern bool SetProcessDpiAwareness(PROCESS_DPI_AWARENESS awareness); + + [DllImport("user32.dll")] + internal static extern bool SetProcessDPIAware(); + + internal enum PROCESS_DPI_AWARENESS + { + Process_DPI_Unaware = 0, + Process_System_DPI_Aware = 1, + Process_Per_Monitor_DPI_Aware = 2 + } + + internal enum DPI_AWARENESS_CONTEXT + { + DPI_AWARENESS_CONTEXT_UNAWARE = 16, + DPI_AWARENESS_CONTEXT_SYSTEM_AWARE = 17, + DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE = 18, + DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 = 34 + } + + public static void Initalize() + { + SetProcessDpiAwarenessContext((int)DPI_AWARENESS_CONTEXT.DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); + } + } +} From 20452110b1569d8b29787c769c7c5f9e4560e157 Mon Sep 17 00:00:00 2001 From: Robert Date: Wed, 7 Apr 2021 19:27:57 +0200 Subject: [PATCH 2/5] Meta - Updated Nuget packages UI - Use Material Design filled input style where possible --- src/Artemis.Core/Artemis.Core.csproj | 10 +- src/Artemis.Core/Constants.cs | 2 +- src/Artemis.Core/packages.lock.json | 47 ++++---- src/Artemis.Storage/Artemis.Storage.csproj | 2 +- src/Artemis.Storage/packages.lock.json | 6 +- .../Artemis.UI.Shared.csproj | 12 +- .../Controls/ColorPicker.xaml | 20 ++-- .../Controls/ColorPicker.xaml.cs | 75 +++++++------ .../Screens/Exceptions/ExceptionView.xaml | 67 ++++++----- .../Screens/Exceptions/ExceptionViewModel.cs | 42 +++---- .../Services/Dialog/DialogService.cs | 25 +++-- .../Services/Interfaces/IDialogService.cs | 8 +- .../Services/Message/IMessageService.cs | 18 +-- .../Services/Message/MessageService.cs | 14 +-- src/Artemis.UI.Shared/packages.lock.json | 90 ++++++++------- src/Artemis.UI/Artemis.UI.csproj | 14 +-- src/Artemis.UI/Screens/Home/HomeView.xaml | 4 +- .../Tabs/ActivationRequirementsView.xaml | 2 +- .../Dialogs/ProfileCreateView.xaml | 9 +- .../Dialogs/ProfileEditView.xaml | 9 +- .../Dialogs/ProfileImportView.xaml | 19 ++-- .../Dialogs/ProfileImportViewModel.cs | 7 +- .../ProfileEditor/Dialogs/RenameView.xaml | 19 +--- .../DataBindings/DataBindingView.xaml | 28 ++--- .../LayerProperties/LayerPropertiesView.xaml | 6 +- .../Dialogs/TimelineSegmentDialogView.xaml | 6 +- .../Dialogs/TimelineSegmentDialogViewModel.cs | 6 +- .../UserControls/LayerShapeControl.xaml | 18 +-- src/Artemis.UI/Screens/RootViewModel.cs | 2 +- .../Settings/Device/DeviceDialogViewModel.cs | 1 + .../Device/Tabs/DevicePropertiesTabView.xaml | 48 ++++---- .../Tabs/General/GeneralSettingsTabView.xaml | 44 ++++++-- .../Tabs/Plugins/PluginSettingsTabView.xaml | 9 +- .../Tabs/Plugins/PluginSettingsViewModel.cs | 1 + .../Dialogs/SurfaceCreateView.xaml | 41 ------- .../Dialogs/SurfaceCreateViewModel.cs | 31 ------ .../SurfaceCreateViewModelValidator.cs | 12 -- src/Artemis.UI/Services/UpdateService.cs | 1 + src/Artemis.UI/packages.lock.json | 104 +++++++++--------- 39 files changed, 419 insertions(+), 460 deletions(-) delete mode 100644 src/Artemis.UI/Screens/SurfaceEditor/Dialogs/SurfaceCreateView.xaml delete mode 100644 src/Artemis.UI/Screens/SurfaceEditor/Dialogs/SurfaceCreateViewModel.cs delete mode 100644 src/Artemis.UI/Screens/SurfaceEditor/Dialogs/SurfaceCreateViewModelValidator.cs diff --git a/src/Artemis.Core/Artemis.Core.csproj b/src/Artemis.Core/Artemis.Core.csproj index 6f8b98767..def264e11 100644 --- a/src/Artemis.Core/Artemis.Core.csproj +++ b/src/Artemis.Core/Artemis.Core.csproj @@ -38,19 +38,19 @@ - + - + - + - + @@ -58,7 +58,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Artemis.Core/Constants.cs b/src/Artemis.Core/Constants.cs index 21c2ca973..4c22e8728 100644 --- a/src/Artemis.Core/Constants.cs +++ b/src/Artemis.Core/Constants.cs @@ -47,7 +47,7 @@ namespace Artemis.Core /// Information is retrieved from buildinfo.json /// public static readonly BuildInfo BuildInfo = File.Exists(Path.Combine(ApplicationFolder, "buildinfo.json")) - ? JsonConvert.DeserializeObject(File.ReadAllText(Path.Combine(ApplicationFolder, "buildinfo.json"))) + ? JsonConvert.DeserializeObject(File.ReadAllText(Path.Combine(ApplicationFolder, "buildinfo.json")))! : new BuildInfo { IsLocalBuild = true, diff --git a/src/Artemis.Core/packages.lock.json b/src/Artemis.Core/packages.lock.json index c422d273d..34a88ddd7 100644 --- a/src/Artemis.Core/packages.lock.json +++ b/src/Artemis.Core/packages.lock.json @@ -4,12 +4,11 @@ ".NETCoreApp,Version=v5.0": { "Ben.Demystifier": { "type": "Direct", - "requested": "[0.1.6, )", - "resolved": "0.1.6", - "contentHash": "sYI8+ANUo78i/vIq9Vjrjjl6A00yVbT6XsuSVvUMVRVEKJHXZu4VE00RZHg/CA7QxmaQ1zfw/Bs6DAU+OJUNAg==", + "requested": "[0.3.0, )", + "resolved": "0.3.0", + "contentHash": "7mTSt0PLeXomarrTXdLcdYAg+zaOunw3KEvWKQ0fQaGySwqOzGxKVq8BDgUXWAyBH2hKhXldkG7uKJGkYBhDiw==", "dependencies": { - "System.Reflection.Metadata": "1.6.0", - "System.Threading.Tasks.Extensions": "4.5.3" + "System.Reflection.Metadata": "5.0.0" } }, "EmbedIO": { @@ -35,9 +34,9 @@ }, "LiteDB": { "type": "Direct", - "requested": "[5.0.9, )", - "resolved": "5.0.9", - "contentHash": "cWnNWXL+qaP/qrkUCYZHBUJcv+IsfJfofa+Ed4EyT0zs/gkXqfKvjTbS3uSMBfcd9I7Yf+q9YPmCpmVFrVGQtw==" + "requested": "[5.0.10, )", + "resolved": "5.0.10", + "contentHash": "x70WuqMDuP75dajqSLvO+AnI/BbwS6da+ukTO7rueV7VoXoQ5CRA9FV4r7cOS4OUr2NS1Up7LDIutjCxQycRvg==" }, "McMaster.NETCore.Plugins": { "type": "Direct", @@ -51,9 +50,9 @@ }, "Newtonsoft.Json": { "type": "Direct", - "requested": "[12.0.3, )", - "resolved": "12.0.3", - "contentHash": "6mgjfnRB4jKMlzHSl+VD+oUc1IebOZabkbyWj2RiTgWwYPPuaK1H97G1sHqGwPlS5npiF5Q0OrxN1wni2n5QWg==" + "requested": "[13.0.1, )", + "resolved": "13.0.1", + "contentHash": "ppPFpBcvxdsfUonNcvITKqLl3bqxWbDCZIzDWHzjpdAHRFfZe0Dw9HmA0+za13IdyrgJwpkDTDA9fHaxOrt20A==" }, "Ninject": { "type": "Direct", @@ -101,12 +100,11 @@ }, "Serilog.Sinks.Debug": { "type": "Direct", - "requested": "[1.0.1, )", - "resolved": "1.0.1", - "contentHash": "nE5wvw9+J/V4lA+rEkFUETGjBabK8IlLQY5Z9KDzoo5LvILC4vhTOXLs7DGYs8h5juIf2nLZnVxHDXf404FqEQ==", + "requested": "[2.0.0, )", + "resolved": "2.0.0", + "contentHash": "Y6g3OBJ4JzTyyw16fDqtFcQ41qQAydnEvEqmXjhwhgjsnG/FaJ8GUqF5ldsC/bVkK8KYmqrPhDO+tm4dF6xx4A==", "dependencies": { - "Serilog": "2.5.0", - "System.Diagnostics.Debug": "4.3.0" + "Serilog": "2.10.0" } }, "Serilog.Sinks.File": { @@ -166,9 +164,9 @@ }, "Unclassified.NetRevisionTask": { "type": "Direct", - "requested": "[0.3.0, )", - "resolved": "0.3.0", - "contentHash": "KwOAbbcAoaOIsyszuOv7ZeLEHfata70iM+0h1jMoMXs87EMXr5E8cFYRrCFbJDdd4Do9dK+L3gwNWjfg/ROUWw==" + "requested": "[0.4.0, )", + "resolved": "0.4.0", + "contentHash": "2Tzz6qoQNciyO4uT6wxByMiyvbve+u4eFIiDewDUbeHuxr/rKuba3/EhhXDsEH9WoKzYlpzqxDfQGPE/bIe5Rw==" }, "Castle.Core": { "type": "Transitive", @@ -1164,8 +1162,13 @@ }, "System.Threading.Tasks.Extensions": { "type": "Transitive", - "resolved": "4.5.3", - "contentHash": "+MvhNtcvIbqmhANyKu91jQnvIRVSTiaOiFNfKWwXGHG48YAb4I/TyH8spsySiPYla7gKal5ZnF3teJqZAximyQ==" + "resolved": "4.3.0", + "contentHash": "npvJkVKl5rKXrtl1Kkm6OhOUaYGEiF9wFbppFRWSMoApKzt2PiPHT2Bb8a5sAWxprvdOAtvaARS9QYMznEUtug==", + "dependencies": { + "System.Collections": "4.3.0", + "System.Runtime": "4.3.0", + "System.Threading.Tasks": "4.3.0" + } }, "System.Threading.Timer": { "type": "Transitive", @@ -1243,7 +1246,7 @@ "artemis.storage": { "type": "Project", "dependencies": { - "LiteDB": "5.0.9", + "LiteDB": "5.0.10", "Serilog": "2.10.0" } } diff --git a/src/Artemis.Storage/Artemis.Storage.csproj b/src/Artemis.Storage/Artemis.Storage.csproj index 4f7e14036..5b7bf94ff 100644 --- a/src/Artemis.Storage/Artemis.Storage.csproj +++ b/src/Artemis.Storage/Artemis.Storage.csproj @@ -9,7 +9,7 @@ - + \ No newline at end of file diff --git a/src/Artemis.Storage/packages.lock.json b/src/Artemis.Storage/packages.lock.json index 64d0ada35..80dc5f587 100644 --- a/src/Artemis.Storage/packages.lock.json +++ b/src/Artemis.Storage/packages.lock.json @@ -4,9 +4,9 @@ ".NETCoreApp,Version=v5.0": { "LiteDB": { "type": "Direct", - "requested": "[5.0.9, )", - "resolved": "5.0.9", - "contentHash": "cWnNWXL+qaP/qrkUCYZHBUJcv+IsfJfofa+Ed4EyT0zs/gkXqfKvjTbS3uSMBfcd9I7Yf+q9YPmCpmVFrVGQtw==" + "requested": "[5.0.10, )", + "resolved": "5.0.10", + "contentHash": "x70WuqMDuP75dajqSLvO+AnI/BbwS6da+ukTO7rueV7VoXoQ5CRA9FV4r7cOS4OUr2NS1Up7LDIutjCxQycRvg==" }, "Serilog": { "type": "Direct", diff --git a/src/Artemis.UI.Shared/Artemis.UI.Shared.csproj b/src/Artemis.UI.Shared/Artemis.UI.Shared.csproj index 9cd78aa94..893ff97d3 100644 --- a/src/Artemis.UI.Shared/Artemis.UI.Shared.csproj +++ b/src/Artemis.UI.Shared/Artemis.UI.Shared.csproj @@ -33,20 +33,20 @@ bin\Artemis.UI.Shared.xml - + - - - + + + - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Artemis.UI.Shared/Controls/ColorPicker.xaml b/src/Artemis.UI.Shared/Controls/ColorPicker.xaml index 7b671e60d..740f659f0 100644 --- a/src/Artemis.UI.Shared/Controls/ColorPicker.xaml +++ b/src/Artemis.UI.Shared/Controls/ColorPicker.xaml @@ -66,17 +66,23 @@ + HorizontalAlignment="Stretch"> + +