| 432 | } |
| 433 | |
| 434 | void ContrastDialog::OnExport(wxCommandEvent & WXUNUSED(event)) |
| 435 | { |
| 436 | // TODO: Handle silence checks better (-infinity dB) |
| 437 | auto project = FindProjectFromWindow( this ); |
| 438 | wxString fName = wxT("contrast.txt"); |
| 439 | |
| 440 | fName = SelectFile(FileNames::Operation::Export, |
| 441 | XO("Export Contrast Result As:"), |
| 442 | wxEmptyString, |
| 443 | fName, |
| 444 | wxT("txt"), |
| 445 | { FileNames::TextFiles, FileNames::AllFiles }, |
| 446 | wxFD_SAVE | wxRESIZE_BORDER, |
| 447 | this); |
| 448 | |
| 449 | if (fName.empty()) |
| 450 | return; |
| 451 | |
| 452 | wxFFileOutputStream ffStream{ fName }; |
| 453 | |
| 454 | if (!ffStream.IsOk()) { |
| 455 | AudacityMessageBox( XO("Couldn't write to file: %s").Format( fName ) ); |
| 456 | return; |
| 457 | } |
| 458 | |
| 459 | wxTextOutputStream ss(ffStream); |
| 460 | |
| 461 | ss |
| 462 | << wxT("===================================") << '\n' |
| 463 | /* i18n-hint: WCAG abbreviates Web Content Accessibility Guidelines */ |
| 464 | << XO("WCAG 2.0 Success Criteria 1.4.7 Contrast Results") << '\n' |
| 465 | << '\n' |
| 466 | << XO("Filename = %s.").Format( ProjectFileIO::Get(*project).GetFileName() ) << '\n' |
| 467 | << '\n' |
| 468 | << XO("Foreground") << '\n'; |
| 469 | |
| 470 | float t = (float)mForegroundStartT->GetValue(); |
| 471 | int h = (int)(t/3600); // there must be a standard function for this! |
| 472 | int m = (int)((t - h*3600)/60); |
| 473 | float s = t - h*3600.0 - m*60.0; |
| 474 | |
| 475 | ss |
| 476 | << XO("Time started = %2d hour(s), %2d minute(s), %.2f seconds.") |
| 477 | .Format( h, m, s ) << '\n'; |
| 478 | |
| 479 | t = (float)mForegroundEndT->GetValue(); |
| 480 | h = (int)(t/3600); |
| 481 | m = (int)((t - h*3600)/60); |
| 482 | s = t - h*3600.0 - m*60.0; |
| 483 | |
| 484 | ss |
| 485 | << XO("Time ended = %2d hour(s), %2d minute(s), %.2f seconds.") |
| 486 | .Format( h, m, s ) << '\n' |
| 487 | << FormatRMSMessage( mForegroundIsDefined ? &foregrounddB : nullptr ) << '\n' |
| 488 | << '\n' |
| 489 | << XO("Background") << '\n'; |
| 490 | |
| 491 | t = (float)mBackgroundStartT->GetValue(); |
nothing calls this directly
no test coverage detected