private void PaintManyInternal(ItemPaintArgs itemPaintArgs) { CurrentRectangle = new Rectangle(); for (int i = 0; i < items.Length; i++) { GridStringItem item = items[i]; Point locStr = itemPaintArgs.Rectangle.Location; locStr.Y += (itemPaintArgs.Rectangle.Height * i) / items.Length; item.OnPaint( new ItemPaintArgs(itemPaintArgs.Graphics, new Rectangle(locStr, new Size(itemPaintArgs.Rectangle.Width, itemPaintArgs.Rectangle.Height / items.Length)), itemPaintArgs.State)); if (item.DataSize.Width > DataSize.Width) { DataSize.Width = item.DataSize.Width; } DataSize.Height += item.DataSize.Height; if (item.CurrentRectangle.Width > CurrentRectangle.Width) { CurrentRectangle.Width = item.CurrentRectangle.Width; } CurrentRectangle.Height += item.CurrentRectangle.Height; } }
public override int CompareTo(GridItemBase gridItem) { GridStringItem other = gridItem as GridStringItem; Object otherdata = other == null ? null : other.sortdata; if (sortdata == null) { return(otherdata == null ? 0 : 1); } if (otherdata == null) { return(-1); } return(StringUtility.NaturalCompare(sortdata.ToString(), other.sortdata.ToString())); }
// NB Brushes and fonts only apply to the sort indicators: those for the header text are declared within the items public GridHeaderArrayItem(GridStringItem[] items, HorizontalAlignment hAlign, VerticalAlignment vAlign, Brush backBrush, Font font, SortOrder defaultSortOrder, int width, int minwidth) : base(hAlign, vAlign, backBrush, font, "_", defaultSortOrder, width, minwidth, null) { this.items = items; }
protected bool CheckVMTools(IXenObject o, out GridItemBase item) { item = null; if (!checkTools) return false; VM vm = o as VM; if (vm != null) { VM.VirtualisationStatus status = vm.virtualisation_status; if (vm.power_state != vm_power_state.Running || status == VM.VirtualisationStatus.OPTIMIZED || status == VM.VirtualisationStatus.UNKNOWN) return false; if (property == PropertyNames.memoryValue) { if (InstallToolsCommand.CanExecute(vm)) { item = new GridStringItem(vm.GetVirtualisationWarningMessages(), HorizontalAlignment.Center, VerticalAlignment.Middle, false, false, QueryPanel.LinkBrush, Program.DefaultFontUnderline, QueryPanel.LinkBrush, Program.DefaultFontUnderline, 3, new EventHandler(delegate { new InstallToolsCommand(Program.MainWindow.CommandInterface, vm).Execute(); }), null); } else { item = new GridStringItem(vm.GetVirtualisationWarningMessages(), HorizontalAlignment.Center, VerticalAlignment.Middle, false, false, QueryPanel.TextBrush, Program.DefaultFont, 3); } } return true; } SR sr = o as SR; if (sr != null && sr.NeedsUpgrading) { if (property == PropertyNames.memoryValue) item = new GridStringItem(Messages.UPGRADE_SR_WARNING, HorizontalAlignment.Center, VerticalAlignment.Middle, false, false, QueryPanel.LinkBrush, Program.DefaultFontUnderline, QueryPanel.LinkBrush, Program.DefaultFontUnderline, 3, new EventHandler(delegate { new UpgradeSRCommand(Program.MainWindow.CommandInterface, sr).Execute(); }), null); return true; } return false; }
/// <remarks> /// For Non-Windows VMs and for Windows VMs pre-Dundee: /// - Memory, Disk and Network values are not available if XenServer Tools are not installed /// /// For Windows VMs on Dundee or higher: /// - Memory value is not available if the Management agent is not installed; /// - Disk and Network vlaues are not available if I/O drivers are not installed /// </remarks> protected bool CheckVMTools(IXenObject o, out GridItemBase item) { item = null; if (!checkTools) return false; VM vm = o as VM; if (vm != null) { VM.VirtualisationStatus status = vm.virtualisation_status; if (vm.power_state != vm_power_state.Running || status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED | VM.VirtualisationStatus.MANAGEMENT_INSTALLED) || status.HasFlag(VM.VirtualisationStatus.UNKNOWN)) return false; if (property == PropertyNames.memoryValue && status.HasFlag(VM.VirtualisationStatus.MANAGEMENT_INSTALLED)) return false; if ((property == PropertyNames.diskText || property == PropertyNames.networkText) && status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED)) return false; string warningMessage; int colSpan; if (property == PropertyNames.memoryValue && !status.HasFlag(VM.VirtualisationStatus.MANAGEMENT_INSTALLED)) { if (vm.HasNewVirtualisationStates) { warningMessage = Messages.VIRTUALIZATION_STATE_VM_MANAGEMENT_AGENT_NOT_INSTALLED; colSpan = 1; } else { warningMessage = vm.GetVirtualisationWarningMessages(); colSpan = 3; } if (InstallToolsCommand.CanExecute(vm)) { item = new GridStringItem(warningMessage, HorizontalAlignment.Center, VerticalAlignment.Middle, false, false, QueryPanel.LinkBrush, Program.DefaultFontUnderline, QueryPanel.LinkBrush, Program.DefaultFontUnderline, colSpan, (sender, args) => new InstallToolsCommand(Program.MainWindow, vm).Execute(), null); } else { item = new GridStringItem(warningMessage, HorizontalAlignment.Center, VerticalAlignment.Middle, false, false, QueryPanel.TextBrush, Program.DefaultFont, colSpan); } } if (property == PropertyNames.diskText && vm.HasNewVirtualisationStates && !status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED)) { warningMessage = Messages.VIRTUALIZATION_STATE_VM_IO_NOT_OPTIMIZED; colSpan = 2; if (InstallToolsCommand.CanExecute(vm)) { item = new GridStringItem(warningMessage, HorizontalAlignment.Center, VerticalAlignment.Middle, false, false, QueryPanel.LinkBrush, Program.DefaultFontUnderline, QueryPanel.LinkBrush, Program.DefaultFontUnderline, colSpan, (sender, args) => new InstallToolsCommand(Program.MainWindow, vm).Execute(), null); } else { item = new GridStringItem(warningMessage, HorizontalAlignment.Center, VerticalAlignment.Middle, false, false, QueryPanel.TextBrush, Program.DefaultFont, colSpan); } } return true; } Pool pool = o as Pool; if (pool != null && !pool.IsPoolFullyUpgraded) { if (property == PropertyNames.memoryValue) { var master = pool.Connection.Resolve(pool.master); item = new GridStringItem(string.Format(Messages.POOL_VERSIONS_LINK_TEXT, master.ProductVersionText), HorizontalAlignment.Center, VerticalAlignment.Middle, false, false, QueryPanel.LinkBrush, Program.DefaultFontUnderline, QueryPanel.LinkBrush, Program.DefaultFontUnderline, 3, (sender, args) => new RollingUpgradeCommand(Program.MainWindow).Execute(), null); } return true; } return false; }
protected bool CheckVMTools(IXenObject o, out GridItemBase item) { item = null; if (!checkTools) return false; VM vm = o as VM; if (vm != null) { VM.VirtualisationStatus status = vm.virtualisation_status; if (vm.power_state != vm_power_state.Running || status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED ) || status.HasFlag(VM.VirtualisationStatus.UNKNOWN)) return false; if (property == PropertyNames.memoryValue) { if (InstallToolsCommand.CanExecute(vm)) { item = new GridStringItem(vm.GetVirtualisationWarningMessages(), HorizontalAlignment.Center, VerticalAlignment.Middle, false, false, QueryPanel.LinkBrush, Program.DefaultFontUnderline, QueryPanel.LinkBrush, Program.DefaultFontUnderline, 3, (sender, args) => new InstallToolsCommand(Program.MainWindow, vm).Execute(), null); } else { item = new GridStringItem(vm.GetVirtualisationWarningMessages(), HorizontalAlignment.Center, VerticalAlignment.Middle, false, false, QueryPanel.TextBrush, Program.DefaultFont, 3); } } return true; } SR sr = o as SR; if (sr != null && sr.NeedsUpgrading) { if (property == PropertyNames.memoryValue) item = new GridStringItem(Messages.UPGRADE_SR_WARNING, HorizontalAlignment.Center, VerticalAlignment.Middle, false, false, QueryPanel.LinkBrush, Program.DefaultFontUnderline, QueryPanel.LinkBrush, Program.DefaultFontUnderline, 3, (sender, args) => new UpgradeSRCommand(Program.MainWindow, sr).Execute(), null); return true; } Pool pool = o as Pool; if (pool != null && !pool.IsPoolFullyUpgraded) { if (property == PropertyNames.memoryValue) { var master = pool.Connection.Resolve(pool.master); item = new GridStringItem(string.Format(Messages.POOL_VERSIONS_LINK_TEXT, master.ProductVersionText), HorizontalAlignment.Center, VerticalAlignment.Middle, false, false, QueryPanel.LinkBrush, Program.DefaultFontUnderline, QueryPanel.LinkBrush, Program.DefaultFontUnderline, 3, (sender, args) => new RollingUpgradeCommand(Program.MainWindow).Execute(), null); } return true; } return false; }
private void AddNoResultsRow() { GridRow row = new GridRow(ROW_HEIGHT); GridStringItem resultsItem = new GridStringItem(Messages.OVERVIEW_NO_RESULTS, HorizontalAlignment.Left, VerticalAlignment.Middle, false, false, TextBrush, Program.DefaultFont, 6); row.AddItem("name", resultsItem); AddRow(row); }
private static void AddCustomFieldsToRow(IXenObject o, GridRow row) { foreach (CustomFieldDefinition customFieldDefinition in CustomFieldsManager.GetCustomFields()) { GridStringItem customFieldItem = new GridStringItem( new CustomFieldWrapper(o, customFieldDefinition), HorizontalAlignment.Center, VerticalAlignment.Middle, false, false, TextBrush, Program.DefaultFont, new EventHandler(delegate { using (PropertiesDialog dialog = new PropertiesDialog(o)) { dialog.SelectCustomFieldsEditPage(); dialog.ShowDialog(); } })); row.AddItem(CustomFieldsManager.CUSTOM_FIELD + customFieldDefinition.Name, customFieldItem); } }