Пример #1
0
        /// <summary>
        /// Attempts to install tools on the vm
        /// </summary>
        /// <param name="vm"></param>
        /// <returns>null if user cancels or an AsyncAction. This is either the InstallPVToolsAction or the CreateCdDriveAction if the VM needed a DVD drive.</returns>
        private void SingleVMExecute(VM vm)
        {
            if (vm.FindVMCDROM() == null)
            {
                DialogResult dialogResult;
                using (var dlg = new NoIconDialog(Messages.NEW_DVD_DRIVE_REQUIRED,
                                                  ThreeButtonDialog.ButtonYes,
                                                  ThreeButtonDialog.ButtonNo))
                {
                    dialogResult = dlg.ShowDialog(Parent);
                }
                if (dialogResult == DialogResult.Yes)
                {
                    //do not register the event ShowUserInstruction; we show explicitly a message afterwards
                    var createDriveAction = new CreateCdDriveAction(vm);

                    using (var dlg = new ActionProgressDialog(createDriveAction, ProgressBarStyle.Marquee))
                        dlg.ShowDialog(Parent);

                    if (createDriveAction.Succeeded)
                    {
                        ShowMustRebootBox();
                    }

                    InstallTools?.Invoke(createDriveAction);
                }
                return;
            }

            using (var dlg = new WarningDialog(Messages.XS_TOOLS_MESSAGE_ONE_VM,
                                               new ThreeButtonDialog.TBDButton(Messages.INSTALL_XENSERVER_TOOLS_BUTTON,
                                                                               DialogResult.OK, ThreeButtonDialog.ButtonType.ACCEPT, true),
                                               ThreeButtonDialog.ButtonCancel)
            {
                ShowLinkLabel = true,
                LinkText = Messages.INSTALLTOOLS_READ_MORE,
                LinkAction = () => Help.HelpManager.Launch("InstallToolsWarningDialog")
            })
                if (dlg.ShowDialog(Parent) == DialogResult.OK && CheckToolSrs(vm))
                {
                    var installToolsAction = new InstallPVToolsAction(vm, Properties.Settings.Default.ShowHiddenVMs);
                    installToolsAction.Completed += InstallToolsActionCompleted;

                    installToolsAction.RunAsync();
                    InstallTools?.Invoke(installToolsAction);
                }
        }
Пример #2
0
        private void InstallTools_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (e.Button != MouseButtons.Left)
            {
                return;
            }

            if (vms.All(v => Helpers.StockholmOrGreater(v.Connection)))
            {
                Help.HelpManager.Launch("InstallToolsWarningDialog");
                return;
            }

            var cmd = new InstallToolsCommand(Program.MainWindow, vms);

            cmd.InstallTools += _ => InstallTools?.Invoke();
            cmd.Execute();
        }
Пример #3
0
        /// <summary>
        /// Attempts to install tools on several VMs
        /// </summary>
        /// <param name="vms"></param>
        /// <returns>Whether the action was launched (i.e., the user didn't Cancel)</returns>
        private void MultipleVMExecute(List <VM> vms)
        {
            bool newDvdDrivesRequired = false;

            foreach (VM vm in vms)
            {
                if (CanExecute(vm) && vm.FindVMCDROM() == null)
                {
                    newDvdDrivesRequired = true;
                    break;
                }
            }

            if (newDvdDrivesRequired)
            {
                DialogResult dialogResult;
                using (var dlg = new WarningDialog(Messages.NEW_DVD_DRIVES_REQUIRED,
                                                   ThreeButtonDialog.ButtonYes, ThreeButtonDialog.ButtonNo))
                {
                    dialogResult = dlg.ShowDialog(Parent);
                }
                if (dialogResult == DialogResult.Yes)
                {
                    foreach (VM vm in vms)
                    {
                        if (CanExecute(vm) && vm.FindVMCDROM() == null)
                        {
                            //do not register the event ShowUserInstruction; we show explicitly a message afterwards
                            var createDriveAction = new CreateCdDriveAction(vm);

                            using (var dlg = new ActionProgressDialog(createDriveAction, ProgressBarStyle.Marquee))
                            {
                                dlg.ShowDialog(Parent);
                            }
                        }
                    }
                    ShowMustRebootBox();
                    InstallTools?.Invoke(null);
                }
            }
            else
            {
                using (var dlg = new WarningDialog(Messages.XS_TOOLS_MESSAGE_MORE_THAN_ONE_VM,
                                                   new ThreeButtonDialog.TBDButton(Messages.INSTALL_XENSERVER_TOOLS_BUTTON,
                                                                                   DialogResult.OK, ThreeButtonDialog.ButtonType.ACCEPT, true),
                                                   ThreeButtonDialog.ButtonCancel)
                {
                    ShowLinkLabel = true,
                    LinkText = Messages.INSTALLTOOLS_READ_MORE,
                    LinkAction = () => Help.HelpManager.Launch("InstallToolsWarningDialog")
                })
                    if (dlg.ShowDialog(Parent) == DialogResult.OK && CheckToolSrs(vms.ToArray()))
                    {
                        foreach (VM vm in vms)
                        {
                            var installToolsAction = new InstallPVToolsAction(vm, Properties.Settings.Default.ShowHiddenVMs);

                            if (vms.IndexOf(vm) == 0)
                            {
                                installToolsAction.Completed += FirstInstallToolsActionCompleted;
                            }
                            else
                            {
                                installToolsAction.Completed += InstallToolsActionCompleted;
                            }

                            installToolsAction.RunAsync();
                        }

                        InstallTools?.Invoke(null);
                    }
            }
        }