예제 #1
0
        public void SetupSidebar()
        {
            SidebarItems.Clear();
            SidebarItemObjects.Clear();

            // Add all default sidebar items
            SidebarItems.Add(new DividerNavigationItem());
            foreach (var screen in DefaultSidebarItems.OrderBy(d => d.DisplayOrder))
            {
                var sidebarItem = new FirstLevelNavigationItem {Icon = screen.DisplayIcon, Label = screen.DisplayName};
                SidebarItems.Add(sidebarItem);
                SidebarItemObjects.Add(sidebarItem, screen);
            }

            // Add all activated modules
            SidebarItems.Add(new DividerNavigationItem());
            SidebarItems.Add(new SubheaderNavigationItem {Subheader = "Modules"});
            var modules = _pluginService.GetPluginsOfType<Core.Plugins.Abstract.Module>().ToList();
            foreach (var module in modules)
                AddModule(module);

            // Select the top item, which will be one of the defaults
            SidebarItems[1].IsSelected = true;
            SelectedItem = (IScreen) SidebarItemObjects[SidebarItems[1]];
        }
예제 #2
0
        public void AddModule(Core.Plugins.Abstract.Module module)
        {
            // Ensure the module is not already in the list
            if (SidebarItemObjects.Any(io => io.Value == module))
                return;

            // Icon is provided as string to avoid having to reference MaterialDesignThemes
            var parsedIcon = Enum.TryParse<PackIconKind>(module.DisplayIcon, true, out var iconEnum);
            if (parsedIcon == false)
                iconEnum = PackIconKind.QuestionMarkCircle;
            var sidebarItem = new FirstLevelNavigationItem {Icon = iconEnum, Label = module.DisplayName};
            SidebarItems.Add(sidebarItem);
            SidebarItemObjects.Add(sidebarItem, module);
        }