Пример #1
0
        protected virtual Point GetCoordinates(int index, Point p)
        {
            int   size   = Enviroment.GetSize();
            Point result = Point.Empty;

            if (index == 1)
            {
                result = new Point(p.X - 1, p.Y - 1);
            }
            else if (index == 2)
            {
                result = new Point(p.X, p.Y - 1);
            }
            else if (index == 3)
            {
                result = new Point(p.X + 1, p.Y - 1);
            }
            else if (index == 4)
            {
                result = new Point(p.X + 1, p.Y);
            }
            else if (index == 5)
            {
                result = new Point(p.X + 1, p.Y + 1);
            }
            else if (index == 6)
            {
                result = new Point(p.X, p.Y + 1);
            }
            else if (index == 7)
            {
                result = new Point(p.X - 1, p.Y + 1);
            }
            else
            {
                result = new Point(p.X - 1, p.Y);
            }

            if (result != Point.Empty)
            {
                if (result.X < 0 || result.Y < 0 || result.X >= size || result.Y >= size)
                {
                    result = Point.Empty;
                }
            }

            return(result);
        }