--- source_files: - Common/DTS.CommonCore/Converters/BooleanToBorderThicknessConverter.cs - Common/DTS.CommonCore/Converters/BooleanToBorderBrushConverter.cs - Common/DTS.CommonCore/Converters/BooleanOrMultiConverter.cs - Common/DTS.CommonCore/Converters/BooleanToGreenBorderConverter.cs - Common/DTS.CommonCore/Converters/DateTimeWithMillisecondsToStringConverter.cs - Common/DTS.CommonCore/Converters/EnumVisibilityConverter.cs - Common/DTS.CommonCore/Converters/InverseEnumVisibilityConverter.cs - Common/DTS.CommonCore/Converters/ActiveContentConverter.cs - Common/DTS.CommonCore/Converters/FaultedTextConverter.cs - Common/DTS.CommonCore/Converters/TriggerTextConverter.cs - Common/DTS.CommonCore/Converters/NullableFloatConverter.cs - Common/DTS.CommonCore/Converters/TriggerColorConverter.cs - Common/DTS.CommonCore/Converters/FaultedColorConverter.cs - Common/DTS.CommonCore/Converters/DateConverter.cs - Common/DTS.CommonCore/Converters/InverseEnumEnabledConverter.cs - Common/DTS.CommonCore/Converters/IsLessThanConverter.cs - Common/DTS.CommonCore/Converters/ListToStringConverter.cs - Common/DTS.CommonCore/Converters/IsGreaterThanConverter.cs - Common/DTS.CommonCore/Converters/NonZeroToColorConverter.cs - Common/DTS.CommonCore/Converters/HeightConverter.cs - Common/DTS.CommonCore/Converters/ErrorToBooleanConverter.cs - Common/DTS.CommonCore/Converters/WidthConverter.cs - Common/DTS.CommonCore/Converters/StringListToVisibilityConverter.cs - Common/DTS.CommonCore/Converters/StatusToBorderThicknessConverter.cs - Common/DTS.CommonCore/Converters/ArrayVisibilityConverter.cs - Common/DTS.CommonCore/Converters/ErrorToColorConverter.cs - Common/DTS.CommonCore/Converters/GreaterThanToBoolConverter.cs - Common/DTS.CommonCore/Converters/BooleanToColorConverter.cs - Common/DTS.CommonCore/Converters/BooleanToItalicFontStyleConverter.cs - Common/DTS.CommonCore/Converters/IntervalToVisibilityConverter.cs - Common/DTS.CommonCore/Converters/DiagStatusShuntColorConverter.cs - Common/DTS.CommonCore/Converters/DiagStatusOffsetColorConverter.cs - Common/DTS.CommonCore/Converters/InverseBooleanToOpacityConverter.cs - Common/DTS.CommonCore/Converters/StatusToColorConverter.cs - Common/DTS.CommonCore/Converters/ColorToSolidColorBrushConverter .cs - Common/DTS.CommonCore/Converters/BooleanAndToVisibiltyMultiConverter.cs - Common/DTS.CommonCore/Converters/BooleanOrToVisibilityMultiConverter.cs - Common/DTS.CommonCore/Converters/DoubleFromThousandthUnitToBaseUnit.cs - Common/DTS.CommonCore/Converters/BooleanToOpacityConverter.cs - Common/DTS.CommonCore/Converters/DASStatusArmTextConverter.cs - Common/DTS.CommonCore/Converters/EnumBooleanConverter.cs - Common/DTS.CommonCore/Converters/InitialOffsetToIEPESensorOffsetConverter.cs - Common/DTS.CommonCore/Converters/DASStatusColorConverter.cs - Common/DTS.CommonCore/Converters/DASStatusArmColorConverter .cs - Common/DTS.CommonCore/Converters/PercentConverter.cs - Common/DTS.CommonCore/Converters/NumericStringFormatConverter.cs - Common/DTS.CommonCore/Converters/VisibilityToRowHeightConverter.cs - Common/DTS.CommonCore/Converters/GroupImportErrorToStringConverter.cs - Common/DTS.CommonCore/Converters/GroupNameToVisibilityConverter.cs - Common/DTS.CommonCore/Converters/FilePathsToShortStringConverter.cs - Common/DTS.CommonCore/Converters/InverseBooleanConverter.cs - Common/DTS.CommonCore/Converters/EnumDescriptionTypeConverter.cs - Common/DTS.CommonCore/Converters/TestDataToRegionOfInterestMaximumConverter.cs generated_at: "2026-04-16T02:13:46.908964+00:00" model: "Qwen/Qwen3-Coder-Next-FP8" schema_version: 1 sha256: "8cec2e1657d13038" --- # DTS.Common.Converters Module Documentation ## 1. Purpose This module provides a collection of WPF `IValueConverter` and `IMultiValueConverter` implementations used for data binding in the DTS application UI. Its primary role is to transform raw data values (booleans, enums, numerics, dates, collections, etc.) into UI-appropriate representations (visibility, colors, text, dimensions, etc.) without modifying the underlying view models. These converters enable declarative UI logic in XAML, reducing code-behind and promoting separation of concerns. ## 2. Public Interface All converters are public classes in the `DTS.Common.Converters` namespace implementing `IValueConverter` or `IMultiValueConverter`. Only converters with non-trivial behavior or special parameters are listed with full detail. ### `BooleanToBorderThicknessConverter` ```csharp public class BooleanToBorderThicknessConverter : IValueConverter ``` - **Convert**: Returns `1` if input `bool` is `true`, otherwise `2`. - **ConvertBack**: Always returns `null`. ### `BooleanToBorderBrushConverter` ```csharp public class BooleanToBorderBrushConverter : IValueConverter ``` - **Convert**: Returns `BrushesAndColors.Brush_Warning` if input is non-null `true`; otherwise `Brushes.Transparent`. - **ConvertBack**: Always returns `null`. ### `BooleanOrMultiConverter` ```csharp public class BooleanOrMultiConverter : IMultiValueConverter ``` - **Convert**: Returns `true` if *any* input in the array is a non-null `bool` with value `true`; otherwise `false`. Validates all inputs are `bool` before evaluating. - **ConvertBack**: Throws `NotImplementedException`. ### `BooleanToGreenBorderConverter` ```csharp public class BooleanToGreenBorderConverter : IValueConverter ``` - **Convert**: Returns `BrushesAndColors.BrushApplicationStatusPowerGreen` if input is non-null `true`; otherwise `BrushesAndColors.BrushFlatControlDarkForeground`. - **ConvertBack**: Always returns `null`. ### `DateTimeWithMillisecondsToStringConverter` ```csharp public class DateTimeWithMillisecondsToStringConverter : IValueConverter ``` - **Convert**: Converts `DateTime` input to string via `Utils.Utils.FormatTimeStamp`. - **ConvertBack**: Always returns `null`. ### `EnumVisibilityConverter` ```csharp public class EnumVisibilityConverter : IValueConverter ``` - **Convert**: Returns `Visibility.Visible` if input `value` equals `parameter`; otherwise `Visibility.Hidden`. - **ConvertBack**: Returns `parameter` if input `value` is `Visibility.Visible`; otherwise `Binding.DoNothing`. ### `InverseEnumVisibilityConverter` ```csharp public class InverseEnumVisibilityConverter : IValueConverter ``` - **Convert**: Returns `Visibility.Hidden` if input `value` equals `parameter`; otherwise `Visibility.Visible`. - **ConvertBack**: Returns `parameter` if input `value` is `Visibility.Hidden`; otherwise `Binding.DoNothing`. ### `ActiveContentConverter` ```csharp public class ActiveContentConverter : IValueConverter ``` - **Convert/ConvertBack**: Returns input `value` if it is a `ContentControl`; otherwise `Binding.DoNothing`. ### `FaultedTextConverter` ```csharp public class FaultedTextConverter : IValueConverter ``` - **Convert**: Returns `Strings.Strings.Faulted` if input is `true`; `Strings.Strings.FaultsClear` if `false` or non-bool; defaults to `Strings.Strings.FaultsClear`. - **ConvertBack**: Always returns `null`. ### `TriggerTextConverter` ```csharp public class TriggerTextConverter : IValueConverter ``` - **Convert**: Returns `Strings.Strings.Triggered` if input is `true`; `Strings.Strings.TriggerClear` if `false` or non-bool; defaults to `Strings.Strings.TriggerClear`. - **ConvertBack**: Always returns `null`. ### `NullableFloatConverter` ```csharp public class NullableFloatConverter : IValueConverter ``` - **Convert**: Returns input `float` if non-null; otherwise `string.Empty`. - **ConvertBack**: Returns input `float` if non-null; otherwise `string.Empty`. ### `TriggerColorConverter` ```csharp public class TriggerColorConverter : IValueConverter ``` - **Convert**: Returns `BrushesAndColors.Brush_ApplicationStatus_Failed.Color` if input is `true`; `BrushesAndColors.Brush_ApplicationStatus_Waiting.Color` if `false`; `Brushes.Transparent.Color` otherwise. - **ConvertBack**: Always returns `null`. ### `FaultedColorConverter` ```csharp public class FaultedColorConverter : IValueConverter ``` - **Convert**: Returns `BrushesAndColors.Brush_ApplicationStatus_Failed.Color` if input is `true`; `BrushesAndColors.Brush_ApplicationStatus_Complete.Color` if `false`; `Brushes.Transparent.Color` otherwise. - **ConvertBack**: Always returns `null`. ### `DateConverter` ```csharp public class DateConverter : IValueConverter ``` - **Convert**: Returns input `DateTime` if non-null; otherwise `Strings.Strings.Table_NA`. - **ConvertBack**: Returns input `DateTime` if non-null; otherwise `Strings.Strings.Table_NA`. ### `InverseEnumEnabledConverter` ```csharp public class InverseEnumEnabledConverter : IValueConverter ``` - **Convert**: Returns `false` if input `value` equals `parameter`; otherwise `true`. - **ConvertBack**: Returns `parameter` if input `value` is `false`; otherwise `Binding.DoNothing`. ### `IsLessThanConverter` ```csharp public class IsLessThanConverter : IValueConverter ``` - **Convert**: Parses `value` and `parameter` as `decimal`; returns `true` if `value < parameter`. Defaults to `0` on parse failure. - **ConvertBack**: Returns `DependencyProperty.UnsetValue`. ### `ListToStringConverter` ```csharp public class ListToStringConverter : IValueConverter ``` - **Convert**: Joins `List` elements with `", "` separator. Throws `InvalidOperationException` if target is not `string` or input is `null`. - **ConvertBack**: Throws `NotImplementedException`. ### `IsGreaterThanConverter` ```csharp public class IsGreaterThanConverter : IValueConverter ``` - **Convert**: Parses `value` and `parameter` as `decimal`; returns `true` if `value > parameter`. Defaults to `0` on parse failure. - **ConvertBack**: Returns `DependencyProperty.UnsetValue`. ### `NonZeroToColorConverter` ```csharp public class NonZeroToColorConverter : IValueConverter ``` - **Convert**: Returns `BrushesAndColors.BrushApplicationStatusPowerGreen` if input string is `"0"`; `BrushesAndColors.BrushApplicationStatusPowerClear` if `"---"`; otherwise `BrushesAndColors.BrushApplicationStatusPowerRed`. - **ConvertBack**: Always returns `null`. ### `HeightConverter` ```csharp public class HeightConverter : MarkupExtension, IValueConverter ``` - **Convert**: Returns `value - parameter` (both converted to `double`/`int`). - **ConvertBack**: Always returns `null`. - **Note**: Implements `MarkupExtension` for XAML usage as `{local:HeightConverter}`. ### `ErrorToBooleanConverter` ```csharp class ErrorToBooleanConverter : IValueConverter // internal (class, not public) ``` - **Convert**: Returns `true` if input is non-null and non-empty string; `null` otherwise. - **ConvertBack**: Throws `NotImplementedException`. ### `WidthConverter` ```csharp public class WidthConverter : MarkupExtension, IValueConverter ``` - **Convert**: Returns `value * parameter` (both converted to `double`). - **ConvertBack**: Throws `NotImplementedException`. - **Note**: Implements `MarkupExtension`. ### `StringListToVisibilityConverter` ```csharp public class StringListToVisibilityConverter : IValueConverter ``` - **Convert**: Returns `Visibility.Visible` if input `List` is non-empty; `Visibility.Collapsed` otherwise. Throws `InvalidOperationException` if target is not `Visibility` or input is `null`. - **ConvertBack**: Throws `NotImplementedException`. ### `StatusToBorderThicknessConverter` ```csharp public class StatusToBorderThicknessConverter : IValueConverter ``` - **Convert**: Returns `2` if input `UIItemStatus` is `Success`, `Failed`, `Error`, or `Warning`; otherwise `1`. - **ConvertBack**: Always returns `null`. ### `ArrayVisibilityConverter` ```csharp public class ArrayVisibilityConverter : IValueConverter ``` - **Convert**: Returns `Visibility.Hidden` if input is `null`; `Visibility.Visible` if input is non-empty `IList` or `Array`; `Visibility.Collapsed` if empty; otherwise `Visibility.Visible`. - **ConvertBack**: Always returns `null`. ### `ErrorToColorConverter` ```csharp public class ErrorToColorConverter : IValueConverter ``` - **Convert**: Returns `new SolidColorBrush(Colors.Red)` if input is non-null non-empty string; `new SolidColorBrush(Colors.Black)` otherwise. - **ConvertBack**: Throws `NotImplementedException`. ### `GreaterEqualThanToBoolConverter` ```csharp public class GreaterEqualThanToBoolConverter : IValueConverter ``` - **Convert**: Returns `true` if `value >= parameter` for `int`, `double`, or `ushort` pairs; otherwise `false`. - **ConvertBack**: Always returns `false`. ### `BooleanToColorConverter` ```csharp public class BooleanToColorConverter : IValueConverter ``` - **Properties**: - `Background` (bool, default `false`) - `Inverted` (bool, default `false`) - `AttentionBrush` (bool, default `false`) - `WarningBrush` (bool, default `false`) - **Convert**: Applies inversion if `Inverted`; returns `BrushesAndColors.Brush_NoError` (or `Brushes.Transparent` if `Background`) if `true`; otherwise returns `Brush_Attention`, `Brush_Warning`, or `Brush_Error` based on flags. - **ConvertBack**: Always returns `null`. ### `BooleanToItalicFontStyleConverter` ```csharp public class BooleanToItalicFontStyleConverter : IValueConverter ``` - **Convert**: Returns `FontStyles.Italic` if input is non-null `true`; otherwise `FontStyles.Normal`. - **ConvertBack**: Always returns `null`. ### `IntervalToVisibilityConverter` ```csharp public class IntervalToVisibilityConverter : IValueConverter ``` - **Convert**: Returns `Visibility.Visible` if `value >= parameter` for `int`, `double`, or `ushort`; otherwise `Visibility.Collapsed`. - **ConvertBack**: Always returns `false`. ### `DiagStatusShuntColorConverter` ```csharp public class DiagStatusShuntColorConverter : IValueConverter ``` - **Convert**: Returns `Brush_ApplicationStatus_Idle` if input `DiagStatuses.NoResults`; `Brush_ApplicationStatus_Failed` if `FailedShunt` flag set; otherwise `Brush_ApplicationStatus_Complete`. - **ConvertBack**: Returns `parameter` if input is `true`; otherwise `Binding.DoNothing`. ### `DiagStatusOffsetColorConverter` ```csharp public class DiagStatusOffsetColorConverter : IValueConverter ``` - **Convert**: Returns `Brush_ApplicationStatus_Idle` if input `DiagStatuses.NoResults`; `Brush_ApplicationStatus_Failed` if `FailedOffset` flag set; otherwise `Brush_ApplicationStatus_Complete`. - **ConvertBack**: Returns `parameter` if input is `true`; otherwise `Binding.DoNothing`. ### `InverseBooleanToOpacityConverter` ```csharp public class InverseBooleanToOpacityConverter : IValueConverter ``` - **Convert**: Returns `1.0` if input is non-null `true`; otherwise `0.5`. - **ConvertBack**: Always returns `null`. ### `StatusToColorConverter` ```csharp public class StatusToColorConverter : IValueConverter ``` - **Convert**: Maps `UIItemStatus` to colors: - `None` → `Brushes.Black` - `Success` → `Brush_ApplicationStatus_Complete` - `Failed` → `Brush_ApplicationStatus_Failed` - `Error` → `Brushes.Red` - `Warning` → `Brushes.OrangeRed` - Default → `Brushes.Black` - **ConvertBack**: Always returns `null`. ### `ColorToSolidColorBrushConverter` ```csharp public class ColorToSolidColorBrushConverter : IValueConverter ``` - **Convert**: Returns `new SolidColorBrush(color)` if input is `Color`; otherwise `null`. - **ConvertBack**: Throws `NotImplementedException`. ### `BooleanAndToVisibilityMultiConverter` ```csharp public class BooleanAndToVisibilityMultiConverter : IMultiValueConverter ``` - **Convert**: Evaluates `values.All(val => (bool)val)`. Supports `parameter` flags `"FALSE"` (treat `false` as visible) and `"HIDE"` (use `Hidden` instead of `Collapsed`). - **ConvertBack**: Throws `NotImplementedException`. ### `BooleanOrToVisibilityMultiConverter` ```csharp public class BooleanOrToVisibilityMultiConverter : IMultiValueConverter ``` - **Convert**: Evaluates `values.Any(val => (bool)val)`. Same parameter flags as `BooleanAndToVisibilityMultiConverter`. - **ConvertBack**: Throws `NotImplementedException`. ### `DoubleFromThousandthUnitToBaseUnit` ```csharp public class DoubleFromThousandthUnitToBaseUnit : IValueConverter ``` - **Convert**: Returns `value / 1000.0` for `double`; `0D` otherwise (handles `NaN`). - **ConvertBack**: Returns `value * 1000.0` for `double`; `0D` otherwise. ### `BooleanToOpacityConverter` ```csharp public class BooleanToOpacityConverter : IValueConverter ``` - **Convert**: Returns `0.5` if input is non-null `true`; otherwise `1`. - **ConvertBack**: Always returns `null`. ### `DASStatusArmTextConverter` ```csharp public class DASStatusArmTextConverter : IValueConverter ``` - **Convert**: Maps `DASStatuses` to text: - `MissingNotBooted`, `BootedNotArmedYet`, `BootedNeverArmed`, `ReadyForDownload` → `Strings.Strings.Table_NA` or `Strings.Strings.NotArmed` - `ArmedReady`, `ArmedButFailedDiag` → `Strings.Strings.Armed` - **ConvertBack**: Returns `parameter` if input is `true`; otherwise `Binding.DoNothing`. ### `EnumBooleanConverter` ```csharp public class EnumBooleanConverter : IValueConverter ``` - **Convert**: Returns `true` if `value.Equals(parameter)`. - **ConvertBack**: Returns `parameter` if input is `true`; otherwise `Binding.DoNothing`. ### `InitialOffsetToIEPESensorOffsetConverter` ```csharp public class InitialOffsetToIEPESensorOffsetConverter : IValueConverter ``` - **Constants**: `IEPE_MIDPOINT = 12.25` - **Convert**: Returns `(value / 1000.0) + IEPE_MIDPOINT` for `double`; `0D` otherwise. - **ConvertBack**: Returns `(value - IEPE_MIDPOINT) * 1000.0` for `double`; `0D` otherwise. ### `DASStatusColorConverter` ```csharp public class DASStatusColorConverter : IValueConverter ``` - **Convert**: Maps `DASStatuses` to colors: - `MissingNotBooted` → `Brush_ApplicationStatus_Idle` - `BootedNotArmedYet` → `Brush_ApplicationStatus_Busy` - `BootedNeverArmed` → `Brush_ApplicationStatus_Failed` - `ArmedReady`, `ReadyForDownload` → `Brush_ApplicationStatus_Complete` - `ArmedButFailedDiag` → `Brush_ApplicationStatus_Failed` - **ConvertBack**: Returns `parameter` if input is `true`; otherwise `Binding.DoNothing`. ### `DASStatusArmColorConverter` ```csharp public class DASStatusArmColorConverter : IValueConverter ``` - **Convert**: Maps `DASStatuses` to colors: - `MissingNotBooted`, `BootedNotArmedYet`, `BootedNeverArmed` → `Brush_ApplicationStatus_Failed` - `ArmedReady` → `Brush_ApplicationStatus_Complete` - `ArmedButFailedDiag` → `Brush_ApplicationStatus_Busy` - `ReadyForDownload` → `Brush_ApplicationStatus_Idle` - **ConvertBack**: Returns `parameter` if input is `true`; otherwise `Binding.DoNothing`. ### `PercentConverter` ```csharp public class PercentConverter : IValueConverter ``` - **Convert**: Formats decimal as `"{0:F1}%"`. - **ConvertBack**: Throws `NotImplementedException`. ### `NumericStringFormatConverter` ```csharp public class NumericStringFormatConverter : IMultiValueConverter ``` - **Convert**: Takes two values: `[0]` numeric (`int`/`double`/`float`/`decimal`), `[1]` format string. Returns formatted string or `Strings.Strings.Table_NA` for `NaN`. Returns `null` on error. - **ConvertBack**: Throws `NotImplementedException`. ### `VisibilityToRowHeightConverter` ```csharp public class VisibilityToRowHeightConverter : DependencyObject, IValueConverter ``` - **Properties**: - `InvertSource` (bool, default `false`) - **Convert**: Returns `0` if input `Visibility.Collapsed`; otherwise returns `parameter` (or `0` if `null`). Inverts source if `InvertSource`. - **ConvertBack**: Always returns `null`. ### `GroupImportErrorToStringConverter` ```csharp public class GroupImportErrorToStringConverter : IValueConverter ``` - **Convert**: Returns `error.ExtraInfo` if input is `GroupImportError`; otherwise `string.Empty`. - **ConvertBack**: Throws `NotImplementedException`. ### `GroupNameToVisibilityConverter` ```csharp public class GroupNameToVisibilityConverter : IValueConverter ``` - **Convert**: Returns `Visibility.Visible` if input string starts with `"Graph"` (after trimming); otherwise `Visibility.Collapsed`. - **ConvertBack**: Always returns `null`. ### `FilePathsToShortStringConverter` ```csharp public class FilePathsToShortStringConverter : IValueConverter ``` - **Convert**: Returns `string.Empty` if input is `null` or empty; `Strings.Strings.MultipleFiles` if >1 path; otherwise `FileInfo.Name`. - **ConvertBack**: Throws `NotImplementedException`. ### `Inverse