예제 #1
0
 public void setStartPoint(int X, int Y)
 {
     if (start != null)
     {
         start.Text = "";
     }
     if (X > mapButtonsList.GetLength(0) || Y > mapButtonsList.GetLength(1))
     {
         return;
     }
     start      = getMapButtonsList()[X, Y];
     start.Text = CHARACTER_MOBILE;
 }
예제 #2
0
        public void registerMatrix(object sender, MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                if (drawingInProgress)
                {
                    return;
                }
                MapButton but = (MapButton)sender;

                var c = but.BackColor.ToKnownColor();
                switch (c)
                {
                case KnownColor.LightGreen:
                    but.BackColor = Color.DarkOrange;
                    break;

                case KnownColor.DarkOrange:
                    but.BackColor = Color.Blue;
                    break;

                case KnownColor.Blue:
                    but.BackColor = Color.Green;
                    break;

                case KnownColor.Green:
                    but.BackColor = Color.Gray;
                    break;

                case KnownColor.Gray:
                    but.BackColor = Color.LightGreen;
                    break;
                }

                char butc = but.colorToString();
                mapUserInterface.setMatrixXY(but.getPosY(), but.getPosX(), butc);
                mapUserInterface.clearTiles();
            }
            else if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                if (drawingInProgress)
                {
                    drawingInProgress = false;
                }

                MapButton but = (MapButton)sender;
                mapUserInterface.setEndPoint(but.getPosY(), but.getPosX());
                startPathFind();
            }
        }
예제 #3
0
        private void startPathFind()
        {
            MapButton start = mapUserInterface.getStartPoint();
            MapButton end   = mapUserInterface.getEndPoint();
            Map       myMap = new Map(mapUserInterface.getMatrix(),
                                      start.getPosY(), start.getPosX(),
                                      end.getPosY(), end.getPosX());
            Executor    exec   = new Executor();
            RadioButton button = algorithmChoice.Controls.OfType <RadioButton>().FirstOrDefault(n => n.Checked);

            mapUserInterface.clearTiles();
            exec.RunAlgorithm(button.Text, myMap);
            result = exec.getResult();
            DrawPath(myMap);
        }
예제 #4
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;
        }
예제 #5
0
 public void pushTile(MapButton tile)
 {
     start.Text = "";
     tile.Text  = CHARACTER_MOBILE;
     start      = tile;
 }