private void Timer_Tick(object sender, EventArgs e) { if (learningProcess) { prgBar.Value = lPr; if (lPr > 99) { this.Close(); } } else if (timer.Interval == new TimeSpan(0, 0, 20)) { testedNote++; lbNote.Content = "Pause"; capturer.StopRecording(); if (testedNote.ToInt() == 0) { learningProcess = true; capturer.StopRecording(); btnStart.IsEnabled = false; btnStop.IsEnabled = false; lbNote.Content = "End"; prgBar.Value = 0; Task.Factory.StartNew(() => Learn()); } timer.Interval = new TimeSpan(0, 0, 2); prgBar.Value = testedNote.ToInt() * 100 / 61; samplesOneType = 0; lbSampleCount.Content = samplesOneType; } else { timer.Interval = new TimeSpan(0, 0, 20); lbNote.Content = testedNote.ToString(); capturer.StartRecording(); } }
private void BtnPlay_Click(object sender, RoutedEventArgs e) { try { capturer.StartRecording(); btnPlay.IsEnabled = false; btnPause.IsEnabled = true; appInfo.SetState(true); updateTimer.Start(); } catch (NAudio.MmException ex) { System.Windows.MessageBox.Show(string.Format("{0} \n Try to connect a microphone.", ex.Message)); } }