mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Calculate screen size using DPI aware routeins (#545)
This commit is contained in:
parent
6f80a40dc9
commit
5b41e2d311
@ -6,6 +6,7 @@
|
||||
* Don't print API keys in logs (#533)
|
||||
* Store xxHash caches in binary format (#530)
|
||||
* Added support for Morrowind BSA creation/unpacking
|
||||
* Calculate screen size using DPI aware routines (#545)
|
||||
|
||||
|
||||
#### Version - 0.9.19.0
|
||||
|
@ -1,16 +1,53 @@
|
||||
using MahApps.Metro.Controls;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using MahApps.Metro.Controls;
|
||||
using Microsoft.VisualBasic;
|
||||
using PInvoke;
|
||||
using Wabbajack.Lib;
|
||||
using static PInvoke.User32;
|
||||
using static PInvoke.Gdi32;
|
||||
|
||||
namespace Wabbajack.Util
|
||||
{
|
||||
// Much of the GDI code here is taken from : https://github.com/ModOrganizer2/modorganizer/blob/master/src/envmetrics.cpp
|
||||
// Thanks to MO2 for being good citizens and supporting OSS code
|
||||
public static class SystemParametersConstructor
|
||||
{
|
||||
private static List<(int Width, int Height, bool IsPrimary)> GetDisplays()
|
||||
{
|
||||
// Needed to make sure we get the right values from this call
|
||||
SetProcessDPIAware();
|
||||
unsafe
|
||||
{
|
||||
|
||||
var col = new List<(int Width, int Height, bool IsPrimary)>();
|
||||
|
||||
EnumDisplayMonitors(IntPtr.Zero, IntPtr.Zero,
|
||||
delegate(IntPtr hMonitor, IntPtr hdcMonitor, RECT* lprcMonitor, void *dwData)
|
||||
{
|
||||
MONITORINFOEX mi = new MONITORINFOEX();
|
||||
mi.cbSize = Marshal.SizeOf(mi);
|
||||
bool success = GetMonitorInfo(hMonitor, (MONITORINFO*)&mi);
|
||||
if (success)
|
||||
{
|
||||
col.Add(((mi.Monitor.right - mi.Monitor.left), (mi.Monitor.bottom - mi.Monitor.top), mi.Flags == 1));
|
||||
}
|
||||
|
||||
return true;
|
||||
}, IntPtr.Zero);
|
||||
return col;
|
||||
}
|
||||
}
|
||||
|
||||
public static SystemParameters Create()
|
||||
{
|
||||
var (width, height, _) = GetDisplays().First(d => d.IsPrimary);
|
||||
return new SystemParameters
|
||||
{
|
||||
ScreenWidth = (int)System.Windows.SystemParameters.PrimaryScreenWidth,
|
||||
ScreenHeight = (int)System.Windows.SystemParameters.PrimaryScreenHeight
|
||||
ScreenWidth = width,
|
||||
ScreenHeight = height
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
<Description>An automated ModList installer</Description>
|
||||
<PublishReadyToRun>true</PublishReadyToRun>
|
||||
<StartupObject></StartupObject>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
@ -65,6 +66,8 @@
|
||||
</PackageReference>
|
||||
<PackageReference Include="MahApps.Metro" Version="2.0.0-alpha0660" />
|
||||
<PackageReference Include="MahApps.Metro.IconPacks" Version="3.2.0" />
|
||||
<PackageReference Include="PInvoke.Gdi32" Version="0.6.6" />
|
||||
<PackageReference Include="PInvoke.User32" Version="0.6.6" />
|
||||
<PackageReference Include="ReactiveUI" Version="11.1.23" />
|
||||
<PackageReference Include="ReactiveUI.Fody" Version="11.1.23" />
|
||||
<PackageReference Include="ReactiveUI.WPF" Version="11.1.23" />
|
||||
|
Loading…
Reference in New Issue
Block a user