Files
HC_APTBS/App.xaml.cs
LucianoDev 37d099cdbd feat: add Ford VP44 unlock progress dialog, K-Line fast unlock, localization, safety dialogs, and settings
Unlock progress UI:
- UnlockProgressDialog with dark-themed progress ring, phase indicator, elapsed
  time, and cancel/close buttons (non-modal, draggable borderless window)
- UnlockProgressViewModel with event-driven progress tracking via IUnlockService
- Triggers on pump selection (manual or K-Line auto-detect), not test start

UnlockService rewrite:
- Persistent CAN senders that outlive the unlock sequence (StopSenders on pump change)
- Concurrent K-Line fast unlock: awaits session Connected, sends RAM timer shortcut
  ({02 88 02 03 A8 01 00}), verifies via CAN TestUnlock before skipping wait
- Fix Type 1 verification (Value == 0 means unlocked, was inverted)

K-Line fast unlock support:
- IKwpService.TryFastUnlockAsync / KwpService implementation

Additional features:
- ILocalizationService with ES/EN resource dictionaries and runtime switching
- Safety dialogs: VoltageWarning, OilPumpConfirm, RpmSafetyWarning
- SettingsDialog for app configuration
- BenchService enhancements, ConfigurationService improvements, PDF report updates
- All UI strings localized via DynamicResource

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-16 13:22:48 +02:00

81 lines
3.5 KiB
C#

using System.Windows;
using HC_APTBS.Infrastructure.Logging;
using HC_APTBS.Infrastructure.Pcan;
using HC_APTBS.Services;
using HC_APTBS.Services.Impl;
using HC_APTBS.ViewModels;
using Microsoft.Extensions.DependencyInjection;
using Peak.Can.Basic;
namespace HC_APTBS;
/// <summary>
/// Application entry-point and DI container host.
///
/// <para>
/// Registers all services, ViewModels, and the main window with
/// <see cref="ServiceCollection"/>, then resolves and shows <see cref="MainWindow"/>
/// on startup. The container is disposed when the application exits.
/// </para>
/// </summary>
public partial class App : Application
{
private ServiceProvider? _serviceProvider;
protected override async void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
var services = new ServiceCollection();
ConfigureServices(services);
_serviceProvider = services.BuildServiceProvider();
// Initialise the ViewModel (loads pump IDs, starts refresh timer, connects CAN).
var mainVm = _serviceProvider.GetRequiredService<MainViewModel>();
await mainVm.InitialiseAsync();
var window = _serviceProvider.GetRequiredService<MainWindow>();
window.Show();
}
protected override void OnExit(ExitEventArgs e)
{
_serviceProvider?.Dispose();
base.OnExit(e);
}
// ── Service registration ──────────────────────────────────────────────────
private static void ConfigureServices(IServiceCollection services)
{
// ── Infrastructure ────────────────────────────────────────────────────
services.AddSingleton<IAppLogger, AppLogger>();
// PcanAdapter requires a channel handle and baudrate read from configuration.
services.AddSingleton<ICanService>(sp =>
{
var cfg = sp.GetRequiredService<IConfigurationService>();
var logger = sp.GetRequiredService<IAppLogger>();
var channel = cfg.Bench.Channel;
// Default to 500 kbps; the channel can switch at runtime via ICanService.SwitchBaudrate.
return new PcanAdapter(channel, TPCANBaudrate.PCAN_BAUD_500K, logger);
});
services.AddSingleton<IKwpService, KwpService>();
// ── Application services ──────────────────────────────────────────────
services.AddSingleton<IConfigurationService, ConfigurationService>();
services.AddSingleton<IBenchService, BenchService>();
services.AddSingleton<IUnlockService, UnlockService>();
services.AddSingleton<ICalibrationService, CalibrationService>();
services.AddSingleton<IPdfService, PdfService>();
services.AddSingleton<ILocalizationService, LocalizationService>();
// ── ViewModels ────────────────────────────────────────────────────────
services.AddSingleton<MainViewModel>();
// ── Views ─────────────────────────────────────────────────────────────
services.AddSingleton<MainWindow>();
}
}