public bool IsChoosen(int x, int y) { for (int i = 0; i < _rows.Length; i++) { for (int j = 1; j < _rows[i].GetSize() - 1; j++) { MatrixElement currentElem = _rows[i].GetElement(j); if (currentElem.IsChoosen(x, y)) { if (!currentElem.IsSelected()) { _from = i; _to = j; _chosenElem = currentElem; } else { _chosenElem = null; } return(true); } } } return(false); }
public Table(Point position, ICityStorage graph) { _graph = graph; _startPos = position; _size = _graph.Count; _rows = new Row[_size]; _colIs = new MatrixElement[_size]; _width = 70; _height = 35; _chosenElem = null; CalcPositions(); }
public void CalcPositions() { Point currentRowStart = new Point(_startPos.X, _startPos.Y + _height); Point currentColStart = new Point(_startPos.X + _width, _startPos.Y); for (int i = 0; i < _size; i++) { _colIs[i] = new MatrixElement(currentColStart, _width, _height); _colIs[i].SetNode(_graph[i].Id); currentColStart.X += _width; _rows[i] = new Row(currentRowStart, _width, _height, _graph, i); currentRowStart.Y += _height; } }
public void CalcPositions() { int sum = 0; Point currentStart = new Point(_startPos.X, _startPos.Y); _elements[0] = new MatrixElement(currentStart, _width, _height); _elements[0].SetNode(_id); for (int i = 0; i < _size - 2; i++) { currentStart.X += _width; ICity currentCity = _Graph[i]; _elements[i + 1] = new MatrixElement(currentStart, _width, _height, currentCity.Id); int currentData = _Graph[_index].GetDistTo(currentCity.Id); _elements[i + 1].SetNode(currentData); sum += currentData; } currentStart.X += _width; _elements[_size - 1] = new MatrixElement(currentStart, _width, _height); _elements[_size - 1].SetNode(sum); }