//получение пути
        private bool GetPath( )
        {
            int  ListCap = Math.Abs(start.xIndex - finish.xIndex) + Math.Abs(start.yIndex - finish.yIndex);
            Cell p       = new Cell(start.xIndex, start.yIndex);
            Cell pTemp   = p;

            map[p.xIndex, p.yIndex].cell   = p;
            map[p.xIndex, p.yIndex].gValue = 0;

            if (algorithm == AlgType.Dijkstra)
            {
                map[p.xIndex, p.yIndex].fValue = 0;
            }
            else
            {
                map[p.xIndex, p.yIndex].fValue = Heruistic(start, finish);
            }
            map[p.xIndex, p.yIndex].parent = nullPoint;

            addToOpenList(map[p.xIndex, p.yIndex]);
            while (OpenList.Count != 0)
            {
                //Извлекаем из открытого списка точку с наименьшей общей стоимость прохода до финиша:
                p = popMinFromOpen(OpenList);
                if (PopBestPointFromOpenList != null)
                {
                    PopBestPointFromOpenList(this, new ListEventArgs(p));
                }
                // Если извлечённая точка - финишная, конструируем путь:
                if (p == finish)
                {
                    //Конструируем путь:
                    path = new List <Cell>(ListCap);
                    path.Add(finish);
                    Cell s = map[p.xIndex, p.yIndex].parent;
                    while (s != start)
                    {
                        path.Add(s);
                        s = map[s.xIndex, s.yIndex].parent;
                    }
                    path.Add(start);
                    for (int i = 0; i < path.Count - 1; i++)
                    {
                        if (PathPoint != null)
                        {
                            PathPoint(this, new PointEventArgs(path[i], path[i + 1]));
                        }
                    }
                    path.Reverse();

                    if (SearchFinished != null)
                    {
                        SearchFinished(this, new SearchHandlerArgs(path, "Path finded!", true));
                    }

                    return(true);
                }
                // Исследуем соседей:
                Cell[] succesors = new Cell[8];

                getSuccesors(p, map, out succesors);
                for (int i = 0; i < 8; i++)
                {
                    byte[] diagCoast = { 10, 14 };
                    int    x         = succesors[i].xIndex;
                    int    y         = succesors[i].yIndex;
                    // Если препятствие стена - пропускаем точку:
                    if (map[x, y].StepCoast == -1)
                    {
                        continue;
                    }

                    switch (algorithm)
                    {
                    case AlgType.BestFirst:
                    {
                        if (isPointInCloseList(succesors[i], OpenList) || isPointInOpenList(succesors[i], CloseList))
                        {
                            continue;
                        }
                        map[x, y].fValue = Heruistic(succesors[i], finish);
                        break;
                    }

                    case AlgType.Dijkstra:
                    {
                        //Считаем диагональный шаг дороже ортогонального в 1.4:
                        int newG = map[p.xIndex, p.yIndex].fValue + (diagCoast[i % 2]) * map[x, y].StepCoast;
                        if (((isPointInCloseList(succesors[i], OpenList)) || (isPointInOpenList(succesors[i], CloseList))) && (map[x, y].fValue <= newG))
                        {
                            continue;
                        }
                        map[x, y].fValue = newG;
                        break;
                    }

                    case AlgType.AStar:
                    {
                        int newG = map[p.xIndex, p.yIndex].gValue + (diagCoast[i % 2]) * map[x, y].StepCoast;
                        if (((isPointInCloseList(succesors[i], OpenList)) || (isPointInOpenList(succesors[i], CloseList))) &&
                            (map[x, y].gValue <= newG))
                        {
                            continue;
                        }
                        map[x, y].gValue = newG;
                        map[x, y].fValue = newG + Heruistic(succesors[i], finish);
                        break;
                    }
                    }

                    map[x, y].parent = p;

                    if (isPointInCloseList(succesors[i], CloseList))
                    {
                        removeFromCloseList(succesors[i]);
                    }

                    if (!isPointInOpenList(succesors[i], OpenList))
                    {
                        map[x, y].cell = succesors[i];
                        if (PointCheked != null)
                        {
                            PointCheked(this, new PointEventArgs(p, succesors[i]));
                        }
                        addToOpenList(map[x, y]);
                    }
                }
                map[p.xIndex, p.yIndex].cell = p;
                addToCloseList(map[p.xIndex, p.yIndex]);
                pTemp = p;
            }
            path = new List <Cell>()
            {
                nullPoint
            };
            if (SearchFinished != null)
            {
                SearchFinished(this, new SearchHandlerArgs(path, "Where is no way finded!", false));
            }
            return(false);
        }
 public PointEventArgs(Cell parent, Cell succesor) : base(parent)
 {
     this.succesor = succesor;
 }
 public ListEventArgs(Cell parent)
 {
     this.parent = parent;
 }