public void SetHintMode(HintMode newHintMode, SodukoPiece selectedPiece) { if (_hintMode == HintMode.Everything && newHintMode != HintMode.Everything) { ClearAllSuggestionText(); } if (selectedPiece != null && _hintMode == HintMode.Adjacent && newHintMode != HintMode.Adjacent) { ClearNeighborsSuggestionText(selectedPiece); } if (newHintMode == HintMode.Everything && _hintMode != HintMode.Everything) { _hintMode = newHintMode; SetSuggestions(0, 0); return; } else if (newHintMode == HintMode.Adjacent && _hintMode != HintMode.Adjacent) { _hintMode = newHintMode; if (selectedPiece != null) { SetSuggestions(selectedPiece); } return; } else if (newHintMode == HintMode.Off && selectedPiece != null) { selectedPiece.SetSuggestionTextToNothing(); } _hintMode = newHintMode; }
private void NumberSelectorTapped(object sender, TappedRoutedEventArgs e) { GC.Collect(); if (_selectedPiece == null) { return; } int senderValue = ((SodukoPiece)sender).NumberValue; if (senderValue == -1 || _puzzle.EnsureValidMove(_selectedPiece, senderValue, true)) { _puzzle.SetPiece(_selectedPiece.Row, _selectedPiece.Col, senderValue); _selectedPiece.RotateAnimation(); _selectedPiece.SetFocus(false); _selectedPiece.NumberValue = senderValue; _selectedPiece.SetSuggestionTextToNothing(); // Update the suggestions. _puzzle.SetSuggestions(_selectedPiece); if (_puzzle.CheckForWin()) { OnGameCompleted(this, new EventArgs()); } } GC.Collect(); }
public void SetSelfHint(bool selfHint, SodukoPiece selectedPiece) { if (selfHint != _showSelfHint) { // _showSelfHint has changed. if (!selfHint && _hintMode != HintMode.Everything) { selectedPiece.SetSuggestionTextToNothing(); } else if (selfHint && _hintMode != HintMode.Off) { SetSuggestions(selectedPiece); } _showSelfHint = selfHint; } }