private void SaveButtonClick(object sender, EventArgs e) //Hitting the save button saves the session info to SessionInfo_{rat#} as well as a screen shot of the GUI { if (ratWasChosen) { Show(); saveButton.ForeColor = Color.DarkGray; saveButton.Enabled = false; //notesReformatted = notesBox.Text.Replace("," , ";"); notes_behaviourReformatted = notesBox_behaviour.Text.Replace(",", ";"); experimenterReformatted = experimenterBox.Text.Replace(",", ";"); CsvFiles.SessionCsv.Write( $"{sessionLabel.Text},{experimenterReformatted},{DateTime.Now},{run_time},{correctNum.Text},{initialNum.Text},{outboundNum.Text},{inboundNum.Text},{repeatNum.Text},{totalErrNum.Text},{totalNum.Text},{notes_behaviourReformatted}\n"); CsvFiles.Close(); if ( !Directory.Exists( $@"C:\Users\sahanasrivathsa\Documents\Barnes Lab\Wmaze\RatData\{ratName[RatSelection.SelectedIndex]}\ScreenShots")) { Directory.CreateDirectory( $@"C:\Users\sahanasrivathsa\Documents\Barnes Lab\Wmaze\RatData\{ratName[RatSelection.SelectedIndex]}\ScreenShots"); } var bmpScreenCapture = new Bitmap(Width, Height); DrawToBitmap(bmpScreenCapture, new Rectangle(0, 0, bmpScreenCapture.Width, bmpScreenCapture.Height)); bmpScreenCapture.Save( $@"C:\Users\sahanasrivathsa\Documents\Barnes Lab\Wmaze\RatData\{ratName[RatSelection.SelectedIndex]}\ScreenShots\GUIscreenshot_{ratName [RatSelection.SelectedIndex]}_Session{sessionNumber}.gif", ImageFormat.Gif); saved = true; } }
private void SaveButtonClick(object sender, EventArgs e) //Hitting the save button saves the session info to SessionInfo_{rat#} as well as a screen shot of the GUI { if (ratWasChosen) { Show(); saveButton.ForeColor = Color.DarkGray; saveButton.Enabled = false; notesReformatted = notesBox.Text.Replace(",", ";"); notes_behaviourReformatted = notesBox_behaviour.Text.Replace(",", ";"); experimenterReformatted = experimenterBox.Text.Replace(",", ";"); if (train) { CsvFiles.trainingCsv.Write($"{DateTime.Now},{experimenterReformatted},{display_time.Text},{correctNum.Text},{notesReformatted},{notes_behaviourReformatted}\n"); CsvFiles.trainingCsv.Close(); } else { CsvFiles.SessionCsv.Write( $"{sessionLabel.Text},{experimenterReformatted},{DateTime.Now},{run_time},{correctNum.Text},{initialNum.Text},{outboundNum.Text},{inboundNum.Text},{repeatNum.Text},{totalErrNum.Text},{totalNum.Text},{notesReformatted},{notes_behaviourReformatted}\n"); CsvFiles.Close(); if ( !Directory.Exists( $@"C:\Users\akoutia\Documents\Barnes Lab\Wmaze\RatData\{ratName[RatSelection.SelectedIndex]}\ScreenShots")) { Directory.CreateDirectory( $@"C:\Users\akoutia\Documents\Barnes Lab\Wmaze\RatData\{ratName[RatSelection.SelectedIndex]}\ScreenShots"); } var bmpScreenCapture = new Bitmap(Width, Height); DrawToBitmap(bmpScreenCapture, new Rectangle(0, 0, bmpScreenCapture.Width, bmpScreenCapture.Height)); bmpScreenCapture.Save( $@"C:\Users\akoutia\Documents\Barnes Lab\Wmaze\RatData\{ratName[RatSelection.SelectedIndex]}\ScreenShots\GUIscreenshot_{ratName [RatSelection.SelectedIndex]}_Session{sessionNumber}.gif", ImageFormat.Gif); } saved = true; if ( File.Exists( $@"C:\Users\akoutia\Documents\Barnes Lab\Wmaze\Videos\Composite_{year}{month}{day}_{hour}{minute}")) { if ( !Directory.Exists( $@"C:\Users\akoutia\Documents\Barnes Lab\Wmaze\Videos\{RatSelection.SelectedIndex}")) { Directory.CreateDirectory( $@"C:\Users\akoutia\Documents\Barnes Lab\Wmaze\Videos\{RatSelection.SelectedIndex}"); } File.Move( $@"C:\Users\akoutia\Documents\Barnes Lab\Wmaze\RatData\Current Cohort Videos\Composite_(NTSC){year}{month}{day}_{hour}{minute}.ts", $@"C:\Users\akoutia\Documents\Barnes Lab\Wmaze\RatData\Current Cohort Videos\{RatSelection.SelectedIndex}\{RatSelection.SelectedIndex}_{sessionLabel}.mpeg"); } } }
private void W_Maze_Gui_FormClosing(object sender, FormClosingEventArgs e) //Opens the exitConfirm form to ensure that you are purposefully exiting the GUI { if (!_exiting) { if (!saved) { _exiting = true; exitConfirm.StartPosition = FormStartPosition.CenterParent; exitConfirm.ShowDialog(); e.Cancel = true; _exiting = false; if (train) { CsvFiles.trainingCsv.Close(); } if (ratWasChosen && !train) { CsvFiles.OpenWriteToRatData(); foreach (var ratname in name_to_age.Keys) { if (ratname == ratbeingtested) { name_to_session[ratname]--; } CsvFiles.RatdataWriter.Write( $"{ratname},{name_to_age[ratname]},{name_to_session[ratname]}\n"); } CsvFiles.RatdataClose(); CsvFiles.Close(); } } else { if (!train) { CsvFiles.RatdataClose(); CsvFiles.Close(); } Environment.Exit(0); } } }