public void OnClick(Object o, MouseEventArgs mea) { Gridpoint _firstPoint = null; Gridpoint _secondPoint = null; Console.WriteLine("MouseClick Cords: " + mea.Location); if (firstClick) { _firstPoint = Gridpoints.Find(x => x.Collision(mea.Location)); if (_firstPoint != null) { Console.WriteLine("First PointClick!"); Console.WriteLine(_firstPoint.Cords); this.firstClick = false; this.firstPoint = _firstPoint; } } else { _secondPoint = Gridpoints.Find(x => x.Collision(mea.Location)); if (_secondPoint != null && _secondPoint != _firstPoint) { Console.WriteLine("Second PointClick!"); Console.WriteLine(_secondPoint.Cords); this.secondPoint = _secondPoint; builder.BuildRoad(this.firstPoint.Cords, this.secondPoint.Cords); this.ResetPoints(); } } }
private void ResetPoints() { this.firstPoint = null; this.secondPoint = null; this.firstClick = true; }