/// <summary> /// Default constructor. Initialises all necessary components /// </summary> public MainWindow() { InitializeComponent(); _gameGrid = new LetterGrid(4, 4, this); ComBoxGridSize.SelectedIndex = 1; ComBoxGameType.SelectedIndex = 0; }
/// <summary> /// Synchronise this button with a LetterGrid and sets options on this button /// </summary> /// <param name="parentGrid">The grid which this button is being displayed on</param> /// <returns>A reference to this button for method chaining</returns> public LetterButton Sync(LetterGrid parentGrid) { _parentGrid = parentGrid; if (_parentGrid.Options.IsAnagram && !_isAddLetter) { this.ContextMenuStrip = _contextMenu; } return(this); }
/// <summary> /// Event handler for when the user selects a different item in the game type combo box /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void GameTypeComBox_SelectedIndexChanged(object sender, EventArgs e) { if (ComBoxGameType.SelectedIndex == _gameTypeIndex) { return; } switch (ComBoxGameType.SelectedIndex) { case 0: ComBoxGridSize.Enabled = true; ChkBoxConnectingLetters.Enabled = true; _gameTypeIndex = 0; TextBoxAnagramSetup.Enabled = false; BtnAnagramSetup.Enabled = false; ChkBoxMultipleWords.Enabled = false; break; case 1: ComBoxGridSize.Enabled = false; ChkBoxConnectingLetters.Enabled = false; _gameTypeIndex = 1; TextBoxAnagramSetup.Enabled = true; ChkBoxMultipleWords.Enabled = true; if (!String.IsNullOrWhiteSpace(TextBoxAnagramSetup.Text)) { BtnAnagramSetup.Enabled = true; } if (_anagramGrid == null) { String result = Interaction.InputBox("Enter the letters to be solved", "Enter the anagram", string.Empty); if (String.IsNullOrWhiteSpace(result)) { _anagramGrid = new LetterGrid(this); } else { result = result.Trim().ToLowerInvariant().Replace(" ", ""); _anagramGrid = new LetterGrid(result, this); } } break; } RefreshPanel(); }
/// <summary> /// Event handler for clicking on the anagram setup button /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AnagramSetupBtn_Click(object sender, EventArgs e) { _anagramGrid = new LetterGrid(TextBoxAnagramSetup.Text.Trim().ToLowerInvariant(), this); GridPanel.Controls.Clear(); GridPanel.Controls.AddRange(_anagramGrid.GetControls()); }