Skip to content

Commit

Permalink
Update RecordControl.razor
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoCoderMatrix86 committed Jul 2, 2024
1 parent 514d11e commit 15fa041
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions AudioCuesheetEditor/Pages/RecordControl.razor
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,12 @@ along with Foobar. If not, see

@code {
//TODO: During countdown the StartRecord button is enabled, which allows the user to manually start the record
//TODO: Display the current value of the RecordCountdownTimer
//TODO: Allow the user to edit the default RecordCountdownTimer
Timer updateGUITimer = new Timer(500);
Timer? startRecordTimer;
DateTime recordTimerStarted;
ApplicationOptions? applicationOptions;

ModalDialog? modalDialog;

Expand All @@ -93,6 +95,7 @@ along with Foobar. If not, see
{
_localizationService.LocalizationChanged -= LocalizationService_LocalizationChanged;
_sessionStateContainer.CuesheetChanged -= SessionStateContainer_CuesheetChanged;
_localStorageOptionsProvider.OptionSaved -= LocalStorageOptionsProvider_OptionsSaved;
}

protected override async Task OnInitializedAsync()
Expand All @@ -101,6 +104,7 @@ along with Foobar. If not, see

_localizationService.LocalizationChanged += LocalizationService_LocalizationChanged;
_sessionStateContainer.CuesheetChanged += SessionStateContainer_CuesheetChanged;
_localStorageOptionsProvider.OptionSaved += LocalStorageOptionsProvider_OptionsSaved;

updateGUITimer.AutoReset = true;
updateGUITimer.Elapsed += delegate
Expand All @@ -117,9 +121,8 @@ along with Foobar. If not, see
}
};

//TODO: Attach to saved event and save the RecordCountdownTimer to adjust the timer when a new value was saved
var options = await _localStorageOptionsProvider.GetOptions<ApplicationOptions>();
startRecordTimer = new Timer(options.RecordCountdownTimer * 1000);
applicationOptions = await _localStorageOptionsProvider.GetOptions<ApplicationOptions>();
startRecordTimer = new Timer(applicationOptions.RecordCountdownTimer * 1000);
startRecordTimer.Elapsed += async delegate
{
await StartRecordingClicked();
Expand Down Expand Up @@ -192,4 +195,16 @@ along with Foobar. If not, see
_sessionStateContainer.Cuesheet.StopRecording(options);
await StopRecordClicked.InvokeAsync();
}

void LocalStorageOptionsProvider_OptionsSaved(object? sender, IOptions options)
{
if (options is ApplicationOptions applicationOption)
{
applicationOptions = applicationOption;
if (startRecordTimer != null)
{
startRecordTimer.Interval = applicationOptions.RecordCountdownTimer * 1000;
}
}
}
}

0 comments on commit 15fa041

Please sign in to comment.