/// <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 AsyncAction SingleVMExecute(VM vm) { if (vm.FindVMCDROM() == null) { if (new ThreeButtonDialog( new ThreeButtonDialog.Details( null, Messages.NEW_DVD_DRIVE_REQUIRED, Messages.XENCENTER), ThreeButtonDialog.ButtonYes, ThreeButtonDialog.ButtonNo).ShowDialog(Parent) == DialogResult.Yes) { MainWindowCommandInterface.AllowHistorySwitch(); CreateCdDriveAction createDriveAction = new CreateCdDriveAction(vm, true,NewDiskDialog.ShowMustRebootBoxCD,NewDiskDialog.ShowVBDWarningBox); new ActionProgressDialog(createDriveAction, ProgressBarStyle.Marquee).ShowDialog(Parent); if (createDriveAction.Succeeded) { ShowMustRebootBox(); } return createDriveAction; } } else { DialogResult dr = new InstallToolsWarningDialog(vm.Connection).ShowDialog(Parent); if (dr == DialogResult.Yes) { MainWindowCommandInterface.AllowHistorySwitch(); InstallPVToolsAction installToolsAction = new InstallPVToolsAction( vm, XSToolsSRNotFound, Properties.Settings.Default.ShowHiddenVMs); installToolsAction.Completed += InstallToolsActionCompleted; installToolsAction.RunAsync(); return installToolsAction; } } return null; }
/// <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 bool MultipleVMExecute(List<VM> vms) { bool newDvdDrivesRequired = false; foreach (VM vm in vms) { if (CanExecute(vm) && vm.FindVMCDROM() == null) { newDvdDrivesRequired = true; break; } } if (newDvdDrivesRequired) { if (new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Warning, Messages.NEW_DVD_DRIVES_REQUIRED, Messages.XENCENTER), ThreeButtonDialog.ButtonYes, ThreeButtonDialog.ButtonNo).ShowDialog(Parent) == DialogResult.Yes) { MainWindowCommandInterface.AllowHistorySwitch(); foreach (VM vm in vms) { if (CanExecute(vm) && vm.FindVMCDROM() == null) { CreateCdDriveAction createDriveAction = new CreateCdDriveAction(vm, true,NewDiskDialog.ShowMustRebootBoxCD,NewDiskDialog.ShowVBDWarningBox); new ActionProgressDialog(createDriveAction, ProgressBarStyle.Marquee).ShowDialog(Parent); } } ShowMustRebootBox(); return true; } } else { List<IXenConnection> vmConnections = new List<IXenConnection>(); foreach (VM vm in vms) vmConnections.Add(vm.Connection); if (new InstallToolsWarningDialog(null, true, vmConnections).ShowDialog(Parent) == DialogResult.Yes) { MainWindowCommandInterface.AllowHistorySwitch(); foreach (VM vm in vms) { InstallPVToolsAction installToolsAction = new InstallPVToolsAction(vm, XSToolsSRNotFound, Properties.Settings.Default.ShowHiddenVMs); if (vms.IndexOf(vm) == 0) { installToolsAction.Completed += FirstInstallToolsActionCompleted; } else { installToolsAction.Completed += InstallToolsActionCompleted; } installToolsAction.RunAsync(); } return true; } } return false; }
/// <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 AsyncAction SingleVMExecute(VM vm) { if (vm.FindVMCDROM() == null) { DialogResult dialogResult; using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( null, Messages.NEW_DVD_DRIVE_REQUIRED, Messages.XENCENTER), ThreeButtonDialog.ButtonYes, ThreeButtonDialog.ButtonNo)) { dialogResult = dlg.ShowDialog(Parent); } if (dialogResult == DialogResult.Yes) { CreateCdDriveAction createDriveAction = new CreateCdDriveAction(vm, true,NewDiskDialog.ShowMustRebootBoxCD,NewDiskDialog.ShowVBDWarningBox); using (var dlg = new ActionProgressDialog(createDriveAction, ProgressBarStyle.Marquee)) { dlg.ShowDialog(Parent); } if (createDriveAction.Succeeded) { ShowMustRebootBox(); } return createDriveAction; } } else { DialogResult dr = new InstallToolsWarningDialog(vm.Connection).ShowDialog(Parent); if (dr == DialogResult.Yes) { var installToolsAction = new InstallPVToolsAction(vm, Properties.Settings.Default.ShowHiddenVMs); installToolsAction.Completed += InstallToolsActionCompleted; installToolsAction.RunAsync(); return installToolsAction; } } return null; }
private void newCDLabel_Click(object sender, EventArgs e) { if (VM != null) { CreateCdDriveAction createDriveAction = new CreateCdDriveAction(VM, false,NewDiskDialog.ShowMustRebootBoxCD,NewDiskDialog.ShowVBDWarningBox); new ActionProgressDialog(createDriveAction, ProgressBarStyle.Marquee).ShowDialog(this); } }
private void newCDLabel_Click(object sender, EventArgs e) { if (VM != null) { CreateCdDriveAction createDriveAction = new CreateCdDriveAction(VM, false,NewDiskDialog.ShowMustRebootBoxCD,NewDiskDialog.ShowVBDWarningBox); new ActionProgressDialog(createDriveAction, ProgressBarStyle.Marquee).ShowDialog(this); if (createDriveAction.Succeeded) { if (!Program.RunInAutomatedTestMode) { new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Information, Messages.NEW_DVD_DRIVE_REBOOT, Messages.NEW_DVD_DRIVE_CREATED)).ShowDialog(Program.MainWindow); } } } }