diff --git a/XenAdmin/Commands/CrossPoolMigrateCommand.cs b/XenAdmin/Commands/CrossPoolMigrateCommand.cs index 2a3d0b0f7..06e0def7a 100644 --- a/XenAdmin/Commands/CrossPoolMigrateCommand.cs +++ b/XenAdmin/Commands/CrossPoolMigrateCommand.cs @@ -68,7 +68,10 @@ namespace XenAdmin.Commands public override string ContextMenuText { get { return Messages.HOST_MENU_CPM_TEXT; } } - public override Image MenuImage { get { return Resources._000_MigrateVM_h32bit_16; } } + public override Image MenuImage + { + get { return preSelectedHost == null ? Resources._000_MigrateVM_h32bit_16 : Resources._000_TreeConnected_h32bit_16; } + } protected override void ExecuteCore(SelectedItemCollection selection) { diff --git a/XenAdmin/Commands/VMOperationHostCommand.cs b/XenAdmin/Commands/VMOperationHostCommand.cs index c342f5f92..bddd7e2a2 100644 --- a/XenAdmin/Commands/VMOperationHostCommand.cs +++ b/XenAdmin/Commands/VMOperationHostCommand.cs @@ -32,6 +32,7 @@ using System; using System.Collections.Generic; using System.Drawing; +using System.Linq; using XenAdmin.Core; using XenAdmin.Properties; using XenAPI; @@ -67,10 +68,11 @@ namespace XenAdmin.Commands VM vm = (VM)item.XenObject; string reason = GetVmCannotBootOnHostReason(vm, GetHost(vm), session, operation); - _cantBootReasons[vm] = reason; if (reason == null) _noneCanBoot = false; + else + _cantBootReasons[vm] = reason; } } @@ -83,24 +85,14 @@ namespace XenAdmin.Commands { get { - List uniqueReasons = new List(); + if (_noneCanBoot) + { + var uniqueReasons = _cantBootReasons.Values.Distinct().ToList(); - foreach (VM vm in _cantBootReasons.Keys) - { - if (!uniqueReasons.Contains(_cantBootReasons[vm])) - { - uniqueReasons.Add(_cantBootReasons[vm]); - } - } - - if (_noneCanBoot && uniqueReasons.Count == 1) - { - return string.Format(Messages.MAINWINDOW_CONTEXT_REASON, _text, uniqueReasons[0]); - } - else - { - return _text; + if (uniqueReasons.Count == 1) + return string.Format(Messages.MAINWINDOW_CONTEXT_REASON, _text, uniqueReasons[0]); } + return _text; } } @@ -108,13 +100,13 @@ namespace XenAdmin.Commands { get { - return _noneCanBoot ? Resources._000_ServerDisconnected_h32bit_16 : Resources._000_TreeConnected_h32bit_16; + return Resources._000_TreeConnected_h32bit_16; } } protected override bool CanExecute(VM vm) { - return vm != null && _cantBootReasons.ContainsKey(vm) && _cantBootReasons[vm] == null; + return vm != null && !_cantBootReasons.ContainsKey(vm); } private static string GetVmCannotBootOnHostReason(VM vm, Host host, Session session, vm_operations operation) @@ -172,13 +164,8 @@ namespace XenAdmin.Commands protected override string GetCantExecuteReasonCore(SelectedItem item) { VM vm = item.XenObject as VM; - if (vm == null) - base.GetCantExecuteReasonCore(item); - - if (_cantBootReasons.ContainsKey(vm)) - { + if (vm != null && _cantBootReasons.ContainsKey(vm)) return _cantBootReasons[vm]; - } return base.GetCantExecuteReasonCore(item); }