Пример #1
0
        /// <summary>
        /// Adds a MenuCommand into the Menu
        /// </summary>
        /// <param name="command">MenuCommand</param>
        public void AddMenuItem(IMenuCommand command)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command", "command is null.");
            }

            var menuItem = new MenuCommandBridge(command);

            _regionTarget.Items.Add(menuItem);
        }
Пример #2
0
        /// <summary>
        /// Adds a new MenuCommand with its action
        /// </summary>
        /// <param name="header">Menu item name</param>
        /// <param name="action">Action</param>
        public void AddMenuItem(string header, Action action)
        {
            if (String.IsNullOrEmpty(header))
            {
                throw new ArgumentException("header is null or empty.", "header");
            }
            if (action == null)
            {
                throw new ArgumentNullException("action", "action is null.");
            }

            var menuItem = new MenuCommandBridge(header, action);

            _regionTarget.Items.Add(menuItem);
        }
Пример #3
0
        /// <summary>
        /// Adds a new Menu item with several submenu commands
        /// </summary>
        /// <param name="header">Menu item name</param>
        /// <param name="submenuCommands">Submenu commands</param>
        public void AddMenuItems(string header, IEnumerable <IMenuCommand> submenuCommands)
        {
            if (String.IsNullOrEmpty(header))
            {
                throw new ArgumentException("header is null or empty.", "header");
            }
            if (submenuCommands == null)
            {
                throw new ArgumentNullException("submenuCommands", "submenuCommands is null.");
            }

            var parentMenuCommand = new MenuCommandBridge(header);

            foreach (var command in submenuCommands)
            {
                parentMenuCommand.Items.Add(new MenuCommandBridge(command));
            }

            _regionTarget.Items.Add(parentMenuCommand);
        }
Пример #4
0
        private MenuCommandBridge GetParentMenuCommandBridge(IMenuCommand parentMenuCommand)
        {
            if (parentMenuCommand == null)
            {
                throw new ArgumentNullException("parentMenuCommand", "parentMenuCommand is null.");
            }

            MenuCommandBridge parentMenuCommandBridge = null;

            foreach (MenuCommandBridge item in _regionTarget.Items)
            {
                if (item.MenuCommand == parentMenuCommand)
                {
                    parentMenuCommandBridge = item;
                    break;
                }
            }

            return(parentMenuCommandBridge);
        }