コード例 #1
0
        /// <summary>
        /// Builds the context menu for the specified selection.
        /// </summary>
        /// <param name="selection">The selection for which the context menu items are required.</param>
        /// <returns>The context menu items.</returns>
        public ToolStripItem[] Build(IEnumerable <SelectedItem> selection)
        {
            Util.ThrowIfParameterNull(selection, "selection");

            foreach (Builder builder in Builders)
            {
                SelectedItemCollection selectionList = new SelectedItemCollection(selection);

                if (builder.IsValid(selectionList))
                {
                    ContextMenuItemCollection items = new ContextMenuItemCollection(_mainWindow, _pluginManager);
                    builder.Build(_mainWindow, selectionList, items);
                    CheckAccessKeys(items);

                    items.RemoveInvalidSeparators();

                    return(items.ToArray());
                }
            }

            return(new ToolStripItem[0]);
        }