Merge pull request #14 from kc284/master

Refactored MainWindow to derive from IMainWindow rather than implement a field deriving from this interface.
This commit is contained in:
Gabor Apati-Nagy 2014-01-27 07:11:14 -08:00
commit f0021bf7d7
59 changed files with 301 additions and 410 deletions

View File

@ -172,7 +172,7 @@ namespace XenAdmin.Actions.Wlb
// Set new ntol, then retry action
XenAPI.Pool.set_ha_host_failures_to_tolerate(session, this.Pool.opaque_ref, newNtol);
// ntol set succeeded, start new action
Program.MainWindow.closeActiveWizards(vm);
Program.MainWindow.CloseActiveWizards(vm);
new VMMigrateAction(vm,toHost).RunAsync();
});
action.RunAsync();

View File

@ -62,7 +62,7 @@ namespace XenAdmin.Alerts
{
get
{
return () => new IqnPropertiesCommand(Program.MainWindow.CommandInterface, Host).Execute();
return () => new IqnPropertiesCommand(Program.MainWindow, Host).Execute();
}
}
}

View File

@ -339,7 +339,7 @@ namespace XenAdmin.Alerts
case XenAPI.Message.MessageType.HA_STATEFILE_APPROACHING_TIMEOUT:
case XenAPI.Message.MessageType.HA_STATEFILE_LOST:
case XenAPI.Message.MessageType.HA_XAPI_HEALTHCHECK_APPROACHING_TIMEOUT:
return () => new HACommand(Program.MainWindow.CommandInterface, XenObject.Connection).Execute();
return () => new HACommand(Program.MainWindow, XenObject.Connection).Execute();
case XenAPI.Message.MessageType.LICENSE_EXPIRES_SOON:
case XenAPI.Message.MessageType.LICENSE_DOES_NOT_SUPPORT_POOLING:

View File

@ -73,7 +73,7 @@ namespace XenAdmin.Commands
c.CachePopulated += c_CachePopulated;
}
XenConnectionUI.BeginConnect(c, false, null, false);
MainWindowCommandInterface.Refresh();
MainWindowCommandInterface.RequestRefreshTreeView();
});
}
}

View File

