Ejemplo n.º 1
0
        // Updates the preview and settings group boxes
        private void updatePanels(BlockPanel block, SettingsBlock settingsBlock)
        {
            // If block is null, then display no preivew and no settings, otherwise...
            if (block != null)
            {
                // Clears the preview box, creates a block based on user input and inserts it in the dead middle of the preview group box
                previewGroupBox.Controls.Clear();
                UserControl previewControl = block;
                previewGroupBox.Controls.Add(previewControl);
                previewControl.Location = new Point((previewGroupBox.Height / 2) - (previewControl.Size.Height / 2), (previewGroupBox.Width / 2) - (previewControl.Size.Width / 2));

                // Clears the settings box, creates a settings block based on user input and inserts it into the settings group box
                settingsGroupBox.Controls.Clear();
                UserControl newSettings = settingsBlock;
                newSettings.Location = new Point(1, 16);
                settingsGroupBox.Controls.Add((UserControl)newSettings);
            }
            else
            {
                // Clears both group boxes
                previewGroupBox.Controls.Clear();
                settingsGroupBox.Controls.Clear();

                // Adds a "No settings..." label if no item is selected in the combo box
                Label newLabel = new Label();
                newLabel.Text     = "The currently selected item has no settings or defaults to configure.";
                newLabel.Dock     = DockStyle.Fill;
                newLabel.AutoSize = false;
                settingsGroupBox.Controls.Add(newLabel);
            }
        }
Ejemplo n.º 2
0
        // Adds the panel using the mainform's public function to add a panel to the current scene
        private void addButton_Click(object sender, EventArgs e)
        {
            switch (itemComboBox.SelectedIndex)
            {
            // If no item is selected
            case 0:
                MessageBox.Show("You have not selected an item to add. Please choose an item from the combobox.");
                break;

            // If any item is selected
            default:
                SettingsBlock currentSettings = (SettingsBlock)settingsGroupBox.Controls[0];
                this.mainWindow.addBlockPanel(currentSettings.makeNewBlockUsingSettings());
                break;
            }
        }