Esempio n. 1
0
        /// <summary>
        /// Generates the components for <see cref="tabPageTexture"/>.
        /// </summary>
        private void InitializeTextureComponents()
        {
            for (int i = 0; i < 16; i++)
            {
                _textureRadios[i] = new RadioButton {
                    UseVisualStyleBackColor = true, AutoSize = true, Left = 6, Top = 6 + 16 * i
                };
                tabPageTexture.Controls.Add(_textureRadios[i]);

                _textureButtons[i] = new Button {
                    UseVisualStyleBackColor = true, Size = new Size(28, 16), Left = 119, Top = 3 + 16 * i, Anchor = AnchorStyles.Top | AnchorStyles.Right, Text = @"..."
                };
                int templateIndex = i; // Copy to local variable to prevent modification by loop outside of closure
                _textureButtons[i].Click += delegate
                {
                    var dialog = new SelectTemplateDialog <TerrainTemplate>(Template <TerrainTemplate> .All);
                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        ExecuteCommandSafe(new ChangeTerrainTemplate <TerrainTemplate>(_universe.Terrain, templateIndex, dialog.SelectedTemplate, _presenter.RebuildTerrain));
                    }
                };
                tabPageTexture.Controls.Add(_textureButtons[i]);
            }
            _textureRadios[0].Checked = true;
        }
Esempio n. 2
0
        private void buttonNewEntity_Click(object sender, EventArgs e)
        {
            var selectTemplate = new SelectTemplateDialog <EntityTemplate>(Template <EntityTemplate> .All);

            if (selectTemplate.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            AddNewPositionable(new Entity
            {
                Position     = GetScreenTerrainCenter(),
                TemplateName = selectTemplate.SelectedTemplate
            });
        }