コード例 #1
0
		public SysTrayIcon()
		{
			this.extradatakey = new StringBuilder(resources.GetString("VBoxService.ExtraDataKey"));
			
			vbox = new VirtualBox.VirtualBox();
			vboxcallback = new virtualboxcallback(this);
			vbox.RegisterCallback(vboxcallback);
			
			this.menuitem = new System.Windows.Forms.ContextMenu();
			for(int i=0; i<((Array)vbox.Machines).Length;i++) {
				MenuItem menu = new MenuItem( vbox.Machines[i].Name);
				menu.Name = vbox.Machines[i].Name;
				menu.Click += contextClick;
				menu.Tag = vbox.Machines[i].Id;
				
				if (vbox.Machines[i].GetExtraData(this.extradatakey.ToString()).ToLower() == "yes")
					menu.Checked = true;
				else
					menu.Checked = false;
				
				this.menuitem.MenuItems.Add(menu);
			}
			this.menuitem.MenuItems.Add("-");
			this.menuitem.MenuItems.Add("&About",AboutBox);
			this.menuitem.MenuItems.Add("E&xit",ExitSystray);
					
			this.notifyIcon = new NotifyIcon();
			this.notifyIcon.Icon = (System.Drawing.Icon)resources.GetObject("icon");
			this.notifyIcon.Visible = true;
			this.notifyIcon.Text = resources.GetString("Application.Name");
			this.notifyIcon.ContextMenu = this.menuitem;
		}
コード例 #2
0
        public SysTrayIcon()
        {
            this.extradatakey = new StringBuilder(resources.GetString("VBoxService.ExtraDataKey"));

            vbox         = new VirtualBox.VirtualBox();
            vboxcallback = new virtualboxcallback(this);
            vbox.RegisterCallback(vboxcallback);

            this.menuitem = new System.Windows.Forms.ContextMenu();
            for (int i = 0; i < ((Array)vbox.Machines).Length; i++)
            {
                MenuItem menu = new MenuItem(vbox.Machines[i].Name);
                menu.Name   = vbox.Machines[i].Name;
                menu.Click += contextClick;
                menu.Tag    = vbox.Machines[i].Id;

                if (vbox.Machines[i].GetExtraData(this.extradatakey.ToString()).ToLower() == "yes")
                {
                    menu.Checked = true;
                }
                else
                {
                    menu.Checked = false;
                }

                this.menuitem.MenuItems.Add(menu);
            }
            this.menuitem.MenuItems.Add("-");
            this.menuitem.MenuItems.Add("&About", AboutBox);
            this.menuitem.MenuItems.Add("E&xit", ExitSystray);

            this.notifyIcon             = new NotifyIcon();
            this.notifyIcon.Icon        = (System.Drawing.Icon)resources.GetObject("icon");
            this.notifyIcon.Visible     = true;
            this.notifyIcon.Text        = resources.GetString("Application.Name");
            this.notifyIcon.ContextMenu = this.menuitem;
        }