Skip to content
This repository has been archived by the owner on May 19, 2022. It is now read-only.

Commit

Permalink
Improved HighDPI support
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton Kasyanov committed Nov 8, 2017
1 parent e682cba commit faa423a
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 20 deletions.
15 changes: 10 additions & 5 deletions Eve-O-Preview/Eve-O-Preview.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,16 @@
</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup />
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="Costura, Version=1.6.2.0, Culture=neutral, PublicKeyToken=9919ef960d84173d, processorArchitecture=MSIL">
<HintPath>..\packages\Costura.Fody.1.6.2\lib\dotnet\Costura.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="LightInject">
<HintPath>R:\eve-o-preview\packages\LightInject.5.1.0\lib\net452\LightInject.dll</HintPath>
<Private>True</Private>
<Reference Include="LightInject, Version=5.1.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\LightInject.5.1.1\lib\net452\LightInject.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>R:\eve-o-preview\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
Expand Down Expand Up @@ -178,6 +180,7 @@
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<EmbeddedResource Include="app.manifest" />
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
Expand All @@ -189,15 +192,17 @@
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Fody.2.1.2\build\netstandard1.0\Fody.targets" Condition="Exists('..\packages\Fody.2.1.2\build\netstandard1.0\Fody.targets')" />
<Import Project="..\packages\Fody.2.2.0\build\netstandard1.2\Fody.targets" Condition="Exists('..\packages\Fody.2.2.0\build\netstandard1.2\Fody.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Fody.2.1.2\build\netstandard1.0\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.2.1.2\build\netstandard1.0\Fody.targets'))" />
<Error Condition="!Exists('..\packages\Fody.2.2.0\build\netstandard1.2\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.2.2.0\build\netstandard1.2\Fody.targets'))" />
<Error Condition="!Exists('..\packages\Costura.Fody.1.6.2\build\dotnet\Costura.Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Costura.Fody.1.6.2\build\dotnet\Costura.Fody.targets'))" />
<Error Condition="!Exists('R:\eve-o-preview\packages\Fody.2.2.0\build\net452\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', 'R:\eve-o-preview\packages\Fody.2.2.0\build\net452\Fody.targets'))" />
</Target>
<Import Project="..\packages\Costura.Fody.1.6.2\build\dotnet\Costura.Fody.targets" Condition="Exists('..\packages\Costura.Fody.1.6.2\build\dotnet\Costura.Fody.targets')" />
<Import Project="R:\eve-o-preview\packages\Fody.2.2.0\build\net452\Fody.targets" Condition="Exists('R:\eve-o-preview\packages\Fody.2.2.0\build\net452\Fody.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
29 changes: 14 additions & 15 deletions Eve-O-Preview/Presentation/ThumbnailManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -462,24 +462,23 @@ private void UpdateClientLayouts()

foreach (Process process in clientProcesses)
{
RECT rect;
WindowManagerNativeMethods.GetWindowRect(process.MainWindowHandle, out rect);
WindowManagerNativeMethods.GetWindowRect(process.MainWindowHandle, out RECT rect);

int clientWidth = Math.Abs(rect.Right - rect.Left);
int clientHeight = Math.Abs(rect.Bottom - rect.Top);
int width = Math.Abs(rect.Right - rect.Left);
int height = Math.Abs(rect.Bottom - rect.Top);

if (!this.IsManageableWindow(rect.Left, rect.Top, clientWidth, clientHeight))
if (!this.IsValidWindowPosition(rect.Left, rect.Top, width, height))
{
continue;
}

ClientLayout clientLayout = new ClientLayout();
clientLayout.X = rect.Left;
clientLayout.Y = rect.Top;
clientLayout.Width = clientWidth;
clientLayout.Height = clientHeight;
ClientLayout layout = new ClientLayout();
layout.X = rect.Left;
layout.Y = rect.Top;
layout.Width = width;
layout.Height = height;

this._configuration.SetClientLayout(process.MainWindowTitle, clientLayout);
this._configuration.SetClientLayout(process.MainWindowTitle, layout);
}
}

Expand All @@ -492,12 +491,12 @@ private bool IsManageableThumbnail(IThumbnailView view)
// Quick sanity check
// EVE Online client can create a window on a really weird position outside of the screen for some reason
// In this case we need to just skip such clients
private bool IsManageableWindow(int letf, int top, int width, int height)
private bool IsValidWindowPosition(int letf, int top, int width, int height)
{
return (letf >= ThumbnailManager.WindowPositionThreshold)
&& (top >= ThumbnailManager.WindowPositionThreshold)
&& (width >= ThumbnailManager.WindowSizeThreshold)
&& (height >= ThumbnailManager.WindowSizeThreshold);
&& (top >= ThumbnailManager.WindowPositionThreshold)
&& (width >= ThumbnailManager.WindowSizeThreshold)
&& (height >= ThumbnailManager.WindowSizeThreshold);
}
}
}
3 changes: 3 additions & 0 deletions Eve-O-Preview/app.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/></startup></configuration>
81 changes: 81 additions & 0 deletions Eve-O-Preview/app.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" >
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the
requestedExecutionLevel node with one of the following.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
Specifying requestedExecutionLevel element will disable file and registry virtualization.
Remove this element if your application requires this virtualization for backwards
compatibility.
-->
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of the Windows versions that this application has been tested on and is
is designed to work with. Uncomment the appropriate elements and Windows will
automatically selected the most compatible environment. -->

<!-- Windows Vista -->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->

<!-- Windows 7 -->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->

<!-- Windows 8 -->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->

<!-- Windows 8.1 -->
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->

<!-- Windows 10 -->
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->

</application>
</compatibility>

<!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher
DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need
to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should
also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config. -->
<!--
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
</windowsSettings>
</application>
-->

<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
<!--
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
-->
<asmv3:application>
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>True/PM</dpiAware>
</asmv3:windowsSettings>
</asmv3:application>

</assembly>

0 comments on commit faa423a

Please sign in to comment.