本文整理汇总了C#中SelectedItemCollection类的典型用法代码示例。如果您正苦于以下问题:C# SelectedItemCollection类的具体用法?C# SelectedItemCollection怎么用?C# SelectedItemCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SelectedItemCollection类属于命名空间,在下文中一共展示了SelectedItemCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteCore
protected override void ExecuteCore(SelectedItemCollection selection)
{
if (selection != null && selection.AllItemsAre<IXenObject>(x => x is Host || x is Pool))
MainWindowCommandInterface.ShowForm(typeof(BugToolWizard), selection.AsXenObjects<IXenObject>().ToArray());
else
MainWindowCommandInterface.ShowForm(typeof(BugToolWizard));
}
示例2: ExecuteCore
protected override void ExecuteCore(SelectedItemCollection selection)
{
List<Folder> folders = new List<Folder>(selection.AsXenObjects<Folder>(CanExecute));
folders.RemoveAll((Predicate<Folder>)delegate(Folder folder)
{
// if the list contains any folders that are children to others in the list then
// they will automatically get deleted, so remove them here.
foreach (Folder f in folders)
{
if (folder.opaque_ref.StartsWith(f.opaque_ref + "/"))
{
return true;
}
}
return false;
});
List<AsyncAction> actions = new List<AsyncAction>();
foreach (Folder folder in folders)
{
actions.Add(new FolderAction((IXenObject)folder, null, FolderAction.Kind.Delete));
}
RunMultipleActions(actions, Messages.DELETING_FOLDERS, Messages.DELETING_FOLDERS, Messages.DELETED_FOLDERS, true);
}
示例3: CanExecuteCore
protected override bool CanExecuteCore(SelectedItemCollection selection)
{
if (selection.FirstAsXenObject != null && selection.FirstAsXenObject.Connection != null && selection.FirstAsXenObject.Connection.IsConnected &&
(selection.PoolAncestor != null || selection.HostAncestor != null)) // this check ensures there's no cross-pool
return !Helpers.FeatureForbidden(selection.FirstAsXenObject.Connection, Host.RestrictExportResourceData);
return false;
}
示例4: ExecuteCore
protected override void ExecuteCore(SelectedItemCollection selection)
{
if (_filenameSpecified)
{
Execute(_filename);
}
else
{
// Showing this dialog has the (undocumented) side effect of changing the working directory
// to that of the file selected. This means a handle to the directory persists, making
// it undeletable until the program exits, or the working dir moves on. So, save and
// restore the working dir...
string oldDir = "";
try
{
oldDir = Directory.GetCurrentDirectory();
OpenFileDialog dialog = new OpenFileDialog();
dialog.AddExtension = true;
dialog.Filter = string.Format("{0} (*.xensearch)|*.xensearch|{1} (*.*)|*.*", Messages.XENSEARCH_SAVED_SEARCH, Messages.ALL_FILES);
dialog.FilterIndex = 0;
dialog.RestoreDirectory = true;
dialog.DefaultExt = "xensearch";
dialog.CheckPathExists = false;
if (dialog.ShowDialog(Parent) == DialogResult.OK)
Execute(dialog.FileName);
}
finally
{
Directory.SetCurrentDirectory(oldDir);
}
}
}
示例5: ExecuteCore
protected override void ExecuteCore(SelectedItemCollection selection)
{
VM vm = selection[0].XenObject as VM;
if (vm != null)
{
if (vm.VBDs.Count < vm.MaxVBDsAllowed)
{
MainWindowCommandInterface.ShowPerXenModelObjectWizard(vm, new NewDiskDialog(vm.Connection, vm));
}
else
{
new ThreeButtonDialog(
new ThreeButtonDialog.Details(
SystemIcons.Error,
FriendlyErrorNames.VBDS_MAX_ALLOWED,
Messages.DISK_ADD)).ShowDialog(Program.MainWindow);
}
}
else
{
SR sr = (SR)selection[0].XenObject;
MainWindowCommandInterface.ShowPerConnectionWizard(sr.Connection, new NewDiskDialog(sr.Connection, sr));
}
}
示例6: ExecuteCore
protected sealed override void ExecuteCore(SelectedItemCollection selection)
{
ConfirmVMDeleteDialog dialog = new ConfirmVMDeleteDialog(selection.AsXenObjects<VM>());
if (MainWindowCommandInterface.RunInAutomatedTestMode || dialog.ShowDialog(Parent) == DialogResult.Yes)
{
CommandErrorDialog errorDialog = null;
Dictionary<SelectedItem, string> cantExecuteReasons = GetCantExecuteReasons();
if (cantExecuteReasons.Count > 0)
{
errorDialog = new CommandErrorDialog(ErrorDialogTitle, ErrorDialogText, GetCantExecuteReasons());
}
List<AsyncAction> actions = new List<AsyncAction>();
foreach (VM vm in selection.AsXenObjects<VM>(CanExecute))
{
var snapshotsToDelete = dialog.DeleteSnapshots.FindAll(x => x.Connection.Resolve(x.snapshot_of) == vm);
actions.Add(GetAction(vm, dialog.DeleteDisks, snapshotsToDelete));
}
RunMultipleActions(actions, Messages.ACTION_VMS_DESTROYING_TITLE, Messages.ACTION_VM_DESTROYING, Messages.ACTION_VM_DESTROYED, true);
if (errorDialog != null)
{
errorDialog.ShowDialog(Parent);
}
}
}
示例7: ExecuteCore
protected override void ExecuteCore(SelectedItemCollection selection)
{
if (Helpers.FeatureForbidden(selection[0].XenObject, Host.RestrictWLB))
{
// Show upsell dialog
UpsellDialog dlg = new UpsellDialog(Messages.UPSELL_BLURB_WLB, InvisibleMessages.UPSELL_LEARNMOREURL_WLB);
dlg.ShowDialog(Parent);
return;
}
try
{
Dialogs.Wlb.DisableWLBDialog disableDialog = new XenAdmin.Dialogs.Wlb.DisableWLBDialog(string.Empty);
DialogResult dr = disableDialog.ShowDialog(MainWindow.ActiveForm);
if (dr == DialogResult.OK)
{
Actions.Wlb.DisableWLBAction action = new Actions.Wlb.DisableWLBAction(selection[0].PoolAncestor, true);
action.Completed += Program.MainWindow.action_Completed;
action.RunAsync();
Program.MainWindow.UpdateToolbars();
}
}
catch (Failure exn)
{
log.Error(exn, exn);
}
}
示例8: CanExecuteCore
protected override bool CanExecuteCore(SelectedItemCollection selection)
{
bool oneIsConnected = false;
bool foundHost = false;
bool foundPool = false;
foreach (SelectedItem item in selection)
{
if (new DisconnectHostCommand(MainWindowCommandInterface, item).CanExecute())
{
oneIsConnected = true;
}
else if (new DisconnectPoolCommand(MainWindowCommandInterface, item).CanExecute())
{
oneIsConnected = true;
}
if (item.XenObject is Host)
{
foundHost = true;
}
else if (item.XenObject is Pool)
{
foundPool = true;
}
}
return oneIsConnected && foundHost && foundPool;
}
示例9: ExecuteCore
protected override void ExecuteCore(SelectedItemCollection selection)
{
IXenObject selected = selection.FirstAsXenObject;
var server = GetStorageLinkServer(selected);
if (server == null)
return;
var dialog = new AddStorageLinkSystemDialog(server.StorageLinkConnection);
var parent = Parent ?? (Control)Program.MainWindow;
dialog.FormClosing += (s, e) =>
{
if (dialog.DialogResult == DialogResult.OK)
{
var adapter = dialog.StorageAdapter;
var port = dialog.StorageSystemPort;
var address = dialog.StorageSystemAddress;
var username = dialog.StorageSystemUsername;
var password = dialog.StorageSystemPassword;
var ns = dialog.StorageSystemNamespace;
// There are no RBAC complexities here since only pool-operator and above can access the password for the storagelink service.
// Therefore only pool-operator and above can get here. These roles are permitted to add and remove storage systems.
var action = new StorageLinkDelegatedAsyncAction(
() => server.StorageLinkConnection.AddStorageSystem(adapter, port, address, username, password, ns),
string.Format(Messages.ADD_STORAGE_LINK_SYSTEM_ACTION_TITLE, address),
string.Format(Messages.ADD_STORAGE_LINK_SYSTEM_ACTION_START_DESCRIPTION, address),
string.Format(Messages.ADD_STORAGE_LINK_SYSTEM_ACTION_END_DESCRIPTION, address));
var actionWithWait = new DelegatedAsyncAction(null,
string.Format(Messages.ADD_STORAGE_LINK_SYSTEM_ACTION_TITLE, address),
string.Format(Messages.ADD_STORAGE_LINK_SYSTEM_ACTION_START_DESCRIPTION, address),
string.Format(Messages.ADD_STORAGE_LINK_SYSTEM_ACTION_END_DESCRIPTION, address), ss =>
{
int storageSystemCountBefore = server.StorageLinkConnection.Cache.StorageSystems.Count;
action.RunExternal(ss);
for (int i = 0; i < 60 && action.Succeeded && server.StorageLinkConnection.Cache.StorageSystems.Count == storageSystemCountBefore; i++)
{
if((i%5)==0)
{
log.Info("Waiting for StorageLink storage-system to be added to cache.");
}
Thread.Sleep(500);
}
}, true);
actionWithWait.AppliesTo.Add(server.opaque_ref);
actionWithWait.Completed += ss => OnCompleted(new CompletedEventArgs(actionWithWait.Succeeded));
new ActionProgressDialog(actionWithWait, ProgressBarStyle.Continuous) { ShowCancel = true }.ShowDialog(dialog);
// keep creds dialog open if it failed.
e.Cancel = !actionWithWait.Succeeded;
}
};
dialog.Show(parent);
}
示例10: ExecuteCore
protected override void ExecuteCore(SelectedItemCollection selection)
{
if (selection.FirstAsXenObject != null)
{
Execute(selection.FirstAsXenObject.Connection);
}
}
示例11: ExecuteCore
protected override void ExecuteCore(SelectedItemCollection selection)
{
if (Helpers.FeatureForbidden(selection[0].XenObject, Host.RestrictWLB))
{
// Show upsell dialog
UpsellDialog dlg = new UpsellDialog(Messages.UPSELL_BLURB_WLB, InvisibleMessages.UPSELL_LEARNMOREURL_WLB);
dlg.ShowDialog(Parent);
return;
}
try
{
WorkloadReports WlbReportWin = new WorkloadReports(_reportFile, _run)
{
Pool = selection[0].PoolAncestor,
Hosts = selection[0].Connection.Cache.Hosts
};
MainWindowCommandInterface.ShowPerConnectionWizard(selection[0].Connection, WlbReportWin);
}
catch (Failure exn)
{
log.Error(exn, exn);
}
}
示例12: ExecuteCore
protected override void ExecuteCore(SelectedItemCollection selection)
{
VM vm = (VM)selection[0].XenObject;
using (var dlg = new ThreeButtonDialog(
new ThreeButtonDialog.Details(
SystemIcons.Warning,
string.Format(Messages.CONVERT_TEMPLATE_DIALOG_TEXT, vm.Name.Ellipsise(25)),
Messages.CONVERT_TO_TEMPLATE),
new ThreeButtonDialog.TBDButton(Messages.CONVERT, DialogResult.OK, ThreeButtonDialog.ButtonType.ACCEPT, true),
ThreeButtonDialog.ButtonCancel))
{
if (dlg.ShowDialog() == DialogResult.OK)
{
List<AsyncAction> actions = new List<AsyncAction>();
actions.Add(new SetVMOtherConfigAction(vm.Connection, vm, "instant", "true"));
actions.Add(new VMToTemplateAction(vm));
MainWindowCommandInterface.CloseActiveWizards(vm);
RunMultipleActions(actions, string.Format(Messages.ACTION_VM_TEMPLATIZING_TITLE, vm.Name),
Messages.ACTION_VM_TEMPLATIZING, Messages.ACTION_VM_TEMPLATIZED, true);
}
}
}
示例13: ExportApplianceWizard
public ExportApplianceWizard(IXenConnection con, SelectedItemCollection selection)
: base(con)
{
InitializeComponent();
m_pageExportAppliance = new ExportAppliancePage();
m_pageRbac = new RBACWarningPage();
m_pageExportSelectVMs = new ExportSelectVMsPage();
m_pageExportEula = new ExportEulaPage();
m_pageExportOptions = new ExportOptionsPage();
m_pageTvmIp = new TvmIpPage();
m_pageFinish = new ExportFinishPage();
m_selectedObject = selection.FirstAsXenObject;
if (selection.Count == 1 && (m_selectedObject is VM || m_selectedObject is VM_appliance))
m_pageExportAppliance.ApplianceFileName = m_selectedObject.Name;
m_pageExportAppliance.OvfModeOnly = m_selectedObject is VM_appliance;
m_pageTvmIp.IsExportMode = true;
m_pageFinish.SummaryRetreiver = GetSummary;
m_pageExportSelectVMs.SelectedItems = selection;
AddPages(m_pageExportAppliance, m_pageExportSelectVMs, m_pageFinish);
}
示例14: ExecuteCore
protected override void ExecuteCore(SelectedItemCollection selection)
{
foreach (SelectedItem item in selection)
{
new DisconnectCommand(MainWindowCommandInterface, item.Connection, false).Execute();
}
}
示例15: ExecuteCore
protected override void ExecuteCore(SelectedItemCollection selection)
{
foreach (VirtualTreeNode node in _nodes)
{
node.ExpandAll();
}
}