/* * 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); })); } }
void ReleaseDesignerOutlets() { if (CounterLabel != null) { CounterLabel.Dispose(); CounterLabel = null; } if (DoStuffButton != null) { DoStuffButton.Dispose(); DoStuffButton = null; } }
public void HasName(string name) { ICounterLabel label = new CounterLabel(name); label.Name.Should().Be(name); }