// Handle a key being pressed. private void HandleMainformKeyUp(object sender, KeyEventArgs e) { // If we have stuff selected... if (PrimaryList.SelectedIndex != -1) { if (e.KeyCode == Keys.Delete) { Confirmation con = new Confirmation( ActiveForm.DesktopLocation, "Are you sure you want to delete this task?", DeleteSelected); con.ShowDialog(); } } }
private void AutoTimeButton_Click(object sender, EventArgs e) { // End timer if (timerActive_) { // Account for user somehow breaking everything. if (PrimaryList.SelectedIndex == -1) { MessageBox.Show( "I'm super impressed, email me at [email protected] if you can reproduce this."); return; } // End timer timerActive_ = false; // Mark time, and create string showing time recorded. end_ = DateTime.Now; string time = (end_ - start_).ToString(); string toDisplay = time.Substring(0, time.IndexOf(".")); toDisplay = "Use this recorded time " + toDisplay + "?\n" + "(" + PrimaryList.SelectedItem + ")"; // Create confirmation window Confirmation con = new Confirmation( ActiveForm.DesktopLocation, toDisplay, AutoTimeCompleteSelected, true); con.ShowDialog(); } // Start timer else { // If we have nothing selected, if (PrimaryList.SelectedIndex == -1) { //Alert a = new Alert(ActiveForm.Location, "DONT"); //a.ShowDialog(); MessageBox.Show("Nothing selected!"); return; } start_ = DateTime.Now; timerActive_ = true; } }