20 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
2026-04-17T15:26:50.716956+00:00 | zai-org/GLM-5-FP8 | 1 | 3c372e9a540e3118 |
DTS.Common.Converters Documentation
1. Purpose
This module provides a comprehensive collection of WPF value converters for data binding transformations in the DTS application. It bridges the gap between domain models and UI presentation by converting values such as booleans, enums, numeric types, and collections into UI-appropriate representations like Visibility, Brush, Thickness, and formatted strings. The converters support common scenarios including conditional visibility, status indication colors, numeric comparisons, and localization-aware enum display.
2. Public Interface
Boolean Converters
| Class | Signature | Behavior |
|---|---|---|
BooleanToBorderThicknessConverter |
Convert(object, Type, object, CultureInfo) → object |
Returns 1 when input bool is true, 2 when false. |
BooleanToBorderBrushConverter |
Convert(object, Type, object, CultureInfo) → object |
Returns BrushesAndColors.Brush_Warning when true, Brushes.Transparent when false or null. |
BooleanToGreenBorderConverter |
Convert(object, Type, object, CultureInfo) → object |
Returns BrushesAndColors.BrushApplicationStatusPowerGreen when true, BrushesAndColors.BrushFlatControlDarkForeground when false or null. |
BooleanToColorConverter |
Convert(object, Type, object, CultureInfo) → object |
Configurable via properties: Background, Inverted, AttentionBrush, WarningBrush. Returns color based on boolean state. |
BooleanToItalicFontStyleConverter |
Convert(object, Type, object, CultureInfo) → object |
Returns FontStyles.Italic when true, FontStyles.Normal when false or null. |
BooleanToOpacityConverter |
Convert(object, Type, object, CultureInfo) → object |
Returns 0.5 when true, 1 when false or null. |
InverseBooleanToOpacityConverter |
Convert(object, Type, object, CultureInfo) → object |
Returns 1.0 when true, 0.5 when false or null. |
InverseBooleanConverter |
Convert(object, Type, object, CultureInfo) → object |
Returns inverted boolean. ConvertBack also inverts. Returns false for null input. |
Multi-Value Boolean Converters
| Class | Signature | Behavior |
|---|---|---|
BooleanOrMultiConverter |
Convert(object[], Type, object, CultureInfo) → object |
Returns true if any boolean in values is true. Returns false if any value is not a bool. |
BooleanAndToVisibilityMultiConverter |
Convert(object[], Type, object, CultureInfo) → object |
Returns Visibility.Visible if all booleans are true. Supports parameter flags: "FALSE" inverts logic, "HIDE" uses Hidden instead of Collapsed. |
BooleanOrToVisibilityMultiConverter |
Convert(object[], Type, object, CultureInfo) → object |
Returns Visibility.Visible if any boolean is true. Same parameter flags as BooleanAndToVisibilityMultiConverter. |
Enum Converters
| Class | Signature | Behavior |
|---|---|---|
EnumVisibilityConverter |
Convert(object, Type, object, CultureInfo) → object |
Returns Visibility.Visible when value.Equals(parameter), otherwise Visibility.Hidden. |
InverseEnumVisibilityConverter |
Convert(object, Type, object, CultureInfo) → object |
Returns Visibility.Hidden when value.Equals(parameter), otherwise Visibility.Visible. |
EnumBooleanConverter |
Convert(object, Type, object, CultureInfo) → object |
Returns true when value.Equals(parameter). ConvertBack returns parameter when value.Equals(true). |
InverseEnumEnabledConverter |
Convert(object, Type, object, CultureInfo) → object |
Returns false when value.Equals(parameter), otherwise true. |
EnumDescriptionTypeConverter |
ConvertTo(ITypeDescriptorContext, CultureInfo, object, Type) → object |
Returns [Description] attribute value from enum, with localization lookup via Strings.Strings.ResourceManager. Includes static helper GetEnumDescription(Enum). |
Status Converters
| Class | Signature | Behavior |
|---|---|---|
StatusToBorderThicknessConverter |
Convert(object, Type, object, CultureInfo) → object |
Converts UIItemStatus enum to thickness: None → 1, all others → 2. |
StatusToColorConverter |
Convert(object, Type, object, CultureInfo) → object |
Converts UIItemStatus to Brush: None → Black, Success → Complete, Failed → Failed, Error → Red, Warning → OrangeRed. |
FaultedTextConverter |
Convert(object, Type, object, CultureInfo) → object |
Returns Strings.Strings.Faulted when true, Strings.Strings.FaultsClear when false or non-bool. |
FaultedColorConverter |
Convert(object, Type, object, CultureInfo) → object |
Returns Brush_ApplicationStatus_Failed.Color when true, Brush_ApplicationStatus_Complete.Color when false. |
TriggerTextConverter |
Convert(object, Type, object, CultureInfo) → object |
Returns Strings.Strings.Triggered when true, Strings.Strings.TriggerClear when false or non-bool. |
TriggerColorConverter |
Convert(object, Type, object, CultureInfo) → object |
Returns Brush_ApplicationStatus_Failed.Color when true, Brush_ApplicationStatus_Waiting.Color when false. |
DAS/Diagnostic Status Converters
| Class | Signature | Behavior |
|---|---|---|
DASStatusColorConverter |
Convert(object, Type, object, CultureInfo) → object |
Converts DASStatuses enum to status brush (Idle, Busy, Failed, Complete). |
DASStatusArmTextConverter |
Convert(object, Type, object, CultureInfo) → object |
Converts DASStatuses to localized arm status text (Table_NA, NotArmed, Armed). |
DASStatusArmColorConverter |
Convert(object, Type, object, CultureInfo) → object |
Converts DASStatuses to arm-specific status colors. |
DiagStatusShuntColorConverter |
Convert(object, Type, object, CultureInfo) → object |
Converts DiagStatuses to color, checking FailedShunt flag via bitwise AND. |
DiagStatusOffsetColorConverter |
Convert(object, Type, object, CultureInfo) → object |
Converts DiagStatuses to color, checking FailedOffset flag via bitwise AND. |
Numeric Converters
| Class | Signature | Behavior |
|---|---|---|
IsLessThanConverter |
Convert(object, Type, object, CultureInfo) → object |
Parses value and parameter as decimal, returns left < right. Returns false on parse failure. |
IsGreaterThanConverter |
Convert(object, Type, object, CultureInfo) → object |
Parses value and parameter as decimal, returns left > right. Returns false on parse failure. |
GreaterEqualThanToBoolConverter |
Convert(object, Type, object, CultureInfo) → object |
Returns value >= parameter for int, double, or ushort. Returns false for unsupported types. |
IntervalToVisibilityConverter |
Convert(object, Type, object, CultureInfo) → object |
Returns Visibility.Visible when value >= parameter for int, double, or ushort. |
DoubleFromThousandthUnitToBaseUnit |
Convert(object, Type, object, CultureInfo) → object |
Divides by 1000 (e.g., mV → V). ConvertBack multiplies by 1000. Returns 0D for NaN or non-double. |
InitialOffsetToIEPESensorOffsetConverter |
Convert(object, Type, object, CultureInfo) → object |
Converts mV to V with IEPE midpoint offset: (mV / 1000) + 12.25. Includes static ConvertDouble(double) method. |
PercentConverter |
Convert(object, Type, object, CultureInfo) → object |
Formats decimal as "{0:F1}%" using CurrentUICulture. |
NumericStringFormatConverter |
Convert(object[], Type, object, CultureInfo) → object |
Multi-value converter. values[0] is number, values[1] is format string. Supports int, double, float, decimal. Returns Strings.Strings.Table_NA for NaN. |
Visibility Converters
| Class | Signature | Behavior |
|---|---|---|
ArrayVisibilityConverter |
Convert(object, Type, object, CultureInfo) → object |
Returns Visibility.Visible if IList.Count > 0 or Array.Length > 0, otherwise Collapsed. Returns Hidden for null. |
StringListToVisibilityConverter |
Convert(object, Type, object, CultureInfo) → object |
Returns Visibility.Visible if List<string>.Any(), otherwise Collapsed. |
GroupNameToVisibilityConverter |
Convert(object, Type, object, CultureInfo) → object |
Returns Visibility.Visible if string starts with "Graph", otherwise Collapsed. |
VisibilityToRowHeightConverter |
Convert(object, Type, object, CultureInfo) → object |
Returns 0 for Collapsed, otherwise returns parameter (or 0 if null). Supports InvertSource dependency property. |
Dimension Converters
| Class | Signature | Behavior |
|---|---|---|
HeightConverter |
Convert(object, Type, object, CultureInfo) → object |
Returns value - parameter as double. Implements MarkupExtension with singleton pattern. |
WidthConverter |
Convert(object, Type, object, CultureInfo) → object |
Returns value * parameter as double. Implements MarkupExtension with singleton pattern. |
String/Text Converters
| Class | Signature | Behavior |
|---|---|---|
ListToStringConverter |
Convert(object, Type, object, CultureInfo) → object |
Joins List<string> with ", ". Throws InvalidOperationException for non-string target or null list. |
DateConverter |
Convert(object, Type, object, CultureInfo) → object |
Returns DateTime if value is DateTime, otherwise Strings.Strings.Table_NA. |
NullableFloatConverter |
Convert(object, Type, object, CultureInfo) → object |
Returns float value or string.Empty for non-float. |
DateTimeWithMillisecondsToStringConverter |
Convert(object, Type, object, CultureInfo) → object |
Delegates to Utils.Utils.FormatTimeStamp(). |
ErrorToBooleanConverter |
Convert(object, Type, object, CultureInfo) → object |
Returns true if string is null/empty, null for non-string. |
ErrorToColorConverter |
Convert(object, Type, object, CultureInfo) → object |
Returns SolidColorBrush(Colors.Red) if string not empty, SolidColorBrush(Colors.Black) otherwise. |
FilePathsToShortStringConverter |
Convert(object, Type, object, CultureInfo) → object |
Returns file name for single path, Strings.Strings.MultipleFiles for multiple, string.Empty for empty/null. |
GroupImportErrorToStringConverter |
Convert(object, Type, object, CultureInfo) → object |
Returns GroupImportError.ExtraInfo or string.Empty. |
Other Converters
| Class | Signature | Behavior |
|---|---|---|
ActiveContentConverter |
Convert(object, Type, object, CultureInfo) → object |
Returns value if ContentControl, otherwise Binding.DoNothing. Bidirectional. |
ColorToSolidColorBrushConverter |
Convert(object, Type, object, CultureInfo) → object |
Returns new SolidColorBrush(color) for Color input, null otherwise. |
NonZeroToColorConverter |
Convert(object, Type, object, CultureInfo) → object |
Returns BrushApplicationStatusPowerGreen for "0", BrushApplicationStatusPowerClear for "---", BrushApplicationStatusPowerRed otherwise. |
TestDataToRegionOfInterestMaximumConverter |
Convert(object[], Type, object, CultureInfo) → object |
Multi-value converter accepting 5 values: dataStart, dataEnd, PreTrigger, PostTrigger, RecordingMode. Returns appropriate maximum based on RecordingModes enum. |
3. Invariants
- Boolean converters: Input must be castable to
boolor nullable bool; unexpected types may return default values ornull. - Enum converters: The
parametermust match the enum type forEquals()comparison to succeed. BooleanOrMultiConverterandBooleanAndToVisibilityMultiConverter: All values in the array must be of typebool; presence of any non-bool results infalse.ListToStringConverter: Input must beList<string>; null or other types throwInvalidOperationException.StringListToVisibilityConverter: Input must beList<string>; null throwsInvalidOperationException.HeightConverterandWidthConverter: Input and parameter must be convertible todouble.IsLessThanConverterandIsGreaterThanConverter: Values are parsed asdecimalusing the provided culture'sNumberFormat.TestDataToRegionOfInterestMaximumConverter: Requires exactly 5 values in specific order; returnsdouble.PositiveInfinityif preconditions not met.EnumDescriptionTypeConverter: Relies on[Description]attributes being present on enum fields.VisibilityToRowHeightConverter:InvertSourceproperty must be set before conversion occurs.
4. Dependencies
External Dependencies (Imports)
System.Windows.Data-IValueConverter,IMultiValueConverter,BindingSystem.Windows-Visibility,DependencyProperty,DependencyObject,FontStyles,MarkupExtensionSystem.Windows.Media-Brush,Brushes,SolidColorBrush,ColorSystem.Windows.Controls-ContentControlSystem.Globalization-CultureInfoSystem.ComponentModel-EnumConverter,DescriptionAttribute,ITypeDescriptorContext
Internal Dependencies
DTS.Common.Base- Referenced byActiveContentConverter(usage unclear from source)DTS.Common.Enums-UIItemStatus,RecordingModesDTS.Common.Interface.Hardware-DASStatuses,DiagStatusesDTS.Common.Classes.Groups-GroupImportErrorDTS.Common.Strings-Stringsstatic class for localized stringsDTS.Common.BrushesAndColors- Static brush definitionsDTS.Common.Utils.Utils-FormatTimeStamp()method
Consumers
Unknown from source alone. These converters are designed for XAML data binding and would be consumed by Views/UserControls in a WPF application.
5. Gotchas
-
Inconsistent null handling:
BooleanToBorderThicknessConverterthrowsNullReferenceExceptionon null input (direct cast), whileBooleanToBorderBrushConverterhandles null gracefully. -
Opacity semantics inverted between converters:
BooleanToOpacityConverterreturns0.5fortrueand1forfalse, whileInverseBooleanToOpacityConverterreturns1.0fortrueand0.5forfalse. The naming is counterintuitive. -
NonZeroToColorConverter uses string comparison: Checks
value.ToString() == "0"rather than numeric comparison, which may produce unexpected results for numeric types. -
HeightConverter singleton pattern: Uses a static
_instancefield with lazy initialization via??operator, which is not thread-safe. -
ConvertBack not implemented consistently: Many converters return
nullor throwNotImplementedExceptionforConvertBack, making them one-way only.InverseBooleanConverteris an exception that supports two-way binding. -
GreaterEqualThanToBoolConverter filename mismatch: The file is named
GreaterThanToBoolConverter.csbut the class isGreaterEqualThanToBoolConverter(with "Equal" in the name). -
NullableFloatConverter XML comment is incorrect: The XML doc says "Date converter that will display Table_NA when date is null" — this appears to be copy-pasted from
DateConverter. -
IntervalToVisibilityConverter XML comment is incorrect: The XML doc mentions "converts between two values and a bool (a >= b)" which describes a different converter.
-
ListToStringConverter throws on null: Unlike
StringListToVisibilityConverterwhich throws, this could be handled more gracefully. -
TestDataToRegionOfInterestMaximumConverter fallthrough: Returns
double.PositiveInfinityfor unrecognized input configurations, which may cause UI issues if not handled by callers. -
BooleanToColorConverter property defaults: Properties
Background,Inverted,AttentionBrush,WarningBrushdefault tofalse. These must be set in XAML as converter properties to change behavior. -
EnumDescriptionTypeConverter localization fallback: If
Strings.Strings.ResourceManager.GetString()returns null/whitespace, falls back to the description attribute text directly.