Files
HC_APTBS/Views/UserControls/PhaseTileView.xaml
LucianoDev 827b811b39 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>
2026-05-07 13:59:50 +02:00

206 lines
11 KiB
XML

<UserControl x:Class="HC_APTBS.Views.UserControls.PhaseTileView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:uc="clr-namespace:HC_APTBS.Views.UserControls"
xmlns:vm="clr-namespace:HC_APTBS.ViewModels"
mc:Ignorable="d"
x:Name="Root"
d:DataContext="{d:DesignInstance Type=vm:PhaseCardViewModel, IsDesignTimeCreatable=False}">
<!--
Fluent phase tile used by both the Plan and Running steps. Set
Compact="true" in Plan to collapse the vertical indicators (showing the
receive parameter list as chips instead) and keep the tile short.
The hover tooltip replaces the old "Show values" toggle globally.
-->
<UserControl.Resources>
<BooleanToVisibilityConverter x:Key="BoolToVis"/>
<DataTemplate DataType="{x:Type vm:OperationValueViewModel}">
<Grid Margin="0,1,0,1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Name}" FontSize="11"
Foreground="{DynamicResource TextFillColorSecondaryBrush}"/>
<TextBlock Grid.Column="2"
Text="{Binding Value, StringFormat=F1}"
FontSize="11" FontFamily="Consolas"
Margin="12,0,0,0"
Foreground="{DynamicResource TextFillColorPrimaryBrush}"/>
</Grid>
</DataTemplate>
<!-- Full vertical indicator (used when NOT compact) -->
<DataTemplate x:Key="FullIndicator" DataType="{x:Type vm:GraphicIndicatorViewModel}">
<uc:GraphicIndicatorView/>
</DataTemplate>
<!-- Compact chip (name + expected±tolerance) for Plan step -->
<DataTemplate x:Key="CompactIndicator" DataType="{x:Type vm:GraphicIndicatorViewModel}">
<Border Background="{DynamicResource ControlFillColorSecondaryBrush}"
BorderBrush="{DynamicResource ControlStrokeColorDefaultBrush}"
BorderThickness="1" CornerRadius="8" Padding="6,1"
Margin="0,1,3,1">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding ParameterName}" FontSize="10"
Foreground="{DynamicResource TextFillColorPrimaryBrush}"/>
<TextBlock Text=":" FontSize="10" Margin="1,0,2,0"
Foreground="{DynamicResource TextFillColorSecondaryBrush}"/>
<TextBlock FontSize="10" FontFamily="Consolas"
Foreground="{DynamicResource TextFillColorSecondaryBrush}">
<Run Text="{Binding ExpectedValue, StringFormat=F1, Mode=OneWay}"/>
<Run Text="±"/>
<Run Text="{Binding Tolerance, StringFormat=F1, Mode=OneWay}"/>
</TextBlock>
</StackPanel>
</Border>
</DataTemplate>
</UserControl.Resources>
<Border MinWidth="84"
Cursor="Hand"
ToolTipService.InitialShowDelay="200"
ToolTipService.ShowDuration="30000"
ToolTipService.Placement="Right">
<Border.InputBindings>
<MouseBinding Gesture="LeftClick"
Command="{Binding ToggleEnabledCommand}"/>
</Border.InputBindings>
<Border.Style>
<Style TargetType="Border" BasedOn="{StaticResource PhaseTile}">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="{DynamicResource ControlFillColorSecondaryBrush}"/>
<Setter Property="BorderBrush" Value="{DynamicResource AccentControlElevationBorderBrush}"/>
</Trigger>
<DataTrigger Binding="{Binding IsActive}" Value="True">
<Setter Property="Background" Value="#FFE082"/>
<Setter Property="BorderBrush" Value="#F9A825"/>
</DataTrigger>
<DataTrigger Binding="{Binding IsPassed}" Value="True">
<Setter Property="Background" Value="#C8E6C9"/>
<Setter Property="BorderBrush" Value="#388E3C"/>
</DataTrigger>
<DataTrigger Binding="{Binding IsFailed}" Value="True">
<Setter Property="Background" Value="#FFCDD2"/>
<Setter Property="BorderBrush" Value="#C62828"/>
</DataTrigger>
<DataTrigger Binding="{Binding IsEnabled}" Value="False">
<Setter Property="Background" Value="#3F808080"/>
<Setter Property="BorderBrush" Value="#60808080"/>
<Setter Property="Opacity" Value="0.6"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
<Border.ToolTip>
<ToolTip Padding="10" MaxWidth="260">
<StackPanel>
<TextBlock Text="{Binding Name}"
FontSize="13" FontWeight="SemiBold"
Foreground="{DynamicResource TextFillColorPrimaryBrush}"
Margin="0,0,0,4"/>
<TextBlock Text="{DynamicResource Test.Critical}"
FontSize="10" FontWeight="Bold" Foreground="#E65100"
Margin="0,0,0,6"
Visibility="{Binding IsCritical, Converter={StaticResource BoolToVis}}"/>
<StackPanel Visibility="{Binding ReadyValues.Count, FallbackValue=Collapsed}">
<TextBlock Text="{DynamicResource Test.Required}"
FontSize="10" FontWeight="SemiBold"
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
Margin="0,2,0,2"/>
<ItemsControl ItemsSource="{Binding ReadyValues}" Margin="0,0,0,4"/>
</StackPanel>
<StackPanel Visibility="{Binding OperationValues.Count, FallbackValue=Collapsed}">
<TextBlock Text="{DynamicResource Test.TestLabel}"
FontSize="10" FontWeight="SemiBold"
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
Margin="0,2,0,2"/>
<ItemsControl ItemsSource="{Binding OperationValues}"/>
</StackPanel>
</StackPanel>
</ToolTip>
</Border.ToolTip>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- Row 0: name + critical dot (click the tile to toggle IsEnabled) -->
<Grid Margin="0,0,0,2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0"
Text="{Binding Name}"
FontSize="11" FontWeight="SemiBold"
Foreground="{DynamicResource TextFillColorPrimaryBrush}"
TextTrimming="CharacterEllipsis"
VerticalAlignment="Center"/>
<Border Grid.Column="1"
Width="8" Height="8" CornerRadius="4"
Background="#E65100" Margin="4,0,0,0"
VerticalAlignment="Center"
ToolTip="{DynamicResource Test.Critical}"
Visibility="{Binding IsCritical, Converter={StaticResource BoolToVis}}"/>
</Grid>
<!-- Row 1: indicators — compact chips when Compact=true, else full bars -->
<ItemsControl Grid.Row="1" ItemsSource="{Binding ResultIndicators}"
Margin="0,2,0,0">
<ItemsControl.Style>
<Style TargetType="ItemsControl">
<Setter Property="ItemTemplate" Value="{StaticResource FullIndicator}"/>
<Style.Triggers>
<DataTrigger Binding="{Binding Compact, ElementName=Root}" Value="True">
<Setter Property="ItemTemplate" Value="{StaticResource CompactIndicator}"/>
</DataTrigger>
</Style.Triggers>
</Style>
</ItemsControl.Style>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" HorizontalAlignment="Center"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
<!-- Row 2: result label -->
<TextBlock Grid.Row="2"
Visibility="Collapsed"
Text="{Binding ResultText}"
FontSize="11" FontWeight="SemiBold"
HorizontalAlignment="Center"
Margin="0,3,0,0">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="Foreground"
Value="{DynamicResource TextFillColorSecondaryBrush}"/>
<Style.Triggers>
<DataTrigger Binding="{Binding IsPassed}" Value="True">
<Setter Property="Foreground" Value="#2E7D32"/>
</DataTrigger>
<DataTrigger Binding="{Binding IsFailed}" Value="True">
<Setter Property="Foreground" Value="#B71C1C"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Grid>
</Border>
</UserControl>