92 lines
3.2 KiB
Plaintext
92 lines
3.2 KiB
Plaintext
@inherits LayoutComponentBase
|
|
@implements IDisposable
|
|
@inject AutoForge.Application.Features.DisplayUnits.DisplayUnitPreferenceService DisplayUnits
|
|
|
|
<div class="app-shell">
|
|
<header class="site-header">
|
|
<a class="brand" href="/">AutoForge</a>
|
|
<nav aria-label="Main navigation">
|
|
<NavLink href="/" Match="NavLinkMatch.All">Home</NavLink>
|
|
<NavLink href="/execution-targets">Target selection</NavLink>
|
|
<NavLink href="/vehicle-profiles">Vehicle profiles</NavLink>
|
|
<NavLink href="/diagnostics">Synthetic diagnostics</NavLink>
|
|
<NavLink href="/simulation">Vehicle simulation</NavLink>
|
|
</nav>
|
|
<section aria-label="Display units">
|
|
<label for="display-unit-system">Unit system</label>
|
|
<select id="display-unit-system"
|
|
@bind:get="DisplayUnits.Selection.UnitSystem"
|
|
@bind:set="SetUnitSystem">
|
|
<option value="ImperialUS">Imperial (US)</option>
|
|
<option value="Metric">Metric</option>
|
|
</select>
|
|
<label for="display-speed-mode">Speed presentation</label>
|
|
<select id="display-speed-mode"
|
|
@bind:get="DisplayUnits.Selection.SpeedMode"
|
|
@bind:set="SetSpeedMode">
|
|
<option value="Road">Road</option>
|
|
<option value="Engineering">Engineering</option>
|
|
</select>
|
|
@if (DisplayUnits.Error is { } error)
|
|
{
|
|
<p id="display-unit-error" role="alert">@error</p>
|
|
}
|
|
else
|
|
{
|
|
<p id="display-unit-status" role="status">
|
|
@DisplayUnits.Selection.UnitSystem / @DisplayUnits.Selection.SpeedMode
|
|
@if (DisplayUnits.IsPersistedSelection)
|
|
{
|
|
<span> saved preference</span>
|
|
}
|
|
else
|
|
{
|
|
<span> first-use/default selection</span>
|
|
}
|
|
display; source data and model calculations remain unchanged.
|
|
</p>
|
|
}
|
|
</section>
|
|
</header>
|
|
|
|
<main id="main-content">
|
|
<CascadingValue Value="DisplayUnits.Selection">
|
|
@Body
|
|
</CascadingValue>
|
|
</main>
|
|
|
|
<footer>
|
|
Target selection is metadata only; it does not connect to a vehicle or authorize an operation.
|
|
</footer>
|
|
</div>
|
|
|
|
@code {
|
|
private bool _disposed;
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
DisplayUnits.Changed += OnDisplayUnitsChanged;
|
|
DisplayUnits.Initialize();
|
|
}
|
|
|
|
private void SetUnitSystem(AutoForge.Application.Features.DisplayUnits.DisplayUnitSystem value) =>
|
|
DisplayUnits.TrySet(DisplayUnits.Selection with { UnitSystem = value });
|
|
|
|
private void SetSpeedMode(AutoForge.Application.Features.DisplayUnits.SpeedDisplayMode value) =>
|
|
DisplayUnits.TrySet(DisplayUnits.Selection with { SpeedMode = value });
|
|
|
|
private void OnDisplayUnitsChanged() => _ = InvokeAsync(() =>
|
|
{
|
|
if (!_disposed)
|
|
{
|
|
StateHasChanged();
|
|
}
|
|
});
|
|
|
|
public void Dispose()
|
|
{
|
|
_disposed = true;
|
|
DisplayUnits.Changed -= OnDisplayUnitsChanged;
|
|
}
|
|
}
|