From 2758501cad9d45fa4c41c4372d5a3d2f1022d4fd Mon Sep 17 00:00:00 2001 From: NeoCoderMatrix86 <40752681+NeoCoderMatrix86@users.noreply.github.com> Date: Fri, 20 Dec 2024 10:54:40 +0100 Subject: [PATCH] added navmenu --- AudioCuesheetEditor/Pages/About.razor | 14 +- AudioCuesheetEditor/Pages/Help.razor | 19 +-- AudioCuesheetEditor/Shared/AppBar.razor | 25 ++-- .../Shared/BaseLocalizedComponent.cs | 59 ++++++++ .../BaseLocalizedLayoutComponentBase.cs | 59 ++++++++ .../Shared/Layouts/MainLayout.razor | 23 +--- .../Layouts/MainLayoutWithoutMenu.razor | 21 +-- AudioCuesheetEditor/Shared/NavMenu.de.resx | 129 ++++++++++++++++++ AudioCuesheetEditor/Shared/NavMenu.razor | 38 ++++++ AudioCuesheetEditor/Shared/NavMenu.resx | 129 ++++++++++++++++++ .../Shared/ViewModes/ViewModeFull.razor | 19 +-- 11 files changed, 432 insertions(+), 103 deletions(-) create mode 100644 AudioCuesheetEditor/Shared/BaseLocalizedComponent.cs create mode 100644 AudioCuesheetEditor/Shared/Layouts/BaseLocalizedLayoutComponentBase.cs create mode 100644 AudioCuesheetEditor/Shared/NavMenu.de.resx create mode 100644 AudioCuesheetEditor/Shared/NavMenu.razor create mode 100644 AudioCuesheetEditor/Shared/NavMenu.resx diff --git a/AudioCuesheetEditor/Pages/About.razor b/AudioCuesheetEditor/Pages/About.razor index faa6ae4f..1ec14e9c 100644 --- a/AudioCuesheetEditor/Pages/About.razor +++ b/AudioCuesheetEditor/Pages/About.razor @@ -15,14 +15,13 @@ You should have received a copy of the GNU General Public License along with Foobar. If not, see . --> -@implements IDisposable +@inherits BaseLocalizedComponent @page "/about" @layout MainLayoutWithoutMenu @inject HttpClient _httpClient @inject IStringLocalizer _localizer -@inject LocalizationService _localizationService @_localizer["About AudioCuesheetEditor"] @_localizer["Version"]: @VersionString @@ -40,24 +39,13 @@ along with Foobar. If not, see @code { String? licence; - public void Dispose() - { - _localizationService.LocalizationChanged -= LocalizationService_LocalizationChanged; - } - protected override async Task OnInitializedAsync() { await base.OnInitializedAsync(); - _localizationService.LocalizationChanged += LocalizationService_LocalizationChanged; var licenceContent = await _httpClient.GetStringAsync("Licence.txt"); licence = Markdown.ToHtml(licenceContent); } - void LocalizationService_LocalizationChanged(object? sender, EventArgs args) - { - StateHasChanged(); - } - public String VersionString { get diff --git a/AudioCuesheetEditor/Pages/Help.razor b/AudioCuesheetEditor/Pages/Help.razor index a2c3a22c..fe58ef38 100644 --- a/AudioCuesheetEditor/Pages/Help.razor +++ b/AudioCuesheetEditor/Pages/Help.razor @@ -18,29 +18,12 @@ along with Foobar. If not, see @page "/Help" @layout MainLayoutWithoutMenu - -@implements IDisposable +@inherits BaseLocalizedComponent @inject IStringLocalizer _localizer -@inject LocalizationService _localizationService @_localizer["Help"] @code { //TODO - public void Dispose() - { - _localizationService.LocalizationChanged -= LocalizationService_LocalizationChanged; - } - - protected override void OnInitialized() - { - base.OnInitialized(); - _localizationService.LocalizationChanged += LocalizationService_LocalizationChanged; - } - - void LocalizationService_LocalizationChanged(object? sender, EventArgs args) - { - StateHasChanged(); - } } \ No newline at end of file diff --git a/AudioCuesheetEditor/Shared/AppBar.razor b/AudioCuesheetEditor/Shared/AppBar.razor index 3634f649..c9481506 100644 --- a/AudioCuesheetEditor/Shared/AppBar.razor +++ b/AudioCuesheetEditor/Shared/AppBar.razor @@ -16,10 +16,11 @@ along with Foobar. If not, see . --> +@inherits BaseLocalizedComponent + @inject NavigationManager _navigationManager @inject TraceChangeManager _traceChangeManager @inject IStringLocalizer _localizer -@inject LocalizationService _localizationService @if (DisplayMenu) @@ -31,18 +32,16 @@ along with Foobar. If not, see @if (DisplayUndoRedoButtonGroup) { - - - + + + @_localizer["Undo"] - - - - + + @_localizer["Redo"] - - - + + + } @@ -70,13 +69,13 @@ along with Foobar. If not, see async Task SelectedCultureChanged(string name) { - await _localizationService.ChangeLanguageAsync(name); + await base.LocalizationService.ChangeLanguageAsync(name); } String GetStyle(CultureInfo cultureInfo) { String style = "white-space: nowrap;"; - if (cultureInfo.Name == _localizationService.SelectedCulture.Name) + if (cultureInfo.Name == base.LocalizationService.SelectedCulture.Name) { style += "background-color: var(--mud-palette-info-lighten);"; } diff --git a/AudioCuesheetEditor/Shared/BaseLocalizedComponent.cs b/AudioCuesheetEditor/Shared/BaseLocalizedComponent.cs new file mode 100644 index 00000000..c97dd2cb --- /dev/null +++ b/AudioCuesheetEditor/Shared/BaseLocalizedComponent.cs @@ -0,0 +1,59 @@ +//This file is part of AudioCuesheetEditor. + +//AudioCuesheetEditor is free software: you can redistribute it and/or modify +//it under the terms of the GNU General Public License as published by +//the Free Software Foundation, either version 3 of the License, or +//(at your option) any later version. + +//AudioCuesheetEditor is distributed in the hope that it will be useful, +//but WITHOUT ANY WARRANTY; without even the implied warranty of +//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//GNU General Public License for more details. + +//You should have received a copy of the GNU General Public License +//along with Foobar. If not, see +//. +using AudioCuesheetEditor.Services.UI; +using Microsoft.AspNetCore.Components; + +namespace AudioCuesheetEditor.Shared +{ + public abstract class BaseLocalizedComponent : ComponentBase, IDisposable + { + private bool disposedValue; + + [Inject] + protected LocalizationService LocalizationService { get; set; } = default!; + + protected override void OnInitialized() + { + base.OnInitialized(); + LocalizationService.LocalizationChanged += LocalizationService_LocalizationChanged; + } + + void LocalizationService_LocalizationChanged(object? sender, EventArgs args) + { + StateHasChanged(); + } + + protected virtual void Dispose(bool disposing) + { + if (!disposedValue) + { + if (disposing) + { + LocalizationService.LocalizationChanged -= LocalizationService_LocalizationChanged; + } + + disposedValue = true; + } + } + + public void Dispose() + { + // Ändern Sie diesen Code nicht. Fügen Sie Bereinigungscode in der Methode "Dispose(bool disposing)" ein. + Dispose(disposing: true); + GC.SuppressFinalize(this); + } + } +} \ No newline at end of file diff --git a/AudioCuesheetEditor/Shared/Layouts/BaseLocalizedLayoutComponentBase.cs b/AudioCuesheetEditor/Shared/Layouts/BaseLocalizedLayoutComponentBase.cs new file mode 100644 index 00000000..63470c21 --- /dev/null +++ b/AudioCuesheetEditor/Shared/Layouts/BaseLocalizedLayoutComponentBase.cs @@ -0,0 +1,59 @@ +//This file is part of AudioCuesheetEditor. + +//AudioCuesheetEditor is free software: you can redistribute it and/or modify +//it under the terms of the GNU General Public License as published by +//the Free Software Foundation, either version 3 of the License, or +//(at your option) any later version. + +//AudioCuesheetEditor is distributed in the hope that it will be useful, +//but WITHOUT ANY WARRANTY; without even the implied warranty of +//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//GNU General Public License for more details. + +//You should have received a copy of the GNU General Public License +//along with Foobar. If not, see +//. +using AudioCuesheetEditor.Services.UI; +using Microsoft.AspNetCore.Components; + +namespace AudioCuesheetEditor.Shared.Layouts +{ + public class BaseLocalizedLayoutComponentBase: LayoutComponentBase, IDisposable + { + private bool disposedValue; + + [Inject] + protected LocalizationService LocalizationService { get; set; } = default!; + + protected override void OnInitialized() + { + base.OnInitialized(); + LocalizationService.LocalizationChanged += LocalizationService_LocalizationChanged; + } + + void LocalizationService_LocalizationChanged(object? sender, EventArgs args) + { + StateHasChanged(); + } + + protected virtual void Dispose(bool disposing) + { + if (!disposedValue) + { + if (disposing) + { + LocalizationService.LocalizationChanged -= LocalizationService_LocalizationChanged; + } + + disposedValue = true; + } + } + + public void Dispose() + { + // Ändern Sie diesen Code nicht. Fügen Sie Bereinigungscode in der Methode "Dispose(bool disposing)" ein. + Dispose(disposing: true); + GC.SuppressFinalize(this); + } + } +} diff --git a/AudioCuesheetEditor/Shared/Layouts/MainLayout.razor b/AudioCuesheetEditor/Shared/Layouts/MainLayout.razor index 6b946e10..3b0396ec 100644 --- a/AudioCuesheetEditor/Shared/Layouts/MainLayout.razor +++ b/AudioCuesheetEditor/Shared/Layouts/MainLayout.razor @@ -16,13 +16,10 @@ along with Foobar. If not, see . --> -@inherits LayoutComponentBase - -@implements IDisposable +@inherits BaseLocalizedLayoutComponentBase @inject NavigationManager _navigationManager @inject IStringLocalizer _localizer -@inject LocalizationService _localizationService @inject IJSRuntime _jsRuntime @* Required *@ @@ -41,7 +38,7 @@ along with Foobar. If not, see - @*NavMenu*@ + @Body @@ -71,22 +68,6 @@ along with Foobar. If not, see _drawerOpen = !_drawerOpen; } - public void Dispose() - { - _localizationService.LocalizationChanged -= LocalizationService_LocalizationChanged; - } - - protected override void OnInitialized() - { - base.OnInitialized(); - _localizationService.LocalizationChanged += LocalizationService_LocalizationChanged; - } - - void LocalizationService_LocalizationChanged(object? sender, EventArgs args) - { - StateHasChanged(); - } - async Task ReloadApplication() { await _jsRuntime.InvokeVoidAsync("removeBeforeunload"); diff --git a/AudioCuesheetEditor/Shared/Layouts/MainLayoutWithoutMenu.razor b/AudioCuesheetEditor/Shared/Layouts/MainLayoutWithoutMenu.razor index 10fadd94..c3af3813 100644 --- a/AudioCuesheetEditor/Shared/Layouts/MainLayoutWithoutMenu.razor +++ b/AudioCuesheetEditor/Shared/Layouts/MainLayoutWithoutMenu.razor @@ -16,13 +16,10 @@ along with Foobar. If not, see . --> -@inherits LayoutComponentBase - -@implements IDisposable +@inherits BaseLocalizedLayoutComponentBase @inject NavigationManager _navigationManager @inject IStringLocalizer _localizer -@inject LocalizationService _localizationService @inject IJSRuntime _jsRuntime @* Required *@ @@ -60,22 +57,6 @@ along with Foobar. If not, see @code { - public void Dispose() - { - _localizationService.LocalizationChanged -= LocalizationService_LocalizationChanged; - } - - protected override void OnInitialized() - { - base.OnInitialized(); - _localizationService.LocalizationChanged += LocalizationService_LocalizationChanged; - } - - void LocalizationService_LocalizationChanged(object? sender, EventArgs args) - { - StateHasChanged(); - } - async Task ReloadApplication() { await _jsRuntime.InvokeVoidAsync("removeBeforeunload"); diff --git a/AudioCuesheetEditor/Shared/NavMenu.de.resx b/AudioCuesheetEditor/Shared/NavMenu.de.resx new file mode 100644 index 00000000..1fbbc3ff --- /dev/null +++ b/AudioCuesheetEditor/Shared/NavMenu.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 + + + Bearbeiten + + + Wiederherstellen + + + Rückgängig + + \ No newline at end of file diff --git a/AudioCuesheetEditor/Shared/NavMenu.razor b/AudioCuesheetEditor/Shared/NavMenu.razor new file mode 100644 index 00000000..d22f2432 --- /dev/null +++ b/AudioCuesheetEditor/Shared/NavMenu.razor @@ -0,0 +1,38 @@ + +@inherits BaseLocalizedComponent + +@inject IStringLocalizer _localizer +@inject TraceChangeManager _traceChangeManager + + + + @_localizer["Undo"] + @_localizer["Redo"] + + + @_localizer["Cuesheetfile"] + @_localizer["Projectfile"] + @_localizer["Other"] + + + +@code { + //TODO: export onclick + //TODO: Colors +} diff --git a/AudioCuesheetEditor/Shared/NavMenu.resx b/AudioCuesheetEditor/Shared/NavMenu.resx new file mode 100644 index 00000000..31aef69d --- /dev/null +++ b/AudioCuesheetEditor/Shared/NavMenu.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 + + + Edit + + + Redo + + + Undo + + \ No newline at end of file diff --git a/AudioCuesheetEditor/Shared/ViewModes/ViewModeFull.razor b/AudioCuesheetEditor/Shared/ViewModes/ViewModeFull.razor index 2d2923c3..79ea78aa 100644 --- a/AudioCuesheetEditor/Shared/ViewModes/ViewModeFull.razor +++ b/AudioCuesheetEditor/Shared/ViewModes/ViewModeFull.razor @@ -15,10 +15,9 @@ You should have received a copy of the GNU General Public License along with Foobar. If not, see . --> -@implements IDisposable +@inherits BaseLocalizedComponent @inject IStringLocalizer _localizer -@inject LocalizationService _localizationService @@ -57,20 +56,4 @@ along with Foobar. If not, see Boolean cuesheetDataExpanded = false; Boolean cuesheetTracksExpanded = false; AudioPlayer? audioPlayer; - - public void Dispose() - { - _localizationService.LocalizationChanged -= LocalizationService_LocalizationChanged; - } - - protected override void OnInitialized() - { - base.OnInitialized(); - _localizationService.LocalizationChanged += LocalizationService_LocalizationChanged; - } - - void LocalizationService_LocalizationChanged(object? sender, EventArgs args) - { - StateHasChanged(); - } }