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; }
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); } }