public FormError(GameErrorInfo error) { InitializeComponent(); this.error = error; lbLetter.Text = error.Letter; lbWord.Text = error.MaskedWord; richTextBox1.Rtf = GameDictionary.GetRuleDescriptioRtf(error.Rule); }
public static void ShowError(IWin32Window owner, GameErrorInfo error) { using (FormError formError = new FormError(error)) { if (owner is Form) { formError.Icon = ((Form)owner).Icon; } formError.ShowDialog(owner); } }
GameWord CheckLetterStopCell(GameCellPos letterPos, GameCell cell, out GameErrorInfo gameError) { GameWord word = cell.GameObject as GameWord; gameError = null; if (word != null) { GameCellPos wordPos; if (mainTable.TryGetObjectPosition(word, out wordPos) && ((wordPos.Column == letterPos.Column) || (wordPos.Column + word.Width > letterPos.Column))) { int wordRelColumn = letterPos.Column - wordPos.Column; if (wordRelColumn >= 0 && wordRelColumn < word.Width){ if (string.Equals(word.StringMap[0, wordRelColumn], currentLetter.StringMap[0, 0], StringComparison.InvariantCultureIgnoreCase)) { return word; } else { gameError = new GameErrorInfo(word.RulesMap[0, wordRelColumn], currentLetter.StringMap[0, 0], word.Word); } } } } return null; }
GameWord CheckLetterStop(out GameErrorInfo gameErrorInfo) { GameCellPos letterPos; gameErrorInfo = null; if (currentLetter == null) return null; if (!mainTable.TryGetObjectPosition(currentLetter, out letterPos)) return null; if (letterPos.Column - 1 >= 0) { GameCell cell = mainTable[letterPos.Row, letterPos.Column - 1]; GameErrorInfo currentGameError; GameWord result = CheckLetterStopCell(letterPos, cell, out currentGameError); if (result != null) { gameErrorInfo = null; return result; } gameErrorInfo = currentGameError; } if (letterPos.Column + 1 < mainTable.Width) { GameCell cell = mainTable[letterPos.Row, letterPos.Column + 1]; GameErrorInfo currentGameError; GameWord result = CheckLetterStopCell(letterPos, cell, out currentGameError); if (result != null) { gameErrorInfo = null; return result; } gameErrorInfo = currentGameError; } return null; }