Esempio n. 1
0
        public void Discovered(CamServerCore.IDevice dev)
        {
            Action add = () =>
            {
                Trace.WriteLine("Adding " + dev + " to menu");
                ToolStripMenuItem item = new ToolStripMenuItem();

                item.Text   = dev.Name;
                item.Tag    = dev;
                item.Click += new EventHandler(item_Click);

                /*
                 * dev.StateChanged += (tdev, st) =>
                 * {
                 *  Trace.WriteLine("State changed for " + tdev + " to " + st);
                 *
                 *  foreach (ToolStripItem ts in strip.Items)
                 *  {
                 *      if (ts.Tag as IDevice == tdev)
                 *      {
                 *          SetState(ts as ToolStripMenuItem, dev.State);
                 *          break;
                 *      }
                 *  }
                 * };
                 */

                //SetState(item, dev.State);


                strip.Items.Insert(2, item);

                /*
                 * mnuLoading.Visible = false;
                 *
                 * MenuItem mi = new MenuItem();
                 * mi.Tag = dev;
                 * mi.Text = dev.Name;
                 * mi.Click += new EventHandler(mi_Click);
                 * menu.MenuItems.Add(0, mi);
                 */
                return;

                if (DavuxLib2.Settings.Get(dev.UID + "_Open", false))
                {
                    OpenWindow(dev);
                }
            };

            Trace.Write("notify add: " + dev.UID);
            if (strip.InvokeRequired)
            {
                strip.BeginInvoke(add);
            }
            else
            {
                add();
            }
        }
Esempio n. 2
0
 public void Update(Action <ITrayMenuMutator> action)
 {
     if (contextMenu.IsHandleCreated)
     {
         contextMenu.BeginInvoke(action, this);
     }
     else
     {
         action(this);
     }
 }