Files
HC_APTBS/Views/Dialogs/UnlockProgressDialog.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

50 lines
1.6 KiB
C#

using System.ComponentModel;
using System.Windows;
using System.Windows.Input;
using HC_APTBS.ViewModels.Dialogs;
namespace HC_APTBS.Views.Dialogs
{
/// <summary>
/// Non-modal window showing immobilizer unlock progress.
/// Prevents user-initiated closing until the unlock sequence completes;
/// programmatic close via <see cref="ForceClose"/> always succeeds.
/// Equivalent to the old <c>WUnlocker</c> window.
/// </summary>
public partial class UnlockProgressDialog : Window
{
private bool _forceClose;
/// <summary>Creates the dialog and wires the ViewModel.</summary>
public UnlockProgressDialog(UnlockProgressViewModel vm)
{
InitializeComponent();
DataContext = vm;
vm.RequestClose += ForceClose;
}
/// <summary>Closes the window unconditionally (bypasses the completion guard).</summary>
public void ForceClose()
{
_forceClose = true;
Close();
}
/// <summary>Allows dragging the borderless window by clicking anywhere.</summary>
private void OnMouseDrag(object sender, MouseButtonEventArgs e)
{
if (e.ChangedButton == MouseButton.Left)
DragMove();
}
/// <summary>Prevents user-initiated closing while the unlock sequence is still running.</summary>
private void OnWindowClosing(object? sender, CancelEventArgs e)
{
if (_forceClose) return;
if (DataContext is UnlockProgressViewModel vm && !vm.IsComplete)
e.Cancel = true;
}
}
}