public TerrainGrid(AddTerrain addTerrain, int width, int length, int minHeight, int maxHeight)
        {
            this.addTerrain = addTerrain;
            InitializeComponent();

            int[] heights = new int[width * length];

            for (int i = 0; i < heights.Length; i++)
            {
                heights[i] = 0;
            }

            Terrain_Grid_Id.ColumnCount += width - 2;
            Terrain_Grid_Id.RowCount    += length - 2;

            float cellWidth  = float.Parse((this.Width / width).ToString());
            float cellHeight = float.Parse((this.Height / length).ToString());

            for (int x = 0; x < Terrain_Grid_Id.ColumnCount; x++)
            {
                Terrain_Grid_Id.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute));
                Terrain_Grid_Id.ColumnStyles[x].Width = cellWidth * 0.9F;
            }

            for (int y = 0; y < Terrain_Grid_Id.RowCount; y++)
            {
                Terrain_Grid_Id.RowStyles.Add(new RowStyle(SizeType.Absolute));
                Terrain_Grid_Id.RowStyles[y].Height = cellHeight * 0.9F;
            }

            for (int x = 0; x < Terrain_Grid_Id.RowCount; x++)
            {
                for (int y = 0; y < Terrain_Grid_Id.ColumnCount; y++)
                {
                    NumericUpDown label = new NumericUpDown();
                    label.Minimum = minHeight;
                    label.Maximum = maxHeight;
                    Terrain_Grid_Id.Controls.Add(label, y, x);
                }
            }

            Set_Height_Btn.Location = new Point(this.Width / 2 - Set_Height_Btn.Width / 2, Terrain_Grid_Id.Height + 10);
        }
Exemplo n.º 2
0
        private void Add_Terrain_Click(object sender, EventArgs e)
        {
            AddTerrain addTerrain = new AddTerrain(connector);

            addTerrain.Show();
        }