Пример #1
0
        /// <summary>
        /// Updates the GUI textbox for a provided tile in the puzzle.
        /// </summary>
        /// <param name="tile"></param>
        private void UpdateTextBoxForTile(Tile tile)
        {
            var textBoxName = TextBoxNameFromTile(tile);
            var textBox     = TileBoxes.FirstOrDefault(t => t.Name == textBoxName);

            textBox.Text = tile.Value.ToString();
        }
Пример #2
0
        /// <summary>
        /// Event handler for when a tile in the puzzle has been updated.
        /// We update the state in the GUI when this happens.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnTileUpdated(object sender, TileUpdatedEventArgs e)
        {
            var textBoxName = TextBoxNameFromTile(e.Tile);
            var textBox     = TileBoxes.FirstOrDefault(t => t.Name == textBoxName);

            // Change the color of the text box briefly to show it has just been updated.
            Task.Run(async() =>
            {
                textBox.BackColor = Color.LightGreen;
                await Task.Delay(100);
                textBox.BackColor = Color.White;
            });

            UpdateTextBoxForTile(e.Tile);
        }