Fixed a few closure variables. The local variables used in the closure can not be shared between closures if their values should be different.
1.1 --- a/GUI/MainForm.cs Tue Sep 07 17:52:43 2010 +0000
1.2 +++ b/GUI/MainForm.cs Tue Sep 07 18:32:37 2010 +0000
1.3 @@ -394,27 +394,29 @@
1.4 sensorContextMenu.MenuItems.Add(item);
1.5 }
1.6 sensorContextMenu.MenuItems.Add(new MenuItem("-"));
1.7 -
1.8 - MenuItem menuItem = new MenuItem("Show in Tray");
1.9 - menuItem.Checked = systemTray.Contains(node.Sensor);
1.10 - menuItem.Click += delegate(object obj, EventArgs args) {
1.11 - if (menuItem.Checked)
1.12 - systemTray.Remove(node.Sensor);
1.13 - else
1.14 - systemTray.Add(node.Sensor, true);
1.15 - };
1.16 - sensorContextMenu.MenuItems.Add(menuItem);
1.17 -
1.18 - menuItem = new MenuItem("Show in Gadget");
1.19 - menuItem.Checked = gadget.Contains(node.Sensor);
1.20 - menuItem.Click += delegate(object obj, EventArgs args) {
1.21 - if (menuItem.Checked) {
1.22 - gadget.Remove(node.Sensor);
1.23 - } else {
1.24 - gadget.Add(node.Sensor);
1.25 - }
1.26 - };
1.27 - sensorContextMenu.MenuItems.Add(menuItem);
1.28 + {
1.29 + MenuItem item = new MenuItem("Show in Tray");
1.30 + item.Checked = systemTray.Contains(node.Sensor);
1.31 + item.Click += delegate(object obj, EventArgs args) {
1.32 + if (item.Checked)
1.33 + systemTray.Remove(node.Sensor);
1.34 + else
1.35 + systemTray.Add(node.Sensor, true);
1.36 + };
1.37 + sensorContextMenu.MenuItems.Add(item);
1.38 + }
1.39 + {
1.40 + MenuItem item = new MenuItem("Show in Gadget");
1.41 + item.Checked = gadget.Contains(node.Sensor);
1.42 + item.Click += delegate(object obj, EventArgs args) {
1.43 + if (item.Checked) {
1.44 + gadget.Remove(node.Sensor);
1.45 + } else {
1.46 + gadget.Add(node.Sensor);
1.47 + }
1.48 + };
1.49 + sensorContextMenu.MenuItems.Add(item);
1.50 + }
1.51
1.52 sensorContextMenu.Show(treeView, new Point(m.X, m.Y));
1.53 }
2.1 --- a/GUI/SensorGadget.cs Tue Sep 07 17:52:43 2010 +0000
2.2 +++ b/GUI/SensorGadget.cs Tue Sep 07 18:32:37 2010 +0000
2.3 @@ -100,13 +100,12 @@
2.4 for (int i = 0; i < 5; i++) {
2.5 MenuItem item = new MenuItem((20 * (i + 1)).ToString() + " %");
2.6 byte o = (byte)(51 * (i + 1));
2.7 - item.Tag = o;
2.8 item.Checked = Opacity == o;
2.9 item.Click += delegate(object sender, EventArgs e) {
2.10 - Opacity = (byte)item.Tag;
2.11 + Opacity = o;
2.12 settings.SetValue("sensorGadget.Opacity", Opacity);
2.13 foreach (MenuItem mi in opacityMenu.MenuItems)
2.14 - mi.Checked = (byte)mi.Tag == Opacity;
2.15 + mi.Checked = mi == item;
2.16 };
2.17 opacityMenu.MenuItems.Add(item);
2.18 }