public static void InitRecorder(string recordDir) { try { if (ClientSetting.Instance.IsFakeSystem) { _recorder = new FakeRecorder(); } else { if (!Directory.Exists(recordDir)) { Directory.CreateDirectory(recordDir); } _recorder = new WaveRecorder(recordDir, CommonResource.Instance.Channels.Count()); var devices = UsbReader.GetUsbDeviceList(); if (devices.Any()) { _recorder.UsbDeviceSerialNumber = devices[0].Key; } _recorder.Start(); } } catch (Exception ex) { LogService.Logger.Error(ex); } }
public RecorderViewModel() { _rootDir = Path.Combine(System.Environment.CurrentDirectory, "TestRecords"); if (!Directory.Exists(_rootDir)) { Directory.CreateDirectory(_rootDir); } this.Recorder = new WaveRecorder(_rootDir); _selectedChannel = this.Recorder.Channels.First(); this.Devices = UsbReader.GetUsbDeviceList(); if (this.Devices.Count > 0) { this.SelectedSerialNumber = this.Devices[0].Key; } this.RecordCommand = new RelayCommand(p => OnRecord(), p => CanRecord()); this.StopRecordCommand = new RelayCommand(p => OnStopRecord(), p => this.Recorder.IsStarted && !CanRecord()); this.OpenRecordFolderCommand = new RelayCommand(p => OpenRecordFolder()); this.OpenDeviceCommand = new RelayCommand(p => OnOpenDevice(), p => this.Recorder.IsStarted == false && !string.IsNullOrEmpty(this.SelectedSerialNumber)); this.CloseDeviceCommand = new RelayCommand(p => OnCloseDevice(), p => this.Recorder.IsStarted); }