Skip to content

Commit 08d809e

Browse files
committed
notify icon font and size changed
1 parent bc89bd1 commit 08d809e

3 files changed

Lines changed: 21 additions & 13 deletions

File tree

GUI/SensorNotifyIcon.cs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,21 @@ public SensorNotifyIcon(SystemTray sensorSystemTray, ISensor sensor,
8585
height = height < 16 ? 16 : height;
8686

8787
// adjust the font size to the icon size
88-
var family = new FontFamily("Segoe UI");// SystemFonts.MessageBoxFont.FontFamily;
88+
FontFamily family;
8989
float baseSize;
90-
switch (family.Name) {
91-
case "Segoe UI": baseSize = 15; break;
92-
case "Tahoma": baseSize = 11; break;
93-
default: baseSize = 12; break;
90+
if (IsFontInstalled("Calibri", 15)) {
91+
family = new FontFamily("Calibri");
92+
baseSize = 15;
93+
} else if (IsFontInstalled("Segoe UI", 15)) {
94+
family = new FontFamily("Segoe UI");
95+
baseSize = 15;
96+
} else {
97+
family = new FontFamily("Tahome");// SystemFonts.MessageBoxFont.FontFamily;
98+
baseSize = 14;
9499
}
95100

96-
font = new Font(family,
97-
baseSize * width / 16.0f, GraphicsUnit.Pixel);
98-
smallFont = new Font(family,
99-
0.75f * baseSize * width / 16.0f, GraphicsUnit.Pixel);
101+
font = new Font(family, baseSize * width / 16.0f, GraphicsUnit.Pixel);
102+
smallFont = new Font(family, 0.85f * baseSize * width / 16.0f, GraphicsUnit.Pixel);
100103

101104
bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb);
102105
graphics = Graphics.FromImage(bitmap);
@@ -181,6 +184,11 @@ private string GetString() {
181184
return "-";
182185
}
183186

187+
private bool IsFontInstalled(string fontName, float fontSize = 12) {
188+
using (Font fontTester = new Font(fontName, fontSize, FontStyle.Regular, GraphicsUnit.Pixel)) {
189+
return fontTester.Name == fontName;
190+
}
191+
}
184192
private Icon CreateTransparentIcon() {
185193
var text = GetString();
186194
var small = text.Length > 2;

OpenHardwareMonitor.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@
523523
$(PostBuildEventDependsOn);
524524
PostBuildMacros;
525525
</PostBuildEventDependsOn>
526-
<PostBuildEvent>echo @(VersionNumber) &gt; ..\version.txt</PostBuildEvent>
526+
<PostBuildEvent>rem echo @(VersionNumber) &gt; ..\version.txt</PostBuildEvent>
527527
</PropertyGroup>
528528
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
529529
<PropertyGroup>

Utilities/Updater.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ internal static class Updater {
4343

4444
static Updater() {
4545
var asm = Assembly.GetExecutingAssembly();
46-
CurrentVersion = asm.GetName().Version.ToString(4); //Application.ProductVersion;
46+
CurrentVersion = asm.GetName().Version.ToString(3); //Application.ProductVersion;
4747
CurrentFileLocation = asm.Location;
4848
selfFileName = Path.GetFileName(CurrentFileLocation);
4949
}
@@ -84,11 +84,11 @@ internal static void CheckForUpdates(bool silent) {
8484

8585
if (string.Compare(CurrentVersion, newVersion, StringComparison.Ordinal) >= 0) {
8686
if (!silent)
87-
MessageBox.Show($"You have the latest version ({CurrentVersion}).", "Update", MessageBoxButtons.OK,
87+
MessageBox.Show($"Your version is: {CurrentVersion}\nLatest released version is: {newVersion}\nNo need to update.", "Update", MessageBoxButtons.OK,
8888
MessageBoxIcon.Information);
8989
return;
9090
}
91-
update = MessageBox.Show($"New version available: {newVersion}. Download this update?",
91+
update = MessageBox.Show($"Your version is: {CurrentVersion}\nLatest released version is: {newVersion}\n. Download this update?",
9292
"Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes;
9393
} catch (Exception ex) {
9494
if (!silent)

0 commit comments

Comments
 (0)