mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2024-11-23 20:36:33 +01:00
Removed method SetParent. Use a setter for the property Parent instead. Property modernisation.
Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
parent
ab59bf22d0
commit
db89699bac
@ -70,7 +70,7 @@ namespace XenAdmin.Commands
|
||||
public AddHostCommand(IMainWindow mainWindow, Control parent)
|
||||
: base(mainWindow)
|
||||
{
|
||||
SetParent(parent);
|
||||
Parent = parent;
|
||||
}
|
||||
|
||||
protected override void ExecuteCore(SelectedItemCollection selection)
|
||||
@ -91,29 +91,10 @@ namespace XenAdmin.Commands
|
||||
MainWindowCommandInterface.TrySelectNewObjectInTree(conn, true, true, true);
|
||||
}
|
||||
|
||||
public override Image MenuImage
|
||||
{
|
||||
get
|
||||
{
|
||||
return Images.StaticImages._000_AddApplicationServer_h32bit_16;
|
||||
}
|
||||
}
|
||||
public override Image MenuImage => Images.StaticImages._000_AddApplicationServer_h32bit_16;
|
||||
|
||||
public override Image ToolBarImage
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
return Images.StaticImages._000_AddApplicationServer_h32bit_24;
|
||||
}
|
||||
}
|
||||
public override Image ToolBarImage => Images.StaticImages._000_AddApplicationServer_h32bit_24;
|
||||
|
||||
public override string MenuText
|
||||
{
|
||||
get
|
||||
{
|
||||
return Messages.MAINWINDOW_ADD_HOST;
|
||||
}
|
||||
}
|
||||
public override string MenuText => Messages.MAINWINDOW_ADD_HOST;
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using XenAdmin.Actions;
|
||||
using XenAdmin.Dialogs;
|
||||
@ -66,7 +65,7 @@ namespace XenAdmin.Commands
|
||||
this.xos = xos;
|
||||
_licenseServerAddress = licenseServerAddress;
|
||||
_licenseServerPort = licenseServerPort;
|
||||
SetParent(parent);
|
||||
Parent = parent;
|
||||
}
|
||||
|
||||
protected override void ExecuteCore(SelectedItemCollection selection)
|
||||
|
@ -187,58 +187,37 @@ namespace XenAdmin.Commands
|
||||
/// <summary>
|
||||
/// Gets the text for a menu item which launches this Command.
|
||||
/// </summary>
|
||||
public virtual string MenuText
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
public virtual string MenuText => null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the text for a context menu item which launches this Command.
|
||||
/// </summary>
|
||||
public virtual string ContextMenuText
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
public virtual string ContextMenuText => null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the image for a menu item which launches this Command.
|
||||
/// </summary>
|
||||
public virtual Image MenuImage
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
public virtual Image MenuImage => null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the image for a context menu item which launches this Command.
|
||||
/// </summary>
|
||||
public virtual Image ContextMenuImage
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
public virtual Image ContextMenuImage => null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the text for the toolbar button which launches this Command.
|
||||
/// </summary>
|
||||
public virtual string ToolBarText
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
public virtual string ToolBarText => null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the image for a toolbar button which launches this Command.
|
||||
/// </summary>
|
||||
public virtual Image ToolBarImage
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
public virtual Image ToolBarImage => null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the text for a button which launches this Command.
|
||||
/// </summary>
|
||||
public virtual string ButtonText
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
public virtual string ButtonText => null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the tool tip text. By default this is the can't execute reason if execution is not possible and
|
||||
@ -285,26 +264,17 @@ namespace XenAdmin.Commands
|
||||
/// <summary>
|
||||
/// Gets the tool tip text when the command is able to run. Null by default.
|
||||
/// </summary>
|
||||
protected virtual string EnabledToolTipText
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
protected virtual string EnabledToolTipText => null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the shortcut key display string. This is only used if this Command is used on the main menu.
|
||||
/// </summary>
|
||||
public virtual string ShortcutKeyDisplayString
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
public virtual string ShortcutKeyDisplayString => null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the shortcut keys. This is only used if this Command is used on the main menu.
|
||||
/// </summary>
|
||||
public virtual Keys ShortcutKeys
|
||||
{
|
||||
get { return Keys.None; }
|
||||
}
|
||||
public virtual Keys ShortcutKeys => Keys.None;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether a confirmation dialog should be shown.
|
||||
@ -415,31 +385,19 @@ namespace XenAdmin.Commands
|
||||
/// <summary>
|
||||
/// Gets the main window to be used by the Command.
|
||||
/// </summary>
|
||||
public IMainWindow MainWindowCommandInterface
|
||||
{
|
||||
get { return _mainWindow; }
|
||||
}
|
||||
public IMainWindow MainWindowCommandInterface => _mainWindow;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Sets the parent for any dialogs. If not called, then the main window is used.
|
||||
/// </summary>
|
||||
/// <param name="parent">The parent.</param>
|
||||
public void SetParent(Control parent)
|
||||
{
|
||||
_parent = parent;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the parent for any dialogs. If SetParent() hasn't been called then the MainWindow is returned.
|
||||
/// Gets or sets the parent control for any dialogs launched during the
|
||||
/// execution of the command. Defaults to the MainWindow Form.
|
||||
/// </summary>
|
||||
public Control Parent
|
||||
{
|
||||
get
|
||||
{
|
||||
return _parent ?? _mainWindow.Form;
|
||||
}
|
||||
get => _parent ?? _mainWindow?.Form;
|
||||
set => _parent = value;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Runs the specified <see cref="AsyncAction"/>s such that they are synchronous per connection but asynchronous across connections.
|
||||
/// </summary>
|
||||
|
@ -36,7 +36,6 @@ using XenAdmin.Actions;
|
||||
using XenAdmin.Core;
|
||||
using System.Windows.Forms;
|
||||
using XenAdmin.Dialogs;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
|
||||
|
||||
@ -76,7 +75,7 @@ namespace XenAdmin.Commands
|
||||
public InstallToolsCommand(IMainWindow mainWindow, VM vm, Control parent)
|
||||
: base(mainWindow, vm)
|
||||
{
|
||||
SetParent(parent);
|
||||
Parent = parent;
|
||||
}
|
||||
|
||||
public InstallToolsCommand(IMainWindow mainWindow, VM vm)
|
||||
|
@ -70,7 +70,7 @@ namespace XenAdmin.Commands
|
||||
public NewFolderCommand(IMainWindow mainWindow, Folder folder, Control parent)
|
||||
: base(mainWindow, folder)
|
||||
{
|
||||
SetParent(parent);
|
||||
Parent = parent;
|
||||
}
|
||||
|
||||
private void Execute(Folder folder, IWin32Window ownerWindow)
|
||||
@ -173,21 +173,9 @@ namespace XenAdmin.Commands
|
||||
return false;
|
||||
}
|
||||
|
||||
public override string MenuText
|
||||
{
|
||||
get
|
||||
{
|
||||
return Messages.NEW_FOLDER;
|
||||
}
|
||||
}
|
||||
public override string MenuText => Messages.NEW_FOLDER;
|
||||
|
||||
public override Image MenuImage
|
||||
{
|
||||
get
|
||||
{
|
||||
return Images.StaticImages._000_Folder_open_h32bit_16;
|
||||
}
|
||||
}
|
||||
public override Image MenuImage => Images.StaticImages._000_Folder_open_h32bit_16;
|
||||
|
||||
protected override string GetCantExecuteReasonCore(IXenObject item)
|
||||
{
|
||||
|
@ -34,7 +34,6 @@ using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using XenAdmin.Actions;
|
||||
using XenAdmin.Properties;
|
||||
using XenAPI;
|
||||
using XenAdmin.Dialogs;
|
||||
|
||||
@ -62,7 +61,7 @@ namespace XenAdmin.Commands
|
||||
public RebootHostCommand(IMainWindow mainWindow, Host host, Control parent)
|
||||
: base(mainWindow, host)
|
||||
{
|
||||
SetParent(parent);
|
||||
Parent = parent;
|
||||
}
|
||||
|
||||
protected override void ExecuteCore(SelectedItemCollection selection)
|
||||
@ -100,21 +99,9 @@ namespace XenAdmin.Commands
|
||||
return false;
|
||||
}
|
||||
|
||||
public override Image MenuImage
|
||||
{
|
||||
get
|
||||
{
|
||||
return Images.StaticImages._001_Reboot_h32bit_16;
|
||||
}
|
||||
}
|
||||
public override Image MenuImage => Images.StaticImages._001_Reboot_h32bit_16;
|
||||
|
||||
public override string MenuText
|
||||
{
|
||||
get
|
||||
{
|
||||
return Messages.MAINWINDOW_REBOOT;
|
||||
}
|
||||
}
|
||||
public override string MenuText => Messages.MAINWINDOW_REBOOT;
|
||||
|
||||
protected override string ConfirmationDialogText
|
||||
{
|
||||
@ -150,13 +137,7 @@ namespace XenAdmin.Commands
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool ConfirmationRequired
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
protected override bool ConfirmationRequired => true;
|
||||
|
||||
protected override string ConfirmationDialogTitle
|
||||
{
|
||||
@ -197,28 +178,10 @@ namespace XenAdmin.Commands
|
||||
return base.GetCantExecuteReasonCore(item);
|
||||
}
|
||||
|
||||
public override string ContextMenuText
|
||||
{
|
||||
get
|
||||
{
|
||||
return Messages.MAINWINDOW_REBOOT_HOST_CONTEXT_MENU;
|
||||
}
|
||||
}
|
||||
public override string ContextMenuText => Messages.MAINWINDOW_REBOOT_HOST_CONTEXT_MENU;
|
||||
|
||||
protected override string ConfirmationDialogYesButtonLabel
|
||||
{
|
||||
get
|
||||
{
|
||||
return Messages.CONFIRM_REBOOT_SERVER_YES_BUTTON_LABEL;
|
||||
}
|
||||
}
|
||||
protected override string ConfirmationDialogYesButtonLabel => Messages.CONFIRM_REBOOT_SERVER_YES_BUTTON_LABEL;
|
||||
|
||||
protected override bool ConfirmationDialogNoButtonSelected
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
protected override bool ConfirmationDialogNoButtonSelected => true;
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,6 @@ using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using XenAdmin.Actions;
|
||||
using XenAdmin.Core;
|
||||
using XenAdmin.Properties;
|
||||
using XenAPI;
|
||||
using XenAdmin.Dialogs;
|
||||
using System.Text;
|
||||
@ -64,7 +63,7 @@ namespace XenAdmin.Commands
|
||||
public ShutDownHostCommand(IMainWindow mainWindow, Host host, Control parent)
|
||||
: base(mainWindow, host)
|
||||
{
|
||||
SetParent(parent);
|
||||
Parent = parent;
|
||||
}
|
||||
|
||||
protected override void ExecuteCore(SelectedItemCollection selection)
|
||||
@ -90,29 +89,11 @@ namespace XenAdmin.Commands
|
||||
return host != null && host.IsLive() && !HelpersGUI.HasActiveHostAction(host) ;
|
||||
}
|
||||
|
||||
public override string MenuText
|
||||
{
|
||||
get
|
||||
{
|
||||
return Messages.MAINWINDOW_SHUTDOWN;
|
||||
}
|
||||
}
|
||||
public override string MenuText => Messages.MAINWINDOW_SHUTDOWN;
|
||||
|
||||
public override Image MenuImage
|
||||
{
|
||||
get
|
||||
{
|
||||
return Images.StaticImages._001_ShutDown_h32bit_16;
|
||||
}
|
||||
}
|
||||
public override Image MenuImage => Images.StaticImages._001_ShutDown_h32bit_16;
|
||||
|
||||
protected override bool ConfirmationRequired
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
protected override bool ConfirmationRequired => true;
|
||||
|
||||
protected override string ConfirmationDialogTitle
|
||||
{
|
||||
@ -216,20 +197,8 @@ namespace XenAdmin.Commands
|
||||
return base.GetCantExecuteReasonCore(item);
|
||||
}
|
||||
|
||||
protected override string ConfirmationDialogYesButtonLabel
|
||||
{
|
||||
get
|
||||
{
|
||||
return Messages.CONFIRM_SHUTDOWN_SERVER_YES_BUTTON_LABEL;
|
||||
}
|
||||
}
|
||||
protected override string ConfirmationDialogYesButtonLabel => Messages.CONFIRM_SHUTDOWN_SERVER_YES_BUTTON_LABEL;
|
||||
|
||||
protected override bool ConfirmationDialogNoButtonSelected
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
protected override bool ConfirmationDialogNoButtonSelected => true;
|
||||
}
|
||||
}
|
||||
|
@ -29,17 +29,11 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using XenAPI;
|
||||
using XenAdmin.Actions;
|
||||
using System.Windows.Forms;
|
||||
using XenAdmin.Network;
|
||||
using System.Collections.ObjectModel;
|
||||
using XenAdmin.Core;
|
||||
using System.Threading;
|
||||
using XenAdmin.Actions.VMActions;
|
||||
|
||||
|
||||
namespace XenAdmin.Commands
|
||||
{
|
||||
@ -66,7 +60,7 @@ namespace XenAdmin.Commands
|
||||
protected VMLifeCycleCommand(IMainWindow mainWindow, VM vm, Control parent)
|
||||
: base(mainWindow, new SelectedItem(vm))
|
||||
{
|
||||
SetParent(parent);
|
||||
Parent = parent;
|
||||
}
|
||||
|
||||
protected abstract bool CanExecute(VM vm);
|
||||
|
Loading…
Reference in New Issue
Block a user