当前位置: 首页>>代码示例>>C#>>正文


C# SelectedItemCollection类代码示例

本文整理汇总了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));
 }
开发者ID:huizh,项目名称:xenadmin,代码行数:7,代码来源:BugToolCommand.cs

示例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);
        }
开发者ID:huizh,项目名称:xenadmin,代码行数:26,代码来源:DeleteFolderCommand.cs

示例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;
 }
开发者ID:huizh,项目名称:xenadmin,代码行数:7,代码来源:ExportResourceReportCommand.cs

示例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);
                }
            }
        }
开发者ID:huizh,项目名称:xenadmin,代码行数:33,代码来源:ImportSearchCommand.cs

示例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));
            }
        }
开发者ID:huizh,项目名称:xenadmin,代码行数:25,代码来源:AddVirtualDiskCommand.cs

示例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);
                }
            }
        }
开发者ID:huizh,项目名称:xenadmin,代码行数:28,代码来源:DeleteVMCommand.cs

示例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);
                }
       }
开发者ID:slamj1,项目名称:xenadmin,代码行数:28,代码来源:DisconnectWlbServerCommand.cs

示例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;
        }
开发者ID:huizh,项目名称:xenadmin,代码行数:29,代码来源:DisconnectHostsAndPoolsCommand.cs

示例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);
        }
开发者ID:agimofcarmen,项目名称:xenadmin,代码行数:60,代码来源:AddStorageLinkSystemCommand.cs

示例10: ExecuteCore

 protected override void ExecuteCore(SelectedItemCollection selection)
 {
     if (selection.FirstAsXenObject != null)
     {
         Execute(selection.FirstAsXenObject.Connection);
     }
 }
开发者ID:huizh,项目名称:xenadmin,代码行数:7,代码来源:ExportResourceReportCommand.cs

示例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);
            }
        }
开发者ID:slamj1,项目名称:xenadmin,代码行数:25,代码来源:ViewWorkloadReportsCommand.cs

示例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);
                }
            }
        }
开发者ID:huizh,项目名称:xenadmin,代码行数:25,代码来源:ConvertVMToTemplateCommand.cs

示例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);
		}
开发者ID:huizh,项目名称:xenadmin,代码行数:25,代码来源:ExportApplianceWizard.cs

示例14: ExecuteCore

 protected override void ExecuteCore(SelectedItemCollection selection)
 {
     foreach (SelectedItem item in selection)
     {
         new DisconnectCommand(MainWindowCommandInterface, item.Connection, false).Execute();
     }
 }
开发者ID:huizh,项目名称:xenadmin,代码行数:7,代码来源:DisconnectHostsAndPoolsCommand.cs

示例15: ExecuteCore

 protected override void ExecuteCore(SelectedItemCollection selection)
 {
     foreach (VirtualTreeNode node in _nodes)
     {
         node.ExpandAll();
     }
 }
开发者ID:huizh,项目名称:xenadmin,代码行数:7,代码来源:ExpandTreeNodesCommand.cs


注:本文中的SelectedItemCollection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。