protected override bool Confirm() { if (Program.RunInAutomatedTestMode) return true; if (NeedMultipleWarnings) { MultipleWarningDialog warningDialog = new MultipleWarningDialog( Messages.MESSAGEBOX_DELETE_VD_TITLE_MUTLIPLE, Messages.MULTI_VDI_DELETE_WARNING, Messages.DELETE_ALL_BUTTON_LABEL); SelectedItemCollection selectedItems = GetSelection(); List<VDI> snapshots = new List<VDI>(); List<VDI> isos = new List<VDI>(); List<VDI> systemVDisks = new List<VDI>(); List<VDI> virtualDisks = new List<VDI>(); foreach (VDI vdi in selectedItems.AsXenObjects<VDI>()) { switch (vdi.VDIType) { case VDI.FriendlyType.SNAPSHOT: snapshots.Add(vdi); break; case VDI.FriendlyType.ISO: isos.Add(vdi); break; case VDI.FriendlyType.SYSTEM_DISK: systemVDisks.Add(vdi); break; case VDI.FriendlyType.VIRTUAL_DISK: virtualDisks.Add(vdi); break; case VDI.FriendlyType.NONE: break; } } if (snapshots.Count == 1) { warningDialog.AddWarningMessage( Messages.MESSAGEBOX_DELETE_SNAPSHOT_TITLE, Messages.WARNING_DELETE_SNAPSHOT, snapshots.ConvertAll<IXenObject>(delegate(VDI v){return (IXenObject)v;})); } else if (snapshots.Count > 1) { warningDialog.AddWarningMessage( Messages.MESSAGEBOX_DELETE_SNAPSHOTS_TITLE_MULTIPLE, Messages.WARNING_DELETE_SNAPSHOT_MULTIPLE, snapshots.ConvertAll<IXenObject>(delegate(VDI v){return (IXenObject)v;})); } if (isos.Count == 1) { warningDialog.AddWarningMessage( Messages.MESSAGEBOX_DELETE_ISO_TITLE, Messages.WARNING_DELETE_ISO, isos.ConvertAll<IXenObject>(delegate(VDI v) { return (IXenObject)v; })); } else if (isos.Count > 1) { warningDialog.AddWarningMessage( Messages.MESSAGEBOX_DELETE_ISO_TITLE_MULTIPLE, Messages.WARNING_DELETE_ISO_MULTIPLE, isos.ConvertAll<IXenObject>(delegate(VDI v) { return (IXenObject)v; })); } if (systemVDisks.Count == 1) { warningDialog.AddWarningMessage( Messages.MESSAGEBOX_DELETE_SYS_DISK_TITLE, Messages.WARNING_DELETE_SYS_DISK, systemVDisks.ConvertAll<IXenObject>(delegate(VDI v) { return (IXenObject)v; })); } else if (systemVDisks.Count > 1) { warningDialog.AddWarningMessage( Messages.MESSAGEBOX_DELETE_SYS_DISK_TITLE_MULTIPLE, Messages.WARNING_DELETE_SYS_DISK_MULTIPLE, systemVDisks.ConvertAll<IXenObject>(delegate(VDI v) { return (IXenObject)v; })); } if (virtualDisks.Count == 1) { warningDialog.AddWarningMessage( Messages.MESSAGEBOX_DELETE_VD_TITLE, Messages.WARNING_DELETE_VD, virtualDisks.ConvertAll<IXenObject>(delegate(VDI v) { return (IXenObject)v; })); } else if (virtualDisks.Count > 1) { warningDialog.AddWarningMessage( Messages.MESSAGEBOX_DELETE_VD_TITLE_MUTLIPLE, Messages.WARNING_DELETE_VD_MULTIPLE, virtualDisks.ConvertAll<IXenObject>(delegate(VDI v) { return (IXenObject)v; })); } return warningDialog.ShowDialog(Parent) == DialogResult.Yes; } else { return base.Confirm(); } }
protected override bool Confirm() { if (Program.RunInAutomatedTestMode) return true; MultipleWarningDialog warningDialog = new MultipleWarningDialog( Messages.MESSAGEBOX_DETACH_VD_TITLE_MUTLIPLE, Messages.MULTI_VDI_DETACH_WARNING, Messages.DETACH_ALL_BUTTON_LABEL); SelectedItemCollection selectedItems = GetSelection(); List<VDI> sysDisks = new List<VDI>(); List<VDI> regularDisks = new List<VDI>(); foreach (VDI vdi in selectedItems.AsXenObjects<VDI>()) { if (vdi.type == vdi_type.system) sysDisks.Add(vdi); else regularDisks.Add(vdi); } // Use the regular confirm dialog if we only have one warning type if (sysDisks.Count == 0 || regularDisks.Count == 0) return base.Confirm(); warningDialog.AddWarningMessage( Messages.MESSAGEBOX_DETACH_SYSTEMVD_TITLE, Messages.MESSAGEBOX_DETACH_SYSTEMVD, sysDisks.ConvertAll<IXenObject>(delegate(VDI v) { return (IXenObject)v; })); warningDialog.AddWarningMessage( Messages.MESSAGEBOX_DETACH_VD_TITLE, Messages.MESSAGEBOX_DETACH_VD, regularDisks.ConvertAll<IXenObject>(delegate(VDI v) { return (IXenObject)v; })); return warningDialog.ShowDialog(MainWindowCommandInterface.Form) == System.Windows.Forms.DialogResult.Yes; }