Skip to content

Commit

Permalink
add DpiAware for demo
Browse files Browse the repository at this point in the history
  • Loading branch information
NaBian committed Jan 27, 2021
1 parent f567724 commit 2fadc54
Show file tree
Hide file tree
Showing 13 changed files with 106 additions and 23 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018-2020 HandyOrg
Copyright (c) 2018-2021 HandyOrg

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -590,5 +590,6 @@
<FileVersion>3.1.0.0</FileVersion>
<Version>3.1.0.0</Version>
<RepositoryUrl>https://github.com/HandyOrg/HandyControl</RepositoryUrl>
<ApplicationManifest>..\..\Shared\HandyControlDemo_Shared\app.manifest</ApplicationManifest>
</PropertyGroup>
</Project>
35 changes: 20 additions & 15 deletions src/Net_40/HandyControl_Net_40/Themes/Theme.xaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<OutputType>WinExe</OutputType>
<AssemblyName>HandyControlDemo</AssemblyName>
<RootNamespace>HandyControlDemo</RootNamespace>
<TargetFrameworks>netcoreapp3.0;netcoreapp3.1;net45;net462;net47;net48;net5.0-windows</TargetFrameworks>
<TargetFrameworks>netcoreapp3.0;netcoreapp3.1;net45;net451;net452;net46;net461;net462;net47;net471;net472;net48;net5.0-windows</TargetFrameworks>
<ApplicationIcon>..\..\Shared\HandyControlDemo_Shared\Resources\Img\icon.ico</ApplicationIcon>
<NoWarn>0108;MSB3026;MSB3061</NoWarn>
<MSBuildWarningsAsMessages>NETSDK1138</MSBuildWarningsAsMessages>
Expand All @@ -13,6 +13,7 @@
<FileVersion>3.1.0.0</FileVersion>
<Version>3.1.0.0</Version>
<RepositoryUrl>https://github.com/HandyOrg/HandyControl</RepositoryUrl>
<ApplicationManifest>..\..\Shared\HandyControlDemo_Shared\app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith('net4'))">
<Reference Include="Microsoft.CSharp" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<AssemblyName>HandyControl</AssemblyName>
<RootNamespace>HandyControl</RootNamespace>
<TargetFrameworks>netcoreapp3.0;netcoreapp3.1;net45;net462;net47;net48;net5.0-windows</TargetFrameworks>
<TargetFrameworks>netcoreapp3.0;netcoreapp3.1;net45;net451;net452;net46;net461;net462;net47;net471;net472;net48;net5.0-windows</TargetFrameworks>
<Description>Contains some commonly used simple WPF controls</Description>
<PackageId>HandyControl</PackageId>
<IncludeSymbols>true</IncludeSymbols>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<UseWPF>true</UseWPF>
<AssemblyName>HandyControlDemoCode</AssemblyName>
<RootNamespace>HandyControlDemoCode</RootNamespace>
<TargetFrameworks>netcoreapp3.0;netcoreapp3.1;net40;net45;net462;net47;net48;net5.0-windows</TargetFrameworks>
<TargetFrameworks>netcoreapp3.0;netcoreapp3.1;net40;net45;net451;net452;net46;net461;net462;net47;net471;net472;net48;net5.0-windows</TargetFrameworks>
<NoWarn>MSB3026;MSB3061</NoWarn>
<MSBuildWarningsAsMessages>NETSDK1138</MSBuildWarningsAsMessages>
<Version>3.1.0.0</Version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1057,4 +1057,7 @@
<ItemGroup>
<Folder Include="$(MSBuildThisFileDirectory)Service\Data\" />
</ItemGroup>
<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)app.manifest" />
</ItemGroup>
</Project>
3 changes: 2 additions & 1 deletion src/Shared/HandyControlDemo_Shared/Properties/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="Langs"/>
</assemblyBinding>
<AppContextSwitchOverrides value="Switch.System.Windows.DoNotScaleForDpiChanges=false"/>
</runtime>
</configuration>
</configuration>
12 changes: 12 additions & 0 deletions src/Shared/HandyControlDemo_Shared/Tools/Helper/VersionHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,22 @@ internal static string GetVersion()
var netVersion = "NET 40";
#elif NET45
var netVersion = "NET 45";
#elif NET451
var netVersion = "NET 451";
#elif NET452
var netVersion = "NET 452";
#elif NET46
var netVersion = "NET 46";
#elif NET461
var netVersion = "NET 461";
#elif NET462
var netVersion = "NET 462";
#elif NET47
var netVersion = "NET 47";
#elif NET471
var netVersion = "NET 471";
#elif NET472
var netVersion = "NET 472";
#elif NET48
var netVersion = "NET 48";
#elif NET5_0
Expand Down
60 changes: 60 additions & 0 deletions src/Shared/HandyControlDemo_Shared/app.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="HandyControlDemo"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<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 designed to work with. Uncomment the appropriate elements
and Windows will automatically select 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>

<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor</dpiAwareness>
</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>


</assembly>
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ private void EnsureFormattedText()
return;
}

#if NET40 || NET45
#if NET40 || NET45 || NET451 || NET452 || NET46|| NET461
_formattedText = new FormattedText(
Text,
CultureInfo.CurrentUICulture,
Expand Down
2 changes: 1 addition & 1 deletion src/Shared/HandyControl_Shared/Controls/Text/SimpleText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private void EnsureFormattedText()
return;
}

#if NET40 || NET45
#if NET40 || NET45 || NET451 || NET452 || NET46|| NET461
_formattedText = new FormattedText(
Text,
CultureInfo.CurrentUICulture,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public static Thickness WindowMaximizedPadding
var autoHide = InteropMethods.SHAppBarMessage(4, ref appBarData) != 0;
#if NET40
return WindowResizeBorderThickness.Add(new Thickness(autoHide ? -8 : 0));
#elif Core
#elif NETCOREAPP
var hdc = InteropMethods.GetDC(IntPtr.Zero);
var scale = InteropMethods.GetDeviceCaps(hdc, InteropValues.DESKTOPVERTRES) / (float)InteropMethods.GetDeviceCaps(hdc, InteropValues.VERTRES);
InteropMethods.ReleaseDC(IntPtr.Zero, hdc);
Expand Down

0 comments on commit 2fadc54

Please sign in to comment.