Exemplo n.º 1
0
        public MapUI(PathFinding mum, int l, int h)
        {
            mother = mum;
            height = h;
            length = l;
            if (h <= 0 || l <= 0)
            {
                return;
            }

            this.Margin    = new Padding(0, 0, 0, 0);
            this.Padding   = new Padding(0, 0, 0, 0);
            matrix         = new char[h, l];
            mapButtonsList = new MapButton[h, l];
            for (int i = 0; i < height; i++)
            {
                for (int j = 0; j < length; j++)
                {
                    MapButton button = new MapButton(i, j, this);
                    button.FlatStyle = FlatStyle.Flat;
                    button.FlatAppearance.BorderColor = Color.Black;
                    button.FlatAppearance.BorderSize  = 0;
                    this.Controls.Add(button);
                    matrix[i, j]         = ' ';
                    mapButtonsList[i, j] = button;
                }
            }
            this.Location = new System.Drawing.Point(10, 100);
            this.Name     = "flowLayoutPanel2";
            this.Size     = new System.Drawing.Size(l * 30, h * 30);
            this.TabIndex = 3;
            this.Visible  = false;
        }
Exemplo n.º 2
0
        public MapUI(PathFinding mom, int l, int h, string val_init)
        {
            mother = mom;
            height = h;
            length = l;
            if (h <= 0 || l <= 0)
            {
                return;
            }
            String[] mapRows = val_init.Split(new char[] { '\n' });
            int      nbRows  = mapRows.Length;
            int      nbCols  = mapRows[0].Length;

            this.Margin    = new Padding(0, 0, 0, 0);
            this.Padding   = new Padding(0, 0, 0, 0);
            matrix         = new char[h, l];
            mapButtonsList = new MapButton[h, l];
            for (int i = 0; i < height; i++)
            {
                for (int j = 0; j < length; j++)
                {
                    MapButton button = new MapButton(i, j, this);
                    button.FlatStyle = FlatStyle.Flat;
                    button.FlatAppearance.BorderColor = Color.Black;
                    button.FlatAppearance.BorderSize  = 0;
                    this.Controls.Add(button);
                    matrix[i, j]         = mapRows[i][j];
                    button.BackColor     = button.charToColor(mapRows[i][j]);
                    mapButtonsList[i, j] = button;
                }
            }
            this.Location = new System.Drawing.Point(10, 100);
            this.Name     = "flowLayoutPanel2";
            this.Size     = new System.Drawing.Size(l * 30, h * 30);
            this.TabIndex = 3;
            this.Visible  = false;
        }