68 lines
1.9 KiB
C#
68 lines
1.9 KiB
C#
using Microsoft.JSInterop;
|
|
using System.Reflection;
|
|
|
|
namespace Duempelkas.App.Components.Layout;
|
|
|
|
public partial class MainLayout
|
|
{
|
|
private int fontScale = 100;
|
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
|
{
|
|
if (firstRender)
|
|
{
|
|
var value = await JS.InvokeAsync<int>("duempelkasReading.get");
|
|
fontScale = value is 75 or 125 or 150 or 200 ? value : 100;
|
|
StateHasChanged();
|
|
}
|
|
}
|
|
private async Task ApplyTextScale() => await JS.InvokeVoidAsync("duempelkasReading.set", fontScale);
|
|
#region Fields
|
|
|
|
private bool showAboutDialog;
|
|
|
|
#endregion
|
|
|
|
#region Properties
|
|
|
|
private static string AppBuildDate
|
|
{
|
|
get
|
|
{
|
|
var value = Assembly.GetEntryAssembly()?.GetCustomAttributes<AssemblyMetadataAttribute>()
|
|
.FirstOrDefault(attribute => attribute.Key == "BuildDate")?.Value;
|
|
return DateTimeOffset.TryParse(value, System.Globalization.CultureInfo.InvariantCulture,
|
|
System.Globalization.DateTimeStyles.AssumeUniversal, out var built)
|
|
? built.UtcDateTime.ToString("dd.MM.yyyy", System.Globalization.CultureInfo.InvariantCulture)
|
|
: "unbekannt";
|
|
}
|
|
}
|
|
|
|
private static string AppVersion
|
|
{
|
|
get
|
|
{
|
|
var entryAssembly = Assembly.GetEntryAssembly();
|
|
var infoVersion = entryAssembly?
|
|
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?
|
|
.InformationalVersion;
|
|
|
|
if (!string.IsNullOrWhiteSpace(infoVersion))
|
|
{
|
|
return infoVersion.Split('+')[0];
|
|
}
|
|
|
|
return entryAssembly?.GetName().Version?.ToString(2) ?? "1.0";
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Event Handlers
|
|
|
|
private void OpenAboutDialog() => showAboutDialog = true;
|
|
|
|
private void CloseAboutDialog() => showAboutDialog = false;
|
|
|
|
#endregion
|
|
}
|