Changed the system tray icon font scaling to adapt to the size of the tray icon in pixels, because on Windows 7 the tray icon scales with the system font size, while on Windows XP the tray icons are always 16 pixels large.

This commit is contained in:
Michael Möller 2012-07-18 19:45:59 +00:00
parent 90838f671b
commit b9d30a4602
4 changed files with 34 additions and 10 deletions

View File

@ -53,8 +53,6 @@ namespace OpenHardwareMonitor.GUI {
"traycolor").ToString(), defaultColor); "traycolor").ToString(), defaultColor);
this.pen = new Pen(Color.FromArgb(96, Color.Black)); this.pen = new Pen(Color.FromArgb(96, Color.Black));
this.font = SystemFonts.MessageBoxFont;
this.smallFont = new Font(font.FontFamily, font.Size * 0.8f);
ContextMenu contextMenu = new ContextMenu(); ContextMenu contextMenu = new ContextMenu();
MenuItem hideShowItem = new MenuItem("Hide/Show"); MenuItem hideShowItem = new MenuItem("Hide/Show");
@ -105,6 +103,20 @@ namespace OpenHardwareMonitor.GUI {
width = width < 16 ? 16 : width; width = width < 16 ? 16 : width;
height = height < 16 ? 16 : height; height = height < 16 ? 16 : height;
// adjust the font size to the icon size
FontFamily family = SystemFonts.MessageBoxFont.FontFamily;
float baseSize;
switch (family.Name) {
case "Segoe UI": baseSize = 12; break;
case "Tahoma": baseSize = 11; break;
default: baseSize = 12; break;
}
this.font = new Font(family,
baseSize * width / 16.0f, GraphicsUnit.Pixel);
this.smallFont = new Font(family,
0.75f * baseSize * width / 16.0f, GraphicsUnit.Pixel);
this.bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb); this.bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb);
this.graphics = Graphics.FromImage(this.bitmap); this.graphics = Graphics.FromImage(this.bitmap);
@ -151,6 +163,7 @@ namespace OpenHardwareMonitor.GUI {
pen.Dispose(); pen.Dispose();
graphics.Dispose(); graphics.Dispose();
bitmap.Dispose(); bitmap.Dispose();
font.Dispose();
smallFont.Dispose(); smallFont.Dispose();
} }

View File

@ -173,7 +173,9 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="App.config" /> <None Include="App.config" />
<None Include="Resources\app.manifest" /> <None Include="Resources\app.manifest">
<SubType>Designer</SubType>
</None>
<None Include="Resources\icon.ico" /> <None Include="Resources\icon.ico" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -10,5 +10,5 @@
using System.Reflection; using System.Reflection;
[assembly: AssemblyVersion("0.4.0.17")] [assembly: AssemblyVersion("0.4.0.18")]
[assembly: AssemblyInformationalVersion("0.4.0.17 Alpha")] [assembly: AssemblyInformationalVersion("0.4.0.18 Alpha")]

View File

@ -1,5 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1"
xmlns:asmv1="urn:schemas-microsoft-com:asm.v1"
xmlns:asmv2="urn:schemas-microsoft-com:asm.v2"
xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security> <security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3"> <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
@ -7,4 +11,9 @@
</requestedPrivileges> </requestedPrivileges>
</security> </security>
</trustInfo> </trustInfo>
<asmv3:application>
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>true</dpiAware>
</asmv3:windowsSettings>
</asmv3:application>
</asmv1:assembly> </asmv1:assembly>