public void setTileState(Letter l) { this.tag = l; this.tile_chip.Content = this.tag.letter_alpha + " (" + this.tag.score_value + ")"; }
private Letter getScoreKey(String letter) { Letter tag = new Letter(); foreach(KeyValuePair<String, int> kvp in this.scoring_keys) { if(letter.Equals(kvp.Key)) { tag.letter_alpha = kvp.Key; tag.score_value = kvp.Value; return tag; } } return new Letter(); }
private BoardTile drawTile(Letter Tag) { BoardTile placer = new BoardTile(); placer.Margin = new Thickness(2, 0, 0, 0); placer.Height = 60; placer.Width = 60; placer.tag = Tag; placer.Background = new ImageBrush { ImageSource = new BitmapImage(new Uri("tile.jpg", UriKind.Relative))}; placer.Content = placer.ToString(); return placer; }
private int GetWordPoints(string word) { int wordPoints = 0; int multiplyFactor = 1; Letter letter = new Letter(); foreach (char lett in word) { wordPoints += letter.GetPoints(lett); } int delay = 1500; /* If the first word is put on a bonus square, this bonus * must be 2w */ foreach (Button button in wordPutOnBoard) { ToolTip toolTipLetter = new ToolTip(); if (button.BackColor == Color.White) { wordPoints -= letter.GetPoints(button.Text[0]); toolTipLetter.Show("0", button, 1, 1, delay); } else { toolTipLetter.Show(letter.GetPoints(button.Text[0]) + "", button, 1, 1, delay); } if (squaresBonuses.ContainsKey(button.Location)) { multiplyFactor *= 2; } delay += 100; } if (multiplyFactor > 1) { ToolTip toolTipDoubleWord = new ToolTip(); toolTipDoubleWord.OwnerDraw = true; // Anonymous event handler using lambda expression toolTipDoubleWord.Draw += (sender, e) => { toolTipDoubleWord.BackColor = Color.LightCyan; e.DrawBackground(); e.DrawText(); }; if (wordPutOnBoard[0].Location.Y == wordPutOnBoard[1].Location.Y) { toolTipDoubleWord.Show(wordPoints + " x " + multiplyFactor, wordPutOnBoard[wordPutOnBoard.Count / 2], 0, 30, 2500); } else { toolTipDoubleWord.Show(wordPoints + " x " + multiplyFactor, wordPutOnBoard[wordPutOnBoard.Count / 2], 30, 0, 2500); } } wordPoints *= multiplyFactor; ToolTip toolTipWordPoints = new ToolTip(); toolTipWordPoints.OwnerDraw = true; toolTipWordPoints.Draw += (sender, e) => { toolTipWordPoints.BackColor = Color.MediumSpringGreen; e.DrawBackground(); e.DrawText(); }; if (wordPutOnBoard[0].Location.Y == wordPutOnBoard[1].Location.Y) { toolTipWordPoints.Show("'" + word + "' : " + wordPoints + " points", wordPutOnBoard[wordPutOnBoard.Count - 1], 30, 0, 4000); } else { toolTipWordPoints.Show("'" + word + "' : " + wordPoints + " points", wordPutOnBoard[wordPutOnBoard.Count - 1], 0, 30, 4000); } return(wordPoints); }