///Runs the wait for start dialog.  Returns false if the user clicks stop while we are recording
///so that the high
bool TimerRecordDialog::RunWaitDialog()
{
   int updateResult = eProgressSuccess;
   if (m_DateTime_Start > wxDateTime::UNow()) 
      updateResult = this->WaitForStart(); 

   if (updateResult != eProgressSuccess) 
   {
      // Don't proceed, but don't treat it as canceled recording. User just canceled waiting. 
      return true;
   }
   else 
   {
      // Record for specified time.
      AudacityProject* pProject = GetActiveProject();
      pProject->OnRecord();
      bool bIsRecording = true;

      wxString strMsg =
         _("Recording start") + (wxString)wxT(":\t\t")
         + GetDisplayDate(m_DateTime_Start) + wxT("\n") + _("Recording end")
         + wxT(":\t\t") + GetDisplayDate(m_DateTime_End) + wxT("\n")
         + _("Duration") + wxT(":\t\t") + m_TimeSpan_Duration.Format(); 

      TimerProgressDialog 
         progress(m_TimeSpan_Duration.GetMilliseconds().GetValue(), 
                  _("Audacity Timer Record Progress"), 
                  strMsg, 
                  pdlgHideCancelButton); 

      // Make sure that start and end time are updated, so we always get the full 
      // duration, even if there's some delay getting here.
      wxTimerEvent dummyTimerEvent;
      this->OnTimer(dummyTimerEvent);

      // Loop for progress display during recording.
      while (bIsRecording && (updateResult == eProgressSuccess)) 
      {
         wxMilliSleep(kTimerInterval);
         updateResult = progress.Update();
         bIsRecording = (wxDateTime::UNow() <= m_DateTime_End); // Call UNow() again for extra accuracy...
      }
      pProject->OnStop();
   }
   // Let the caller handle cancellation or failure from recording progress. 
   if (updateResult == eProgressCancelled || updateResult == eProgressFailed)
      return false;
   return true;
}
Exemplo n.º 2
0
void TimerRecordDialog::OnOK(wxCommandEvent& event)
{
   m_timer.Stop(); // Don't need to keep updating m_DateTime_Start to prevent backdating.

   this->TransferDataFromWindow();

   bool bDidCancel = false;
   if (m_DateTime_Start > wxDateTime::UNow()) 
      bDidCancel = !this->WaitForStart(); 

   if (!bDidCancel)  
   {
      // Record for specified time.
   	AudacityProject* pProject = GetActiveProject();
      pProject->OnRecord();

      bool bIsRecording = true;

      /* Although inaccurate, use the wxProgressDialog wxPD_ELAPSED_TIME | wxPD_REMAINING_TIME 
         instead of calculating and presenting it.
            wxTimeSpan remaining_TimeSpan;
            wxString strNewMsg;
         */

      wxString strMsg = 
         _("Recording start") + (wxString)wxT(":\t\t")
		 + GetDisplayDate(m_DateTime_Start) + wxT("\n") + _("Recording end")
       + wxT(":\t\t") + GetDisplayDate(m_DateTime_End) + wxT("\n")
		 + _("Duration") + wxT(":\t\t") + m_TimeSpan_Duration.Format(); 

      ProgressDialog progress(
               _("Audacity Timer Record Progress"), // const wxString& title,
               strMsg); // const wxString& message

      // Make sure that start and end time are updated, so we always get the full 
      // duration, even if there's some delay getting here.
      wxTimerEvent dummyTimerEvent;
      this->OnTimer(dummyTimerEvent);

      wxDateTime dateTime_UNow;
      wxTimeSpan done_TimeSpan;
      while (bIsRecording && !bDidCancel) {
		 // sit in this loop during the recording phase, i.e. from rec start to
		 // recording end
         wxMilliSleep(kTimerInterval);
         
         dateTime_UNow = wxDateTime::UNow();	// get time now
         done_TimeSpan = dateTime_UNow - m_DateTime_Start;
		 // work out how long we have been recording for
         // remaining_TimeSpan = m_DateTime_End - dateTime_UNow;

         // strNewMsg = strMsg + _("\nDone: ") + done_TimeSpan.Format() + _("     Remaining: ") + remaining_TimeSpan.Format();
         bDidCancel = !progress.Update(done_TimeSpan.GetSeconds(),
                                       m_TimeSpan_Duration.GetSeconds()); // , strNewMsg);
         bIsRecording = (wxDateTime::UNow() <= m_DateTime_End);
      }
      pProject->OnStop();
   }

   this->EndModal(wxID_OK);
}
Exemplo n.º 3
0
/// Runs the wait for start dialog.  Returns -1 if the user clicks stop while we are recording
/// or if the post recording actions fail.
int TimerRecordDialog::RunWaitDialog()
{
   AudacityProject* pProject = GetActiveProject();
   
   auto updateResult = ProgressResult::Success;

   if (m_DateTime_Start > wxDateTime::UNow())
      updateResult = this->WaitForStart();

   if (updateResult != ProgressResult::Success)  {
      // Don't proceed, but don't treat it as canceled recording. User just canceled waiting.
      return POST_TIMER_RECORD_CANCEL_WAIT;
   } else {
      // Record for specified time.
      pProject->OnRecord(*pProject);
      bool bIsRecording = true;

      wxString sPostAction = m_pTimerAfterCompleteChoiceCtrl->GetString(m_pTimerAfterCompleteChoiceCtrl->GetSelection());

      // Two column layout.
      TimerProgressDialog::MessageTable columns(2);
      auto &column1 = columns[0];
      auto &column2 = columns[1];

      column1.push_back( _("Recording start:") );
      column2.push_back( GetDisplayDate(m_DateTime_Start) );

      column1.push_back( _("Duration:") );
      column2.push_back( m_TimeSpan_Duration.Format() );

      column1.push_back( _("Recording end:") );
      column2.push_back( GetDisplayDate(m_DateTime_End) );

      column1.push_back( {} );
      column2.push_back( {} );

      column1.push_back( _("Automatic Save enabled:") );
      column2.push_back( (m_bAutoSaveEnabled ? _("Yes") : _("No")) );

      column1.push_back( _("Automatic Export enabled:") );
      column2.push_back( (m_bAutoExportEnabled ? _("Yes") : _("No")) );

      column1.push_back( _("Action after Timer Recording:") );
      column2.push_back( sPostAction );

      TimerProgressDialog
         progress(m_TimeSpan_Duration.GetMilliseconds().GetValue(),
                  _("Audacity Timer Record Progress"),
                  columns,
                  pdlgHideCancelButton | pdlgConfirmStopCancel);

      // Make sure that start and end time are updated, so we always get the full
      // duration, even if there's some delay getting here.
      wxTimerEvent dummyTimerEvent;
      this->OnTimer(dummyTimerEvent);

      // Loop for progress display during recording.
      while (bIsRecording && (updateResult == ProgressResult::Success)) {
         updateResult = progress.UpdateProgress();
         wxMilliSleep(kTimerInterval);
         bIsRecording = (wxDateTime::UNow() <= m_DateTime_End); // Call UNow() again for extra accuracy...
      }
   }

   // Must do this AFTER the timer project dialog has been deleted to ensure the application
   // responds to the AUDIOIO events...see not about bug #334 in the ProgressDialog constructor.
   pProject->OnStop(*pProject);

   // Let the caller handle cancellation or failure from recording progress.
   if (updateResult == ProgressResult::Cancelled || updateResult == ProgressResult::Failed)
      return POST_TIMER_RECORD_CANCEL;

   return ExecutePostRecordActions((updateResult == ProgressResult::Stopped));
}