@ -1,212 +0,0 @@
/* Copyright (c) Citrix Systems Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms,
* with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above
* copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the
* following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel;
using XenAdmin.Network;
using XenAPI;
using System.Collections.ObjectModel;
using XenAdmin.Actions;
using XenAdmin.Core;
namespace XenAdmin
{
/// <summary>
/// An interface by which the Commands communicate with MainWindow. This abstraction improves maintainability
/// and testability of the Commands.
/// </summary>
public interface IMainWindow
{
void Invoke(MethodInvoker method);
bool SelectObjectInTree(IXenObject xenObject);
void TrySelectNewObjectInTree(Predicate<object> tagMatch, bool selectNode, bool expandNode, bool ensureNodeVisible);
void TrySelectNewObjectInTree(IXenConnection c, bool selectNode, bool expandNode, bool ensureNodeVisible);
void Refresh();
void ShowPerXenModelObjectWizard(IXenObject obj, Form wizard);
void ShowPerConnectionWizard(IXenConnection connection, Form wizard);
void ShowForm(Type type);
void ShowForm(Type type, object[] args);
void CloseActiveWizards(IXenConnection connection);
void CloseActiveWizards(IXenObject xenObject);
Collection<IXenConnection> GetXenConnectionsCopy();
void SaveServerList();
ReadOnlyCollection<ActionBase> History { get; }
bool DoSearch(string filename);
bool RunInAutomatedTestMode { get;}
void RemoveConnection(IXenConnection connection);
void BringToFront();
void PutSelectedNodeIntoEditMode();
void SwitchToTab(MainWindow.Tab tab);
bool MenuShortcutsEnabled { get;}
Form Form { get; }
}
partial class MainWindow
{
/// <summary>
/// The MainWindow implementation of <see cref="IMainWindowCommandInterface"/>. Used by Commands to
/// communicate with <see cref="MainWindow"/>.
/// </summary>
internal class MainWindowCommandInterface : IMainWindow
{
private readonly MainWindow _owner;
public MainWindowCommandInterface(MainWindow owner)
{
Util.ThrowIfParameterNull(owner, "owner");
_owner = owner;
}
#region IMainWindowCommandInterface Members
public Form Form
{
get
{
return _owner;
}
}
public void Invoke(MethodInvoker method)
{
Program.Invoke(_owner, method);
}
public bool SelectObjectInTree(IXenObject xenObject)
{
return _owner.SelectObject(xenObject);
}
public void Refresh()
{
_owner.RequestRefreshTreeView();
}
public void ShowPerXenModelObjectWizard(IXenObject obj, Form wizard)
{
_owner.ShowPerXenModelObjectWizard(obj, wizard);
}
public void ShowPerConnectionWizard(IXenConnection connection, Form wizard)
{
_owner.ShowPerConnectionWizard(connection, wizard);
}
public void ShowForm(Type type)
{
_owner.ShowForm(type);
}
public void ShowForm(Type type, object[] args)
{
_owner.ShowForm(type, args);
}
public void CloseActiveWizards(IXenConnection connection)
{
_owner.closeActiveWizards(connection);
}
public void CloseActiveWizards(IXenObject xenObject)
{
_owner.closeActiveWizards(xenObject);
}
public Collection<IXenConnection> GetXenConnectionsCopy()
{
return new Collection<IXenConnection>(ConnectionsManager.XenConnectionsCopy);
}
public void SaveServerList()
{
Settings.SaveServerList();
}
public ReadOnlyCollection<ActionBase> History
{
get
{
return new ReadOnlyCollection<ActionBase>(ConnectionsManager.History);
}
}
public bool DoSearch(string filename)
{
return _owner.DoSearch(filename);
}
public bool RunInAutomatedTestMode
{
get { return Program.RunInAutomatedTestMode; }
}
public void RemoveConnection(IXenConnection connection)
{
ConnectionsManager.ClearCacheAndRemoveConnection(connection);
}
public void BringToFront()
{
HelpersGUI.BringFormToFront(_owner);
}
public void PutSelectedNodeIntoEditMode()
{
_owner.EditSelectedNodeInTreeView();
}
public void SwitchToTab(Tab tab)
{
_owner.SwitchToTab(tab);
}
public void TrySelectNewObjectInTree(Predicate<object> tagMatch, bool selectNode, bool expandNode, bool ensureNodeVisible)
{
_owner.TrySelectNewNode(tagMatch, selectNode, expandNode, ensureNodeVisible);
}
public void TrySelectNewObjectInTree(IXenConnection c, bool selectNode, bool expandNode, bool ensureNodeVisible)
{
_owner.TrySelectNewNode(c, selectNode, expandNode, ensureNodeVisible);
}
public bool MenuShortcutsEnabled
{
get { return _owner._menuShortcuts; }
}
#endregion
}
}
}

View File

@ -333,7 +333,7 @@ namespace XenAdmin.Commands
if (vbd.currently_attached)
{
//Check if we can unplug
DeactivateVBDCommand cmd = new DeactivateVBDCommand(Program.MainWindow.CommandInterface, vbd);
DeactivateVBDCommand cmd = new DeactivateVBDCommand(Program.MainWindow, vbd);
if (!AllowRunningVMDelete || !cmd.CanExecute())
return false;
}
@ -416,7 +416,7 @@ namespace XenAdmin.Commands
return string.Format(Messages.CANNOT_DELETE_VDI_ACTIVE_ON,
Helpers.GetName(vm).Ellipsise(20));
}
DeactivateVBDCommand cmd = new DeactivateVBDCommand(Program.MainWindow.CommandInterface, vbd);
DeactivateVBDCommand cmd = new DeactivateVBDCommand(Program.MainWindow, vbd);
if (!cmd.CanExecute())
{
return string.Format(Messages.CANNOT_DELETE_CANNOT_DEACTIVATE_REASON,

View File

@ -117,7 +117,7 @@ namespace XenAdmin.Commands
if (!vbd.currently_attached)
continue;
DeactivateVBDCommand cmd = new DeactivateVBDCommand(Program.MainWindow.CommandInterface, vbd);
DeactivateVBDCommand cmd = new DeactivateVBDCommand(Program.MainWindow, vbd);
if (!cmd.CanExecute())
return false;
}
@ -140,7 +140,7 @@ namespace XenAdmin.Commands
if (!vbd.currently_attached)
continue;
DeactivateVBDCommand cmd = new DeactivateVBDCommand(Program.MainWindow.CommandInterface, vbd);
DeactivateVBDCommand cmd = new DeactivateVBDCommand(Program.MainWindow, vbd);
if (!cmd.CanExecute())
return cmd.ToolTipText;
}

View File

@ -150,7 +150,7 @@ namespace XenAdmin.Commands
XenDialogBase.CloseAll(connection);
connection.EndConnect();
MainWindowCommandInterface.SaveServerList();
MainWindowCommandInterface.Refresh();
MainWindowCommandInterface.RequestRefreshTreeView();
}
}
}

View File

@ -128,9 +128,9 @@ namespace XenAdmin.Commands
MainWindowCommandInterface.CloseActiveWizards(host.Connection);
var action = new EnableHostAction(host, result == DialogResult.Yes,AddHostToPoolCommand.EnableNtolDialog);
action.Completed += delegate { MainWindowCommandInterface.Refresh(); };
action.Completed += delegate { MainWindowCommandInterface.RequestRefreshTreeView(); };
action.RunAsync();
MainWindowCommandInterface.Refresh();
MainWindowCommandInterface.RequestRefreshTreeView();
}
protected override void ExecuteCore(SelectedItemCollection selection)

View File

@ -95,7 +95,7 @@ namespace XenAdmin.Commands
foreach (Host host in selection.AsXenObjects<Host>(CanExecute))
{
var action = new HostPowerOnAction( host);
action.Completed += s => MainWindowCommandInterface.Refresh();
action.Completed += s => MainWindowCommandInterface.RequestRefreshTreeView();
actions.Add(action);
}
RunMultipleActions(actions, null, Messages.ACTION_HOST_STARTING, Messages.ACTION_HOST_STARTED, true);

View File

@ -71,7 +71,7 @@ namespace XenAdmin.Commands
{
MainWindowCommandInterface.CloseActiveWizards(host.Connection);
RebootHostAction action = new RebootHostAction( host,AddHostToPoolCommand.NtolDialog);
action.Completed += s => MainWindowCommandInterface.Refresh();
action.Completed += s => MainWindowCommandInterface.RequestRefreshTreeView();
actions.Add(action);
}
RunMultipleActions(actions, null, Messages.ACTION_HOSTS_REBOOTING, Messages.ACTION_HOSTS_REBOOTED, true);

View File

@ -78,7 +78,7 @@ namespace XenAdmin.Commands
}
}
MainWindowCommandInterface.Refresh();
MainWindowCommandInterface.RequestRefreshTreeView();
}
private void Connection_CachePopulated(object sender, EventArgs e)

View File

@ -80,7 +80,7 @@ namespace XenAdmin.Commands
}
MainWindowCommandInterface.SaveServerList();
MainWindowCommandInterface.Refresh();
MainWindowCommandInterface.RequestRefreshTreeView();
}
private static bool CanExecute(Host host)

View File

@ -199,7 +199,7 @@ namespace XenAdmin.Commands
MainWindowCommandInterface.Invoke(delegate
{
XenConnectionUI.BeginConnect(connection, false, null, false);
MainWindowCommandInterface.Refresh();
MainWindowCommandInterface.RequestRefreshTreeView();
});
return;
}

View File

@ -84,7 +84,7 @@ namespace XenAdmin.Commands
private void Execute(Host host, string filepath)
{
MainWindowCommandInterface.BringToFront();
HelpersGUI.BringFormToFront(MainWindowCommandInterface.Form);
if (filepath == "")
{

View File

@ -72,7 +72,7 @@ namespace XenAdmin.Commands
{
this.MainWindowCommandInterface.CloseActiveWizards(host.Connection);
ShutdownHostAction action = new ShutdownHostAction(host,AddHostToPoolCommand.NtolDialog);
action.Completed += e => MainWindowCommandInterface.Refresh();
action.Completed += e => MainWindowCommandInterface.RequestRefreshTreeView();
actions.Add(action);
}
RunMultipleActions(actions, null, Messages.ACTION_HOSTS_SHUTTING_DOWN, Messages.ACTION_HOSTS_SHUTDOWN, true);

View File

@ -77,7 +77,7 @@ namespace XenAdmin.Commands
{
foreach (VM vm in vms)
{
foreach (ActionBase action in MainWindowCommandInterface.History)
foreach (ActionBase action in ConnectionsManager.History)
{
if (vm.Equals(action.VM) && !action.IsCompleted && action.CanCancel)
{

View File

@ -501,7 +501,7 @@ namespace XenAdmin.ConsoleView
private void cdLabel_Click(object sender, EventArgs e)
{
new InstallToolsCommand(Program.MainWindow.CommandInterface, source, this).Execute();
new InstallToolsCommand(Program.MainWindow, source, this).Execute();
}
private void updatePowerState()
@ -644,7 +644,7 @@ namespace XenAdmin.ConsoleView
{
DisablePowerStateLabel(powerStateLabel.Text);
new StartVMCommand(Program.MainWindow.CommandInterface, source).Execute();
new StartVMCommand(Program.MainWindow, source).Execute();
}
break;
case vm_power_state.Paused:
@ -657,7 +657,7 @@ namespace XenAdmin.ConsoleView
if (source.allowed_operations.Contains(vm_operations.resume))
{
DisablePowerStateLabel(powerStateLabel.Text);
new ResumeVMCommand(Program.MainWindow.CommandInterface, source).Execute();
new ResumeVMCommand(Program.MainWindow, source).Execute();
}
break;
}
@ -1261,18 +1261,18 @@ namespace XenAdmin.ConsoleView
// We're looking at the host console
if (host.Connection.IsConnected)
{
contextMenuItems.Add(new ShutDownHostCommand(Program.MainWindow.CommandInterface, host, this));
contextMenuItems.Add(new RebootHostCommand(Program.MainWindow.CommandInterface, host, this));
contextMenuItems.Add(new ShutDownHostCommand(Program.MainWindow, host, this));
contextMenuItems.Add(new RebootHostCommand(Program.MainWindow, host, this));
}
}
else
{
contextMenuItems.AddIfEnabled(new ShutDownVMCommand(Program.MainWindow.CommandInterface, source, this));
contextMenuItems.AddIfEnabled(new RebootVMCommand(Program.MainWindow.CommandInterface, source, this));
contextMenuItems.AddIfEnabled(new SuspendVMCommand(Program.MainWindow.CommandInterface, source, this));
contextMenuItems.AddIfEnabled(new InstallToolsCommand(Program.MainWindow.CommandInterface, source, this));
contextMenuItems.AddIfEnabled(new ForceVMShutDownCommand(Program.MainWindow.CommandInterface, source, this));
contextMenuItems.AddIfEnabled(new ForceVMRebootCommand(Program.MainWindow.CommandInterface, source, this));
contextMenuItems.AddIfEnabled(new ShutDownVMCommand(Program.MainWindow, source, this));
contextMenuItems.AddIfEnabled(new RebootVMCommand(Program.MainWindow, source, this));
contextMenuItems.AddIfEnabled(new SuspendVMCommand(Program.MainWindow, source, this));
contextMenuItems.AddIfEnabled(new InstallToolsCommand(Program.MainWindow, source, this));
contextMenuItems.AddIfEnabled(new ForceVMShutDownCommand(Program.MainWindow, source, this));
contextMenuItems.AddIfEnabled(new ForceVMRebootCommand(Program.MainWindow, source, this));
}
LifeCycleMenuStrip.Items.Clear();

View File

@ -254,7 +254,7 @@ namespace XenAdmin.Controls.Ballooning
if (e.Button != MouseButtons.Left)
return;
if (new InstallToolsCommand(Program.MainWindow.CommandInterface, vms).ConfirmAndExecute())
if (new InstallToolsCommand(Program.MainWindow, vms).ConfirmAndExecute())
OnInstallTools();
}

View File

@ -429,17 +429,17 @@ namespace XenAdmin.Controls.MainWindowControls
private List<DragDropCommand> GetDragDropCommands(VirtualTreeNode targetNode, IDataObject dragData)
{
List<DragDropCommand> commands = new List<DragDropCommand>();
commands.Add(new DragDropAddHostToPoolCommand(Program.MainWindow.CommandInterface, targetNode, dragData));
commands.Add(new DragDropMigrateVMCommand(Program.MainWindow.CommandInterface, targetNode, dragData));
commands.Add(new DragDropRemoveHostFromPoolCommand(Program.MainWindow.CommandInterface, targetNode, dragData));
commands.Add(new DragDropAddHostToPoolCommand(Program.MainWindow, targetNode, dragData));
commands.Add(new DragDropMigrateVMCommand(Program.MainWindow, targetNode, dragData));
commands.Add(new DragDropRemoveHostFromPoolCommand(Program.MainWindow, targetNode, dragData));
if (NavigationMode == NavigationPane.NavigationMode.Tags
|| NavigationMode == NavigationPane.NavigationMode.Folders
|| NavigationMode == NavigationPane.NavigationMode.CustomFields
|| NavigationMode == NavigationPane.NavigationMode.vApps)
{
commands.Add(new DragDropTagCommand(Program.MainWindow.CommandInterface, targetNode, dragData));
commands.Add(new DragDropIntoFolderCommand(Program.MainWindow.CommandInterface, targetNode, dragData));
commands.Add(new DragDropTagCommand(Program.MainWindow, targetNode, dragData));
commands.Add(new DragDropIntoFolderCommand(Program.MainWindow, targetNode, dragData));
}
return commands;
@ -483,17 +483,17 @@ namespace XenAdmin.Controls.MainWindowControls
{
if (e.Node.Tag == null)// XenCenter (top most)
{
TreeContextMenu.Items.Add(new CommandToolStripMenuItem(new AddHostCommand(Program.MainWindow.CommandInterface), true));
TreeContextMenu.Items.Add(new CommandToolStripMenuItem(new NewPoolCommand(Program.MainWindow.CommandInterface, new SelectedItem[0]), true));
TreeContextMenu.Items.Add(new CommandToolStripMenuItem(new ConnectAllHostsCommand(Program.MainWindow.CommandInterface), true));
TreeContextMenu.Items.Add(new CommandToolStripMenuItem(new DisconnectAllHostsCommand(Program.MainWindow.CommandInterface), true));
TreeContextMenu.Items.Add(new CommandToolStripMenuItem(new AddHostCommand(Program.MainWindow), true));
TreeContextMenu.Items.Add(new CommandToolStripMenuItem(new NewPoolCommand(Program.MainWindow, new SelectedItem[0]), true));
TreeContextMenu.Items.Add(new CommandToolStripMenuItem(new ConnectAllHostsCommand(Program.MainWindow), true));
TreeContextMenu.Items.Add(new CommandToolStripMenuItem(new DisconnectAllHostsCommand(Program.MainWindow), true));
}
else
{
var groupingTag = e.Node.Tag as GroupingTag;
if (groupingTag != null && groupingTag.Grouping as OrganizationViewFolders != null)
TreeContextMenu.Items.Add(new CommandToolStripMenuItem(
new NewFolderCommand(Program.MainWindow.CommandInterface, new[] { new SelectedItem(groupingTag, e.Node) }),
new NewFolderCommand(Program.MainWindow, new[] { new SelectedItem(groupingTag, e.Node) }),
true));
}
}
@ -526,11 +526,11 @@ namespace XenAdmin.Controls.MainWindowControls
if (nodes.Count == 1 && nodes[0].Nodes.Count == 0)
return;
Command cmd = new CollapseChildTreeNodesCommand(Program.MainWindow.CommandInterface, nodes);
Command cmd = new CollapseChildTreeNodesCommand(Program.MainWindow, nodes);
if (cmd.CanExecute())
TreeContextMenu.Items.Insert(insertIndex, new CommandToolStripMenuItem(cmd, true));
cmd = new ExpandTreeNodesCommand(Program.MainWindow.CommandInterface, nodes);
cmd = new ExpandTreeNodesCommand(Program.MainWindow, nodes);
if (cmd.CanExecute())
TreeContextMenu.Items.Insert(insertIndex, new CommandToolStripMenuItem(cmd, true));
}
@ -545,12 +545,12 @@ namespace XenAdmin.Controls.MainWindowControls
return;
}
Command cmd = new RemoveFromFolderCommand(Program.MainWindow.CommandInterface, nodes);
Command cmd = new RemoveFromFolderCommand(Program.MainWindow, nodes);
if (cmd.CanExecute())
TreeContextMenu.Items.Insert(insertIndex, new CommandToolStripMenuItem(cmd, true));
cmd = new UntagCommand(Program.MainWindow.CommandInterface, nodes);
cmd = new UntagCommand(Program.MainWindow, nodes);
if (cmd.CanExecute())
TreeContextMenu.Items.Insert(insertIndex, new CommandToolStripMenuItem(cmd, true));
@ -593,14 +593,14 @@ namespace XenAdmin.Controls.MainWindowControls
{
if (folder != null)
{
RenameFolderCommand cmd = new RenameFolderCommand(Program.MainWindow.CommandInterface, folder, e.Label);
RenameFolderCommand cmd = new RenameFolderCommand(Program.MainWindow, folder, e.Label);
command = cmd;
cmd.Completed += completed;
newTag = new Folder(null, e.Label);
}
else if (groupingTag != null)
{
RenameTagCommand cmd = new RenameTagCommand(Program.MainWindow.CommandInterface, groupingTag.Group.ToString(), e.Label);
RenameTagCommand cmd = new RenameTagCommand(Program.MainWindow, groupingTag.Group.ToString(), e.Label);
command = cmd;
cmd.Completed += completed;
newTag = new GroupingTag(groupingTag.Grouping, groupingTag.Parent, e.Label);
@ -759,7 +759,7 @@ namespace XenAdmin.Controls.MainWindowControls
break;
case Keys.F2:
var cmd = new PropertiesCommand(Program.MainWindow.CommandInterface, Program.MainWindow.SelectionManager.Selection);
var cmd = new PropertiesCommand(Program.MainWindow, Program.MainWindow.SelectionManager.Selection);
if (cmd.CanExecute())
cmd.Execute();
break;
@ -802,7 +802,7 @@ namespace XenAdmin.Controls.MainWindowControls
}
if (conn != null && !conn.IsConnected)
{
new ReconnectHostCommand(Program.MainWindow.CommandInterface, conn).Execute();
new ReconnectHostCommand(Program.MainWindow, conn).Execute();
return;
}
@ -813,15 +813,15 @@ namespace XenAdmin.Controls.MainWindowControls
if (vm.is_a_template)
{
cmd = new NewVMCommand(Program.MainWindow.CommandInterface, Program.MainWindow.SelectionManager.Selection);
cmd = new NewVMCommand(Program.MainWindow, Program.MainWindow.SelectionManager.Selection);
}
else if (vm.power_state == vm_power_state.Halted && vm.allowed_operations.Contains(vm_operations.start))
{
cmd = new StartVMCommand(Program.MainWindow.CommandInterface, Program.MainWindow.SelectionManager.Selection);
cmd = new StartVMCommand(Program.MainWindow, Program.MainWindow.SelectionManager.Selection);
}
else if (vm.power_state == vm_power_state.Suspended && vm.allowed_operations.Contains(vm_operations.resume))
{
cmd = new ResumeVMCommand(Program.MainWindow.CommandInterface, Program.MainWindow.SelectionManager.Selection);
cmd = new ResumeVMCommand(Program.MainWindow, Program.MainWindow.SelectionManager.Selection);
}
if (cmd != null && cmd.CanExecute())
@ -835,7 +835,7 @@ namespace XenAdmin.Controls.MainWindowControls
Host host = e.Node.Tag as Host;
if (host != null)
{
Command cmd = new PowerOnHostCommand(Program.MainWindow.CommandInterface, host);
Command cmd = new PowerOnHostCommand(Program.MainWindow, host);
if (cmd.CanExecute())
{
treeView.SelectedNode = e.Node;

View File

@ -507,7 +507,7 @@ namespace XenAdmin.Controls.NetworkingTab
Proxy_VIF pVif = d.GetNewSettings();
pVif.VM = vm.opaque_ref;
CreateVIFCommand action = new CreateVIFCommand(Program.MainWindow.CommandInterface,vm, pVif);
CreateVIFCommand action = new CreateVIFCommand(Program.MainWindow, vm, pVif);
action.Execute();
}
else if (XenObject is Host)
@ -568,7 +568,7 @@ namespace XenAdmin.Controls.NetworkingTab
XenAPI.Network network = SelectedNetwork;
if (network != null && network.IsBond)
{
var destroyBondCommand = new DestroyBondCommand(Program.MainWindow.CommandInterface, network);
var destroyBondCommand = new DestroyBondCommand(Program.MainWindow, network);
destroyBondCommand.Execute();
}
else
@ -730,7 +730,7 @@ namespace XenAdmin.Controls.NetworkingTab
return;
Proxy_VIF proxyVIF = d.GetNewSettings();
UpdateVIFCommand command = new UpdateVIFCommand(Program.MainWindow.CommandInterface,vm, vif, proxyVIF);
UpdateVIFCommand command = new UpdateVIFCommand(Program.MainWindow, vm, vif, proxyVIF);
InBuildList = true;
command.Completed += new EventHandler((s, f) => Program.Invoke(this, () =>
{

View File

@ -467,7 +467,7 @@ namespace XenAdmin.Controls.Wlb
private void linkLabelReportHistory_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
new ViewWorkloadReportsCommand(Program.MainWindow.CommandInterface, _pool, ReportFile, true).Execute();
new ViewWorkloadReportsCommand(Program.MainWindow, _pool, ReportFile, true).Execute();
}
private static void UpdateRow(ListViewItem row)

View File

@ -52,7 +52,7 @@ namespace XenAdmin.Diagnostics.Problems.HostProblem
protected override AsyncAction CreateAction(out bool cancelled)
{
cancelled = false;
Program.MainWindow.closeActiveWizards(Server.Connection);
Program.MainWindow.CloseActiveWizards(Server.Connection);
return new EnableHostAction(Server, false, AddHostToPoolCommand.EnableNtolDialog);
}
@ -63,7 +63,7 @@ namespace XenAdmin.Diagnostics.Problems.HostProblem
public override AsyncAction UnwindChanges()
{
Program.MainWindow.closeActiveWizards(Server.Connection);
Program.MainWindow.CloseActiveWizards(Server.Connection);
return new DisableHostAction(Server); ;
}

View File

@ -68,7 +68,7 @@ namespace XenAdmin.Diagnostics.Problems.HostProblem
bool canStartHost = false;
Program.Invoke(Program.MainWindow, delegate
{
var powerOnCommand = new PowerOnHostCommand(Program.MainWindow.CommandInterface, Server);
var powerOnCommand = new PowerOnHostCommand(Program.MainWindow, Server);
canStartHost = powerOnCommand.CanExecute();
});
return canStartHost;

View File

@ -139,7 +139,7 @@ namespace XenAdmin.Dialogs
private void okButton_Click(object sender, EventArgs e)
{
ApplyLicenseEditionCommand command = new ApplyLicenseEditionCommand(Program.MainWindow.CommandInterface, xos, GetCheckedEdition(), licenseServerNameTextBox.Text, licenseServerPortTextBox.Text, this);
ApplyLicenseEditionCommand command = new ApplyLicenseEditionCommand(Program.MainWindow, xos, GetCheckedEdition(), licenseServerNameTextBox.Text, licenseServerPortTextBox.Text, this);
command.Succedded += delegate
{

View File

@ -568,7 +568,7 @@ namespace XenAdmin.Dialogs
break;
case Solution.InstallPVDrivers:
a = new InstallToolsCommand(Program.MainWindow.CommandInterface, vm).ExecuteGetAction();
a = new InstallToolsCommand(Program.MainWindow, vm).ExecuteGetAction();
// The install pv tools action is marked as complete after they have taken the user to the console and loaded the disc
// Rescanning when the action is 'complete' in this case doesn't gain us anything then. Keep showing the "Click here to install PV drivers" text.
dialog.SetSession(a);
@ -602,7 +602,7 @@ namespace XenAdmin.Dialogs
Program.MainWindow.UpdateToolbars();
//Closes all per-Connection and per-VM wizards for the given connection.
Program.MainWindow.closeActiveWizards(host.Connection);
Program.MainWindow.CloseActiveWizards(host.Connection);
EvacuateButton.Enabled = false; // disable evac button, it will get re-enabled when action completes

View File

@ -229,7 +229,7 @@ namespace XenAdmin.Dialogs
private void newButton_Click(object sender, EventArgs e)
{
new NewFolderCommand(Program.MainWindow.CommandInterface, null, this).Execute();
new NewFolderCommand(Program.MainWindow, null, this).Execute();
}
private void newMenuItem_Click(object sender, EventArgs e)
@ -242,7 +242,7 @@ namespace XenAdmin.Dialogs
if (folder == null)
return;
new NewFolderCommand(Program.MainWindow.CommandInterface, folder, this).Execute();
new NewFolderCommand(Program.MainWindow, folder, this).Execute();
}
private void treeView_NodeMouseClick(object sender, VirtualTreeNodeMouseClickEventArgs e)

View File

@ -273,7 +273,7 @@ namespace XenAdmin.Dialogs
protected virtual IMainWindow CommandInterface
{
get { return Program.MainWindow.CommandInterface; }
get { return Program.MainWindow; }
}
private void SetRowInformation(List<LicenseDataGridViewRow> rows, string information)

View File

@ -63,7 +63,7 @@ namespace XenAdmin.Dialogs
// start logout then wait for connection to become disconnected
xc.ConnectionStateChanged += new EventHandler<EventArgs>(xc_ConnectionStateChanged);
if (!new DisconnectCommand(Program.MainWindow.CommandInterface, xc, true).Execute())
if (!new DisconnectCommand(Program.MainWindow, xc, true).Execute())
{
// User wimped out
xc.ConnectionStateChanged -= xc_ConnectionStateChanged;
@ -96,7 +96,7 @@ namespace XenAdmin.Dialogs
void xc_CachePopulated(object sender, EventArgs e)
{
xc.CachePopulated -= new EventHandler<EventArgs>(xc_CachePopulated);
Program.MainWindow.CommandInterface.TrySelectNewObjectInTree(xc, true, true, false);
Program.MainWindow.TrySelectNewObjectInTree(xc, true, true, false);
}
private void buttonCancel_Click(object sender, EventArgs e)

View File

@ -75,7 +75,7 @@ namespace XenAdmin.Dialogs
private void button3_Click(object sender, EventArgs e)
{
new AddHostCommand(Program.MainWindow.CommandInterface, this).Execute();
new AddHostCommand(Program.MainWindow, this).Execute();
}
public Host TheHost

View File

@ -82,7 +82,7 @@ namespace XenAdmin.Dialogs
private List<VDI> VdisToMove()
{
return (from vdi in vdis
let moveCmd = new MoveVirtualDiskCommand(Program.MainWindow.CommandInterface, vdi)
let moveCmd = new MoveVirtualDiskCommand(Program.MainWindow, vdi)
where moveCmd.CanExecute()
select vdi).ToList();
}
@ -90,7 +90,7 @@ namespace XenAdmin.Dialogs
private List<VDI> VdisToMigrate()
{
return (from vdi in vdis
let cmd = new MigrateVirtualDiskCommand(Program.MainWindow.CommandInterface, vdi)
let cmd = new MigrateVirtualDiskCommand(Program.MainWindow, vdi)
where cmd.CanExecute()
select vdi).ToList();
}

70
XenAdmin/IMainWindow.cs Normal file
View File

@ -0,0 +1,70 @@
/* Copyright (c) Citrix Systems Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms,
* with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above
* copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the
* following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using XenAdmin.Network;
using XenAPI;
using System.Collections.ObjectModel;
namespace XenAdmin
{
/// <summary>
/// An interface by which the Commands communicate with MainWindow. This abstraction improves maintainability
/// and testability of the Commands.
/// </summary>
public interface IMainWindow
{
void Invoke(MethodInvoker method);
bool SelectObjectInTree(IXenObject xenObject);
void TrySelectNewObjectInTree(Predicate<object> tagMatch, bool selectNode, bool expandNode, bool ensureNodeVisible);
void TrySelectNewObjectInTree(IXenConnection c, bool selectNode, bool expandNode, bool ensureNodeVisible);
void RequestRefreshTreeView();
void ShowPerXenModelObjectWizard(IXenObject obj, Form wizard);
void ShowPerConnectionWizard(IXenConnection connection, Form wizard);
void ShowForm(Type type);
void ShowForm(Type type, object[] args);
void CloseActiveWizards(IXenConnection connection);
void CloseActiveWizards(IXenObject xenObject);
Collection<IXenConnection> GetXenConnectionsCopy();
void SaveServerList();
bool DoSearch(string filename);
bool RunInAutomatedTestMode { get;}
void RemoveConnection(IXenConnection connection);
void PutSelectedNodeIntoEditMode();
void SwitchToTab(MainWindow.Tab tab);
bool MenuShortcutsEnabled { get;}
Form Form { get; }
}
}

View File

@ -31,6 +31,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Configuration;
using System.Diagnostics;
@ -66,7 +67,7 @@ namespace XenAdmin
{
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
[ComVisibleAttribute(true)]
public partial class MainWindow : Form, ISynchronizeInvoke
public partial class MainWindow : Form, ISynchronizeInvoke, IMainWindow
{
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
@ -118,7 +119,6 @@ namespace XenAdmin
private readonly PluginManager pluginManager;
private readonly ContextMenuBuilder contextMenuBuilder;
private readonly MainWindowCommandInterface commandInterface;
private readonly LicenseManagerLauncher licenseManagerLauncher;
private readonly LicenseTimer licenseTimer;
@ -188,11 +188,10 @@ namespace XenAdmin
CommandLineArgType = argType;
CommandLineParam = args;
commandInterface = new MainWindowCommandInterface(this);
pluginManager = new PluginManager();
pluginManager.PluginsChanged += pluginManager_PluginsChanged;
pluginManager.LoadPlugins();
contextMenuBuilder = new ContextMenuBuilder(pluginManager, commandInterface);
contextMenuBuilder = new ContextMenuBuilder(pluginManager, this);
eventsPage.GoToXenObjectRequested += eventsPage_GoToXenObjectRequested;
SearchPage.SearchChanged += SearchPanel_SearchChanged;
@ -210,8 +209,8 @@ namespace XenAdmin
statusProgressBar.Visible = false;
SelectionManager.BindTo(MainMenuBar.Items, commandInterface);
SelectionManager.BindTo(ToolStrip.Items, commandInterface);
SelectionManager.BindTo(MainMenuBar.Items, this);
SelectionManager.BindTo(ToolStrip.Items, this);
Properties.Settings.Default.SettingChanging += Default_SettingChanging;
licenseTimer = new LicenseTimer(licenseManagerLauncher);
@ -268,14 +267,6 @@ namespace XenAdmin
}
}
internal IMainWindow CommandInterface
{
get
{
return commandInterface;
}
}
protected override void OnLoad(EventArgs e)
{
Program.AssertOnEventThread();
@ -636,7 +627,7 @@ namespace XenAdmin
break;
case ArgType.Restore:
log.DebugFormat("Restoring host backup from {0}", args[0]);
new RestoreHostFromBackupCommand(commandInterface, null, args[0]).Execute();
new RestoreHostFromBackupCommand(this, null, args[0]).Execute();
break;
case ArgType.Update:
log.DebugFormat("Installing server update from {0}", args[0]);
@ -644,7 +635,7 @@ namespace XenAdmin
break;
case ArgType.XenSearch:
log.DebugFormat("Importing saved XenSearch from '{0}'", args[0]);
new ImportSearchCommand(commandInterface, args[0]).Execute();
new ImportSearchCommand(this, args[0]).Execute();
break;
case ArgType.Connect:
log.DebugFormat("Connecting to server '{0}'", args[0]);
@ -666,7 +657,7 @@ namespace XenAdmin
{
// The user has launched the splash screen, but we're already running.
// Draw his attention.
BringToFront();
HelpersGUI.BringFormToFront(this);
Activate();
}
break;
@ -778,7 +769,7 @@ namespace XenAdmin
private void connection_ClearingCache(object sender, EventArgs e)
{
IXenConnection connection = (IXenConnection)sender;
closeActiveWizards(connection);
CloseActiveWizards(connection);
Alert.RemoveAlert(alert => alert.Connection != null && alert.Connection.Equals(connection));
Updates.CheckServerPatches();
Updates.CheckServerVersion();
@ -882,7 +873,7 @@ namespace XenAdmin
{
if (host.IsLive && host.MaintenanceMode && host.enabled)
{
Program.MainWindow.closeActiveWizards(host);
Program.MainWindow.CloseActiveWizards(host);
var action = new DisableHostAction(host);
action.Completed += action_Completed;
@ -939,11 +930,11 @@ namespace XenAdmin
{
VM vm = (VM)e.Element;
ConsolePanel.closeVNCForSource(vm);
closeActiveWizards(vm);
CloseActiveWizards(vm);
}
selectedTabs.Remove(o);
pluginManager.DisposeURLs((IXenObject)o);
pluginManager.DisposeURLs(o);
}
}
@ -1118,7 +1109,7 @@ namespace XenAdmin
try
{
IXenConnection connection = (IXenConnection)sender;
closeActiveWizards(connection);
CloseActiveWizards(connection);
UpdateToolbars();
}
@ -1522,7 +1513,7 @@ namespace XenAdmin
if (menuItemFeature != null && menuItemFeature.ParentFeature == null && (int)menuItemFeature.Menu == MainMenuBar.Items.IndexOf(menu))
{
Command cmd = menuItemFeature.GetCommand(commandInterface, SelectionManager.Selection);
Command cmd = menuItemFeature.GetCommand(this, SelectionManager.Selection);
menu.DropDownItems.Insert(insertIndex, new CommandToolStripMenuItem(cmd));
insertIndex++;
@ -1533,7 +1524,7 @@ namespace XenAdmin
if (parentMenuItemFeature != null && (int)parentMenuItemFeature.Menu == MainMenuBar.Items.IndexOf(menu))
{
Command cmd = parentMenuItemFeature.GetCommand(commandInterface, SelectionManager.Selection);
Command cmd = parentMenuItemFeature.GetCommand(this, SelectionManager.Selection);
CommandToolStripMenuItem parentMenuItem = new CommandToolStripMenuItem(cmd);
menu.DropDownItems.Insert(insertIndex, parentMenuItem);
@ -1542,7 +1533,7 @@ namespace XenAdmin
foreach (MenuItemFeature childFeature in parentMenuItemFeature.Features)
{
Command childCommand = childFeature.GetCommand(commandInterface, SelectionManager.Selection);
Command childCommand = childFeature.GetCommand(this, SelectionManager.Selection);
parentMenuItem.DropDownItems.Add(new CommandToolStripMenuItem(childCommand));
}
}
@ -1790,7 +1781,7 @@ namespace XenAdmin
}
else if (t == TabPagePhysicalStorage)
{
PhysicalStoragePage.SetSelectionBroadcaster(SelectionManager, commandInterface);
PhysicalStoragePage.SetSelectionBroadcaster(SelectionManager, this);
PhysicalStoragePage.Host = SelectionManager.Selection.First as Host;
PhysicalStoragePage.Connection = SelectionManager.Selection.GetConnectionOfFirstItem();
}
@ -2001,18 +1992,20 @@ namespace XenAdmin
ConsolePanel.SendCAD();
}
#region IMainWindowCommandInterface Members
/// <summary>
/// Closes all per-Connection and per-VM wizards for the given connection.
/// </summary>
/// <param name="connection"></param>
public void closeActiveWizards(IXenConnection connection)
public void CloseActiveWizards(IXenConnection connection)
{
Program.Invoke(Program.MainWindow, delegate
{
// Close and remove any active wizards for any VMs
foreach (VM vm in connection.Cache.VMs)
{
closeActiveWizards(vm);
CloseActiveWizards(vm);
}
closeActivePoolWizards(connection);
});
@ -2043,7 +2036,7 @@ namespace XenAdmin
/// Closes all per-XenObject wizards.
/// </summary>
/// <param name="obj"></param>
public void closeActiveWizards(IXenObject obj)
public void CloseActiveWizards(IXenObject obj)
{
Program.Invoke(Program.MainWindow, delegate
{
@ -2066,7 +2059,7 @@ namespace XenAdmin
/// <param name="wizard">The new wizard to show</param>
public void ShowPerXenModelObjectWizard(IXenObject obj, Form wizard)
{
closeActiveWizards(obj);
CloseActiveWizards(obj);
activeXenModelObjectWizards.Add(obj, wizard);
wizard.Show(this);
}
@ -2144,6 +2137,64 @@ namespace XenAdmin
newForm.Show(this);
}
public Form Form
{
get { return this; }
}
public void Invoke(MethodInvoker method)
{
Program.Invoke(this, method);
}
public bool SelectObjectInTree(IXenObject xenObject)
{
return SelectObject(xenObject);
}
public Collection<IXenConnection> GetXenConnectionsCopy()
{
return new Collection<IXenConnection>(ConnectionsManager.XenConnectionsCopy);
}
public void SaveServerList()
{
Settings.SaveServerList();
}
public bool RunInAutomatedTestMode
{
get { return Program.RunInAutomatedTestMode; }
}
public void RemoveConnection(IXenConnection connection)
{
ConnectionsManager.ClearCacheAndRemoveConnection(connection);
}
public void PutSelectedNodeIntoEditMode()
{
EditSelectedNodeInTreeView();
}
public void TrySelectNewObjectInTree(Predicate<object> tagMatch, bool selectNode, bool expandNode, bool ensureNodeVisible)
{
TrySelectNewNode(tagMatch, selectNode, expandNode, ensureNodeVisible);
}
public void TrySelectNewObjectInTree(IXenConnection c, bool selectNode, bool expandNode, bool ensureNodeVisible)
{
TrySelectNewNode(c, selectNode, expandNode, ensureNodeVisible);
}
public bool MenuShortcutsEnabled
{
get { return _menuShortcuts; }
}
#endregion
#region Help
private string TabHelpID()
@ -2471,7 +2522,7 @@ namespace XenAdmin
}
}
private bool DoSearch(string filename)
public bool DoSearch(string filename)
{
List<Search> searches = Search.LoadFile(filename);
if (searches != null && searches.Count > 0)

View File

@ -144,7 +144,7 @@ namespace XenAdmin.TabPages
private void EditButton_Click(object sender, EventArgs e)
{
new PropertiesCommand(Program.MainWindow.CommandInterface, xenObject).Execute();
new PropertiesCommand(Program.MainWindow, xenObject).Execute();
}
private IXenObject xenObject;
@ -598,7 +598,7 @@ namespace XenAdmin.TabPages
}
CommandToolStripMenuItem applypatch = new CommandToolStripMenuItem(
new InstallNewUpdateCommand(Program.MainWindow.CommandInterface), true);
new InstallNewUpdateCommand(Program.MainWindow), true);
var menuItems = new[] { applypatch };
@ -638,7 +638,7 @@ namespace XenAdmin.TabPages
{
CommandToolStripMenuItem applypatch =
new CommandToolStripMenuItem(
new InstallNewUpdateCommand(Program.MainWindow.CommandInterface), true);
new InstallNewUpdateCommand(Program.MainWindow), true);
var menuItems = new[] { applypatch };
s.AddEntry(FriendlyName("Pool_patch.not_applied"), hostUnappliedPatches(host), menuItems, Color.Red);
@ -658,7 +658,7 @@ namespace XenAdmin.TabPages
PDSection s = pdSectionHighAvailability;
s.AddEntry(FriendlyName("VM.ha_restart_priority"), Helpers.RestartPriorityI18n(vm.HARestartPriority),
new PropertiesToolStripMenuItem(new VmEditHaCommand(Program.MainWindow.CommandInterface, xenObject)));
new PropertiesToolStripMenuItem(new VmEditHaCommand(Program.MainWindow, xenObject)));
}
@ -682,7 +682,7 @@ namespace XenAdmin.TabPages
repair.Click += delegate
{
if (sr.NeedsUpgrading)
new UpgradeSRCommand(Program.MainWindow.CommandInterface, sr).Execute();
new UpgradeSRCommand(Program.MainWindow, sr).Execute();
else
Program.MainWindow.ShowPerConnectionWizard(xenObject.Connection, new RepairSRDialog(sr));
};
@ -892,18 +892,18 @@ namespace XenAdmin.TabPages
if (!Helpers.BostonOrGreater(vm.Connection))
{
s.AddEntry(FriendlyName("VM.auto_boot"), Helpers.BoolToString(vm.AutoPowerOn),
new PropertiesToolStripMenuItem(new VmEditStartupOptionsCommand(Program.MainWindow.CommandInterface, vm)));
new PropertiesToolStripMenuItem(new VmEditStartupOptionsCommand(Program.MainWindow, vm)));
}
if (vm.IsHVM)
{
s.AddEntry(FriendlyName("VM.BootOrder"), HVMBootOrder(vm),
new PropertiesToolStripMenuItem(new VmEditStartupOptionsCommand(Program.MainWindow.CommandInterface, vm)));
new PropertiesToolStripMenuItem(new VmEditStartupOptionsCommand(Program.MainWindow, vm)));
}
else
{
s.AddEntry(FriendlyName("VM.PV_args"), vm.PV_args,
new PropertiesToolStripMenuItem(new VmEditStartupOptionsCommand(Program.MainWindow.CommandInterface, vm)));
new PropertiesToolStripMenuItem(new VmEditStartupOptionsCommand(Program.MainWindow, vm)));
}
}
@ -1060,7 +1060,7 @@ namespace XenAdmin.TabPages
PDSection s = pdSectionGeneral;
s.AddEntry(FriendlyName("host.name_label"), Helpers.GetName(xenObject),
new PropertiesToolStripMenuItem(new PropertiesCommand(Program.MainWindow.CommandInterface, xenObject)));
new PropertiesToolStripMenuItem(new PropertiesCommand(Program.MainWindow, xenObject)));
if (!(xenObject is IStorageLinkObject))
{
@ -1068,7 +1068,7 @@ namespace XenAdmin.TabPages
if (vm == null || vm.DescriptionType != VM.VmDescriptionType.None)
{
s.AddEntry(FriendlyName("host.name_description"), xenObject.Description,
new PropertiesToolStripMenuItem(new DescriptionPropertiesCommand(Program.MainWindow.CommandInterface, xenObject)));
new PropertiesToolStripMenuItem(new DescriptionPropertiesCommand(Program.MainWindow, xenObject)));
}
GenTagRow(s);
@ -1091,7 +1091,7 @@ namespace XenAdmin.TabPages
var item = new ToolStripMenuItem(Messages.EXIT_MAINTENANCE_MODE);
item.Click += delegate
{
new HostMaintenanceModeCommand(Program.MainWindow.CommandInterface, host,
new HostMaintenanceModeCommand(Program.MainWindow, host,
HostMaintenanceModeCommandParameter.Exit).Execute();
};
s.AddEntry(FriendlyName("host.enabled"),
@ -1104,16 +1104,16 @@ namespace XenAdmin.TabPages
var item = new ToolStripMenuItem(Messages.ENTER_MAINTENANCE_MODE);
item.Click += delegate
{
new HostMaintenanceModeCommand(Program.MainWindow.CommandInterface, host,
new HostMaintenanceModeCommand(Program.MainWindow, host,
HostMaintenanceModeCommandParameter.Enter).Execute();
};
s.AddEntry(FriendlyName("host.enabled"), Messages.YES, item);
}
s.AddEntry(FriendlyName("host.iscsi_iqn"), host.iscsi_iqn,
new PropertiesToolStripMenuItem(new IqnPropertiesCommand(Program.MainWindow.CommandInterface, xenObject)));
new PropertiesToolStripMenuItem(new IqnPropertiesCommand(Program.MainWindow, xenObject)));
s.AddEntry(FriendlyName("host.log_destination"), host.SysLogDestination ?? Messages.HOST_LOG_DESTINATION_LOCAL,
new PropertiesToolStripMenuItem(new HostEditLogDestinationCommand(Program.MainWindow.CommandInterface, xenObject)));
new PropertiesToolStripMenuItem(new HostEditLogDestinationCommand(Program.MainWindow, xenObject)));
PrettyTimeSpan uptime = host.Uptime;
PrettyTimeSpan agentUptime = host.AgentUptime;
@ -1176,11 +1176,11 @@ namespace XenAdmin.TabPages
var installtools = new ToolStripMenuItem(Messages.INSTALL_XENSERVER_TOOLS_DOTS);
installtools.Click += delegate
{
new InstallToolsCommand(Program.MainWindow.CommandInterface, vm).Execute();
new InstallToolsCommand(Program.MainWindow, vm).Execute();
};
s.AddEntryLink(FriendlyName("VM.VirtualizationState"), vm.VirtualisationStatusString,
new[] { installtools },
new InstallToolsCommand(Program.MainWindow.CommandInterface, vm));
new InstallToolsCommand(Program.MainWindow, vm));
}
else
{
@ -1207,7 +1207,7 @@ namespace XenAdmin.TabPages
if (VMCanChooseHomeServer(vm))
{
s.AddEntry(FriendlyName("VM.affinity"), vm.AffinityServerString,
new PropertiesToolStripMenuItem(new VmEditHomeServerCommand(Program.MainWindow.CommandInterface, xenObject)));}
new PropertiesToolStripMenuItem(new VmEditHomeServerCommand(Program.MainWindow, xenObject)));}
}
}
else if (xenObject is XenObject<SR>)
@ -1260,7 +1260,7 @@ namespace XenAdmin.TabPages
}
else
{
var cmd = new RollingUpgradeCommand(Program.MainWindow.CommandInterface);
var cmd = new RollingUpgradeCommand(Program.MainWindow);
var runRpuWizard = new ToolStripMenuItem(Messages.ROLLING_POOL_UPGRADE_ELLIPSIS,
null,
(sender, args) => cmd.Execute());
@ -1399,11 +1399,11 @@ namespace XenAdmin.TabPages
goToTag.DropDownItems.Add(item);
}
s.AddEntry(Messages.TAGS, TagsString(), new[] { goToTag, new PropertiesToolStripMenuItem(new PropertiesCommand(Program.MainWindow.CommandInterface, xenObject)) });
s.AddEntry(Messages.TAGS, TagsString(), new[] { goToTag, new PropertiesToolStripMenuItem(new PropertiesCommand(Program.MainWindow, xenObject)) });
return;
}
s.AddEntry(Messages.TAGS, Messages.NONE, new PropertiesToolStripMenuItem(new PropertiesCommand(Program.MainWindow.CommandInterface, xenObject)));
s.AddEntry(Messages.TAGS, Messages.NONE, new PropertiesToolStripMenuItem(new PropertiesCommand(Program.MainWindow, xenObject)));
}
private string TagsString()
@ -1424,7 +1424,7 @@ namespace XenAdmin.TabPages
item.Click += delegate { Program.MainWindow.SearchForFolder(xenObject.Path); };
menuItems.Add(item);
}
menuItems.Add(new PropertiesToolStripMenuItem(new PropertiesCommand(Program.MainWindow.CommandInterface, xenObject)));
menuItems.Add(new PropertiesToolStripMenuItem(new PropertiesCommand(Program.MainWindow, xenObject)));
s.AddEntry(
Messages.FOLDER,
new FolderListItem(xenObject.Path, FolderListItem.AllowSearch.None, false),

View File

@ -79,7 +79,7 @@ namespace XenAdmin.TabPages
private void panelAdd_Click(object sender, EventArgs e)
{
new AddHostCommand(Program.MainWindow.CommandInterface).Execute();
new AddHostCommand(Program.MainWindow).Execute();
}
private void panelGet_Click(object sender, EventArgs e)

View File

@ -250,13 +250,13 @@ namespace XenAdmin.TabPages
PIF pif = ((PIFRow)dataGridView1.SelectedRows[0]).pif;
System.Diagnostics.Trace.Assert(pif.IsBondNIC);
XenAPI.Network network = pif.Connection.Resolve(pif.network);
var destroyBondCommand = new DestroyBondCommand(Program.MainWindow.CommandInterface, network);
var destroyBondCommand = new DestroyBondCommand(Program.MainWindow, network);
destroyBondCommand.Execute();
}
private void buttonRescan_Click(object sender, EventArgs e)
{
RescanPIFsCommand cmd = new RescanPIFsCommand(Program.MainWindow.CommandInterface, host);
RescanPIFsCommand cmd = new RescanPIFsCommand(Program.MainWindow, host);
if (cmd.CanExecute())
cmd.Execute();
}

View File

@ -308,7 +308,7 @@ namespace XenAdmin.TabPages
private void newSRButton_Click(object sender, EventArgs e)
{
new NewSRCommand(Program.MainWindow.CommandInterface, connection).Execute();
new NewSRCommand(Program.MainWindow, connection).Execute();
}
/// <summary>

View File

@ -316,7 +316,7 @@ namespace XenAdmin.TabPages
private void buttonImport_Click(object sender, EventArgs e)
{
new ImportSearchCommand(Program.MainWindow.CommandInterface).Execute();
new ImportSearchCommand(Program.MainWindow).Execute();
}
private void applySavedSearch_Click(object sender, EventArgs e)

View File

@ -1086,7 +1086,7 @@ namespace XenAdmin.TabPages
private void takeSnapshotToolStripButton_Click(object sender, EventArgs e)
{
TakeSnapshotCommand command = new TakeSnapshotCommand(Program.MainWindow.CommandInterface, VM);
TakeSnapshotCommand command = new TakeSnapshotCommand(Program.MainWindow, VM);
command.Execute();
}
@ -1247,17 +1247,17 @@ namespace XenAdmin.TabPages
private void saveAsATemplateToolStripMenuItem_Click(object sender, EventArgs e)
{
new NewTemplateFromSnapshotCommand(Program.MainWindow.CommandInterface, GetSelectedSnapshot()).Execute();
new NewTemplateFromSnapshotCommand(Program.MainWindow, GetSelectedSnapshot()).Execute();
}
private void saveAsAVirtualMachineToolStripMenuItem_Click(object sender, EventArgs e)
{
new NewVMFromSnapshotCommand(Program.MainWindow.CommandInterface, GetSelectedSnapshot()).Execute();
new NewVMFromSnapshotCommand(Program.MainWindow, GetSelectedSnapshot()).Execute();
}
private void exportSnapshotToolStripMenuItem_Click(object sender, EventArgs e)
{
new ExportSnapshotAsTemplateCommand(Program.MainWindow.CommandInterface, GetSelectedSnapshot()).Execute();
new ExportSnapshotAsTemplateCommand(Program.MainWindow, GetSelectedSnapshot()).Execute();
}
private void snapshotTreeView1_MouseDoubleClick(object sender, MouseEventArgs e)
@ -1345,17 +1345,17 @@ namespace XenAdmin.TabPages
private void saveAsTemplateToolStripMenuItem_Click(object sender, EventArgs e)
{
new NewTemplateFromSnapshotCommand(Program.MainWindow.CommandInterface, GetSelectedSnapshot()).Execute();
new NewTemplateFromSnapshotCommand(Program.MainWindow, GetSelectedSnapshot()).Execute();
}
private void toolStripMenuItem1_Click(object sender, EventArgs e)
{
new NewVMFromSnapshotCommand(Program.MainWindow.CommandInterface, GetSelectedSnapshot()).Execute();
new NewVMFromSnapshotCommand(Program.MainWindow, GetSelectedSnapshot()).Execute();
}
private void exportAsBackupToolStripMenuItem_Click(object sender, EventArgs e)
{
new ExportSnapshotAsTemplateCommand(Program.MainWindow.CommandInterface, GetSelectedSnapshot()).Execute();
new ExportSnapshotAsTemplateCommand(Program.MainWindow, GetSelectedSnapshot()).Execute();
}
private void gridToolStripMenuItem_Click(object sender, EventArgs e)
@ -1414,7 +1414,7 @@ namespace XenAdmin.TabPages
{
DeleteSnapshotCommand deleteSnapshotCommand = new DeleteSnapshotCommand(
Program.MainWindow.CommandInterface, snapshots.ConvertAll<SelectedItem>(input => new SelectedItem(input)));
Program.MainWindow, snapshots.ConvertAll<SelectedItem>(input => new SelectedItem(input)));
deleteSnapshotCommand.Execute();
}
@ -1424,7 +1424,7 @@ namespace XenAdmin.TabPages
{
if (vm.current_operations.Count == 0)
{
RevertToSnapshotCommand cmd = new RevertToSnapshotCommand(Program.MainWindow.CommandInterface, vm, snapshot);
RevertToSnapshotCommand cmd = new RevertToSnapshotCommand(Program.MainWindow, vm, snapshot);
cmd.Execute();
}
}
@ -1599,7 +1599,7 @@ namespace XenAdmin.TabPages
}
else
{
var command = new VMGroupCommand<VMPP>(Program.MainWindow.CommandInterface, VM);
var command = new VMGroupCommand<VMPP>(Program.MainWindow, VM);
command.Execute();
}
}

View File

@ -349,7 +349,7 @@ namespace XenAdmin.TabPages
contextMenuStrip1.Items.Clear();
DeleteVirtualDiskCommand deleteCmd = new DeleteVirtualDiskCommand(Program.MainWindow.CommandInterface, vdis);
DeleteVirtualDiskCommand deleteCmd = new DeleteVirtualDiskCommand(Program.MainWindow, vdis);
contextMenuStrip1.Items.Add(new CommandToolStripMenuItem(deleteCmd, true));
contextMenuStrip1.Items.Add(new CommandToolStripMenuItem(MoveMigrateCommand(vdis), true));
@ -360,12 +360,12 @@ namespace XenAdmin.TabPages
private Command MoveMigrateCommand(IEnumerable<SelectedItem> selection)
{
MoveVirtualDiskCommand moveCmd = new MoveVirtualDiskCommand(Program.MainWindow.CommandInterface, selection);
MoveVirtualDiskCommand moveCmd = new MoveVirtualDiskCommand(Program.MainWindow, selection);
if (moveCmd.CanExecute())
return moveCmd;
return new MigrateVirtualDiskCommand(Program.MainWindow.CommandInterface, selection);
return new MigrateVirtualDiskCommand(Program.MainWindow, selection);
}
private void RefreshButtons()
@ -374,7 +374,7 @@ namespace XenAdmin.TabPages
SelectedItemCollection vdis = SelectedVDIs;
// Delete button
DeleteVirtualDiskCommand deleteCmd = new DeleteVirtualDiskCommand(Program.MainWindow.CommandInterface, vdis);
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;
@ -441,10 +441,10 @@ namespace XenAdmin.TabPages
SelectedItemCollection vdis = SelectedVDIs;
if (vdis.Count > 0)
{
Command cmd = new DeleteVirtualDiskCommand(Program.MainWindow.CommandInterface, vdis);
Command cmd = new DeleteVirtualDiskCommand(Program.MainWindow, vdis);
removeContextMenuStrip.Items.Add(new CommandToolStripMenuItem(cmd, Messages.DELETE_VIRTUAL_DISK));
cmd = new RemoveStorageLinkVolumeCommand(Program.MainWindow.CommandInterface, sr.StorageLinkRepository(Program.StorageLinkConnections), vdis);
cmd = new RemoveStorageLinkVolumeCommand(Program.MainWindow, sr.StorageLinkRepository(Program.StorageLinkConnections), vdis);
removeContextMenuStrip.Items.Add(new CommandToolStripMenuItem(cmd, Messages.DELETE_SL_VOLUME_CONTEXT_MENU_ELIPS));
}
}
@ -453,10 +453,10 @@ namespace XenAdmin.TabPages
{
addContextMenuStrip.Items.Clear();
Command cmd = new AddVirtualDiskCommand(Program.MainWindow.CommandInterface, sr);
Command cmd = new AddVirtualDiskCommand(Program.MainWindow, sr);
addContextMenuStrip.Items.Add(new CommandToolStripMenuItem(cmd, Messages.ADD_VIRTUAL_DISK));
cmd = new ImportStorageLinkVolumeCommand(Program.MainWindow.CommandInterface, sr.StorageLinkRepository(Program.StorageLinkConnections));
cmd = new ImportStorageLinkVolumeCommand(Program.MainWindow, sr.StorageLinkRepository(Program.StorageLinkConnections));
addContextMenuStrip.Items.Add(new CommandToolStripMenuItem(cmd, Messages.ADD_SL_VOLUME));
}
#endregion
@ -465,7 +465,7 @@ namespace XenAdmin.TabPages
private void removeVirtualDisk_Click(object sender, EventArgs e)
{
SelectedItemCollection vdis = SelectedVDIs;
DeleteVirtualDiskCommand cmd = new DeleteVirtualDiskCommand(Program.MainWindow.CommandInterface, vdis);
DeleteVirtualDiskCommand cmd = new DeleteVirtualDiskCommand(Program.MainWindow, vdis);
cmd.AllowMultipleVBDDelete = true;
if (cmd.CanExecute())
cmd.Execute();

View File

@ -305,7 +305,7 @@ namespace XenAdmin.TabPages
private void UpdateButtons()
{
AttachVirtualDiskCommand attachCmd = new AttachVirtualDiskCommand(Program.MainWindow.CommandInterface, vm);
AttachVirtualDiskCommand attachCmd = new AttachVirtualDiskCommand(Program.MainWindow, vm);
AttachButton.Enabled = attachCmd.CanExecute();
AddButton.Enabled = attachCmd.CanExecute();
@ -330,7 +330,7 @@ namespace XenAdmin.TabPages
selectedVDIs.Add(new SelectedItem(r.VDI));
selectedVBDs.Add(new SelectedItem(r.VBD));
}
DeleteVirtualDiskCommand deleteCmd = new DeleteVirtualDiskCommand(Program.MainWindow.CommandInterface, selectedVDIs);
DeleteVirtualDiskCommand deleteCmd = new DeleteVirtualDiskCommand(Program.MainWindow, selectedVDIs);
// User has visibility that this disk in use by this VM. Allow unplug + delete in single step (non default behaviour),
// but only if we are the only VBD (default behaviour)
deleteCmd.AllowRunningVMDelete = true;
@ -352,14 +352,14 @@ namespace XenAdmin.TabPages
{
// no VBDs are attached so we are deactivating
DeactivateButton.Text = Messages.DEACTIVATE;
activationCmd = new DeactivateVBDCommand(Program.MainWindow.CommandInterface, selectedVBDs);
activationCmd = new DeactivateVBDCommand(Program.MainWindow, selectedVBDs);
}
else
{
// this is the default cause in the mixed attached/detatched scenario. We try to activate all the selection
// The command error reports afterwards about the ones which are already attached
DeactivateButton.Text = Messages.ACTIVATE;
activationCmd = new ActivateVBDCommand(Program.MainWindow.CommandInterface, selectedVBDs);
activationCmd = new ActivateVBDCommand(Program.MainWindow, selectedVBDs);
}
if (activationCmd.CanExecute())
@ -373,7 +373,7 @@ namespace XenAdmin.TabPages
DeactivateButton.Enabled = false;
}
DetachVirtualDiskCommand detachCmd = new DetachVirtualDiskCommand(Program.MainWindow.CommandInterface, selectedVDIs, vm);
DetachVirtualDiskCommand detachCmd = new DetachVirtualDiskCommand(Program.MainWindow, selectedVDIs, vm);
if (detachCmd.CanExecute())
{
DetachButtonContainer.RemoveAll();
@ -401,17 +401,17 @@ namespace XenAdmin.TabPages
private Command MoveMigrateCommand(IEnumerable<SelectedItem> selection)
{
MoveVirtualDiskCommand moveCmd = new MoveVirtualDiskCommand(Program.MainWindow.CommandInterface, selection);
MoveVirtualDiskCommand moveCmd = new MoveVirtualDiskCommand(Program.MainWindow, selection);
if (moveCmd.CanExecute())
return moveCmd;
return new MigrateVirtualDiskCommand(Program.MainWindow.CommandInterface, selection);
return new MigrateVirtualDiskCommand(Program.MainWindow, selection);
}
private void AddButton_Click(object sender, EventArgs e)
{
var cmd = new AddVirtualDiskCommand(Program.MainWindow.CommandInterface, vm);
var cmd = new AddVirtualDiskCommand(Program.MainWindow, vm);
if (cmd.CanExecute())
cmd.Execute();
@ -421,7 +421,7 @@ namespace XenAdmin.TabPages
private void AttachButton_Click(object sender, EventArgs e)
{
AttachVirtualDiskCommand cmd = new AttachVirtualDiskCommand(Program.MainWindow.CommandInterface, vm);
AttachVirtualDiskCommand cmd = new AttachVirtualDiskCommand(Program.MainWindow, vm);
if (cmd.CanExecute())
cmd.Execute();
@ -454,7 +454,7 @@ namespace XenAdmin.TabPages
foreach (VBDRow r in rows)
l.Add(new SelectedItem(r.VDI));
DetachVirtualDiskCommand cmd = new DetachVirtualDiskCommand(Program.MainWindow.CommandInterface, l, vm);
DetachVirtualDiskCommand cmd = new DetachVirtualDiskCommand(Program.MainWindow, l, vm);
if (cmd.CanExecute())
cmd.Execute();
}
@ -468,7 +468,7 @@ namespace XenAdmin.TabPages
foreach (VBDRow r in rows)
l.Add(new SelectedItem(r.VDI));
DeleteVirtualDiskCommand cmd = new DeleteVirtualDiskCommand(Program.MainWindow.CommandInterface, l);
DeleteVirtualDiskCommand cmd = new DeleteVirtualDiskCommand(Program.MainWindow, l);
// User has visibility that this disk in use by this VM. Allow unplug + delete in single step (non default behaviour),
// but only if we are the only VBD (default behaviour)
cmd.AllowRunningVMDelete = true;
@ -560,9 +560,9 @@ namespace XenAdmin.TabPages
SelectedItemCollection col = new SelectedItemCollection(l);
Command cmd = null;
if (col.AsXenObjects<VBD>().Find(vbd => !vbd.currently_attached) == null)
cmd = new DeactivateVBDCommand(Program.MainWindow.CommandInterface, l);
cmd = new DeactivateVBDCommand(Program.MainWindow, l);
else
cmd = new ActivateVBDCommand(Program.MainWindow.CommandInterface, l);
cmd = new ActivateVBDCommand(Program.MainWindow, l);
if (cmd.CanExecute())
cmd.Execute();

View File

@ -682,7 +682,7 @@ namespace XenAdmin.TabPages
private void buttonReports_Click(object sender, EventArgs e)
{
ViewWorkloadReportsCommand viewWorkloadReportsCommand = new ViewWorkloadReportsCommand(Program.MainWindow.CommandInterface, _pool);
ViewWorkloadReportsCommand viewWorkloadReportsCommand = new ViewWorkloadReportsCommand(Program.MainWindow, _pool);
viewWorkloadReportsCommand.Execute();
}

View File

@ -384,7 +384,7 @@ namespace XenAdmin.Wizards.BugToolWizardFiles
private void connectbutton_Click(object sender, EventArgs e)
{
new AddHostCommand(Program.MainWindow.CommandInterface, ParentForm).Execute();
new AddHostCommand(Program.MainWindow, ParentForm).Execute();
}
private void HostListTreeView_ItemCheckChanged(object sender, EventArgs e)

View File

@ -65,7 +65,7 @@ namespace XenAdmin.Wizards.GenericPages
public void ExecuteCommand(Control parent)
{
new AddHostCommand(Program.MainWindow.CommandInterface, parent).Execute();
new AddHostCommand(Program.MainWindow, parent).Execute();
}
public bool Enabled

View File

@ -103,7 +103,7 @@ namespace XenAdmin.Wizards.ImportWizard
private void m_buttonAddNewServer_Click(object sender, EventArgs e)
{
new AddHostCommand(Program.MainWindow.CommandInterface, this).Execute();
new AddHostCommand(Program.MainWindow, this).Execute();
}
#endregion

View File

@ -426,7 +426,7 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends
return;
var systemsBefore = new List<StorageLinkSystem>(slCon.Cache.StorageSystems);
AddStorageLinkSystemCommand command = new AddStorageLinkSystemCommand(Program.MainWindow.CommandInterface, slCon.Cache.Server, Parent);
AddStorageLinkSystemCommand command = new AddStorageLinkSystemCommand(Program.MainWindow, slCon.Cache.Server, Parent);
command.Completed += (s, ee) =>
{

View File

@ -2709,9 +2709,7 @@
<Compile Include="Commands\Controls\CommandEditorControl.Designer.cs">
<DependentUpon>CommandEditorControl.cs</DependentUpon>
</Compile>
<Compile Include="Commands\Controls\MainWindowCommandInterface.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="IMainWindow.cs" />
<Compile Include="Commands\Controls\VMLifeCycleToolStripMenuItem.cs">
<SubType>Component</SubType>
</Compile>

View File

@ -112,10 +112,7 @@ namespace XenAdmin.XenSearch
QueryPanel.LinkBrush,
Program.DefaultFontUnderline,
3,
new EventHandler(delegate
{
new InstallToolsCommand(Program.MainWindow.CommandInterface, vm).Execute();
}), null);
(sender, args) => new InstallToolsCommand(Program.MainWindow, vm).Execute(), null);
}
else
{
@ -139,10 +136,7 @@ namespace XenAdmin.XenSearch
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);
(sender, args) => new UpgradeSRCommand(Program.MainWindow, sr).Execute(), null);
return true;
}
@ -158,7 +152,7 @@ namespace XenAdmin.XenSearch
HorizontalAlignment.Center, VerticalAlignment.Middle, false, false,
QueryPanel.LinkBrush, Program.DefaultFontUnderline, QueryPanel.LinkBrush,
Program.DefaultFontUnderline, 3,
(sender, args) => new RollingUpgradeCommand(Program.MainWindow.CommandInterface).Execute(),
(sender, args) => new RollingUpgradeCommand(Program.MainWindow).Execute(),
null);
}

View File

@ -58,7 +58,7 @@ namespace XenAdminTests.CommandTests
{
internal override Command CreateCommand()
{
return new AddHostCommand(Program.MainWindow.CommandInterface);
return new AddHostCommand(Program.MainWindow);
}
public void Test()

View File

@ -76,7 +76,7 @@ namespace XenAdminTests.CommandTests
{
internal override Command CreateCommand()
{
return new AddHostToPoolCommand(Program.MainWindow.CommandInterface, new List<Host> { GetAnyHost(h => h.name_label == "krakout") }, GetAnyPool(), false);
return new AddHostToPoolCommand(Program.MainWindow, new List<Host> { GetAnyHost(h => h.name_label == "krakout") }, GetAnyPool(), false);
}
private bool Finished()

View File

@ -61,7 +61,7 @@ namespace XenAdminTests.CommandTests
{
internal override Command CreateCommand()
{
return new AddNewHostToPoolCommand(Program.MainWindow.CommandInterface, GetAnyPool());
return new AddNewHostToPoolCommand(Program.MainWindow, GetAnyPool());
}
public void TestRbacGeorge()

View File

@ -89,7 +89,7 @@ namespace XenAdminTests.CommandTests
string tempFile = Path.GetTempFileName();
try
{
MW(new BackupHostCommand(Program.MainWindow.CommandInterface, host, tempFile).Execute);
MW(new BackupHostCommand(Program.MainWindow, host, tempFile).Execute);
Func<bool> finished = delegate
{

View File

@ -90,7 +90,7 @@ namespace XenAdminTests.CommandTests
{
Command = CreateCommand();
((ICommand)Command).SetMainWindow(Program.MainWindow.CommandInterface);
((ICommand)Command).SetMainWindow(Program.MainWindow);
bool noneExecuted = true;

View File

@ -90,7 +90,7 @@ namespace XenAdminTests.CommandTests
MW(() => _node.EnsureVisible());
return new RemoveFromFolderCommand(Program.MainWindow.CommandInterface, new List<VirtualTreeNode> { _node });
return new RemoveFromFolderCommand(Program.MainWindow, new List<VirtualTreeNode> { _node });
}
public void Test()

View File

@ -60,7 +60,7 @@ namespace XenAdminTests.CommandTests
internal override Command CreateCommand()
{
return new RenameTagCommand(Program.MainWindow.CommandInterface, oldTag, newTag);
return new RenameTagCommand(Program.MainWindow, oldTag, newTag);
}
public void Test()

View File

@ -102,7 +102,7 @@ namespace XenAdminTests.CommandTests
MW(() => _node.EnsureVisible());
return new UntagCommand(Program.MainWindow.CommandInterface, new List<VirtualTreeNode> { _node });
return new UntagCommand(Program.MainWindow, new List<VirtualTreeNode> { _node });
}
public void Test()

View File

@ -61,7 +61,7 @@ namespace XenAdminTests
return false;
}
public void Refresh()
public void RequestRefreshTreeView()
{
}
@ -105,11 +105,6 @@ namespace XenAdminTests
throw new Exception("The method or operation is not implemented.");
}
public System.Collections.ObjectModel.ReadOnlyCollection<XenAdmin.Actions.ActionBase> History
{
get { throw new Exception("The method or operation is not implemented."); }
}
public bool DoSearch(string filename)
{
throw new Exception("The method or operation is not implemented.");
@ -125,11 +120,6 @@ namespace XenAdminTests
throw new Exception("The method or operation is not implemented.");
}
public void BringToFront()
{
throw new Exception("The method or operation is not implemented.");
}
public void PutSelectedNodeIntoEditMode()
{
throw new Exception("The method or operation is not implemented.");

View File

@ -59,7 +59,7 @@ namespace XenAdminTests.TabsAndMenus
IXenConnection connection = GetAnyPool().Connection;
// now disconnect
MW<bool>(new DisconnectCommand(Program.MainWindow.CommandInterface, connection, false).Execute);
MW<bool>(new DisconnectCommand(Program.MainWindow, connection, false).Execute);
// wait until the New Storage button is disabled.
MWWaitFor(() => !MainWindowWrapper.MainToolStrip.Items[6].Enabled);

View File

@ -120,7 +120,7 @@ namespace XenAdminTests.TabsAndMenus
[Test]
public void TestContextMenuFontCorrect()
{
ContextMenuBuilder builder = new ContextMenuBuilder(MainWindowWrapper.PluginManager, Program.MainWindow.CommandInterface);
ContextMenuBuilder builder = new ContextMenuBuilder(MainWindowWrapper.PluginManager, Program.MainWindow);
MW(() => TestMenuFontCorrect(builder.Build(GetAnyVM())));
}