コード例 #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>
        /// Confirms from that user that they definitely want to reset this puzzle, and if they do
        /// then proceeds to reset.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnReset_Click(object sender, EventArgs e)
        {
            var result = MessageBox.Show("Do you really want to reset the puzzle?", "Confirm Reset", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                TileBoxes.ForEach(t => t.Text = string.Empty);
            }
        }
コード例 #3
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);
        }