Skip to content

Commit

Permalink
added navmenu
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoCoderMatrix86 committed Dec 20, 2024
1 parent 2cda1bb commit 2758501
Show file tree
Hide file tree
Showing 11 changed files with 432 additions and 103 deletions.
14 changes: 1 addition & 13 deletions AudioCuesheetEditor/Pages/About.razor
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ You should have received a copy of the GNU General Public License
along with Foobar. If not, see
<http: //www.gnu.org/licenses />.
-->
@implements IDisposable
@inherits BaseLocalizedComponent

@page "/about"
@layout MainLayoutWithoutMenu

@inject HttpClient _httpClient
@inject IStringLocalizer<About> _localizer
@inject LocalizationService _localizationService

<MudText Typo="Typo.h3">@_localizer["About AudioCuesheetEditor"]</MudText>
<MudText Typo="Typo.h5">@_localizer["Version"]: @VersionString</MudText>
Expand All @@ -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
Expand Down
19 changes: 1 addition & 18 deletions AudioCuesheetEditor/Pages/Help.razor
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,12 @@ along with Foobar. If not, see

@page "/Help"
@layout MainLayoutWithoutMenu

@implements IDisposable
@inherits BaseLocalizedComponent

@inject IStringLocalizer<Help> _localizer
@inject LocalizationService _localizationService

<MudText Typo="Typo.h1">@_localizer["Help"]</MudText>

@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();
}
}
25 changes: 12 additions & 13 deletions AudioCuesheetEditor/Shared/AppBar.razor
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ along with Foobar. If not, see
<http: //www.gnu.org/licenses />.
-->

@inherits BaseLocalizedComponent

@inject NavigationManager _navigationManager
@inject TraceChangeManager _traceChangeManager
@inject IStringLocalizer<AppBar> _localizer
@inject LocalizationService _localizationService

<MudAppBar Elevation="1" Color="Color.Dark" Fixed>
@if (DisplayMenu)
Expand All @@ -31,18 +32,16 @@ along with Foobar. If not, see
</MudButton>
@if (DisplayUndoRedoButtonGroup)
{
<MudButtonGroup Color="Color.Primary" Variant="Variant.Filled" OverrideStyles>
<MudButton StartIcon="@Icons.Material.Outlined.Undo" Disabled="!_traceChangeManager.CanUndo" OnClick="() => _traceChangeManager.Undo()">
<MudHidden Breakpoint="Breakpoint.SmAndDown">
<MudHidden Breakpoint="Breakpoint.Xs">
<MudButtonGroup Color="Color.Primary" Variant="Variant.Filled" OverrideStyles>
<MudButton StartIcon="@Icons.Material.Outlined.Undo" Disabled="!_traceChangeManager.CanUndo" OnClick="() => _traceChangeManager.Undo()">
@_localizer["Undo"]
</MudHidden>
</MudButton>
<MudButton StartIcon="@Icons.Material.Outlined.Redo" Disabled="!_traceChangeManager.CanRedo" OnClick="() => _traceChangeManager.Redo()">
<MudHidden Breakpoint="Breakpoint.SmAndDown">
</MudButton>
<MudButton StartIcon="@Icons.Material.Outlined.Redo" Disabled="!_traceChangeManager.CanRedo" OnClick="() => _traceChangeManager.Redo()">
@_localizer["Redo"]
</MudHidden>
</MudButton>
</MudButtonGroup>
</MudButton>
</MudButtonGroup>
</MudHidden>
}
<MudSpacer />
<MudMenu Icon="@Icons.Material.Outlined.Language" Color="Color.Inherit" AriaLabel="@_localizer["Change language"]" TransformOrigin="Origin.TopCenter">
Expand Down Expand Up @@ -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);";
}
Expand Down
59 changes: 59 additions & 0 deletions AudioCuesheetEditor/Shared/BaseLocalizedComponent.cs
Original file line number Diff line number Diff line change
@@ -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
//<http: //www.gnu.org/licenses />.
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);
}
}
}
Original file line number Diff line number Diff line change
@@ -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
//<http: //www.gnu.org/licenses />.
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);
}
}
}
23 changes: 2 additions & 21 deletions AudioCuesheetEditor/Shared/Layouts/MainLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@ along with Foobar. If not, see
<http: //www.gnu.org/licenses />.
-->

@inherits LayoutComponentBase

@implements IDisposable
@inherits BaseLocalizedLayoutComponentBase

@inject NavigationManager _navigationManager
@inject IStringLocalizer<MainLayout> _localizer
@inject LocalizationService _localizationService
@inject IJSRuntime _jsRuntime

@* Required *@
Expand All @@ -41,7 +38,7 @@ along with Foobar. If not, see
<MudLayout>
<AppBar DisplayMenu DisplayUndoRedoButtonGroup MenuClicked="() => DrawerToggle()" />
<MudDrawer @bind-Open="_drawerOpen" ClipMode="DrawerClipMode.Always" Elevation="2">
@*NavMenu*@
<NavMenu />
</MudDrawer>
<MudMainContent>
@Body
Expand Down Expand Up @@ -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");
Expand Down
21 changes: 1 addition & 20 deletions AudioCuesheetEditor/Shared/Layouts/MainLayoutWithoutMenu.razor
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@ along with Foobar. If not, see
<http: //www.gnu.org/licenses />.
-->

@inherits LayoutComponentBase

@implements IDisposable
@inherits BaseLocalizedLayoutComponentBase

@inject NavigationManager _navigationManager
@inject IStringLocalizer<MainLayout> _localizer
@inject LocalizationService _localizationService
@inject IJSRuntime _jsRuntime

@* Required *@
Expand Down Expand Up @@ -60,22 +57,6 @@ along with Foobar. If not, see
</ErrorBoundary>

@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");
Expand Down
Loading

0 comments on commit 2758501

Please sign in to comment.