31 lines
2.2 KiB
Markdown
31 lines
2.2 KiB
Markdown
|
|
---
|
||
|
|
source_files:
|
||
|
|
- DataPRO/Modules/Groups/GroupChannelList/Converters/BooleanToWidthConverter.cs
|
||
|
|
- DataPRO/Modules/Groups/GroupChannelList/Converters/SensorIdBackgroundConverter.cs
|
||
|
|
generated_at: "2026-04-17T16:13:20.076259+00:00"
|
||
|
|
model: "zai-org/GLM-5-FP8"
|
||
|
|
schema_version: 1
|
||
|
|
sha256: "e25d08690ef1d9de"
|
||
|
|
---
|
||
|
|
|
||
|
|
# Converters
|
||
|
|
|
||
|
|
### Purpose
|
||
|
|
This module provides WPF value converters for the `GroupChannelList` UI component. It exists to transform data values into visual representations in XAML bindings, specifically converting boolean values to width measurements and background brush colors for sensor ID display elements.
|
||
|
|
|
||
|
|
### Public Interface
|
||
|
|
- **`BooleanToWidthConverter` class** (public) - Implements `IValueConverter`. Converts boolean values to width values for UI element sizing.
|
||
|
|
- `object Convert(object value, Type targetType, object parameter, CultureInfo culture)` - Returns `width` (parsed from parameter) if `value` is `true`, returns `0` if `value` is `false`, returns `0` if `value` is `null`. If parameter parsing fails, returns `double.NaN`.
|
||
|
|
- `object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)` - Throws `NotImplementedException`.
|
||
|
|
|
||
|
|
- **`SensorIdBackgroundConverter` class** (public) - Implements `IValueConverter`. Converts boolean values to background brush colors.
|
||
|
|
- `object Convert(object value, Type targetType, object parameter, CultureInfo culture)` - Returns a light green brush (`#FFE3FBE1`) if `value` is `true`, returns `Brushes.Transparent` if `value` is `false` or `null`. Catches and traces exceptions.
|
||
|
|
- `object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)` - Throws `NotImplementedException`.
|
||
|
|
|
||
|
|
### Invariants
|
||
|
|
- `ConvertBack` is not implemented on either converter; these are one-way converters only.
|
||
|
|
- `SensorIdBackgroundConverter.SensorIdBrush` is a static field that is frozen before return to make it thread-safe and non-modifiable.
|
||
|
|
|
||
|
|
### Dependencies
|
||
|
|
- **Depends on**: `System.Windows.Data.IValueConverter`, `System.Windows.Media.SolidColorBrush`, `System.Windows.Media.Color`, `System.Windows.Media.Brushes`, `System.Globalization.CultureInfo`, `System.Diagnostics.Trace`.
|
||
|
|
- **Depended on by**: XAML views in the `GroupChannelList
|