/* * Method: startRecording() * Summary: Begins the playback of keystrokes * Parameter: sender - The control that the action is for, in this case the button * Parameter: e - Any arguments the function may use */ private void startRecording(object sender, EventArgs e) { BigMessageBox.Show("Recording has now begun. Press control and space to end the recording, or use the buttons in the application"); startStopRecBtn.BackgroundImage = Properties.Resources.stop; recButtonLabel.Text = "Press the red button again to stop the recording"; recButtonLabel2.Hide(); startStopRecBtn.Tag = "stopRecTag"; createRec = new CreateRecording(); // Reinitialise the createRec variable, restarting the clock and clearning the dictionary of recorded keys createRec.Start(); // Begin recording recCreatedLabel.Hide(); recStatusText.ForeColor = Color.Green; recStatusText.Text = "Recording active"; // Initialise the keyboard shortcut shortcut = new KeyboardShortcut(); shortcut.KeyPressed += new EventHandler<KeyPressedEventArgs>(shortcut_Pressed); // Display the status box containing the elapsed time and a stopbutton recStatus = new RecStatus(1); recStatus.stopButtonEvent += recStatus_StopCreate; recStatus.Show(); // Alter the button so that clicking no longer invokes the launchRecording method, but instead the stopRecording method startStopRecBtn.Click -= startRecording; startStopRecBtn.Click += stopRecording; }
/* * Method: stopRecording() * Summary: Stops the recording of keystrokes * Parameter: sender - The control that the action is for, in this case the button * Parameter: e - Any arguments the function may use */ private void stopRecording(object sender, EventArgs e) { startStopRecBtn.BackgroundImage = Properties.Resources.record; recButtonLabel.Text = "Begin recording"; recStatusText.ForeColor = Color.Red; recStatusText.Text = "Not recording"; startStopRecBtn.Tag = "startRecTag"; // Alter the button rso that clicking no longer invokes the stopRecording method, but instead the launchRecording method startStopRecBtn.Click += startRecording; startStopRecBtn.Click -= stopRecording; recJson = createRec.Stop(); // Stop recording recStatus.Dispose(); shortcut.Dispose(); shortcut = null; }