public void OnBlockUpdated(CharacterBlock block) { if (finished) { return; } if (IsFilled()) { finished = TryConfirm(); if (finished) { onFinish.Invoke(this); } } else if (this == MainWindow.selectedWord) { int currentIndex = Array.FindIndex(blocks, p => p == block) + 1; if (blocks.Length > currentIndex) { blocks[currentIndex].Focus(); } } }
// This will only generate the block if not already set. public CharacterBlock GenerateBlock(int position) { var block = blocks[position]; if (block == null) { block = new CharacterBlock(correctWord[position]); blocks[position] = block; } return(block); }
internal void BackspaceBefore(CharacterBlock characterBlock) { if (finished) { return; } int currentIndex = Array.FindIndex(blocks, p => p == characterBlock) - 1; if (currentIndex >= 0) { blocks[currentIndex].Backspace(); } }
public void SetSharedBlock(CharacterBlock block, int position) { switch (direction) { case Direction.Horizontal: block.SetHorizontalWord(this); break; case Direction.Vertical: block.SetVerticalWord(this); break; default: throw new Exception("Unhandled case for enum WordDirection."); } blocks.SetValue(block, position); }