diff --git a/Converters/NullToVisibilityConverter.cs b/Converters/NullToVisibilityConverter.cs new file mode 100644 index 0000000..a2e8516 --- /dev/null +++ b/Converters/NullToVisibilityConverter.cs @@ -0,0 +1,20 @@ +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; + +namespace HC_APTBS.Converters +{ + /// + /// Returns when the value is non-null, + /// and when the value is null. + /// + public sealed class NullToVisibilityConverter : IValueConverter + { + public object Convert(object? value, Type targetType, object parameter, CultureInfo culture) + => value is null ? Visibility.Collapsed : Visibility.Visible; + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + => throw new NotSupportedException(); + } +} diff --git a/MainWindow.xaml b/MainWindow.xaml index 3ce5a18..a893893 100644 --- a/MainWindow.xaml +++ b/MainWindow.xaml @@ -123,10 +123,12 @@ - - - - + + + + + + Pump: @@ -323,6 +348,7 @@ No WARNING disabled + Dismiss Generate Report diff --git a/Resources/Strings.es.xaml b/Resources/Strings.es.xaml index 5dfe0c4..d38262b 100644 --- a/Resources/Strings.es.xaml +++ b/Resources/Strings.es.xaml @@ -166,6 +166,31 @@ RPM T-ein 1/min + °C + µs + Pump Commands + ME + FBKW + Pre-inj + Live Data + RPM Bomba + T-hyb + T-ein + ME + FBKW + Tendencia RPM + Activo + Calibración Ralentí + Versión + DFI Actual + Códigos de Falla + Identificación + Marca + Sin bomba seleccionada + CAN + K-Line + Sin bomba seleccionada — seleccione una bomba para habilitar el diagnóstico. + Intento de desbloqueo rápido... Bomba: @@ -323,6 +348,7 @@ No ADVERTENCIA deshabilitado + Cerrar Generar Informe diff --git a/Resources/Styles.xaml b/Resources/Styles.xaml index 8fc9816..c806b27 100644 --- a/Resources/Styles.xaml +++ b/Resources/Styles.xaml @@ -1,9 +1,13 @@ + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:conv="clr-namespace:HC_APTBS.Converters"> + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - diff --git a/Views/Dialogs/UnlockProgressDialog.xaml.cs b/Views/Dialogs/UnlockProgressDialog.xaml.cs deleted file mode 100644 index eb7c181..0000000 --- a/Views/Dialogs/UnlockProgressDialog.xaml.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System.ComponentModel; -using System.Windows; -using System.Windows.Input; -using HC_APTBS.ViewModels.Dialogs; - -namespace HC_APTBS.Views.Dialogs -{ - /// - /// Non-modal window showing immobilizer unlock progress. - /// Prevents user-initiated closing until the unlock sequence completes; - /// programmatic close via always succeeds. - /// Equivalent to the old WUnlocker window. - /// - public partial class UnlockProgressDialog : Window - { - private bool _forceClose; - - /// Creates the dialog and wires the ViewModel. - public UnlockProgressDialog(UnlockProgressViewModel vm) - { - InitializeComponent(); - DataContext = vm; - vm.RequestClose += ForceClose; - } - - /// Closes the window unconditionally (bypasses the completion guard). - public void ForceClose() - { - _forceClose = true; - Close(); - } - - /// Allows dragging the borderless window by clicking anywhere. - private void OnMouseDrag(object sender, MouseButtonEventArgs e) - { - if (e.ChangedButton == MouseButton.Left) - DragMove(); - } - - /// Prevents user-initiated closing while the unlock sequence is still running. - private void OnWindowClosing(object? sender, CancelEventArgs e) - { - if (_forceClose) return; - - if (DataContext is UnlockProgressViewModel vm && !vm.IsComplete) - e.Cancel = true; - } - } -} diff --git a/Views/Pages/PumpPage.xaml b/Views/Pages/PumpPage.xaml index 7c4e68e..a5fddd3 100644 --- a/Views/Pages/PumpPage.xaml +++ b/Views/Pages/PumpPage.xaml @@ -4,262 +4,62 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:uc="clr-namespace:HC_APTBS.Views.UserControls" - xmlns:vm="clr-namespace:HC_APTBS.ViewModels.Pages" mc:Ignorable="d" - d:DesignHeight="780" d:DesignWidth="1100"> + d:DesignHeight="900" d:DesignWidth="1400"> - - - - - - + - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - + - - + + + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + - - + + + - - - - - - + + - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + diff --git a/Views/UserControls/DfiCalibrationCard.xaml b/Views/UserControls/DfiCalibrationCard.xaml new file mode 100644 index 0000000..d1b45ec --- /dev/null +++ b/Views/UserControls/DfiCalibrationCard.xaml @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Views/UserControls/DfiCalibrationCard.xaml.cs b/Views/UserControls/DfiCalibrationCard.xaml.cs new file mode 100644 index 0000000..dab08ca --- /dev/null +++ b/Views/UserControls/DfiCalibrationCard.xaml.cs @@ -0,0 +1,9 @@ +using System.Windows.Controls; + +namespace HC_APTBS.Views.UserControls +{ + public partial class DfiCalibrationCard : UserControl + { + public DfiCalibrationCard() => InitializeComponent(); + } +} diff --git a/Views/UserControls/DfiManageView.xaml b/Views/UserControls/DfiManageView.xaml deleted file mode 100644 index 8b57a6a..0000000 --- a/Views/UserControls/DfiManageView.xaml +++ /dev/null @@ -1,115 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Views/UserControls/UnlockPanelView.xaml.cs b/Views/UserControls/UnlockPanelView.xaml.cs deleted file mode 100644 index d5391a0..0000000 --- a/Views/UserControls/UnlockPanelView.xaml.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Windows.Controls; - -namespace HC_APTBS.Views.UserControls -{ - /// - /// Inline unlock panel (Pump page §3.e). DataContext is the - /// shared UnlockProgressViewModel also driving the floating - /// progress dialog. - /// - public partial class UnlockPanelView : UserControl - { - public UnlockPanelView() - { - InitializeComponent(); - } - } -} diff --git a/Views/UserControls/UnlockSnackbarView.xaml b/Views/UserControls/UnlockSnackbarView.xaml new file mode 100644 index 0000000..f2efc07 --- /dev/null +++ b/Views/UserControls/UnlockSnackbarView.xaml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Views/UserControls/UnlockSnackbarView.xaml.cs b/Views/UserControls/UnlockSnackbarView.xaml.cs new file mode 100644 index 0000000..5097468 --- /dev/null +++ b/Views/UserControls/UnlockSnackbarView.xaml.cs @@ -0,0 +1,54 @@ +using System; +using System.ComponentModel; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Threading; +using HC_APTBS.ViewModels.Dialogs; + +namespace HC_APTBS.Views.UserControls +{ + public partial class UnlockSnackbarView : UserControl + { + private DispatcherTimer? _autoHideTimer; + + public UnlockSnackbarView() + { + InitializeComponent(); + DataContextChanged += OnDataContextChanged; + } + + private void OnDataContextChanged(object sender, DependencyPropertyChangedEventArgs e) + { + if (e.OldValue is UnlockProgressViewModel oldVm) + oldVm.PropertyChanged -= OnVmPropertyChanged; + + if (e.NewValue is UnlockProgressViewModel newVm) + newVm.PropertyChanged += OnVmPropertyChanged; + } + + private void OnVmPropertyChanged(object? sender, PropertyChangedEventArgs e) + { + if (e.PropertyName != nameof(UnlockProgressViewModel.IsSuccess)) return; + if (DataContext is not UnlockProgressViewModel vm) return; + + if (vm.IsSuccess == true) + { + _autoHideTimer?.Stop(); + _autoHideTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(3) }; + _autoHideTimer.Tick += (_, _) => + { + _autoHideTimer!.Stop(); + if (vm.CloseCommand.CanExecute(null)) + vm.CloseCommand.Execute(null); + }; + _autoHideTimer.Start(); + } + } + + private void OnDismissClick(object sender, RoutedEventArgs e) + { + if (DataContext is UnlockProgressViewModel vm && vm.CloseCommand.CanExecute(null)) + vm.CloseCommand.Execute(null); + } + } +}