Skip to content

Commit 2692089

Browse files
committed
icon: draw decimal part with smaller font size
1 parent 25ebd88 commit 2692089

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

GUI/SensorNotifyIcon.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ public SensorNotifyIcon(SystemTray sensorSystemTray, ISensor sensor,
4242
Color = settings.GetValue(new Identifier(sensor.Identifier, "traycolor").ToString(), defaultColor);
4343

4444
var contextMenu = new ContextMenu();
45-
var hideShowItem = new MenuItem("Hide/Show");
46-
hideShowItem.DefaultItem = true;
45+
var hideShowItem = new MenuItem("Hide/Show") {DefaultItem = true};
4746
hideShowItem.Click += (sender, args) => sensorSystemTray.SendHideShowCommand();
4847
contextMenu.MenuItems.Add(hideShowItem);
4948
contextMenu.MenuItems.Add(new MenuItem("-"));
@@ -52,8 +51,7 @@ public SensorNotifyIcon(SystemTray sensorSystemTray, ISensor sensor,
5251
contextMenu.MenuItems.Add(removeItem);
5352
var colorItem = new MenuItem("Change Color...");
5453
colorItem.Click += (obj, args) => {
55-
var dialog = new ColorDialog();
56-
dialog.Color = Color;
54+
var dialog = new ColorDialog {Color = Color};
5755
if (dialog.ShowDialog() == DialogResult.OK) {
5856
Color = dialog.Color;
5957
settings.SetValue(new Identifier(sensor.Identifier, "traycolor").ToString(), Color);
@@ -97,7 +95,7 @@ public SensorNotifyIcon(SystemTray sensorSystemTray, ISensor sensor,
9795
}
9896

9997
font = new Font(family, baseSize * width / 16.0f, GraphicsUnit.Pixel);
100-
smallFont = new Font(family, 0.85f * baseSize * width / 16.0f, GraphicsUnit.Pixel);
98+
smallFont = new Font(family, 0.75f * baseSize * width / 16.0f, GraphicsUnit.Pixel);
10199

102100
bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb);
103101
graphics = Graphics.FromImage(bitmap);
@@ -191,6 +189,7 @@ private bool IsFontInstalled(string fontName, float fontSize = 12) {
191189
return fontTester.Name == fontName;
192190
}
193191
}
192+
194193
private Icon CreateTransparentIcon() {
195194
var text = GetString();
196195
var small = text.Length > 2;
@@ -210,8 +209,16 @@ private Icon CreateTransparentIcon() {
210209
graphics.Clear(defaultBackColor);
211210
}
212211

213-
TextRenderer.DrawText(graphics, text, small ? smallFont : font,
214-
new Point(-4, small ? 1 : -2), color, defaultBackColor);
212+
if (small) {
213+
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);
216+
}
217+
else
218+
TextRenderer.DrawText(graphics, text, smallFont, new Point(-4, 1), color, defaultBackColor);
219+
}
220+
else
221+
TextRenderer.DrawText(graphics, text, font, new Point(-4, -2), color, defaultBackColor);
215222

216223
var data = bitmap.LockBits(
217224
new Rectangle(0, 0, bitmap.Width, bitmap.Height),

0 commit comments

Comments
 (0)