private void btnCapture_Click(object sender, RoutedEventArgs e) { bool isSweeping = _captureController.SessionManager.isSweeping; this.Dispatcher.Invoke(() => { btnEndSessionAndUpload.IsEnabled = true; btnEndAndStartNewSession.IsEnabled = true; SetBtnCaptureContent("Stop"); try { if (_captureController.FrameReader.Record) { SetBtnCaptureContent("Saving Sweep..."); btnCapture.IsEnabled = false; btnEndAndStartNewSession.IsEnabled = false; btnEndSessionAndUpload.IsEnabled = false; _captureController.FrameReader.RecordedFile = null; _captureController.FrameReader.Record = false; _captureController.FrameReader.Playback = false; _captureController.FrameReader.InitRecordPlay(); StopCapture(); } else { if (_captureController.FrameReader.RecordedFile != null) _captureController.FrameReader.Playback = true; else { if (_captureController.FrameReader.RecordNumber == 0) { Directory.CreateDirectory(baseDirectory + "\\" + inputName.Text + "-rssdk"); _captureController.FrameReader.FolderPath = baseDirectory + "\\" + inputName.Text + "-rssdk"; string CALIBRATION_FILE = "Calibration.json"; string calibrationCopyPath = System.IO.Path.Combine(_captureController.FrameReader.FolderPath, CALIBRATION_FILE); CollectData dataAndCalibration = new CollectData(); dataAndCalibration.calibration = SmithersDS4.Reading.Calibration.Calibrator.Calibrate(_captureController.FrameReader.Device); dataAndCalibration.shortMetadata = new SmithersDS4.Sessions.DS4Meta(); dataAndCalibration.shortMetadata.Name = _captureController.Session.Metadata.Name; dataAndCalibration.shortMetadata.Gender = _captureController.Session.Metadata.Gender; dataAndCalibration.shortMetadata.Height = _captureController.Session.Metadata.Height; dataAndCalibration.shortMetadata.Weight = _captureController.Session.Metadata.Weight; Smithers.Sessions.JSONHelper.Instance.Serialize(dataAndCalibration, calibrationCopyPath); } string fileName = string.Format("sweep_{0:D2}.rssdk", ++_captureController.FrameReader.RecordNumber); _captureController.FrameReader.RecordedFile = System.IO.Path.Combine(_captureController.FrameReader.FolderPath, fileName); _captureController.FrameReader.Record = true; } _captureController.FrameReader.InitRecordPlay(); StartCapture(); } } catch (InvalidOperationException ex) { MessageBox.Show(ex.Message); } }); }
private void btnCapture_Click(object sender, RoutedEventArgs e) { bool isSweeping = _captureController.SessionManager.isSweeping; this.Dispatcher.Invoke(() => { btnEndSessionAndUpload.IsEnabled = true; btnEndAndStartNewSession.IsEnabled = true; SetBtnCaptureContent("Stop"); try { if (_captureController.FrameReader.Record) { SetBtnCaptureContent("Saving Sweep..."); btnCapture.IsEnabled = false; btnEndAndStartNewSession.IsEnabled = false; btnEndSessionAndUpload.IsEnabled = false; _captureController.FrameReader.RecordedFile = null; _captureController.FrameReader.Record = false; _captureController.FrameReader.Playback = false; _captureController.FrameReader.InitRecordPlay(); StopCapture(); } else { if (_captureController.FrameReader.RecordedFile != null) { _captureController.FrameReader.Playback = true; } else { if (_captureController.FrameReader.RecordNumber == 0) { Directory.CreateDirectory(baseDirectory + "\\" + inputName.Text + "-rssdk"); _captureController.FrameReader.FolderPath = baseDirectory + "\\" + inputName.Text + "-rssdk"; string CALIBRATION_FILE = "Calibration.json"; string calibrationCopyPath = System.IO.Path.Combine(_captureController.FrameReader.FolderPath, CALIBRATION_FILE); CollectData dataAndCalibration = new CollectData(); dataAndCalibration.calibration = SmithersDS4.Reading.Calibration.Calibrator.Calibrate(_captureController.FrameReader.Device); dataAndCalibration.shortMetadata = new SmithersDS4.Sessions.DS4Meta(); dataAndCalibration.shortMetadata.Name = _captureController.Session.Metadata.Name; dataAndCalibration.shortMetadata.Gender = _captureController.Session.Metadata.Gender; dataAndCalibration.shortMetadata.Height = _captureController.Session.Metadata.Height; dataAndCalibration.shortMetadata.Weight = _captureController.Session.Metadata.Weight; Smithers.Sessions.JSONHelper.Instance.Serialize(dataAndCalibration, calibrationCopyPath); } string fileName = string.Format("sweep_{0:D2}.rssdk", ++_captureController.FrameReader.RecordNumber); _captureController.FrameReader.RecordedFile = System.IO.Path.Combine(_captureController.FrameReader.FolderPath, fileName); _captureController.FrameReader.Record = true; } _captureController.FrameReader.InitRecordPlay(); StartCapture(); } } catch (InvalidOperationException ex) { MessageBox.Show(ex.Message); } }); }