private CellDetail GetCellDetail(int id)
        {
            CellDetail ret = null;

            var dev = GetDeviceByCellNumber(id);

            if (dev != null)
            {
                ret = new CellDetail
                {
                    Name       = $"Ячейка {id}",
                    StatusText = GetRepairStatus(dev),
                    Model      = dev.Name,
                    Serial     = dev.Serial
                };

                if (dev.LastCharge != null)
                {
                    ret.Charge = $"{dev.LastCharge}%";
                }

                if (dev.LastOperation == DeviceOperation.Surrender)
                {
                    ret.Place = "в ячейке";
                }
                else
                {
                    if (dev.LastOperationUserId == null)
                    {
                        ret.Place = "-";
                    }
                    else
                    {
                        var user = _userRepository.GetUserById(dev.LastOperationUserId.Value);
                        ret.Place = UserRepository.GetShortFio(user?.Name);
                    }
                }
            }

            return(ret);
        }
        public void StateAdminCellDetail(CellDetail det)
        {
            SetState(AppState.AdminCellDetail);

            //var adminListPage = new AdminPage(this);
            Dispatcher.Invoke(() =>
            {
                _adminPage.CellName.Text   = det.Name;
                _adminPage.CellModel.Text  = det.Model;
                _adminPage.CellSerial.Text = det.Serial;
                _adminPage.CellPlace.Text  = det.Place;
                _adminPage.CellCharge.Text = det.Charge;
                _adminPage.CellStatus.Text = det.StatusText;

                _adminPage.CellWindow.Visibility           = Visibility.Visible;
                _adminPage.CellOpenReasonWindow.Visibility = Visibility.Hidden;
                _adminPage.ClearDbConfirmWindow.Visibility = Visibility.Hidden;
                _adminPage.UncloseableMsgBox.Visibility    = Visibility.Hidden;
                _adminPage.AdminListCanvasBlur.Radius      = 20;

                MainFrame.NavigationService.Navigate(_adminPage);
            });
        }
Exemple #3
0
    public static List <Vector2> SearchPath(Vector3 src, Vector3 dest)
    {
        if (!IsValid(src.x, src.y) || !IsValid(dest.x, dest.y))
        {
            return(null);
        }

        if (IsDestination(src.x, src.y, dest))
        {
            return(null);
        }

        // Create a closed list and initialise it to false which means
        // that no cell has been included yet
        // This closed list is implemented as a boolean 2D array
        Dictionary <string, Vector2> closedList = new Dictionary <string, Vector2>();

        // Declare a 2D array of structure to hold the details
        //of that cell
        Dictionary <string, CellDetail> cellDetails = new Dictionary <string, CellDetail>();

        float          i, j;
        float          nextI, nextJ;
        string         currentKey;
        List <Vector2> path;

        // Initialising the parameters of the starting node
        i = src.x;
        j = src.y;
        CellDetail srcCell = new CellDetail(i, j, 0.0, 0.0, 0.0);

        cellDetails.Add(GetListKey(i, j), srcCell);

        /*
         * Create an open list having information as-
         * <f, <i, j>>
         * where f = g + h,
         * and i, j are the row and column index of that cell
         * Note that 0 <= i <= ROW-1 & 0 <= j <= COL-1
         * This open list is implenented as a set of pair of pair.*/
        List <VectorP> openList = new List <VectorP>();

        // Put the starting cell on the open list and set its
        // 'f' as 0
        openList.Add(new VectorP(0.0, new Vector2(i, j)));

        while (openList.Count != 0)
        {
            VectorP p = openList[0];

            // Remove this vertex from the open list
            openList.RemoveAt(0);

            // Add this vertex to the closed list
            i          = p.position.x;
            j          = p.position.y;
            currentKey = GetListKey(i, j);
            if (!closedList.ContainsKey(currentKey))
            {
                closedList.Add(currentKey, p.position);
            }
            CellDetail     cellDetail = cellDetails[currentKey];
            List <Vector2> successors = IdentifySuccessors(cellDetail.parentI, cellDetail.parentJ, i, j, src, dest);
            foreach (var successor in successors)
            {
                nextI = successor.x;
                nextJ = successor.y;
                path  = ProcessSuccessor(i,
                                         j,
                                         nextI,
                                         nextJ,
                                         currentKey,
                                         dest,
                                         GRID_SIZE,
                                         openList,
                                         closedList,
                                         cellDetails);
                if (path != null)
                {
                    // path.Reverse();
                    return(path);
                }
            }
        }
        // When the destination cell is not found and the open
        // list is empty, then we conclude that we failed to
        // reach the destiantion cell. This may happen when the
        // there is no way to destination cell (due to blockages)
        return(null);
    }