Skip to content

Commit a487da9

Browse files
committed
fixed notifyicon text for 16x16 and 32x32 mode
1 parent 78eda31 commit a487da9

3 files changed

Lines changed: 17 additions & 13 deletions

File tree

GUI/MainForm.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ public MainForm() {
5959
Icon = Icon.ExtractAssociatedIcon(Updater.CurrentFileLocation);
6060

6161
settings = new PersistentSettings();
62-
settings.Load(Path.ChangeExtension(
63-
Application.ExecutablePath, ".config"));
62+
settings.Load(Application.ExecutablePath);
6463

6564
unitManager = new UnitManager(settings);
6665

GUI/SensorNotifyIcon.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public SensorNotifyIcon(SystemTray sensorSystemTray, ISensor sensor,
9090
family = new FontFamily("Segoe UI");
9191
baseSize = 15;
9292
} else {
93-
family = new FontFamily("Tahome");// SystemFonts.MessageBoxFont.FontFamily;
93+
family = SystemFonts.MessageBoxFont.FontFamily;
9494
baseSize = 14;
9595
}
9696

@@ -209,16 +209,20 @@ private Icon CreateTransparentIcon() {
209209
graphics.Clear(defaultBackColor);
210210
}
211211

212+
var textShift = bitmap.Width / 8 - 1; //todo: tested for 16 & 32 only
212213
if (small) {
213214
if (text[1] == '.' || text[1] == ',') {
214-
TextRenderer.DrawText(graphics, text.Substring(0, 1), font, new Point(-4, -2), color, defaultBackColor);
215-
TextRenderer.DrawText(graphics, text.Substring(1), smallFont, new Point(8, 4), color, defaultBackColor);
215+
var bigPart = text.Substring(0, 1);
216+
var smallPart = text.Substring(1);
217+
TextRenderer.DrawText(graphics, bigPart, font, new Point(-4, -2), color, defaultBackColor);
218+
TextRenderer.DrawText(graphics, smallPart, smallFont, new Point(4 * textShift, 1 * textShift), color, defaultBackColor);
219+
} else {
220+
TextRenderer.DrawText(graphics, text, smallFont, new Point(-2 * textShift, 2 * textShift), color, defaultBackColor);
216221
}
217-
else
218-
TextRenderer.DrawText(graphics, text, smallFont, new Point(-4, 1), color, defaultBackColor);
219222
}
220-
else
221-
TextRenderer.DrawText(graphics, text, font, new Point(-4, -2), color, defaultBackColor);
223+
else {
224+
TextRenderer.DrawText(graphics, text, font, new Point(-2 * textShift, -1 * textShift), color, defaultBackColor);
225+
}
222226

223227
var data = bitmap.LockBits(
224228
new Rectangle(0, 0, bitmap.Width, bitmap.Height),

Utilities/PersistentSettings.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@ public class PersistentSettings : ISettings {
1313

1414
private IDictionary<string, string> settings = new Dictionary<string, string>();
1515

16-
public void Load(string fileName) {
17-
if (!File.Exists(fileName)) return;
16+
public void Load(string executablePath) {
17+
var configPath = Path.ChangeExtension(executablePath, ".config");
18+
if (!File.Exists(configPath)) return;
1819
try {
19-
var json = File.ReadAllText(fileName);
20+
var json = File.ReadAllText(configPath);
2021
settings = json.FromJson<IDictionary<string, string>>();
2122
}
2223
catch (Exception) {
23-
LoadOld(fileName);
24+
LoadOld(configPath);
2425
}
2526
}
2627

0 commit comments

Comments
 (0)