Esempio n. 1
0
        private TabControl CreateTabs()
        {
            TabControl tabs = new TabControl();

            tabs.Dock = DockStyle.Fill;
            tabs.Font = ConstantsGUI.FONT_SMALL;

            listedGeneticSettings = new ListedGeneticSettingsGUI(snakeAISettings, true);
            listedNetworkSettings = new ListedNetworkSettingsGUI(snakeAISettings, true);
            listedSnakeSettings   = new ListedSnakeSettingsGUI(snakeAISettings, true);

            TabPage geneticTab = new TabPage();

            geneticTab.Text = "Genetic Algorithm";
            geneticTab.Controls.Add(CreateLayout("Genetic Algorithm",
                                                 listedGeneticSettings));

            TabPage networkTab = new TabPage();

            networkTab.Text = "Neural Network";
            networkTab.Controls.Add(CreateLayout("Neural Network",
                                                 listedNetworkSettings));

            TabPage snakeTab = new TabPage();

            snakeTab.Text = "Snake Game";
            snakeTab.Controls.Add(CreateLayout("Snake Game",
                                               listedSnakeSettings));

            tabs.Controls.Add(geneticTab);
            tabs.Controls.Add(networkTab);
            tabs.Controls.Add(snakeTab);

            return(tabs);
        }
Esempio n. 2
0
        private TableLayoutPanel CreateTableLayout()
        {
            TableLayoutPanel layout        = new TableLayoutPanel();
            TableLayoutPanel buttonsLayout = new TableLayoutPanel();

            buttonsLayout.Height       = 30;
            buttonsLayout.AutoSize     = true;
            buttonsLayout.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            buttonsLayout.Dock         = DockStyle.Top;

            buttonsLayout.ColumnCount = 2;
            buttonsLayout.RowCount    = 1;

            buttonsLayout.RowStyles.Add(new RowStyle(SizeType.Absolute, 30));

            buttonsLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
            buttonsLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));

            Button saveButton = new Button();

            saveButton.Click += OnClickSave; // Fjern comment når impl.
            saveButton.Dock   = DockStyle.Top;
            saveButton.Text   = "Apply changes";

            Button exitButton = new Button();

            exitButton.Click += OnClickExit;
            exitButton.Dock   = DockStyle.Top;
            exitButton.Text   = "Exit";

            buttonsLayout.Controls.Add(saveButton);
            buttonsLayout.Controls.Add(exitButton);

            layout.AutoSize          = true;
            layout.AutoSizeMode      = AutoSizeMode.GrowAndShrink;
            layout.AutoScroll        = true;
            layout.AutoScrollMinSize = new Size(0, 600);
            layout.Dock = DockStyle.Fill;

            layout.ColumnCount = 1;
            layout.RowCount    = 7;

            Label geneticTitle = new Label();

            geneticTitle.Text     = "Genetic Algorithm";
            geneticTitle.Anchor   = AnchorStyles.Top;
            geneticTitle.AutoSize = true;
            geneticTitle.Font     = ConstantsGUI.FONT_HEADER;

            Label networkTitle = new Label();

            networkTitle.Text     = "Neural Network";
            networkTitle.Anchor   = AnchorStyles.Top;
            networkTitle.AutoSize = true;
            networkTitle.Font     = ConstantsGUI.FONT_HEADER;

            Label snakeTitle = new Label();

            snakeTitle.Text     = "Snake Game";
            snakeTitle.Anchor   = AnchorStyles.Top;
            snakeTitle.AutoSize = true;
            snakeTitle.Font     = ConstantsGUI.FONT_HEADER;

            listedGeneticSettings = new ListedGeneticSettingsGUI(snakeAISettings, true);
            listedNetworkSettings = new ListedNetworkSettingsGUI(snakeAISettings, true);
            listedSnakeSettings   = new ListedSnakeSettingsGUI(snakeAISettings, true);

            layout.RowStyles.Add(new RowStyle(SizeType.AutoSize));
            layout.RowStyles.Add(new RowStyle(SizeType.AutoSize));
            layout.RowStyles.Add(new RowStyle(SizeType.AutoSize));
            layout.RowStyles.Add(new RowStyle(SizeType.AutoSize));
            layout.RowStyles.Add(new RowStyle(SizeType.AutoSize));
            layout.RowStyles.Add(new RowStyle(SizeType.AutoSize));
            layout.RowStyles.Add(new RowStyle(SizeType.Absolute, 30));

            layout.Controls.Add(geneticTitle, 0, 0);
            layout.Controls.Add(listedGeneticSettings, 0, 1);
            layout.Controls.Add(networkTitle, 0, 2);
            layout.Controls.Add(listedNetworkSettings, 0, 3);
            layout.Controls.Add(snakeTitle, 0, 4);
            layout.Controls.Add(listedSnakeSettings, 0, 5);
            layout.Controls.Add(buttonsLayout, 0, 6);

            return(layout);
        }