예제 #1
0
            public override void Build(IMainWindow mainWindow, SelectedItemCollection selection, ContextMenuItemCollection items)
            {
                Host host = (Host)selection[0].XenObject;

                items.AddIfEnabled(new NewVMCommand(mainWindow, selection));
                items.AddIfEnabled(new NewSRCommand(mainWindow, selection));
                items.AddIfEnabled(new ImportCommand(mainWindow, selection));
                items.AddSeparator();
                items.AddIfEnabled(new InstallCertificateCommand(mainWindow, selection));
                items.AddIfEnabled(new HostMaintenanceModeCommand(mainWindow, selection));
                items.AddSeparator();

                items.AddIfEnabled(new RebootHostCommand(mainWindow, selection));
                items.AddIfEnabled(new ShutDownHostCommand(mainWindow, selection));
                items.AddIfEnabled(new RestartToolstackCommand(mainWindow, selection));
                items.AddSeparator();

                items.AddIfEnabled(new RemoveHostCrashDumpsCommand(mainWindow, selection));

                var cmd = new RemoveHostFromPoolCommand(mainWindow, selection);

                if (cmd.CanExecute())
                {
                    items.AddSeparator();
                    items.Add(cmd);
                }

                items.AddPluginItems(PluginContextMenu.server, selection);
                items.AddSeparator();
                items.AddIfEnabled(new HostPropertiesCommand(mainWindow, selection));
            }
        protected override void OnDropDownOpening(EventArgs e)
        {
            DropDownItems.Clear();

            var hosts = Command.GetSelection().GetConnectionOfAllItems().Cache.Hosts;

            foreach (var host in hosts)
            {
                if (!RemoveHostFromPoolCommand.CanExecute(host))
                {
                    continue;
                }

                var cmd = new RemoveHostFromPoolCommand(Command.MainWindowCommandInterface, host);
                DropDownItems.Add(new CommandToolStripMenuItem(cmd, host.Name(), Images.GetImage16For(host)));
            }
        }