/// <summary>
        /// Recreates the dynamically created menu buttons
        /// </summary>
        public void Refresh()
        {
            // For every button container...
            foreach (var container in mDynamicPageButtonContainers)
            {
                // Remove it
                LeftMenuItemsContainer.Children.Remove(container);
            }

            // Get the manager
            var manager = CeidDiplomatikiDI.GetCeidDiplomatikiManager;

            // For every root page map grouped by category...
            foreach (var rootPageMapGroup in manager.RootPages.OrderBy(x => x.Order).GroupBy(x => x.Category))
            {
                // Create the presenter menu options container
                var presenterMenuOptionsContainer = new StackPanelCollapsibleVerticalMenu()
                {
                    IsOpen = true,
                    Text   = rootPageMapGroup.Key
                };

                // For every map...
                foreach (var rootPageMap in rootPageMapGroup)
                {
                    // Create the button
                    var button = new MenuButton()
                    {
                        Text         = rootPageMap.Name,
                        VectorSource = rootPageMap.PathData,
                        BackColor    = rootPageMap.Color.ToColor(),
                        ForeColor    = rootPageMap.Color.ToColor().DarkOrWhite(),
                        IsEnabled    = !(rootPageMap.Presenter == null && rootPageMap.Pages.Count == 0)
                    };

                    button.Command = new RelayCommand(() =>
                    {
                        WindowsControlsDI.GetWindowsDialogManager.OpenAsync(rootPageMap.Name, rootPageMap.PathData, () =>
                        {
                            // If there are other paged...
                            if (rootPageMap.Pages.Count() > 0)
                            {
                                // Create a sub pages page
                                return(new PageMapPage(rootPageMap));
                            }
                            // Else...
                            else
                            {
                                // Get the presenter
                                var presenter = rootPageMap.Presenter;

                                // Create and return a page
                                return(PresenterPagesFactory.CreatePresenterPage(presenter, rootPageMap));
                            }
                        }, rootPageMap.Id);
                    });

                    // Add it to the menu
                    presenterMenuOptionsContainer.Add(button);
                }

                // Add it to the containers
                mDynamicPageButtonContainers.Add(presenterMenuOptionsContainer);

                // Add it to the left side menu
                AddLeftMenuElement(presenterMenuOptionsContainer);
            }
        }
Exemple #2
0
        /// <summary>
        /// Creates and adds the required GUI
        /// </summary>
        private void CreateGUI()
        {
            // Lock the menu
            VerticalMenu.MenuLocked = true;

            // For every sub page map...
            foreach (var pageMap in PageMap.Pages.OrderBy(x => x.Order))
            {
                // Create the button
                var button = new VerticalMenuButton(VerticalMenu, async(menu, button) =>
                {
                    // If there are other pages...
                    if (pageMap.Pages.Count() > 0)
                    {
                        // Create a sub pages page
                        return(await Task.FromResult(new PageMapPage(pageMap)));
                    }
                    // Else...
                    else
                    {
                        // Get the presenter
                        var presenter = pageMap.Presenter;

                        // Create and return a page
                        return(await Task.FromResult(PresenterPagesFactory.CreatePresenterPage(presenter, pageMap)));
                    }
                })
                {
                    Text         = pageMap.Name,
                    VectorSource = pageMap.PathData,
                    BackColor    = pageMap.Color.ToColor(),
                    ForeColor    = pageMap.Color.ToColor().DarkOrWhite(),
                    IsEnabled    = !(pageMap.Presenter == null && pageMap.Pages.Count == 0)
                };

                // Create the context menu
                var contextMenu = new StandardContextMenu();

                contextMenu.AddOpenOption((button) =>
                {
                    WindowsControlsDI.GetWindowsDialogManager.OpenAsync(pageMap.Name, pageMap.PathData, () =>
                    {
                        // If there are other pages...
                        if (pageMap.Pages.Count() > 0)
                        {
                            // Create a sub pages page
                            return(new PageMapPage(pageMap));
                        }
                        // Else...
                        else
                        {
                            // Get the presenter
                            var presenter = pageMap.Presenter;

                            // Create and return a page
                            return(PresenterPagesFactory.CreatePresenterPage(presenter, pageMap));
                        }
                    }, pageMap.Id);
                });

                // Set it to the button
                button.ContextMenu = contextMenu;

                // Add it to the menu
                Add(button, pageMap.Category);
            }
        }