private void GameSurface_MouseUp(object sender, MouseEventArgs e) { int x = SnapToClosest(e.X); int y = SnapToClosest(e.Y); if (_isDragOperation) { // calculate the new offset based on the drag // the offset is calculated in gridSize increments. int beforeX = SnapToClosest(_mouseDownLocation.X); int beforeY = SnapToClosest(_mouseDownLocation.Y); _game.TranslateAllMoves(x - beforeX, y - beforeY); Refresh(); } else { // put a visual node Debug.WriteLine($"Trying to add new node at offsetX:{x}, offsetY:{y}"); if (!_game.GameEnded) { var move = _game.AddMove(x, y, CurrentPlayer); if (!PlaceMove(move)) { // if we are playing against AI... suggest a move. if (rbAI.Checked) { PlaceAIMove(); } } } } _isDragOperation = false; }