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.
authormoel.mich
Wed, 18 Jul 2012 19:45:59 +0000
changeset 366667c75cad937
parent 365 a8a8ff22d959
child 367 45215572a774
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.
GUI/SensorNotifyIcon.cs
OpenHardwareMonitor.csproj
Properties/AssemblyVersion.cs
Resources/app.manifest
     1.1 --- a/GUI/SensorNotifyIcon.cs	Tue Jul 17 16:12:07 2012 +0000
     1.2 +++ b/GUI/SensorNotifyIcon.cs	Wed Jul 18 19:45:59 2012 +0000
     1.3 @@ -53,8 +53,6 @@
     1.4          "traycolor").ToString(), defaultColor);      
     1.5        
     1.6        this.pen = new Pen(Color.FromArgb(96, Color.Black));
     1.7 -      this.font = SystemFonts.MessageBoxFont;
     1.8 -      this.smallFont = new Font(font.FontFamily, font.Size * 0.8f);
     1.9  
    1.10        ContextMenu contextMenu = new ContextMenu();
    1.11        MenuItem hideShowItem = new MenuItem("Hide/Show");
    1.12 @@ -88,7 +86,7 @@
    1.13        this.notifyIcon.ContextMenu = contextMenu;
    1.14        this.notifyIcon.DoubleClick += delegate(object obj, EventArgs args) {
    1.15          sensorSystemTray.SendHideShowCommand();
    1.16 -      };
    1.17 +      };      
    1.18  
    1.19        // get the default dpi to create an icon with the correct size
    1.20        float dpiX, dpiY;
    1.21 @@ -102,8 +100,22 @@
    1.22        int height = (int)Math.Round(16 * dpiY / 96);
    1.23  
    1.24        // make sure it does never get smaller than 16x16
    1.25 -      width = width < 16 ? 16: width;
    1.26 -      height = height < 16 ? 16: height;
    1.27 +      width = width < 16 ? 16 : width;
    1.28 +      height = height < 16 ? 16 : height;
    1.29 +
    1.30 +      // adjust the font size to the icon size
    1.31 +      FontFamily family = SystemFonts.MessageBoxFont.FontFamily;
    1.32 +      float baseSize;
    1.33 +      switch (family.Name) {
    1.34 +        case "Segoe UI": baseSize = 12; break;
    1.35 +        case "Tahoma": baseSize = 11; break;
    1.36 +        default: baseSize = 12; break;
    1.37 +      }
    1.38 +
    1.39 +      this.font = new Font(family,
    1.40 +        baseSize * width / 16.0f, GraphicsUnit.Pixel);
    1.41 +      this.smallFont = new Font(family, 
    1.42 +        0.75f * baseSize * width / 16.0f, GraphicsUnit.Pixel);
    1.43  
    1.44        this.bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb);      
    1.45        this.graphics = Graphics.FromImage(this.bitmap);
    1.46 @@ -151,6 +163,7 @@
    1.47        pen.Dispose();
    1.48        graphics.Dispose();      
    1.49        bitmap.Dispose();
    1.50 +      font.Dispose();
    1.51        smallFont.Dispose();
    1.52      }
    1.53  
    1.54 @@ -169,7 +182,7 @@
    1.55            if (unitManager.TemperatureUnit == TemperatureUnit.Fahrenheit)
    1.56              return string.Format("{0:F0}", 
    1.57                UnitManager.CelsiusToFahrenheit(sensor.Value));
    1.58 -          else 
    1.59 +          else
    1.60              return string.Format("{0:F0}", sensor.Value);
    1.61          case SensorType.Fan: 
    1.62            return string.Format("{0:F1}", 1e-3f * sensor.Value);
     2.1 --- a/OpenHardwareMonitor.csproj	Tue Jul 17 16:12:07 2012 +0000
     2.2 +++ b/OpenHardwareMonitor.csproj	Wed Jul 18 19:45:59 2012 +0000
     2.3 @@ -173,7 +173,9 @@
     2.4    </ItemGroup>
     2.5    <ItemGroup>
     2.6      <None Include="App.config" />
     2.7 -    <None Include="Resources\app.manifest" />
     2.8 +    <None Include="Resources\app.manifest">
     2.9 +      <SubType>Designer</SubType>
    2.10 +    </None>
    2.11      <None Include="Resources\icon.ico" />
    2.12    </ItemGroup>
    2.13    <ItemGroup>
     3.1 --- a/Properties/AssemblyVersion.cs	Tue Jul 17 16:12:07 2012 +0000
     3.2 +++ b/Properties/AssemblyVersion.cs	Wed Jul 18 19:45:59 2012 +0000
     3.3 @@ -10,5 +10,5 @@
     3.4  
     3.5  using System.Reflection;
     3.6  
     3.7 -[assembly: AssemblyVersion("0.4.0.17")]
     3.8 -[assembly: AssemblyInformationalVersion("0.4.0.17 Alpha")]
     3.9 \ No newline at end of file
    3.10 +[assembly: AssemblyVersion("0.4.0.18")]
    3.11 +[assembly: AssemblyInformationalVersion("0.4.0.18 Alpha")]
    3.12 \ No newline at end of file
     4.1 --- a/Resources/app.manifest	Tue Jul 17 16:12:07 2012 +0000
     4.2 +++ b/Resources/app.manifest	Wed Jul 18 19:45:59 2012 +0000
     4.3 @@ -1,5 +1,9 @@
     4.4  <?xml version="1.0" encoding="utf-8"?>
     4.5 -<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">
     4.6 +<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" 
     4.7 +  xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" 
     4.8 +  xmlns:asmv2="urn:schemas-microsoft-com:asm.v2"
     4.9 +  xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"
    4.10 +  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    4.11    <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    4.12      <security>
    4.13        <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
    4.14 @@ -7,4 +11,9 @@
    4.15        </requestedPrivileges>
    4.16      </security>
    4.17    </trustInfo>
    4.18 +  <asmv3:application>
    4.19 +    <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
    4.20 +      <dpiAware>true</dpiAware>
    4.21 +    </asmv3:windowsSettings>
    4.22 +  </asmv3:application>
    4.23  </asmv1:assembly>