Exemplo n.º 1
0
        public void ToggleExpandedGroup(ModuleInfoVm menuItem)
        {
            if (menuItem == null)
            {
                throw new ArgumentNullException(nameof(menuItem));
            }

            menuItem.IsExpanded = !menuItem.IsExpanded;
            NotifyStateChanged();
        }
Exemplo n.º 2
0
        public void SetActiveItem(ModuleInfoVm menuItem, ModuleInfoVm groupItem)
        {
            if (menuItem == null)
            {
                string currentUrlWithoutBase = NavigationManager.Uri.Substring(NavigationManager.BaseUri.Length - 1);

                menuItem  = GeMenuItems().SingleOrDefault(x => x.Meta.Url.OriginalString == currentUrlWithoutBase);
                groupItem = GetGroupItems().SingleOrDefault(x => currentUrlWithoutBase.StartsWith(x.Meta.Url.OriginalString, StringComparison.InvariantCulture));
            }

            if (menuItem != null)
            {
                menuItem.IsActive = true;
            }
            var otherItems = GeMenuItems().Except(new List <ModuleInfoVm> {
                menuItem
            });

            foreach (var item in otherItems)
            {
                item.IsActive = false;
            }

            var otherGroups = GetGroupItems();

            if (groupItem != null)
            {
                groupItem.IsExpanded = true;
                groupItem.IsActive   = true;
                otherGroups          = otherGroups.Except(new List <ModuleInfoVm> {
                    groupItem
                }).ToList();
            }
            foreach (var group in otherGroups)
            {
                group.IsExpanded = false;
                group.IsActive   = false;
            }

            NotifyStateChanged();
        }