mirror of
https://github.com/openhardwaremonitor/openhardwaremonitor
synced 2025-08-31 22:35:11 +00:00
Fixed a few closure variables. The local variables used in the closure can not be shared between closures if their values should be different.
This commit is contained in:
@@ -394,27 +394,29 @@ namespace OpenHardwareMonitor.GUI {
|
|||||||
sensorContextMenu.MenuItems.Add(item);
|
sensorContextMenu.MenuItems.Add(item);
|
||||||
}
|
}
|
||||||
sensorContextMenu.MenuItems.Add(new MenuItem("-"));
|
sensorContextMenu.MenuItems.Add(new MenuItem("-"));
|
||||||
|
{
|
||||||
MenuItem menuItem = new MenuItem("Show in Tray");
|
MenuItem item = new MenuItem("Show in Tray");
|
||||||
menuItem.Checked = systemTray.Contains(node.Sensor);
|
item.Checked = systemTray.Contains(node.Sensor);
|
||||||
menuItem.Click += delegate(object obj, EventArgs args) {
|
item.Click += delegate(object obj, EventArgs args) {
|
||||||
if (menuItem.Checked)
|
if (item.Checked)
|
||||||
systemTray.Remove(node.Sensor);
|
systemTray.Remove(node.Sensor);
|
||||||
else
|
else
|
||||||
systemTray.Add(node.Sensor, true);
|
systemTray.Add(node.Sensor, true);
|
||||||
};
|
};
|
||||||
sensorContextMenu.MenuItems.Add(menuItem);
|
sensorContextMenu.MenuItems.Add(item);
|
||||||
|
}
|
||||||
menuItem = new MenuItem("Show in Gadget");
|
{
|
||||||
menuItem.Checked = gadget.Contains(node.Sensor);
|
MenuItem item = new MenuItem("Show in Gadget");
|
||||||
menuItem.Click += delegate(object obj, EventArgs args) {
|
item.Checked = gadget.Contains(node.Sensor);
|
||||||
if (menuItem.Checked) {
|
item.Click += delegate(object obj, EventArgs args) {
|
||||||
|
if (item.Checked) {
|
||||||
gadget.Remove(node.Sensor);
|
gadget.Remove(node.Sensor);
|
||||||
} else {
|
} else {
|
||||||
gadget.Add(node.Sensor);
|
gadget.Add(node.Sensor);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
sensorContextMenu.MenuItems.Add(menuItem);
|
sensorContextMenu.MenuItems.Add(item);
|
||||||
|
}
|
||||||
|
|
||||||
sensorContextMenu.Show(treeView, new Point(m.X, m.Y));
|
sensorContextMenu.Show(treeView, new Point(m.X, m.Y));
|
||||||
}
|
}
|
||||||
|
@@ -100,13 +100,12 @@ namespace OpenHardwareMonitor.GUI {
|
|||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
MenuItem item = new MenuItem((20 * (i + 1)).ToString() + " %");
|
MenuItem item = new MenuItem((20 * (i + 1)).ToString() + " %");
|
||||||
byte o = (byte)(51 * (i + 1));
|
byte o = (byte)(51 * (i + 1));
|
||||||
item.Tag = o;
|
|
||||||
item.Checked = Opacity == o;
|
item.Checked = Opacity == o;
|
||||||
item.Click += delegate(object sender, EventArgs e) {
|
item.Click += delegate(object sender, EventArgs e) {
|
||||||
Opacity = (byte)item.Tag;
|
Opacity = o;
|
||||||
settings.SetValue("sensorGadget.Opacity", Opacity);
|
settings.SetValue("sensorGadget.Opacity", Opacity);
|
||||||
foreach (MenuItem mi in opacityMenu.MenuItems)
|
foreach (MenuItem mi in opacityMenu.MenuItems)
|
||||||
mi.Checked = (byte)mi.Tag == Opacity;
|
mi.Checked = mi == item;
|
||||||
};
|
};
|
||||||
opacityMenu.MenuItems.Add(item);
|
opacityMenu.MenuItems.Add(item);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user