Example #1
0
        public bool PutPositionIntoArray(IPosition_Connected_Edit p)
        {
            float x = p.GetX(), y = p.GetY();

            if (InBound(x, y))
            {
                mapAry[(int)x, (int)y].Add(p);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        private void panel1_MouseMove(object sender, MouseEventArgs e)
        {
            int x = e.X / blockSize, y = e.Y / blockSize;

            toolStripLabel1.Text = "(" + Convert.ToString(x) + "," + Convert.ToString(y) + ") (" + Convert.ToString(e.X) + "," + Convert.ToString(e.Y) + ")";
            if (x0 != x || y0 != y)
            {
                using (Graphics g = panel1.CreateGraphics())
                {
                    if (x0 >= 0 && y0 >= 0)
                    {
                        refreshBlock(x0, y0);
                        if (Math.Abs(x1 - x0) <= 1 && Math.Abs(y1 - y0) <= 1)
                        {
                            DrawSelectedNode();
                        }
                        IPosition_Connected_Edit p1 = map.GetStartPosition(), p2 = map.GetEndPosition();
                        if ((p1 != null && Math.Abs(p1.GetX() - x0) <= 1 && Math.Abs(p1.GetY() - y0) <= 1) || (p2 != null && Math.Abs(p2.GetX() - x0) <= 1 && Math.Abs(p2.GetY() - y0) <= 1))
                        {
                            DrawStartEndNode();
                        }
                        if (path != null)
                        {
                            foreach (IPosition_Connected p in path)
                            {
                                if (Math.Abs(p.GetX() - x0) <= 1 && Math.Abs(p.GetY() - y0) <= 1)
                                {
                                    DrawPathNode(p);
                                }
                            }
                        }
                    }
                    g.DrawRectangle(selectBoxPen, x * blockSize, y * blockSize, blockSize, blockSize);
                }
                x0 = x;
                y0 = y;
            }
        }