private void RefreshButtons() { bool flag = (this.sr == null) || this.sr.Locked; SelectedItemCollection selectedVDIs = this.SelectedVDIs; DeleteVirtualDiskCommand command = new DeleteVirtualDiskCommand(Program.MainWindow, selectedVDIs) { AllowMultipleVBDDelete = true, AllowRunningVMDelete = true }; if (command.CanExecute()) { this.RemoveButton.Enabled = true; this.RemoveButtonContainer.RemoveAll(); } else { this.RemoveButton.Enabled = false; this.RemoveButtonContainer.SetToolTip(command.ToolTipText); } Command command2 = this.MoveMigrateCommand(selectedVDIs); if (command2.CanExecute()) { this.buttonMove.Enabled = true; this.toolTipContainerMove.RemoveAll(); } else { this.buttonMove.Enabled = false; this.toolTipContainerMove.SetToolTip(command2.ToolTipText); } if (flag) { this.buttonRefresh.Enabled = false; } else if (HelpersGUI.BeingScanned(this.sr)) { this.buttonRefresh.Enabled = false; this.toolTipContainerRescan.SetToolTip(Messages.SCAN_IN_PROGRESS_TOOLTIP); } else { this.buttonRefresh.Enabled = true; this.toolTipContainerRescan.RemoveAll(); } this.addVirtualDiskButton.Enabled = !flag; if (selectedVDIs.Count == 1) { VDI vdi = selectedVDIs.AsXenObjects <VDI>()[0]; this.EditButton.Enabled = (!flag && !vdi.is_a_snapshot) && !vdi.Locked; } else { this.EditButton.Enabled = false; } this.removeDropDownButton.Enabled = command.CanExecute(); }
private void RefreshButtons() { var vdis = dataGridViewVDIs.SelectedRows.Cast <VDIRow>().Select(r => new SelectedItem(r.VDI)).ToList(); // Delete button // The user can see that this disk is attached to more than one VMs. Allow deletion of multiple VBDs (non default behaviour), // but don't allow them to be deleted if a running vm is using the disk (default behaviour). RemoveButton.Command = new DeleteVirtualDiskCommand(Program.MainWindow, vdis) { AllowMultipleVBDDelete = true }; // Move button buttonMove.Command = MoveVirtualDiskDialog.MoveMigrateCommand(Program.MainWindow, new SelectedItemCollection(vdis)); // Rescan button if (sr == null || sr.Locked) { buttonRescan.Enabled = false; } else if (HelpersGUI.BeingScanned(sr)) { buttonRescan.Enabled = false; toolTipContainerRescan.SetToolTip(Messages.SCAN_IN_PROGRESS_TOOLTIP); } else { buttonRescan.Enabled = true; toolTipContainerRescan.RemoveAll(); } // Add VDI button addVirtualDiskButton.Enabled = sr != null && !sr.Locked; // Properties button EditButton.Enabled = vdis.Count == 1 && vdis[0].XenObject is VDI vdi && sr != null && !sr.Locked && !vdi.is_a_snapshot && !vdi.Locked; EditButton.Tag = EditButton.Enabled ? vdis[0].XenObject as VDI : null; }
private void RefreshButtons() { bool srLocked = sr == null || sr.Locked; SelectedItemCollection vdis = SelectedVDIs; // Delete button DeleteVirtualDiskCommand deleteCmd = new DeleteVirtualDiskCommand(Program.MainWindow, vdis); // User has visibility that this disk is related to all it's VM. Allow deletion with multiple VBDs (non default behaviour), // but don't allow them to delete if a running vm is using the disk (default behaviour). deleteCmd.AllowMultipleVBDDelete = true; if (deleteCmd.CanExecute()) { RemoveButton.Enabled = true; RemoveButtonContainer.RemoveAll(); } else { RemoveButton.Enabled = false; RemoveButtonContainer.SetToolTip(deleteCmd.ToolTipText); } // Move button Command moveCmd = MoveMigrateCommand(vdis); if (moveCmd.CanExecute()) { buttonMove.Enabled = true; toolTipContainerMove.RemoveAll(); } else { buttonMove.Enabled = false; toolTipContainerMove.SetToolTip(moveCmd.ToolTipText); } // Rescan button if (srLocked) { buttonRefresh.Enabled = false; } else if (HelpersGUI.BeingScanned(sr)) { buttonRefresh.Enabled = false; toolTipContainerRescan.SetToolTip(Messages.SCAN_IN_PROGRESS_TOOLTIP); } else { buttonRefresh.Enabled = true; toolTipContainerRescan.RemoveAll(); } // Add VDI button addVirtualDiskButton.Enabled = !srLocked; // Properties button if (vdis.Count == 1) { VDI vdi = vdis.AsXenObjects <VDI>()[0]; EditButton.Enabled = !srLocked && !vdi.is_a_snapshot && !vdi.Locked; } else { EditButton.Enabled = false; } // Remove drop down button removeDropDownButton.Enabled = deleteCmd.CanExecute(); }
private void RefreshButtons() { SelectedItemCollection vdis = SelectedVDIs; // Delete button // The user can see that this disk is attached to more than one VMs. Allow deletion of multiple VBDs (non default behaviour), // but don't allow them to be deleted if a running vm is using the disk (default behaviour). DeleteVirtualDiskCommand deleteCmd = new DeleteVirtualDiskCommand(Program.MainWindow, vdis) { AllowMultipleVBDDelete = true }; if (deleteCmd.CanExecute()) { RemoveButton.Enabled = true; RemoveButtonContainer.RemoveAll(); } else { RemoveButton.Enabled = false; RemoveButtonContainer.SetToolTip(deleteCmd.ToolTipText); } // Move button Command moveCmd = MoveVirtualDiskDialog.MoveMigrateCommand(Program.MainWindow, vdis); if (moveCmd.CanExecute()) { buttonMove.Enabled = true; toolTipContainerMove.RemoveAll(); } else { buttonMove.Enabled = false; toolTipContainerMove.SetToolTip(moveCmd.ToolTipText); } // Rescan button if (sr == null || sr.Locked) { buttonRescan.Enabled = false; } else if (HelpersGUI.BeingScanned(sr)) { buttonRescan.Enabled = false; toolTipContainerRescan.SetToolTip(Messages.SCAN_IN_PROGRESS_TOOLTIP); } else { buttonRescan.Enabled = true; toolTipContainerRescan.RemoveAll(); } // Add VDI button addVirtualDiskButton.Enabled = sr != null && !sr.Locked; // Properties button if (vdis.Count == 1) { VDI vdi = vdis.AsXenObjects <VDI>()[0]; EditButton.Enabled = sr != null && !sr.Locked && !vdi.is_a_snapshot && !vdi.Locked; } else { EditButton.Enabled = false; } }