private void AddTaskForm_KeyDown(object sender, KeyEventArgs e) { var button = new Button(); if (e.KeyCode == Keys.Enter) { button.PerformClick(); } }
private void listBox2_SelectedIndexChanged(object sender, EventArgs e) { int selectedIndex = TreeOfStates.SelectedIndex; if (!flagSavedState) { Button saveButton = (Button)PropertiesOfElements.Controls.Find("saveButton", false).FirstOrDefault(); if (saveButton != null) { saveButton.PerformClick(); } flagSavedState = true; TreeOfStates.SelectedIndex = selectedIndex; } else { // this method not effective. need rewrite this code AState selectedState; char type = TreeOfStates.SelectedItem.ToString()[1]; PropertiesOfElements.Controls.Clear(); // find selected state uint index = indexTreeOfStateToIDOfState[TreeOfStates.SelectedIndex]; foreach (thread th in gameContext.Threads) { foreach (KeyValuePair <uint?, IState> st in th.MIDToIState) { if (index == st.Value.getID()) { selectedState = (AState)st.Value; // draw interface switch (type) { case 'D': drawObj = new drawDialogue(gameContext, PropertiesOfElements); break; case 'W': drawObj = new drawWait(gameContext, PropertiesOfElements); break; case 'E': break; case 'C': drawObj = new drawChoice(gameContext, PropertiesOfElements); break; case 'I': drawObj = new drawImage(gameContext, PropertiesOfElements); break; case 'F': drawObj = new drawFullScreen(gameContext, PropertiesOfElements); break; } drawObj.drawInterface(selectedState); break; } } } flagSavedState = false; } }