private void leaveSetupOrStartRecordingButton_Click(object sender, EventArgs e) { if (recordsFile == "none") { DialogResult dialogResult = saveRecordFileDialog.ShowDialog(); if (dialogResult == DialogResult.OK) { recordsFile = saveRecordFileDialog.FileName; recordsFileLabel.Text = ("Recording to \"" + recordsFile + "\""); leaveSetupOrStartRecordingButton.Text = (" In setup mode.\nClick to enter timing/counting mode."); } } else if (inSetupMode) { intervalSecondsInput.Enabled = false; experimenterNameTextBox.Enabled = false; leaveSetupOrStartRecordingButton.Text = ("In timing/counting mode.\n" + "Click here or press " + startRecordingKey.ToString() + " to start the timer."); loadSettingsButton.Enabled = false; clearSettingsButton.Enabled = false; if (anyStartKeyRadioButton.Checked) { leaveSetupOrStartRecordingButton.Text = ("This button has been disabled.\n" + "Press any activity key to start timing/counting."); leaveSetupOrStartRecordingButton.Enabled = false; } specificStartKeyRadioButton.Enabled = false; anyStartKeyRadioButton.Enabled = false; modeManager = new RecordingManager(modeManager, saveSettingsButton, recordsFile, totalTimerLabel, durationProgressBar, startRecordingKey, activitiesTimer); inSetupMode = false; setupManager.SaveSettingsToFile(SetupManager.lastSettingsFilename); } else { modeManager.RespondToKeyDown(startRecordingKey); } }
public RecordingManager(ModeManager previousManager, Button saveSettingsButton, string recordsFile, Label totalTimerLabel, ProgressBar durationProgressBar, Keys startRecordingKey, System.Diagnostics.Stopwatch activitiesTimer) : base(previousManager) { this.activitiesTimer = activitiesTimer; this.saveSettingsButton = saveSettingsButton; numberOfIntervals = Convert.ToInt32(numberOfIntervalsInput.Value); intervalLength = ModeManager.IntervalDuration(intervalSecondsInput); allowedTotalDuration = (numberOfIntervals * intervalLength); numberOfIntervalsInput.Enabled = false; intervalSecondsInput.Enabled = false; recordingActivities = false; readyToStartRecording = true; this.totalTimerLabel = totalTimerLabel; this.durationProgressBar = durationProgressBar; this.recordsFile = recordsFile; animalIndex = 1; using (StreamWriter streamWriter = new StreamWriter(recordsFile, false)) { // [index of recording] [date timestamp] [animal name (auto/optional)] // ... [activity info]... [additional comments] // More testing of Git through Visual Studio 2015! string lineToWrite = ("\"Index of recording\"" + ";\"Date timestamp\"" + ";\"Experimenter name\"" + ";\"Animal name\""); foreach (ActivityRecorder activityRecorder in activityRecorders) { activityRecorder.LockActivityName(); if (activityRecorder.ActivationKey != Keys.None) { lineToWrite += (";" + activityRecorder.StringForHeader(numberOfIntervals)); } } lineToWrite += (";\"Additional comments\""); streamWriter.WriteLine(lineToWrite); } this.startRecordingKey = startRecordingKey; ResetRecords(); discardRecordButton.Enabled = true; }
public ModeManager(ModeManager copySource) { this.activityRecorders = copySource.activityRecorders; this.leaveSetupOrStartRecordingButton = copySource.leaveSetupOrStartRecordingButton; this.saveRecordButton = copySource.saveRecordButton; this.discardRecordButton = copySource.discardRecordButton; // this.pauseButton = copySource.pauseButton; this.numberOfIntervalsInput = copySource.numberOfIntervalsInput; this.intervalSecondsInput = copySource.intervalSecondsInput; this.experimenterName = copySource.experimenterName; this.animalName = copySource.animalName; this.additionalComments = copySource.additionalComments; this.specificStartKeyRadioButton = copySource.specificStartKeyRadioButton; this.anyStartKeyRadioButton = copySource.anyStartKeyRadioButton; }
private void intervalSecondsInput_TextChanged(object sender, EventArgs e) { intervalDuration = ModeManager.IntervalDuration(intervalSecondsInput); totalDurationLabel.Text = (numberOfIntervals * intervalDuration).ToString(); }
public MainForm() { // TODO: // 1) Fix focus problem - DONE! // 2) Fix cancel on choose file - DONE! // 3) Add time intervals - DONE! // 4) Allow installation folder to be chosen // 1) & 2) can probably be solved together with the // "in setup mode / in timing mode" button initially being a // "select file" button. InitializeComponent(); numberOfIntervals = Convert.ToInt32(numberOfIntervalsInput.Value); intervalDuration = ModeManager.IntervalDuration(intervalSecondsInput); activitiesTimer = new System.Diagnostics.Stopwatch(); isPaused = false; // pauseButton.Enabled = false; // I don't have a better way of linking all the buttons, text boxes, & // labels to the recorders. activityRecorders = new List <ActivityRecorder>(); oneOnAtAnyTimeTimers = new List <OneOnAtAnyTimeTimer>(); OneOnAtAnyTimeTimer oneOnAtAnyTimeTimer = new OneOnAtAnyTimeTimer(leftButtonOne, leftDescriptionOne, leftCountOne, leftDurationOne, activitiesTimer, oneOnAtAnyTimeTimers); oneOnAtAnyTimeTimers.Add(oneOnAtAnyTimeTimer); activityRecorders.Add(oneOnAtAnyTimeTimer); oneOnAtAnyTimeTimer = new OneOnAtAnyTimeTimer(leftButtonTwo, leftDescriptionTwo, leftCountTwo, leftDurationTwo, activitiesTimer, oneOnAtAnyTimeTimers); oneOnAtAnyTimeTimers.Add(oneOnAtAnyTimeTimer); activityRecorders.Add(oneOnAtAnyTimeTimer); oneOnAtAnyTimeTimer = new OneOnAtAnyTimeTimer(leftButtonThree, leftDescriptionThree, leftCountThree, leftDurationThree, activitiesTimer, oneOnAtAnyTimeTimers); oneOnAtAnyTimeTimers.Add(oneOnAtAnyTimeTimer); activityRecorders.Add(oneOnAtAnyTimeTimer); oneOnAtAnyTimeTimer = new OneOnAtAnyTimeTimer(leftButtonFour, leftDescriptionFour, leftCountFour, leftDurationFour, activitiesTimer, oneOnAtAnyTimeTimers); oneOnAtAnyTimeTimers.Add(oneOnAtAnyTimeTimer); activityRecorders.Add(oneOnAtAnyTimeTimer); oneOnAtAnyTimeTimer = new OneOnAtAnyTimeTimer(leftButtonFive, leftDescriptionFive, leftCountFive, leftDurationFive, activitiesTimer, oneOnAtAnyTimeTimers); oneOnAtAnyTimeTimers.Add(oneOnAtAnyTimeTimer); activityRecorders.Add(oneOnAtAnyTimeTimer); oneOnAtAnyTimeTimer = new OneOnAtAnyTimeTimer(leftButtonSix, leftDescriptionSix, leftCountSix, leftDurationSix, activitiesTimer, oneOnAtAnyTimeTimers); oneOnAtAnyTimeTimers.Add(oneOnAtAnyTimeTimer); activityRecorders.Add(oneOnAtAnyTimeTimer); oneOnAtAnyTimeTimer = new OneOnAtAnyTimeTimer(leftButtonSeven, leftDescriptionSeven, leftCountSeven, leftDurationSeven, activitiesTimer, oneOnAtAnyTimeTimers); oneOnAtAnyTimeTimers.Add(oneOnAtAnyTimeTimer); activityRecorders.Add(oneOnAtAnyTimeTimer); oneOnAtAnyTimeTimer = new OneOnAtAnyTimeTimer(leftButtonEight, leftDescriptionEight, leftCountEight, leftDurationEight, activitiesTimer, oneOnAtAnyTimeTimers); oneOnAtAnyTimeTimers.Add(oneOnAtAnyTimeTimer); activityRecorders.Add(oneOnAtAnyTimeTimer); onIfButtonPressedTimers = new List <OnIfButtonPressedTimer>(); OnIfButtonPressedTimer onIfButtonPressedTimer = new OnIfButtonPressedTimer(rightButtonOne, rightDescriptionOne, rightCountOne, rightDurationOne, activitiesTimer); onIfButtonPressedTimers.Add(onIfButtonPressedTimer); activityRecorders.Add(onIfButtonPressedTimer); onIfButtonPressedTimer = new OnIfButtonPressedTimer(rightButtonTwo, rightDescriptionTwo, rightCountTwo, rightDurationTwo, activitiesTimer); onIfButtonPressedTimers.Add(onIfButtonPressedTimer); activityRecorders.Add(onIfButtonPressedTimer); onIfButtonPressedTimer = new OnIfButtonPressedTimer(rightButtonThree, rightDescriptionThree, rightCountThree, rightDurationThree, activitiesTimer); onIfButtonPressedTimers.Add(onIfButtonPressedTimer); activityRecorders.Add(onIfButtonPressedTimer); onIfButtonPressedTimer = new OnIfButtonPressedTimer(rightButtonFour, rightDescriptionFour, rightCountFour, rightDurationFour, activitiesTimer); onIfButtonPressedTimers.Add(onIfButtonPressedTimer); activityRecorders.Add(onIfButtonPressedTimer); onIfButtonPressedTimer = new OnIfButtonPressedTimer(rightButtonFive, rightDescriptionFive, rightCountFive, rightDurationFive, activitiesTimer); onIfButtonPressedTimers.Add(onIfButtonPressedTimer); activityRecorders.Add(onIfButtonPressedTimer); onIfButtonPressedTimer = new OnIfButtonPressedTimer(rightButtonSix, rightDescriptionSix, rightCountSix, rightDurationSix, activitiesTimer); onIfButtonPressedTimers.Add(onIfButtonPressedTimer); activityRecorders.Add(onIfButtonPressedTimer); onIfButtonPressedTimer = new OnIfButtonPressedTimer(rightButtonSeven, rightDescriptionSeven, rightCountSeven, rightDurationSeven, activitiesTimer); onIfButtonPressedTimers.Add(onIfButtonPressedTimer); activityRecorders.Add(onIfButtonPressedTimer); onIfButtonPressedTimer = new OnIfButtonPressedTimer(rightButtonEight, rightDescriptionEight, rightCountEight, rightDurationEight, activitiesTimer); onIfButtonPressedTimers.Add(onIfButtonPressedTimer); activityRecorders.Add(onIfButtonPressedTimer); // The event handler for a key press has to be initialized. KeyPreview = true; KeyDown += new KeyEventHandler(MainForm_KeyDown); KeyUp += new KeyEventHandler(MainForm_KeyUp); startRecordingKey = Keys.Space; specificStartKeyRadioButton.Text = ("Start recording only with " + startRecordingKey.ToString() + " (starts 1st activity in list too)"); recordsFileLabel.Text = ("No record file chosen!"); leaveSetupOrStartRecordingButton.Text = ("Click here to choose a file\nto record the data."); recordsFile = "none"; // The form begins in setup mode. inSetupMode = true; setupManager = new SetupManager(activityRecorders, leaveSetupOrStartRecordingButton, nextAnimalButton, discardAnimalButton, // pauseButton, numberOfIntervalsInput, intervalSecondsInput, experimenterNameTextBox, animalNameTextBox, additionalCommentsRichTextBox, specificStartKeyRadioButton, anyStartKeyRadioButton); modeManager = setupManager; if (System.IO.File.Exists(SetupManager.lastSettingsFilename)) { modeManager.LoadSettingsFromFile(SetupManager.lastSettingsFilename); } }