mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Added Utilities to change DPIAwareness
This commit is contained in:
parent
5d6a2610b9
commit
6ffa53f6ee
@ -14,6 +14,7 @@ using Artemis.UI.Services;
|
|||||||
using Artemis.UI.Shared;
|
using Artemis.UI.Shared;
|
||||||
using Artemis.UI.Shared.Services;
|
using Artemis.UI.Shared.Services;
|
||||||
using Artemis.UI.Stylet;
|
using Artemis.UI.Stylet;
|
||||||
|
using Artemis.UI.Utilities;
|
||||||
using Ninject;
|
using Ninject;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using Stylet;
|
using Stylet;
|
||||||
@ -47,6 +48,8 @@ namespace Artemis.UI
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try { DPIAwareness.Initalize(); } catch (Exception ex) { logger.Error($"Failed to set DPI-Awareness: {ex.Message}"); }
|
||||||
|
|
||||||
IViewManager viewManager = Kernel.Get<IViewManager>();
|
IViewManager viewManager = Kernel.Get<IViewManager>();
|
||||||
StartupArguments = Args.ToList();
|
StartupArguments = Args.ToList();
|
||||||
|
|
||||||
@ -68,7 +71,7 @@ namespace Artemis.UI
|
|||||||
Execute.OnUIThreadSync(() =>
|
Execute.OnUIThreadSync(() =>
|
||||||
{
|
{
|
||||||
UIElement view = viewManager.CreateAndBindViewForModelIfNecessary(RootViewModel);
|
UIElement view = viewManager.CreateAndBindViewForModelIfNecessary(RootViewModel);
|
||||||
((TrayViewModel) RootViewModel).SetTaskbarIcon(view);
|
((TrayViewModel)RootViewModel).SetTaskbarIcon(view);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Initialize the core async so the UI can show the progress
|
// Initialize the core async so the UI can show the progress
|
||||||
|
|||||||
@ -1,11 +1,14 @@
|
|||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using System.Windows.Media;
|
||||||
|
|
||||||
// Setting ComVisible to false makes the types in this assembly not visible
|
// 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
|
// to COM components. If you need to access a type in this assembly from
|
||||||
// COM, set the ComVisible attribute to true on that type.
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
[assembly: DisableDpiAwareness]
|
||||||
|
|
||||||
//In order to begin building localizable applications, set
|
//In order to begin building localizable applications, set
|
||||||
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
|
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
|
||||||
//inside a <PropertyGroup>. For example, if you are using US english
|
//inside a <PropertyGroup>. For example, if you are using US english
|
||||||
@ -15,7 +18,6 @@ using System.Windows;
|
|||||||
|
|
||||||
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
||||||
|
|
||||||
|
|
||||||
[assembly: ThemeInfo(
|
[assembly: ThemeInfo(
|
||||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||||
//(used if a resource is not found in the page,
|
//(used if a resource is not found in the page,
|
||||||
|
|||||||
36
src/Artemis.UI/Utilities/DPIAwareness.cs
Normal file
36
src/Artemis.UI/Utilities/DPIAwareness.cs
Normal file
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user