From 98face0951e87901e5e6386faa5e5926e7517666 Mon Sep 17 00:00:00 2001 From: NeoCoderMatrix86 <40752681+NeoCoderMatrix86@users.noreply.github.com> Date: Tue, 2 Apr 2024 16:50:44 +0200 Subject: [PATCH] Fixes export dialog --- AudioCuesheetEditor/Shared/MainLayout.razor | 12 ++------ .../Shared/ModalExportdialog.razor | 30 +++++++++++-------- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/AudioCuesheetEditor/Shared/MainLayout.razor b/AudioCuesheetEditor/Shared/MainLayout.razor index 1e8fe17a..05a3cf61 100644 --- a/AudioCuesheetEditor/Shared/MainLayout.razor +++ b/AudioCuesheetEditor/Shared/MainLayout.razor @@ -766,9 +766,9 @@ along with Foobar. If not, see _logger.LogInformation("SelectedExportProfileChanged with {0}", newValue); selectedExportProfileId = newValue; modalExportdialogExportprofile?.Validations?.ValidateAll().GetAwaiter().GetResult(); - if ((modalExportdialogExportprofile != null) && (modalExportdialogExportprofile.ExportfileGenerator != null)) + if (modalExportdialogExportprofile != null) { - modalExportdialogExportprofile.ExportfileGenerator.Exportprofile = SelectedExportProfile; + modalExportdialogExportprofile.SelectedExportProfile = SelectedExportProfile; modalExportdialogExportprofile.Reset(); } StateHasChanged(); @@ -797,19 +797,11 @@ along with Foobar. If not, see void ModalExportdialogExportprofile_GenerateExportfilesClicked(object? sender, EventArgs args) { Task.Run(SaveExportProfiles); - if ((modalExportdialogExportprofile != null) && (modalExportdialogExportprofile.ExportfileGenerator != null)) - { - modalExportdialogExportprofile.ExportfileGenerator.Exportprofile = SelectedExportProfile; - } } void ModalExportdialogCuesheet_GenerateExportfilesClicked(object? sender, EventArgs args) { Task.Run(SaveApplicationOptions); - if ((modalExportdialogCuesheet != null) && (modalExportdialogCuesheet.ExportfileGenerator != null)) - { - modalExportdialogCuesheet.ExportfileGenerator.ApplicationOptions = applicationOptions; - } } Task OnApplicationOptionsCuesheetFilenameChanged(string value) diff --git a/AudioCuesheetEditor/Shared/ModalExportdialog.razor b/AudioCuesheetEditor/Shared/ModalExportdialog.razor index 10d8231f..0940e47e 100644 --- a/AudioCuesheetEditor/Shared/ModalExportdialog.razor +++ b/AudioCuesheetEditor/Shared/ModalExportdialog.razor @@ -110,7 +110,6 @@ along with Foobar. If not, see @code { - //TODO: Export of cuesheet doesn't work (ApplicationOptions missing in ExportfileGenerator) public event EventHandler? GenerateExportfilesClicked; [Parameter] @@ -125,9 +124,10 @@ along with Foobar. If not, see [EditorRequired] public ExportType ExportType { get; set; } + public Exportprofile? SelectedExportProfile{ get; set; } + public Boolean IsVisible { get; private set; } public Validations? Validations { get; private set; } - public ExportfileGenerator? ExportfileGenerator { get; private set; } public Boolean LockUserInputs { get => exportProgress != null; } Modal? modalExportdialog; @@ -136,6 +136,7 @@ along with Foobar. If not, see Boolean prepareExportCompleted = false; HotKeysContext? hotKeysContext; int? exportProgress; + ApplicationOptions? applicationOptions; Boolean StepNavigationAllowed { @@ -162,7 +163,8 @@ along with Foobar. If not, see { get { - var validationResult = ExportfileGenerator?.Validate(); + var generator = new ExportfileGenerator(ExportType, _sessionStateContainer.Cuesheet, SelectedExportProfile, applicationOptions); + var validationResult = generator.Validate(); if (validationResult?.Status == Model.Entity.ValidationStatus.Error) { string? detailText = null; @@ -197,7 +199,8 @@ along with Foobar. If not, see hotKeysContext = _hotKeys.CreateContext() .Add(Key.Enter, OnEnterKeyDown); - ExportfileGenerator = new ExportfileGenerator(ExportType, _sessionStateContainer.Cuesheet); + applicationOptions = await _localStorageOptionsProvider.GetOptions(); + _localStorageOptionsProvider.OptionSaved += LocalStorageOptionsProvider_OptionSaved; await base.OnInitializedAsync(); } @@ -205,6 +208,7 @@ along with Foobar. If not, see public void Dispose() { hotKeysContext?.Dispose(); + _localStorageOptionsProvider.OptionSaved -= LocalStorageOptionsProvider_OptionSaved; } public async Task Show() @@ -240,12 +244,10 @@ along with Foobar. If not, see { GenerateExportfilesClicked?.Invoke(this, EventArgs.Empty); exportProgress = 0; - if (ExportfileGenerator != null) - { - exportfiles = ExportfileGenerator.GenerateExportfiles(); - selectedStep = "displayExportResult"; - prepareExportCompleted = true; - } + var generator = new ExportfileGenerator(ExportType, _sessionStateContainer.Cuesheet, SelectedExportProfile, applicationOptions); + exportfiles = generator.GenerateExportfiles(); + selectedStep = "displayExportResult"; + prepareExportCompleted = true; exportProgress = null; } return Task.CompletedTask; @@ -281,9 +283,11 @@ along with Foobar. If not, see } } - void IAudioConverterService_ProgressChanged(object? sender, int progress) + void LocalStorageOptionsProvider_OptionSaved(object? sender, IOptions options) { - exportProgress = progress; - InvokeAsync(StateHasChanged); + if (options is ApplicationOptions) + { + applicationOptions = (ApplicationOptions)options; + } } }