コード例 #1
0
        /// <summary>
        /// Add another TopMenu to this NavigationMenu.
        /// </summary>
        /// <param name="topMenu">The new TopMenu to be added.</param>
        public void AddTopMenu(TopMenu topMenu)
        {
            // Get an Enumerator for the collection of TopMenus
            IEnumerator <TopMenu> topMenusEnum = _topMenus.GetEnumerator();

            // Determine if the TopMenu already exists
            while (topMenusEnum.MoveNext())
            {
                if (topMenusEnum.Current.MenuId.Equals(topMenu.MenuId))
                {
                    topMenusEnum.Dispose();
                    throw new ApplicationException("Attempting to add TopMenu with non-unique ID.");
                }
            }

            // Add our TopMenu event handler to the TopMenuEvent for this new menu
            topMenu.AddTopMenuEventListener(TopMenuEventHandler);

            // If no matches are found, add the new TopMenu
            _topMenus.Add(topMenu);

            // If this is the first TopMenu to be added, default it to selected
            if (_topMenus.Count == 1)
            {
                // Set the TopMenu to selected
                topMenu.IsSelected = true;

                // Store a reference to the selected TopMenu
                _selectedTopMenu = topMenu;
            }

            // Trigger a NavigationMenuEvent
            if (_navMenuEvent != null)
            {
                _navMenuEvent(this, NavigationMenuEventType.MENU_MODIFIED);
            }
        }
コード例 #2
0
        /// <summary>
        /// Add another TopMenu to this NavigationMenu.
        /// </summary>
        /// <param name="topMenu">The new TopMenu to be added.</param>
        public void AddTopMenu(TopMenu topMenu)
        {
            // Get an Enumerator for the collection of TopMenus
            IEnumerator<TopMenu> topMenusEnum = _topMenus.GetEnumerator();

            // Determine if the TopMenu already exists
            while (topMenusEnum.MoveNext())
            {
                if (topMenusEnum.Current.MenuId.Equals(topMenu.MenuId))
                {
                    topMenusEnum.Dispose();
                    throw new ApplicationException("Attempting to add TopMenu with non-unique ID.");
                }
            }

            // Add our TopMenu event handler to the TopMenuEvent for this new menu
            topMenu.AddTopMenuEventListener(TopMenuEventHandler);

            // If no matches are found, add the new TopMenu
            _topMenus.Add(topMenu);

            // If this is the first TopMenu to be added, default it to selected
            if (_topMenus.Count == 1)
            {
                // Set the TopMenu to selected
                topMenu.IsSelected = true;

                // Store a reference to the selected TopMenu
                _selectedTopMenu = topMenu;
            }

            // Trigger a NavigationMenuEvent
            if (_navMenuEvent != null)
            {
                _navMenuEvent(this, NavigationMenuEventType.MENU_MODIFIED);
            }
        }