示例#1
0
        /// <summary>
        /// Creates and adds the required GUI elements
        /// </summary>
        private void CreateGUI()
        {
            // Create the column maps component container
            ColumnMapsPageContainer = new StackPanelCollapsibleVerticalMenu <UIElement>()
            {
                IsOpen = true,
                Text   = "Column configurations",
            };

            // Create the column maps page
            ColumnMapsPage = new PropertyMapsPage(QueryMap)
            {
                AllowVerticalScroll = false
            };

            // Add it to the container
            ColumnMapsPageContainer.Add(ColumnMapsPage);

            // Add it to the stack panel
            ContentStackPanel.Add(ColumnMapsPageContainer);

            // Create the data grid presenters component container
            DataGridPresentersComponentContainer = new StackPanelCollapsibleVerticalMenu <UIElement>()
            {
                IsOpen = true,
                Text   = "Data grid presenters"
            };

            // Create the data grid presenter maps page
            DataGridPresenterMapsPage = new DataGridPresenterMapsPage(QueryMap)
            {
                AllowVerticalScroll = false
            };

            // Add it to the container
            DataGridPresentersComponentContainer.Add(DataGridPresenterMapsPage);

            // Add it to the stack panel
            ContentStackPanel.Add(DataGridPresentersComponentContainer);
        }
        /// <summary>
        /// Creates and adds the required GUI elements
        /// </summary>
        private void CreateGUI()
        {
            Add("Overview", new Grid(), false);

            Host.Get(0).SelectTab(0);

            // Create the application menu options container
            ApplicationMenuOptionsContainer = new StackPanelCollapsibleVerticalMenu()
            {
                Text   = "Application",
                IsOpen = true
            };

            // Add the options button
            OptionsMenuButton = ApplicationMenuOptionsContainer.Add("Options", IconPaths.SettingsPath);

            OptionsMenuButton.Command = new RelayCommand(() =>
            {
                WindowsControlsDI.GetWindowsDialogManager.OpenAsync("Options", IconPaths.SettingsPath, () => new OptionsPage(), "options");
            });

            // Add it to the left side menu
            AddLeftMenuElement(ApplicationMenuOptionsContainer);
        }
        /// <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);
            }
        }
        /// <summary>
        /// Creates and returns the GUI in a form of a <see cref="FrameworkElement"/>
        /// </summary>
        /// <returns></returns>
        protected override FrameworkElement CreateBaseGUIElement()
        {
            // Create the content stack panel
            ContentStackPanel = new StackPanel()
            {
                Orientation = Orientation.Vertical
            };

            #region SQLite

            // Create the SQLite stack panel collapsible vertical menu
            SQLiteStackPanelCollapsibleVerticalMenu = new StackPanelCollapsibleVerticalMenu <UIElement>()
            {
                IsOpen = true,
                Text   = "SQLite"
            };

            // Create the SQLite options data grid
            SQLiteOptionsDataGrid = CeidDiplomatikiDataModelHelpers.CreateDefaultSQLiteOptionsDataModelDataGrid();

            SQLiteOptionsDataGrid.ConfigureOptions((container, grid, row, model) =>
            {
                container.AddDeleteOption(async(button) => await RemoveOptionAsync(model));
            });


            SQLiteOptionsDataGrid.Margin = new Thickness(NormalUniformMargin);

            // Add it to the collapsible menu
            SQLiteStackPanelCollapsibleVerticalMenu.Add(SQLiteOptionsDataGrid);

            // Add the collapsible menu to the stack panel
            ContentStackPanel.Children.Add(SQLiteStackPanelCollapsibleVerticalMenu);

            #endregion

            #region MySQL

            // Create the MySQL stack panel collapsible vertical menu
            MySQLStackPanelCollapsibleVerticalMenu = new StackPanelCollapsibleVerticalMenu <UIElement>()
            {
                IsOpen = true,
                Text   = "MySQL"
            };

            // Create the MySQL options data grid
            MySQLOptionsDataGrid = CeidDiplomatikiDataModelHelpers.CreateDefaultMySQLOptionsDataModelDataGrid();

            MySQLOptionsDataGrid.ConfigureOptions((container, grid, row, model) =>
            {
                container.AddOpenOption(async(button) =>
                {
                    var provider = SQLDatabaseProvider.MySQL;

                    // Get the analyzer
                    var analyzer = CeidDiplomatikiDI.GetDatabaseAnalyzer(provider);

                    // Get the connection string
                    model.TryGetConnectionString(out var connectionString);

                    // Get the database
                    var database = analyzer.GetDatabases().First(x => x.DatabaseName == model.DatabaseName);

                    // Show the page
                    await WindowsControlsDI.GetWindowsDialogManager.OpenAsync(model.DatabaseName, IconPaths.DatabasePath, () =>
                    {
                        return(new QueryMapsPage(database, model));
                    }, connectionString);
                });
                container.AddDeleteOption(async(button) => await RemoveOptionAsync(model));
            });



            MySQLOptionsDataGrid.Margin = new Thickness(NormalUniformMargin);

            // Add it to the collapsible menu
            MySQLStackPanelCollapsibleVerticalMenu.Add(MySQLOptionsDataGrid);

            // Add the collapsible menu to the stack panel
            ContentStackPanel.Children.Add(MySQLStackPanelCollapsibleVerticalMenu);

            #endregion

            #region SQLServer

            // Create the SQLServer stack panel collapsible vertical menu
            SQLServerStackPanelCollapsibleVerticalMenu = new StackPanelCollapsibleVerticalMenu <UIElement>()
            {
                IsOpen = true,
                Text   = "SQLServer"
            };

            // Create the SQLServer options data grid
            SQLServerOptionsDataGrid = CeidDiplomatikiDataModelHelpers.CreateDefaultSQLServerOptionsDataModelDataGrid();

            SQLServerOptionsDataGrid.ConfigureOptions((container, grid, row, model) =>
            {
                container.AddDeleteOption(async(button) => await RemoveOptionAsync(model));
            });


            SQLServerOptionsDataGrid.Margin = new Thickness(NormalUniformMargin);

            // Add it to the collapsible menu
            SQLServerStackPanelCollapsibleVerticalMenu.Add(SQLServerOptionsDataGrid);

            // Add the collapsible menu to the stack panel
            ContentStackPanel.Children.Add(SQLServerStackPanelCollapsibleVerticalMenu);

            #endregion

            #region PostgreSQL

            // Create the PostgreSQL stack panel collapsible vertical menu
            PostgreSQLStackPanelCollapsibleVerticalMenu = new StackPanelCollapsibleVerticalMenu <UIElement>()
            {
                IsOpen = true,
                Text   = "PostgreSQL"
            };

            // Create the PostgreSQL options data grid
            PostgreSQLOptionsDataGrid = CeidDiplomatikiDataModelHelpers.CreateDefaultPostgreSQLOptionsDataModelDataGrid();

            PostgreSQLOptionsDataGrid.ConfigureOptions((container, grid, row, model) =>
            {
                container.AddDeleteOption(async(button) => await RemoveOptionAsync(model));
            });

            PostgreSQLOptionsDataGrid.Margin = new Thickness(NormalUniformMargin);

            // Add it to the collapsible menu
            PostgreSQLStackPanelCollapsibleVerticalMenu.Add(PostgreSQLOptionsDataGrid);

            // Add the collapsible menu to the stack panel
            ContentStackPanel.Children.Add(PostgreSQLStackPanelCollapsibleVerticalMenu);

            #endregion

            // Return the content stack panel
            return(ContentStackPanel);
        }