feat: developer tools page, auto-test orchestrator, BIP display, tests redesign
Bundles several feature streams that have been iterating on the working tree: - Developer Tools page (Debug-only via DEVELOPER_TOOLS symbol): hosts the identification card, manual KWP write + transaction log, ROM/EEPROM dump card with progress banner and completion message, persisted custom-commands library, persisted EEPROM passwords library. New service primitives: IKwpService.SendRawCustomAsync / ReadEepromAsync / ReadRomEepromAsync. Persistence mirrors the Clients XML pattern in two new files (custom_commands.xml, eeprom_passwords.xml). - Auto-test orchestrator (IAutoTestOrchestrator + AutoTestState): linear K-Line read -> unlock -> bench-on -> test sequence with snackbar UI and progress dialog VM, gated on dashboard alarms. - BIP-STATUS display: BipDisplayViewModel + BipDisplayView, RAM read at 0x0106 via IKwpService.ReadBipStatusAsync; status definitions in BipStatusDefinition. - Tests page redesign: TestSectionCard + PhaseTileView replacing the old TestPlanView/TestRunningView/TestDoneView/TestPreconditionsView/ TestSectionView controls and their VMs. - Pump command sliders: Fluent thick-track style with overhang thumb, click-anywhere-and-drag, mouse-wheel adjustment. - Window startup: app.manifest declares PerMonitorV2 DPI awareness, MainWindow installs a WM_GETMINMAXINFO hook in OnSourceInitialized and maximizes there (after the hook is in place) so the app fits the work area exactly on any display configuration. - Misc: PercentToPixelsConverter, seed_aliases.py one-shot pump-alias importer, tools/Import-BipStatus.ps1, kline_eeprom_spec.md and dump-functions reference docs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using HC_APTBS.Infrastructure.Logging;
|
||||
|
||||
namespace HC_APTBS.Services.Impl
|
||||
{
|
||||
@@ -14,11 +15,19 @@ namespace HC_APTBS.Services.Impl
|
||||
/// </remarks>
|
||||
public sealed class LocalizationService : ILocalizationService
|
||||
{
|
||||
private const string LogId = "LOCALIZATION";
|
||||
private const string EspUri = "pack://application:,,,/Resources/Strings.es.xaml";
|
||||
private const string EngUri = "pack://application:,,,/Resources/Strings.en.xaml";
|
||||
|
||||
private readonly IConfigurationService _config;
|
||||
private ResourceDictionary? _currentDictionary;
|
||||
private readonly IAppLogger _log;
|
||||
|
||||
// Single, persistent slot in Application.Resources.MergedDictionaries whose
|
||||
// Source we re-point on every language change. Mutating an existing
|
||||
// dictionary's Source triggers WPF's DynamicResource invalidation reliably,
|
||||
// whereas removing-and-adding entries can leave stale resolved values
|
||||
// depending on the dictionary's parent/owner state.
|
||||
private readonly ResourceDictionary _stringsSlot = new();
|
||||
|
||||
/// <inheritdoc />
|
||||
public string CurrentLanguage { get; private set; } = "ESP";
|
||||
@@ -30,9 +39,14 @@ namespace HC_APTBS.Services.Impl
|
||||
/// Initialises the localization service and loads the language
|
||||
/// stored in <see cref="Models.AppSettings.Language"/>.
|
||||
/// </summary>
|
||||
public LocalizationService(IConfigurationService config)
|
||||
public LocalizationService(IConfigurationService config, IAppLogger log)
|
||||
{
|
||||
_config = config;
|
||||
_log = log;
|
||||
|
||||
// Mount the persistent slot once. From here on we only update its Source.
|
||||
Application.Current.Resources.MergedDictionaries.Add(_stringsSlot);
|
||||
|
||||
// Load persisted language without saving (already persisted).
|
||||
LoadDictionary(_config.Settings.Language);
|
||||
}
|
||||
@@ -41,8 +55,12 @@ namespace HC_APTBS.Services.Impl
|
||||
public void SetLanguage(string languageCode)
|
||||
{
|
||||
var code = NormaliseCode(languageCode);
|
||||
_log.Info(LogId, $"SetLanguage('{languageCode}') -> normalised='{code}', current='{CurrentLanguage}'");
|
||||
if (code == CurrentLanguage)
|
||||
{
|
||||
_log.Info(LogId, "SetLanguage: already current, no-op.");
|
||||
return;
|
||||
}
|
||||
|
||||
LoadDictionary(code);
|
||||
|
||||
@@ -66,15 +84,20 @@ namespace HC_APTBS.Services.Impl
|
||||
var code = NormaliseCode(languageCode);
|
||||
var uri = code == "ENG" ? EngUri : EspUri;
|
||||
|
||||
var dict = new ResourceDictionary { Source = new Uri(uri, UriKind.Absolute) };
|
||||
try
|
||||
{
|
||||
_stringsSlot.Source = new Uri(uri, UriKind.Absolute);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_log.Error(LogId, $"LoadDictionary({code}) failed to load {uri}: {ex.Message}");
|
||||
return;
|
||||
}
|
||||
|
||||
var merged = Application.Current.Resources.MergedDictionaries;
|
||||
if (_currentDictionary != null)
|
||||
merged.Remove(_currentDictionary);
|
||||
|
||||
merged.Add(dict);
|
||||
_currentDictionary = dict;
|
||||
CurrentLanguage = code;
|
||||
|
||||
_log.Info(LogId,
|
||||
$"LoadDictionary({code}): {uri} loaded with {_stringsSlot.Count} keys.");
|
||||
}
|
||||
|
||||
private static string NormaliseCode(string code) =>
|
||||
|
||||
Reference in New Issue
Block a user