diff --git a/AudioCuesheetEditor/AudioCuesheetEditor.csproj b/AudioCuesheetEditor/AudioCuesheetEditor.csproj index cd8b709c..2bda446a 100644 --- a/AudioCuesheetEditor/AudioCuesheetEditor.csproj +++ b/AudioCuesheetEditor/AudioCuesheetEditor.csproj @@ -14,120 +14,6 @@ service-worker-assets.js - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/AudioCuesheetEditor/Shared/MainLayout.de.resx b/AudioCuesheetEditor/Shared/MainLayout.de.resx new file mode 100644 index 00000000..fc62d010 --- /dev/null +++ b/AudioCuesheetEditor/Shared/MainLayout.de.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Es ist ein Fehler in der Anwendung aufgetreten. Bitte melden Sie diesen Fehler unter Angabe von möglichst vielen Details hier: + + + Fehlerdetails + + + Applikation neu laden + + \ No newline at end of file diff --git a/AudioCuesheetEditor/Shared/MainLayout.razor b/AudioCuesheetEditor/Shared/MainLayout.razor index b1b270f1..68c69949 100644 --- a/AudioCuesheetEditor/Shared/MainLayout.razor +++ b/AudioCuesheetEditor/Shared/MainLayout.razor @@ -18,897 +18,78 @@ along with Foobar. If not, see @inherits LayoutComponentBase -@implements IAsyncDisposable +@implements IDisposable @inject NavigationManager _navigationManager -@inject ITextLocalizer _localizer -@inject ITextLocalizerService _localizationService -@inject TraceChangeManager _traceChangeManager -@inject ILogger _logger +@inject IStringLocalizer _localizer +@inject LocalizationService _localizationService @inject IJSRuntime _jsRuntime -@inject HotKeys _hotKeys -@inject ILocalStorageOptionsProvider _localStorageOptionsProvider -@inject SessionStateContainer _sessionStateContainer -@inject IBlazorDownloadFileService _blazorDownloadFileService -@inject ITextLocalizer _validationMessageLocalizer + +@* Required *@ + + + +@* Needed for dialogs *@ + + +@* Needed for snackbars *@ + - - - - @if ((displayMenuBar) && (sidebar != null)) - { - //Just a little a hack for displaying a toggler for the sidebar always and independent from the breakpoint of the top bar - - - - } - - - - - - - AudioCuesheetEditor - - - @if (displayMenuBar) - { - - - - - - - - - - - - - - } - - - - - - - - - - - - - - @_localizer["Help"] - @_localizer["About"] - @_localizer["Preview environment"] - - - - - - - - @if (displayMenuBar) - { - - - - - - - - - - - - - @_localizer["ViewMode"] - - - @foreach (var name in Enum.GetNames(typeof(ViewMode))) - { - - - - } - - - - - - - - - - - @_localizer["Export"] - - - - - - - - - - - - - - - - - - - - - - - - - - @_localizer["Reset"] - - - - - - - - - - - - - - - - - - - - - - - - - - - } - - - @Body - - - - + + + + @*NavMenu*@ + + + @Body + + - @_localizer["An error occured"] - @((MarkupString)_localizer["An error has occured in this application. Please report this error with as much details as possible here: https://github.com/NeoCoderMatrix86/AudioCuesheetEditor/issues/new?assignees=&labels=unreviewed+bug&template=bug_report.md&title=."]) - @_localizer["Error details"] - @context - + + @_localizer["An error has occured in this application. Please report this error with as much details as possible here:"]https://github.com/NeoCoderMatrix86/AudioCuesheetEditor/issues/new?&labels=bug&template=bug_report.md +
+ @_localizer["Error details"] +
+ @context +
+ @_localizer["Reload application"] +
- - - -@if (applicationOptions != null) -{ - - - - - @_localizer["Save project"] - - - - - - - - @_localizer["Filename"] - - - - - - - - - - - - - - - - - -} - - - - @if (applicationOptions != null) - { - - - @_localizer["Filename"] - - - - - - - - - - } - - - - - - @if (exportOptions != null) - { - - @_localizer["Select exportprofile"] - - - - - - - - - - @_localizer["Name"] - - - - - - - - - - - - @_localizer["Filename"] - - - - - - - - - - - - - - @_localizer["Exportprofilescheme head"] - - - - - - - - - - - - - - - @_localizer["Select placeholder"] - - - @foreach (var availableScheme in Exportprofile.AvailableCuesheetSchemes) - { - @_localizer[availableScheme.Key] - } - - - - - - - - - - - - @_localizer["Exportprofilescheme track"] - - - - - - - - - - - - - - - @_localizer["Select placeholder"] - - - @foreach (var availableScheme in Exportprofile.AvailableTrackSchemes) - { - @_localizer[availableScheme.Key] - } - - - - - - - - - - - - @_localizer["Exportprofilescheme footer"] - - - - - - - - - - - - - - - @_localizer["Select placeholder"] - - - @foreach (var availableScheme in Exportprofile.AvailableCuesheetSchemes) - { - @_localizer[availableScheme.Key] - } - - - - - - - - } - - - @code { - Bar? sidebar; - Boolean displayMenuBar = false; - HotKeysContext? hotKeysContext; - ApplicationOptions? applicationOptions; - Boolean modalDownloadProjectfileVisible = false; - Boolean sidebarVisible = false; + //TODO + bool _drawerOpen = false; - OptionsDialog? optionsDialog; - ModalDialog? modalDialog; - Modal? modalDownloadProjectfile; - ModalExportdialog? modalExportdialogCuesheet; - ModalExportdialog? modalExportdialogExportprofile; - ExportOptions? exportOptions; - - String? IsCuesheetExportableTooltip + void DrawerToggle() { - get - { - var generator = new ExportfileGenerator(ExportType.Cuesheet, _sessionStateContainer.Cuesheet, applicationOptions: applicationOptions); - var validationResult = generator.Validate(); - if (validationResult.Status == Model.Entity.ValidationStatus.Error) - { - string? detailText = null; - if (validationResult.ValidationMessages != null) - { - foreach (var validationMessage in validationResult.ValidationMessages) - { - detailText += String.Format("{0}{1}", validationMessage.GetMessageLocalized(_validationMessageLocalizer), Environment.NewLine); - } - } - return _localizer["Please check processinghints for errors, otherwise the file is not exportable: {0}", detailText]; - } - return null; - } - } - - Boolean IsCuesheetExportable => IsCuesheetExportableTooltip == null; - - protected override async Task OnInitializedAsync() - { - _localizationService.LocalizationChanged += LocalizationService_LocalizationChanged; - _traceChangeManager.TracedObjectHistoryChanged += TraceChangeManager_TracedObjectHistoryChanged; - _traceChangeManager.UndoDone += TraceChangeManager_UndoDone; - _traceChangeManager.RedoDone += TraceChangeManager_RedoDone; - hotKeysContext = _hotKeys.CreateContext() - .Add(ModKey.Ctrl, Key.h, OnCtrlHKeyDown) - .Add(ModKey.Ctrl, Key.e, OnCtrlEKeyDown) - .Add(ModKey.Ctrl, Key.s, OnCtrlSKeyDown) - .Add(Key.Enter, OnEnterKeyDown); - - applicationOptions = await _localStorageOptionsProvider.GetOptions(); - exportOptions = await _localStorageOptionsProvider.GetOptions(); - _localStorageOptionsProvider.OptionSaved += LocalStorageOptionsProvider_OptionSaved; - - if (modalExportdialogExportprofile != null) - { - modalExportdialogExportprofile.GenerateExportfilesClicked += ModalExportdialogExportprofile_GenerateExportfilesClicked; - } - if (modalExportdialogCuesheet != null) - { - modalExportdialogCuesheet.GenerateExportfilesClicked += ModalExportdialogCuesheet_GenerateExportfilesClicked; - } - - _sessionStateContainer.CurrentViewMode = applicationOptions.ViewMode; - - await base.OnInitializedAsync(); + _drawerOpen = !_drawerOpen; } - public async ValueTask DisposeAsync() + public void Dispose() { _localizationService.LocalizationChanged -= LocalizationService_LocalizationChanged; - _localStorageOptionsProvider.OptionSaved -= LocalStorageOptionsProvider_OptionSaved; - _traceChangeManager.TracedObjectHistoryChanged -= TraceChangeManager_TracedObjectHistoryChanged; - _traceChangeManager.UndoDone -= TraceChangeManager_UndoDone; - _traceChangeManager.RedoDone -= TraceChangeManager_RedoDone; - if (modalExportdialogExportprofile != null) - { - modalExportdialogExportprofile.GenerateExportfilesClicked -= ModalExportdialogExportprofile_GenerateExportfilesClicked; - } - if (modalExportdialogCuesheet != null) - { - modalExportdialogCuesheet.GenerateExportfilesClicked -= ModalExportdialogCuesheet_GenerateExportfilesClicked; - } - if (hotKeysContext != null) - { - await hotKeysContext.DisposeAsync(); - } } - public void SetDisplayMenuBar(Boolean display) + protected override void OnInitialized() { - if (displayMenuBar != display) - { - displayMenuBar = display; - StateHasChanged(); - } - } - - async Task OnDeleteAllTracksClicked() - { - _logger.LogInformation("OnDeleteAllTracksClicked"); - //Display a confirm warning - if (modalDialog != null) - { - modalDialog.Title = _localizer["Confirmation required"]; - modalDialog.Text = _localizer["Do you really want to delete all tracks? This can not be reversed."]; - modalDialog.ModalSize = ModalSize.Small; - modalDialog.Mode = ModalDialog.DialogMode.Confirm; - void deleteTracksDelegate(object? sender, EventArgs args) - { - _logger.LogInformation("deleteTracksDelegate"); - _sessionStateContainer.Cuesheet.RemoveTracks(_sessionStateContainer.Cuesheet.Tracks); - modalDialog.Confirmed -= deleteTracksDelegate; - StateHasChanged(); - }; - modalDialog.Confirmed += deleteTracksDelegate; - await modalDialog.ShowModal(); - } - } - - async Task RestartCuesheetClicked() - { - _logger.LogInformation("RestartCuesheetClicked clicked"); - //Display a confirm warning - if (modalDialog != null) - { - modalDialog.Title = _localizer["Confirmation required"]; - modalDialog.Text = _localizer["Do you really want to reset the cuesheet? This can not be reversed."]; - modalDialog.ModalSize = ModalSize.Small; - modalDialog.Mode = ModalDialog.DialogMode.Confirm; - void newCuesheetDelegate(object? sender, EventArgs args) - { - _logger.LogInformation("newCuesheetDelegate"); - _sessionStateContainer.Cuesheet = new Cuesheet(_traceChangeManager); - modalDialog.Confirmed -= newCuesheetDelegate; - StateHasChanged(); - }; - modalDialog.Confirmed += newCuesheetDelegate; - await modalDialog.ShowModal(); - } - } - - async Task OnRestartCompleteApplicationClicked() - { - _logger.LogInformation("OnRestartCompleteApplicationClicked"); - //Display a confirm warning - if (modalDialog != null) - { - modalDialog.Title = _localizer["Confirmation required"]; - modalDialog.Text = _localizer["Confirm restart of application. All unsaved changes are lost!"]; - modalDialog.ModalSize = ModalSize.Small; - modalDialog.Mode = ModalDialog.DialogMode.Confirm; - async void restartApplicationDelegate(object? sender, EventArgs args) - { - _logger.LogInformation("restartApplicationDelegate"); - modalDialog.Confirmed -= restartApplicationDelegate; - await ReloadApplication(); - }; - modalDialog.Confirmed += restartApplicationDelegate; - await modalDialog.ShowModal(); - } - } - - async Task OnResetCompleteApplicationClicked() - { - _logger.LogInformation("OnResetCompleteApplicationClicked"); - //Display a confirm warning - if (modalDialog != null) - { - modalDialog.Title = _localizer["Confirmation required"]; - modalDialog.Text = _localizer["Confirm reset of application. All unsaved changes are lost and the application is reloaded!"]; - modalDialog.ModalSize = ModalSize.Small; - modalDialog.Confirmed += OnRestartApplicationConfirmed; - await modalDialog.ShowModal(); - } - } - - private async void OnRestartApplicationConfirmed(object? sender, EventArgs args) - { - _logger.LogInformation("OnRestartApplicationConfirmed"); - await _jsRuntime.InvokeVoidAsync("resetLocalStorage"); - await _jsRuntime.InvokeVoidAsync("removeBeforeunload"); - if (modalDialog != null) - { - modalDialog.Confirmed -= OnRestartApplicationConfirmed; - } - _navigationManager.NavigateTo(_navigationManager.Uri, true); - } - - async Task OnDisplayExportDialogClicked() - { - if (modalExportdialogCuesheet != null) - { - await modalExportdialogCuesheet.Show(); - } - } - - async Task OnDisplayExportProfilesClicked() - { - if (modalExportdialogExportprofile != null) - { - await modalExportdialogExportprofile.Show(); - } - } - - private async Task DownloadProjectfileClicked() - { - if (applicationOptions == null) - { - applicationOptions = await _localStorageOptionsProvider.GetOptions(); - } - //Save ApplicationOptions with information from modal popup! - await _localStorageOptionsProvider.SaveOptions(applicationOptions); - var projectFile = new Projectfile(_sessionStateContainer.Cuesheet); - var fileData = projectFile.GenerateFile(); - await _blazorDownloadFileService.DownloadFile(applicationOptions.ProjectFilename, fileData, "text/plain"); - if (modalDownloadProjectfile != null) - { - await modalDownloadProjectfile.Hide(); - } - } - - async ValueTask OnEnterKeyDown() - { - if (modalDownloadProjectfileVisible) - { - await DownloadProjectfileClicked(); - } - } - - ValueTask OnCtrlHKeyDown() - { - if (ShortCutsEnabled) - { - _navigationManager.NavigateTo("Help"); - } - return ValueTask.CompletedTask; - } - - async ValueTask OnCtrlEKeyDown() - { - if (ShortCutsEnabled) - { - await OnDisplayExportProfilesClicked(); - } - } - - async ValueTask OnCtrlSKeyDown() - { - if ((ShortCutsEnabled) && (modalDownloadProjectfile != null)) - { - await modalDownloadProjectfile.Show(); - } - } - - private Task OnViewModeSelected(ViewMode selectedViewMode) - { - _sessionStateContainer.CurrentViewMode = selectedViewMode; - return Task.CompletedTask; - } - - private void LocalizationService_LocalizationChanged(object? sender, EventArgs args) - { - StateHasChanged(); - } - - private void TraceChangeManager_TracedObjectHistoryChanged(object? sender, EventArgs args) - { - StateHasChanged(); - } - - void TraceChangeManager_UndoDone(object? sender, EventArgs args) - { - StateHasChanged(); - } - - void TraceChangeManager_RedoDone(object? sender, EventArgs args) - { - StateHasChanged(); - } - - private void ModalDownloadProjectfile_VisibleChanged(Boolean visible) - { - modalDownloadProjectfileVisible = visible; - } - - async Task ControlModalDialog(Modal? dialog, Boolean show) - { - if (dialog != null) - { - if (show) - { - await dialog.Show(); - } - else - { - await dialog.Hide(); - } - } - } - - async Task OpenOptionsDialog(OptionsDialog? dialog) - { - if (dialog != null) - { - await dialog.Show(); - } - } - - void LocalStorageOptionsProvider_OptionSaved(object? sender, IOptions options) - { - if (options is ApplicationOptions) - { - applicationOptions = (ApplicationOptions)options; - } - if (options is ExportOptions) - { - exportOptions = (ExportOptions)options; - } - } - - void OnAddNewExportProfileClicked() - { - _logger.LogInformation("OnAddNewExportProfileClicked"); - if (exportOptions != null) - { - var newProfile = new Exportprofile(); - exportOptions.ExportProfiles.Add(newProfile); - exportOptions.SelectedExportProfile = newProfile; - } - Task.Run(SaveExportOptions); - } - - void OnDeleteExportProfileClicked() - { - _logger.LogInformation("OnDeleteExportProfileClicked"); - if (exportOptions?.SelectedExportProfile != null) - { - exportOptions.ExportProfiles.Remove(exportOptions.SelectedExportProfile); - exportOptions.SelectedExportProfile = exportOptions.ExportProfiles.LastOrDefault(); - } - Task.Run(SaveExportOptions); + base.OnInitialized(); + _localizationService.LocalizationChanged += LocalizationService_LocalizationChanged; } - void SelectedExportProfileChanged(Guid? newValue) + void LocalizationService_LocalizationChanged(object? sender, EventArgs args) { - _logger.LogInformation("SelectedExportProfileChanged with {0}", newValue); - if (exportOptions != null) - { - var selectedProfile = exportOptions.ExportProfiles.First(x => x.Id == newValue); - exportOptions.SelectedExportProfile = selectedProfile; - } - modalExportdialogExportprofile?.Validations?.ValidateAll().GetAwaiter().GetResult(); - modalExportdialogExportprofile?.Reset(); - Task.Run(SaveExportOptions); StateHasChanged(); } - async Task SaveExportOptions() - { - _logger.LogDebug("SaveExportOptions"); - if (exportOptions != null) - { - await _localStorageOptionsProvider.SaveOptions(exportOptions); - } - } - - async Task SaveApplicationOptions() - { - _logger.LogDebug("SaveApplicationOptions"); - if (applicationOptions != null) - { - await _localStorageOptionsProvider.SaveOptions(applicationOptions); - } - } - - void ModalExportdialogExportprofile_GenerateExportfilesClicked(object? sender, EventArgs args) - { - Task.Run(SaveExportOptions); - } - - void ModalExportdialogCuesheet_GenerateExportfilesClicked(object? sender, EventArgs args) - { - Task.Run(SaveApplicationOptions); - } - - Task OnApplicationOptionsCuesheetFilenameChanged(string value) - { - if (applicationOptions != null) - { - applicationOptions.CuesheetFilename = value; - } - if (modalExportdialogCuesheet != null) - { - modalExportdialogCuesheet.Reset(); - } - return Task.CompletedTask; - } - - async Task OnSelectedProfileNameChanged(string value) - { - if (exportOptions?.SelectedExportProfile != null) - { - exportOptions.SelectedExportProfile.Name = value; - } - modalExportdialogExportprofile?.Reset(); - await SaveExportOptions(); - } - - async Task OnSelectedExportProfileFilenameChanged(string value) - { - if (exportOptions?.SelectedExportProfile != null) - { - exportOptions.SelectedExportProfile.Filename = value; - } - modalExportdialogExportprofile?.Reset(); - await SaveExportOptions(); - } - - async Task OnSelectedExportProfileSchemeHeadChanged(string value) - { - if (exportOptions?.SelectedExportProfile != null) - { - exportOptions.SelectedExportProfile.SchemeHead = value; - } - modalExportdialogExportprofile?.Reset(); - await SaveExportOptions(); - } - - async Task OnSelectedExportProfileSchemeTracksChanged(string value) - { - if (exportOptions?.SelectedExportProfile != null) - { - exportOptions.SelectedExportProfile.SchemeTracks = value; - } - modalExportdialogExportprofile?.Reset(); - await SaveExportOptions(); - } - - async Task OnSelectedExportProfileSchemeFooterChanged(string value) - { - if (exportOptions?.SelectedExportProfile != null) - { - exportOptions.SelectedExportProfile.SchemeFooter = value; - } - modalExportdialogExportprofile?.Reset(); - await SaveExportOptions(); - } - - async Task DropDownItemSelected(string schemeName, string value) - { - if (exportOptions?.SelectedExportProfile != null) - { - switch (schemeName) - { - case nameof(Exportprofile.SchemeHead): - await OnSelectedExportProfileSchemeHeadChanged(exportOptions.SelectedExportProfile.SchemeHead += value); - break; - case nameof(Exportprofile.SchemeTracks): - await OnSelectedExportProfileSchemeTracksChanged(exportOptions.SelectedExportProfile.SchemeTracks += value); - break; - case nameof(Exportprofile.SchemeFooter): - await OnSelectedExportProfileSchemeFooterChanged(exportOptions.SelectedExportProfile.SchemeFooter += value); - break; - } - - } - } - async Task ReloadApplication() { await _jsRuntime.InvokeVoidAsync("removeBeforeunload"); _navigationManager.NavigateTo(_navigationManager.Uri, true); } - - Task SideBarToogleClicked() - { - sidebarVisible = !sidebarVisible; - if (sidebar != null) - { - sidebar.OnBreakpoint(sidebarVisible); - } - return Task.CompletedTask; - } - - Boolean ShortCutsEnabled - { - get - { - return !(_navigationManager.Uri.EndsWith("/help", StringComparison.InvariantCultureIgnoreCase)) && !(_navigationManager.Uri.EndsWith("/about", StringComparison.InvariantCultureIgnoreCase)); - } - } } \ No newline at end of file diff --git a/AudioCuesheetEditor/Shared/MainLayout.resx b/AudioCuesheetEditor/Shared/MainLayout.resx new file mode 100644 index 00000000..5348a143 --- /dev/null +++ b/AudioCuesheetEditor/Shared/MainLayout.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + An error has occured in this application. Please report this error with as much details as possible here: + + + Error details + + + Reload application + + \ No newline at end of file