Skip to content

Commit

Permalink
Add icon for timer start
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoCoderMatrix86 committed Jul 4, 2024
1 parent 6964d64 commit 3c18dc9
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 39 deletions.
1 change: 0 additions & 1 deletion AudioCuesheetEditor/Model/Options/ApplicationOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ public String? ViewModename
}
public Boolean LinkTracksWithPreviousOne { get; set; } = true;
public String? ProjectFilename { get; set; } = Projectfile.DefaultFilename;
public uint RecordCountdownTimer { get; set; } = 5;
public TimeSpanFormat? TimeSpanFormat { get; set; }

protected override ValidationResult Validate(string property)
Expand Down
1 change: 1 addition & 0 deletions AudioCuesheetEditor/Model/Options/RecordOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class RecordOptions : Validateable<RecordOptions>, IOptions
public String RecordedAudiofilename { get; set; } = Audiofile.RecordingFileName;
[JsonIgnore]
public TimeSensitivityMode RecordTimeSensitivity { get; set; }
public uint RecordCountdownTimer { get; set; } = 5;
public String? RecordTimeSensitivityname
{
get { return Enum.GetName(typeof(TimeSensitivityMode), RecordTimeSensitivity); }
Expand Down
93 changes: 59 additions & 34 deletions AudioCuesheetEditor/Pages/RecordControl.razor
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ along with Foobar. If not, see
}
<Row>
<Column>
<Dropdown Direction="Direction.End">
<Dropdown Direction="Direction.End" Disabled="_sessionStateContainer.Cuesheet.IsRecording || startRecordTimer?.Enabled == true">
<Button Color="Color.Danger" Clicked="StartRecordingClicked" Disabled="_sessionStateContainer.Cuesheet.IsRecording || startRecordTimer?.Enabled == true">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-record2" viewBox="0 0 16 16">
<path d="M8 12a4 4 0 1 1 0-8 4 4 0 0 1 0 8zm0 1A5 5 0 1 0 8 3a5 5 0 0 0 0 10z" />
Expand All @@ -47,7 +47,7 @@ along with Foobar. If not, see
</Button>
<DropdownToggle Color="Color.Danger" Split Disabled="_sessionStateContainer.Cuesheet.IsRecording || startRecordTimer?.Enabled == true"></DropdownToggle>
<DropdownMenu>
<DropdownItem Clicked="StartRecordCountdownTimer" Disabled="_sessionStateContainer.Cuesheet.IsRecording || startRecordTimer?.Enabled == true">@_localizer["Start record countdown timer ({0} seconds)", (startRecordTimer?.Interval / 1000)]</DropdownItem>
<DropdownItem Clicked="OpenCountdownModal" Disabled="_sessionStateContainer.Cuesheet.IsRecording || startRecordTimer?.Enabled == true">@_localizer["Start record countdown timer"]</DropdownItem>
</DropdownMenu>
</Dropdown>
</Column>
Expand All @@ -74,15 +74,41 @@ along with Foobar. If not, see

<ModalDialog @ref="modalDialog" />

<Modal @ref="modalInputCountdownTime">
<ModalContent Centered>
<ModalHeader>
<ModalTitle>@_localizer["Start record countdown timer"]</ModalTitle>
<CloseButton />
</ModalHeader>
<ModalBody>
<Field Horizontal>
<FieldLabel ColumnSize="ColumnSize.Is5.OnWidescreen.Is12.OnDesktop">@_localizer["Seconds till record starts"]</FieldLabel>
<FieldBody ColumnSize="ColumnSize.Is7.OnWidescreen.Is12.OnDesktop"><NumericEdit TValue="uint" Min="1" /></FieldBody>
</Field>
</ModalBody>
<ModalFooter>
<Button Color="Color.Primary" Clicked="StartRecordCountdownTimer">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-stopwatch" viewBox="0 0 16 16">
<path d="M8.5 5.6a.5.5 0 1 0-1 0v2.9h-3a.5.5 0 0 0 0 1H8a.5.5 0 0 0 .5-.5z" />
<path d="M6.5 1A.5.5 0 0 1 7 .5h2a.5.5 0 0 1 0 1v.57c1.36.196 2.594.78 3.584 1.64l.012-.013.354-.354-.354-.353a.5.5 0 0 1 .707-.708l1.414 1.415a.5.5 0 1 1-.707.707l-.353-.354-.354.354-.013.012A7 7 0 1 1 7 2.071V1.5a.5.5 0 0 1-.5-.5M8 3a6 6 0 1 0 .001 12A6 6 0 0 0 8 3" />
</svg>
@_localizer["Start countdown"]
</Button>
<Button Color="Color.Secondary" Clicked="HideCountdownModal">@_localizer["Abort"]</Button>
</ModalFooter>
</ModalContent>
</Modal>

