Skip to content

Commit 59f1ced

Browse files
committed
fix theme support for notify icon context menu
1 parent e459a09 commit 59f1ced

2 files changed

Lines changed: 22 additions & 21 deletions

File tree

OpenHardwareMonitor/UI/SensorNotifyIcon.cs

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

4545
_pen = new Pen(Color.FromArgb(96, Color.Black));
46-
var contextMenuStrip = new ContextMenu();
47-
var hideShowItem = new MenuItem("Hide/Show") { DefaultItem = true };
46+
var contextMenuStrip = new ContextMenuStrip();
47+
contextMenuStrip.Renderer = new ThemedToolStripRenderer();
48+
var hideShowItem = new ToolStripMenuItem("Hide/Show");
4849
hideShowItem.Click += delegate
4950
{
5051
sensorSystemTray.SendHideShowCommand();
5152
};
52-
contextMenuStrip.MenuItems.Add(hideShowItem);
53-
contextMenuStrip.MenuItems.Add("-");
54-
var removeItem = new MenuItem("Remove Sensor");
53+
contextMenuStrip.Items.Add(hideShowItem);
54+
contextMenuStrip.Items.Add("-");
55+
var removeItem = new ToolStripMenuItem("Remove Sensor");
5556
removeItem.Click += delegate
5657
{
5758
sensorSystemTray.Remove(Sensor);
5859
};
59-
contextMenuStrip.MenuItems.Add(removeItem);
60-
var colorItem = new MenuItem("Change Color...");
60+
contextMenuStrip.Items.Add(removeItem);
61+
var colorItem = new ToolStripMenuItem("Change Color...");
6162
colorItem.Click += delegate
6263
{
6364
ColorDialog dialog = new ColorDialog { Color = Color };
6465
if (dialog.ShowDialog() == DialogResult.OK)
6566
{
6667
Color = dialog.Color;
67-
settings.SetValue(new Identifier(sensor.Identifier,
68-
"traycolor").ToString(), Color);
68+
settings.SetValue(new Identifier(sensor.Identifier, "traycolor").ToString(), Color);
6969
}
7070
};
71-
contextMenuStrip.MenuItems.Add(colorItem);
72-
contextMenuStrip.MenuItems.Add("-");
73-
var exitItem = new MenuItem("Exit");
71+
contextMenuStrip.Items.Add(colorItem);
72+
contextMenuStrip.Items.Add("-");
73+
var exitItem = new ToolStripMenuItem("Exit");
7474
exitItem.Click += delegate
7575
{
7676
sensorSystemTray.SendExitCommand();
7777
};
78-
contextMenuStrip.MenuItems.Add(exitItem);
79-
_notifyIcon.ContextMenu = contextMenuStrip;
78+
contextMenuStrip.Items.Add(exitItem);
79+
_notifyIcon.ContextMenuStrip = contextMenuStrip;
8080
_notifyIcon.DoubleClick += delegate
8181
{
8282
sensorSystemTray.SendHideShowCommand();

OpenHardwareMonitor/UI/SystemTray.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,22 @@ public SystemTray(IComputer computer, PersistentSettings settings, UnitManager u
2727

2828
_mainIcon = new NotifyIconAdv();
2929

30-
ContextMenu contextMenuStrip = new ContextMenu();
31-
var hideShowItem = new MenuItem("Hide/Show") { DefaultItem = true };
30+
var contextMenuStrip = new ContextMenuStrip();
31+
contextMenuStrip.Renderer = new ThemedToolStripRenderer();
32+
var hideShowItem = new ToolStripMenuItem("Hide/Show");
3233
hideShowItem.Click += delegate
3334
{
3435
SendHideShowCommand();
3536
};
36-
contextMenuStrip.MenuItems.Add(hideShowItem);
37-
contextMenuStrip.MenuItems.Add("-");
38-
var exitItem = new MenuItem("Exit");
37+
contextMenuStrip.Items.Add(hideShowItem);
38+
contextMenuStrip.Items.Add("-");
39+
var exitItem = new ToolStripMenuItem("Exit");
3940
exitItem.Click += delegate
4041
{
4142
SendExitCommand();
4243
};
43-
contextMenuStrip.MenuItems.Add(exitItem);
44-
_mainIcon.ContextMenu = contextMenuStrip;
44+
contextMenuStrip.Items.Add(exitItem);
45+
_mainIcon.ContextMenuStrip = contextMenuStrip;
4546
_mainIcon.DoubleClick += delegate
4647
{
4748
SendHideShowCommand();

0 commit comments

Comments
 (0)