From b4918b3cc395b42df31b971da840a8df8cf0091e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=B6ller?= Date: Tue, 2 Mar 2010 22:52:37 +0000 Subject: [PATCH] Set the system tray icon font to a fixed size. Fixed the exiting of the application when the form was never shown and Close() is called. --- GUI/MainForm.cs | 5 ++++- GUI/SensorNotifyIcon.cs | 5 ++++- Properties/AssemblyInfo.cs | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/GUI/MainForm.cs b/GUI/MainForm.cs index 2228118..1f9e361 100644 --- a/GUI/MainForm.cs +++ b/GUI/MainForm.cs @@ -157,6 +157,9 @@ namespace OpenHardwareMonitor.GUI { } else { Show(); } + + // Create a handle, otherwise calling Close() does not fire FormClosed + CreateHandle(); } private void SubHardwareAdded(IHardware hardware, Node node) { @@ -233,7 +236,7 @@ namespace OpenHardwareMonitor.GUI { } private void exitToolStripMenuItem_Click(object sender, EventArgs e) { - Close(); + Close(); } private void timer_Tick(object sender, EventArgs e) { diff --git a/GUI/SensorNotifyIcon.cs b/GUI/SensorNotifyIcon.cs index f1d3229..dc50a19 100644 --- a/GUI/SensorNotifyIcon.cs +++ b/GUI/SensorNotifyIcon.cs @@ -59,6 +59,7 @@ namespace OpenHardwareMonitor.GUI { private Brush brush; private Brush darkBrush; private Pen pen; + private Font font; public SensorNotifyIcon(SensorSystemTray sensorSystemTray, ISensor sensor, bool balloonTip) @@ -73,6 +74,7 @@ namespace OpenHardwareMonitor.GUI { Color = Config.Get(sensor.Identifier + "/traycolor", defaultColor); this.pen = new Pen(Color.FromArgb(96, Color.Black)); + this.font = new Font(SystemFonts.StatusFont.FontFamily, 9); ContextMenuStrip contextMenuStrip = new ContextMenuStrip(); ToolStripMenuItem removeItem = new ToolStripMenuItem("Remove"); @@ -134,6 +136,7 @@ namespace OpenHardwareMonitor.GUI { if (darkBrush != null) darkBrush.Dispose(); pen.Dispose(); + font.Dispose(); graphics.Dispose(); graphics = null; bitmap.Dispose(); @@ -161,7 +164,7 @@ namespace OpenHardwareMonitor.GUI { private Icon CreateTransparentIcon() { graphics.Clear(Color.Black); - TextRenderer.DrawText(graphics, GetString(), SystemFonts.StatusFont, + TextRenderer.DrawText(graphics, GetString(), font, new Point(-2, 0), Color.White, Color.Black); BitmapData data = bitmap.LockBits( diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 04857da..c87bf2e 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -69,5 +69,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.1.24.3")] -[assembly: AssemblyFileVersion("0.1.24.3")] +[assembly: AssemblyVersion("0.1.25.0")] +[assembly: AssemblyFileVersion("0.1.25.0")]