@code {
//TODO: Allow the user to edit the default RecordCountdownTimer
//TODO: Allow the user to stop the record countdown
//TODO: Keyboard enter for modal
Timer updateGUITimer = new Timer(300);
Timer? startRecordTimer;

Check warning on line 107 in AudioCuesheetEditor/Pages/RecordControl.razor

View workflow job for this annotation

GitHub Actions / run-unit-tests

Field 'RecordControl.startRecordTimer' is never assigned to, and will always have its default value null
DateTime recordTimerStarted;
ApplicationOptions? applicationOptions;

ModalDialog? modalDialog;
Modal? modalInputCountdownTime;

[Parameter]
public EventCallback StartRecordClicked { get; set; }
Expand All @@ -94,26 +120,16 @@ along with Foobar. If not, see
{
_localizationService.LocalizationChanged -= LocalizationService_LocalizationChanged;
_sessionStateContainer.CuesheetChanged -= SessionStateContainer_CuesheetChanged;
_localStorageOptionsProvider.OptionSaved -= LocalStorageOptionsProvider_OptionsSaved;
}

protected override async Task OnInitializedAsync()
protected override void OnInitialized()
{
base.OnInitialized();

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

InitializeUIUpdate();

applicationOptions = await _localStorageOptionsProvider.GetOptions<ApplicationOptions>();
startRecordTimer = new Timer(applicationOptions.RecordCountdownTimer * 1000);
startRecordTimer.Elapsed += async delegate
{
await StartRecordingClicked();
startRecordTimer.Stop();
};
}

void InitializeUIUpdate()
Expand All @@ -122,12 +138,7 @@ along with Foobar. If not, see
updateGUITimer.Elapsed += delegate
{
StateHasChanged();
Boolean startRecordTimeEnabled = false;
if (startRecordTimer != null)
{
startRecordTimeEnabled = startRecordTimer.Enabled;
}
if ((startRecordTimeEnabled == false) && (_sessionStateContainer.Cuesheet.IsRecording == false))
if (_sessionStateContainer.Cuesheet.IsRecording == false)
{
updateGUITimer.Stop();
}
Expand Down Expand Up @@ -183,11 +194,37 @@ along with Foobar. If not, see
}
}

void StartRecordCountdownTimer()
async Task OpenCountdownModal()
{
if (modalInputCountdownTime != null)
{
await modalInputCountdownTime.Show();
}
}

async Task HideCountdownModal()
{
if (modalInputCountdownTime != null)
{
await modalInputCountdownTime.Hide();
}
}

async Task StartRecordCountdownTimer()
{
recordTimerStarted = DateTime.Now;
startRecordTimer?.Start();
//TODO: Save input of modal to record options
//TODO: Create timer with input of modal
// var recordOptions = await _localStorageOptionsProvider.GetOptions<RecordOptions>();
// startRecordTimer = new Timer(recordOptions.RecordCountdownTimer * 1000);
// startRecordTimer.Elapsed += async delegate
// {
// await StartRecordingClicked();
// startRecordTimer.Stop();
// };
// startRecordTimer?.Start();
updateGUITimer.Start();
await HideCountdownModal();
}

async Task StopRecordingClicked()
Expand All @@ -196,16 +233,4 @@ 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;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
"Record running!": "Aufnahme aktiv!",
"Start recording": "Aufnahme starten",
"Stop recording": "Aufnahme beenden",
"Start record countdown timer ({0} seconds)": "Aufnahmecountdown starten ({0} Sekunden)",
"Start record countdown timer": "Aufnahmecountdown starten",
"Record will start in {0} seconds!": "Aufnahme wird in {0} Sekunden starten!",
"Error": "Fehler",
"Cuesheet already contains tracks. Recording is not possible, if tracks are present. Please save your work and start with a clean cuesheet.": "Das Cuesheet enthält bereits Titel. Die Aufnahme ist nicht möglich, wenn bereits Titel vorhanden sind. Bitte speichern Sie ihre Arbeit und starten Sie anschließend mit einem leeren Cuesheet."
"Cuesheet already contains tracks. Recording is not possible, if tracks are present. Please save your work and start with a clean cuesheet.": "Das Cuesheet enthält bereits Titel. Die Aufnahme ist nicht möglich, wenn bereits Titel vorhanden sind. Bitte speichern Sie ihre Arbeit und starten Sie anschließend mit einem leeren Cuesheet.",
"Start countdown": "Aufnahmecountdown starten",
"Abort": "Abbrechen",
"Seconds till record starts": "Sekunden bis die Aufnahme startet"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
"Record running!": "Record is running!",
"Start recording": "Start recording",
"Stop recording": "Stop recording",
"Start record countdown timer ({0} seconds)": "Start record countdown timer ({0} seconds)",
"Start record countdown timer": "Start record countdown timer",
"Record will start in {0} seconds!": "Record will start in {0} seconds!",
"Error": "Error",
"Cuesheet already contains tracks. Recording is not possible, if tracks are present. Please save your work and start with a clean cuesheet.": "Cuesheet already contains tracks. Recording is not possible, if tracks are present. Please save your work and start with a clean cuesheet."
"Cuesheet already contains tracks. Recording is not possible, if tracks are present. Please save your work and start with a clean cuesheet.": "Cuesheet already contains tracks. Recording is not possible, if tracks are present. Please save your work and start with a clean cuesheet.",
"Start countdown": "Start countdown",
"Abort": "Abort",
"Seconds till record starts": "Seconds till record starts"
}
}

0 comments on commit 3c18dc9

Please sign in to comment.