xenadmin/XenAdmin/Commands/UpgradeVmLaunchUICommand.cs
Gabor Apati-Nagy a73a91c1a7 CP-14573: UI: Improvements on Upgrade VM UI
Fixed when to enable the Command, the screen uses the connection (works for standalone hosts)
Using CollectionChanged instead of BatchCollectionChanged
Removed unnecessary Invoke
Removed values from the VmUpgradeState enum

Signed-off-by: Gabor Apati-Nagy <gabor.apati-nagy@citrix.com>
2015-10-19 12:13:26 +01:00

45 lines
1.4 KiB
C#

using System.Linq;
using XenAdmin.Core;
using XenAdmin.Dialogs;
using XenAdmin.Network;
using XenAPI;
namespace XenAdmin.Commands
{
internal class UpgradeVmLaunchUICommand : Command
{
/// <summary>
/// Initializes a new instance of this Command. The parameter-less constructor is required if
/// this Command is to be attached to a ToolStrip menu item or button. It should not be used in any other scenario.
/// </summary>
public UpgradeVmLaunchUICommand()
{
}
public UpgradeVmLaunchUICommand(IMainWindow mainWindow)
: base(mainWindow)
{
}
protected override void ExecuteCore(SelectedItemCollection selection)
{
new UpgradeVmDialog(selection, MainWindowCommandInterface).Show(Parent);
}
protected override bool CanExecuteCore(SelectedItemCollection selection)
{
IXenConnection connection = null;
if (selection != null && selection.Count == 1)
{
if (selection[0].XenObject is Pool || selection[0].XenObject is Host)
connection = selection[0].XenObject.Connection;
}
return connection != null && connection.IsConnected && Helpers.DundeeOrGreater(connection);
}
}
}