private void button1_KeyDown(object sender, KeyEventArgs e) { string s = WordLabel.Text; char[] charArray = s.ToCharArray(); foreach (var letter in charArray) { if (e.KeyCode.ToString().ToUpper() == charArray[start].ToString()) { WordLabel.Select(0, end); WordLabel.SelectionBackColor = Color.Blue; if (start < charArray.Length - 1) { start++; // duplicate letters end++; break; } else { score++; Points.Text = score.ToString(); playGame(); } } } }
public string GetChassisNumRawValueByLabel(WordLabel label) { string value = string.Empty; var matchedLabel = wordMatcher.GetMatchedLabel(label.Text); if (matchedLabel == null) { //TO DO add log info return(value); } var words = chassisNumFinder.FindWords(matchedLabel, label.Type); if (words.Count == 0) { //TO DO add log info } else { value = ConcatinateWordsText(words); } return(value); }
/* * Animate the next path. NOTE: This method should not be run in a synchronous event handler; it is * meant to be called within a concurrent thread. */ private void VisualizePath() { // If there are no more paths to display if (NextPathIdx == AllPaths.Count) { PopupDialog popup = new PopupDialog( "No more words!", "You have entered all the words we've found on the grid.", this.Location, false); popup.ShowDialog(); return; } WordamentPath nextPath = AllPaths[NextPathIdx++]; WordLabel.Invoke(new EventHandler(delegate { WordLabel.Text = nextPath.Word; })); ScoreLabel.Invoke(new EventHandler(delegate { ScoreLabel.Text = nextPath.TotalScore.ToString(); })); CounterLabel.Invoke(new EventHandler(delegate { CounterLabel.Text = $"{NextPathIdx}/{AllPaths.Count}"; })); if (nextPath.Locations.Count == 1) { // If the path is one tile long, just put a stop image on it GridCell startingPt = nextPath.Locations[0]; PictureBox pic = TilePics[startingPt]; pic.Invoke(new EventHandler(delegate { pic.Image = TileImageTable.GetImage(ImageType.Stop); })); } else { // Select the starting tile image GridCell startingPt = nextPath.Locations[0]; PictureBox startPic = TilePics[startingPt]; startPic.Invoke(new EventHandler(delegate { startPic.Image = GetStartImage(startingPt, nextPath.Locations[1]); })); Thread.Sleep(ANIMATION_DELAY_MS); // Select each of the inner tile images for (int i = 1; i < nextPath.Locations.Count - 1; i++) { GridCell currentPt = nextPath.Locations[i]; PictureBox pic = TilePics[currentPt]; pic.Invoke(new EventHandler(delegate { pic.Image = GetPathImage(currentPt, nextPath.Locations[i + 1]); })); Thread.Sleep(ANIMATION_DELAY_MS); } // Put a stop image on the final tile GridCell lastPt = nextPath.Locations[nextPath.Locations.Count - 1]; PictureBox lastPic = TilePics[lastPt]; lastPic.Invoke(new EventHandler(delegate { lastPic.Image = TileImageTable.GetImage(ImageType.Stop); })); } }