20 KiB
20 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
2026-04-16T02:53:33.629685+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | e705305552eb4c3f |
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 (Data Acquisition and Test System) application. These converters enable UI elements to dynamically reflect application state by transforming values (e.g., booleans, enums, numbers, dates, collections) into display-appropriate types such as Visibility, Brush, Thickness, Opacity, FontStyle, or formatted strings. They serve as a bridge between domain models and XAML views, reducing logic in view models and centralizing UI presentation rules.
2. Public Interface
All converters implement IValueConverter or IMultiValueConverter and reside in the DTS.Common.Converters namespace.
BooleanToBorderThicknessConverter
- Signature:
public class BooleanToBorderThicknessConverter : IValueConverter - Behavior: Converts
true→1,false→2. Used to visually distinguish active/inactive states via border thickness.
BooleanToBorderBrushConverter
- Signature:
public class BooleanToBorderBrushConverter : IValueConverter - Behavior: Converts
true→BrushesAndColors.Brush_Warning,false/null→Brushes.Transparent.
BooleanToGreenBorderConverter
- Signature:
public class BooleanToGreenBorderConverter : IValueConverter - Behavior: Converts
true→BrushesAndColors.BrushApplicationStatusPowerGreen,false/null→Brushes.Transparent.
YesNoRadioButtonsConventer (Note: Typo in class name)
- Signature:
public class YesNoRadioButtonsConventer : IValueConverter - Behavior:
Convert: Returnstrueifparameter.ToString() == value.ToString()(used to bind radio buttons to enum/string values).ConvertBack: Returnsparameterifvalue == true, elseBinding.DoNothing.
BooleanOrMultiConverter
- Signature:
public class BooleanOrMultiConverter : IMultiValueConverter - Behavior: Returns
trueif any input boolean in the array istrue; otherwisefalse. ThrowsNotImplementedExceptioninConvertBack.
DateTimeWithMillisecondsToStringConverter
- Signature:
public class DateTimeWithMillisecondsToStringConverter : IValueConverter - Behavior: Converts
DateTimeto string usingUtils.Utils.FormatTimeStamp.ConvertBackreturnsnull.
EnumVisibilityConverter
- Signature:
public class EnumVisibilityConverter : IValueConverter - Behavior: Returns
Visibility.Visibleifvalue == parameter, elseVisibility.Hidden.ConvertBackreturnsparameterifvalue == Visibility.Visible, elseBinding.DoNothing.
InverseEnumVisibilityConverter
- Signature:
public class InverseEnumVisibilityConverter : IValueConverter - Behavior: Returns
Visibility.Hiddenifvalue == parameter, elseVisibility.Visible.ConvertBackreturnsparameterifvalue == Visibility.Hidden, elseBinding.DoNothing.
ActiveContentConverter
- Signature:
public class ActiveContentConverter : IValueConverter - Behavior: Returns the input
ContentControlunchanged if it is aContentControl; otherwiseBinding.DoNothing. Supports both directions.
FaultedTextConverter
- Signature:
public class FaultedTextConverter : IValueConverter - Behavior: Converts
true→Strings.Strings.Faulted,false→Strings.Strings.FaultsClear,null/non-bool →Strings.Strings.FaultsClear.
TriggerTextConverter
- Signature:
public class TriggerTextConverter : IValueConverter - Behavior: Converts
true→Strings.Strings.Triggered,false→Strings.Strings.TriggerClear,null/non-bool →Strings.Strings.TriggerClear.
TriggerColorConverter
- Signature:
public class TriggerColorConverter : IValueConverter - Behavior: Converts
true→BrushesAndColors.Brush_ApplicationStatus_Failed.Color,false→BrushesAndColors.Brush_ApplicationStatus_Waiting.Color,null/non-bool →Brushes.Transparent.Color.
FaultedColorConverter
- Signature:
public class FaultedColorConverter : IValueConverter - Behavior: Converts
true→BrushesAndColors.Brush_ApplicationStatus_Failed.Color,false→BrushesAndColors.Brush_ApplicationStatus_Complete.Color,null/non-bool →Brushes.Transparent.Color.
DateConverter
- Signature:
public class DateConverter : IValueConverter - Behavior: Converts
DateTime→DateTime,null/non-DateTime→Strings.Strings.Table_NA.ConvertBackbehaves similarly.
NullableFloatConverter
- Signature:
public class NullableFloatConverter : IValueConverter - Behavior: Converts
double→double,float→float,null/other →string.Empty.ConvertBackreturnsfloatorstring.Empty.
InverseEnumEnabledConverter
- Signature:
public class InverseEnumEnabledConverter : IValueConverter - Behavior: Returns
falseifvalue == parameter, elsetrue. Used forIsEnabled.ConvertBackreturnsparameterifvalue == false, elseBinding.DoNothing.
IsLessThanConverter
- Signature:
public class IsLessThanConverter : IValueConverter - Behavior: Compares
value < parameter(both parsed asdecimal). Defaults to0if parsing fails. Returnsbool.ConvertBackreturnsDependencyProperty.UnsetValue.
ListToStringConverter
- Signature:
public class ListToStringConverter : IValueConverter - Behavior: Converts
List<string>→ comma-separated string. ThrowsInvalidOperationExceptioniftargetType != typeof(string)or input isnull.ConvertBackthrowsNotImplementedException.
IsGreaterThanConverter
- Signature:
public class IsGreaterThanConverter : IValueConverter - Behavior: Compares
value > parameter(both parsed asdecimal). Defaults to0if parsing fails. Returnsbool.ConvertBackreturnsDependencyProperty.UnsetValue.
NonZeroToColorConverter
- Signature:
public class NonZeroToColorConverter : IValueConverter - Behavior:
"0"→BrushesAndColors.BrushApplicationStatusPowerGreen"---"→BrushesAndColors.BrushApplicationStatusPowerClear- Other →
BrushesAndColors.BrushApplicationStatusPowerRed
HeightConverter
- Signature:
public class HeightConverter : MarkupExtension, IValueConverter - Behavior: Returns
value - parameter(both parsed asdouble/int). ImplementsMarkupExtensionfor XAML usage (singleton instance).ConvertBackreturnsnull.
ErrorToBooleanConverter
- Signature:
internal class ErrorToBooleanConverter : IValueConverter - Behavior: Returns
trueifvalueisstring.IsNullOrEmpty, elsenull.ConvertBackthrowsNotImplementedException.
WidthConverter
- Signature:
public class WidthConverter : MarkupExtension, IValueConverter - Behavior: Returns
value * parameter(both parsed asdouble). ImplementsMarkupExtension.ConvertBackthrowsNotImplementedException.
StringListToVisibilityConverter
- Signature:
public class StringListToVisibilityConverter : IValueConverter - Behavior: Returns
Visibility.VisibleifList<string>is non-empty, elseVisibility.Collapsed. ThrowsInvalidOperationExceptioniftargetType != typeof(Visibility)or input isnull.ConvertBackthrowsNotImplementedException.
StatusToBorderThicknessConverter
- Signature:
public class StatusToBorderThicknessConverter : IValueConverter - Behavior: Maps
UIItemStatusto border thickness:None→1, all others (Success,Failed,Error,Warning) →2. Non-UIItemStatus→1.
ArrayVisibilityConverter
- Signature:
public class ArrayVisibilityConverter : IValueConverter - Behavior: Returns
Visibility.Hiddenifnull,Visibility.VisibleifIList.Count > 0orArray.Length > 0, elseVisibility.Visible.
DSPStreamingFilterFrequencyConverter
- Signature:
public class DSPStreamingFilterFrequencyConverter : IValueConverter - Behavior:
double.NaN→string.Empty0.0(withinEPSILON = 0.00001) →Strings.Strings.Table_NA- Otherwise → formatted as
"F1"(e.g.,"123.4")
ConvertBack: Returnsparameterifvalue == true, elseBinding.DoNothing.
ErrorToColorConverter
- Signature:
public class ErrorToColorConverter : IValueConverter - Behavior: Returns
Brushes.Redifvalueis non-emptystring, elseBrushes.Black. Non-string input →Brushes.Black.ConvertBackthrowsNotImplementedException.
GreaterThanToBoolConverter
- Signature:
public class GreaterEqualThanToBoolConverter : IValueConverter - Behavior: Returns
trueifvalue >= parameterforint,double, orushorttypes. Returnsfalseotherwise.ConvertBackreturnsfalse.
BooleanToColorConverter
- Signature:
public class BooleanToColorConverter : IValueConverter - Behavior: Configurable via properties:
Inverted: Inverts input boolean.Background: Iftrue, returnsBrushes.Transparentfortrue.AttentionBrush: Iftrue, returnsBrushesAndColors.Brush_Attentionforfalse.WarningBrush: Iftrue, returnsBrushesAndColors.Brush_Warningforfalse.- Default:
true→Brush_NoError,false→Brush_Error.
BooleanToItalicFontStyleConverter
- Signature:
public class BooleanToItalicFontStyleConverter : IValueConverter - Behavior: Converts
true→FontStyles.Italic,false/null→FontStyles.Normal.
IntervalToVisibilityConverter
- Signature:
public class IntervalToVisibilityConverter : IValueConverter - Behavior: Returns
Visibility.Visibleifvalue >= parameter(forint,double,ushort), elseVisibility.Collapsed.ConvertBackreturnsfalse.
StatusToColorConverter
- Signature:
public class StatusToColorConverter : IValueConverter - Behavior: Maps
UIItemStatusto color:None→Brushes.BlackSuccess→Brush_ApplicationStatus_CompleteFailed/Error→Brush_ApplicationStatus_Failed/Brushes.RedWarning→Brushes.OrangeRed- Default →
Brushes.Transparent.
DiagStatusShuntColorConverter
- Signature:
public class DiagStatusShuntColorConverter : IValueConverter - Behavior: Maps
DiagStatuses:NoResults→Brush_ApplicationStatus_IdleFailedShuntbit set →Brush_ApplicationStatus_Failed- Otherwise →
Brush_ApplicationStatus_Complete - Default →
Brush_ApplicationStatus_Idle.
DiagStatusOffsetColorConverter
- Signature:
public class DiagStatusOffsetColorConverter : IValueConverter - Behavior: Same logic as
DiagStatusShuntColorConverter, but checksFailedOffsetbit.
InverseBooleanToOpacityConverter
- Signature:
public class InverseBooleanToOpacityConverter : IValueConverter - Behavior: Converts
true→1.0,false/null→0.5.
ColorToSolidColorBrushConverter
- Signature:
public class ColorToSolidColorBrushConverter : IValueConverter - Behavior: Converts
Color→SolidColorBrush. Non-Colorinput →null.ConvertBackthrowsNotImplementedException.
BooleanAndToVisibilityMultiConverter
- Signature:
public class BooleanAndToVisibilityMultiConverter : IMultiValueConverter - Behavior: Returns
Visibility.Visibleif all inputs aretrue. Supportsparameterflags:"FALSE": Invert logic (false→ visible)."HIDE": UseVisibility.Hiddeninstead ofCollapsed.
ConvertBackthrowsNotImplementedException.
BooleanOrToVisibilityMultiConverter
- Signature:
public class BooleanOrToVisibilityMultiConverter : IMultiValueConverter - Behavior: Returns
Visibility.Visibleif any input istrue. Same parameter flags asBooleanAndToVisibilityMultiConverter. ConvertBackthrowsNotImplementedException.
DoubleFromThousandthUnitToBaseUnit
- Signature:
public class DoubleFromThousandthUnitToBaseUnit : IValueConverter - Behavior: Converts thousandths to base unit (e.g., mV → V):
value / 1000.ConvertBack:value * 1000.double.NaN→0D.
BooleanToOpacityConverter
- Signature:
public class BooleanToOpacityConverter : IValueConverter - Behavior: Converts
true→0.5,false/null→1.0. Used for disabled/enabled visual feedback.
DASStatusArmTextConverter
- Signature:
public class DASStatusArmTextConverter : IValueConverter - Behavior: Maps
DASStatusesto text:MissingNotBooted,BootedNotArmedYet,BootedNeverArmed,ReadyForDownload→Strings.Strings.Table_NA/Strings.Strings.NotArmedArmedReady,ArmedButFailedDiag→Strings.Strings.Armed- Default →
Strings.Strings.Table_NA.
RecordingModePreTriggerVisibilityConverter
- Signature:
public class RecordingModePreTriggerVisibilityConverter : IValueConverter - Behavior: Returns
Visibility.Visibleif pre-trigger should be shown (i.e.,RecordingModesis active or can program pre-trigger).parameter = "True"inverts result.
EnumBooleanConverter
- Signature:
public class EnumBooleanConverter : IValueConverter - Behavior: Returns
trueifvalue.Equals(parameter).ConvertBack: Returnsparameterifvalue == true, elseBinding.DoNothing.
InitialOffsetToIEPESensorOffsetConverter
- Signature:
public class InitialOffsetToIEPESensorOffsetConverter : IValueConverter - Behavior: Converts millivolt offset to IEPE sensor offset (volts):
(milliUnit / 1000) + 12.25.ConvertBack:(unit - 12.25) * 1000.double.NaN→0D.
DASStatusColorConverter
- Signature:
public class DASStatusColorConverter : IValueConverter - Behavior: Maps
DASStatusesto color:MissingNotBooted→Brush_ApplicationStatus_IdleBootedNotArmedYet→Brush_ApplicationStatus_BusyBootedNeverArmed,ArmedButFailedDiag→Brush_ApplicationStatus_FailedArmedReady,ReadyForDownload→Brush_ApplicationStatus_Complete- Default →
Brush_ApplicationStatus_Idle.
DASStatusArmColorConverter
- Signature:
public class DASStatusArmColorConverter : IValueConverter - Behavior: Maps
DASStatusesto color:MissingNotBooted,BootedNotArmedYet,BootedNeverArmed→Brush_ApplicationStatus_FailedArmedReady→Brush_ApplicationStatus_CompleteArmedButFailedDiag→Brush_ApplicationStatus_BusyReadyForDownload→Brush_ApplicationStatus_Idle- Default →
Brush_ApplicationStatus_Idle.
PercentConverter
- Signature:
public class PercentConverter : IValueConverter - Behavior: Converts
decimal?→ formatted string"{value:F1}%". Defaults to0ifnull.ConvertBackthrowsNotImplementedException.
NumericStringFormatConverter
- Signature:
public class NumericStringFormatConverter : IMultiValueConverter - Behavior: Converts first value (
int/double/float/decimal) to string using format string from second value.NaN→Strings.Strings.Table_NA.ConvertBackthrowsNotImplementedException.
VisibilityToRowHeightConverter
- Signature:
public class VisibilityToRowHeightConverter : DependencyObject, IValueConverter - Behavior:
Visibility.Collapsed→0- Other →
parameter(default0ifnull) InvertSourceproperty invertsVisible↔Collapsedbefore conversion.
GroupImportErrorToStringConverter
- Signature:
public class GroupImportErrorToStringConverter : IValueConverter - Behavior: Returns
GroupImportError.ExtraInfoif input is non-nullGroupImportError, elsestring.Empty.ConvertBackthrowsNotImplementedException.
GroupNameToVisibilityConverter
- Signature:
public class GroupNameToVisibilityConverter : IValueConverter - Behavior: Returns
Visibility.Visibleifvalue.ToString().Trim()starts with"Graph", elseVisibility.Collapsed.
FilePathsToShortStringConverter
- Signature:
public class FilePathsToShortStringConverter : IValueConverter - Behavior:
null/empty array →string.Empty- Multiple files →
Strings.Strings.MultipleFiles - Single file →
FileInfo.Name
InverseBooleanConverter
- Signature:
public class InverseBooleanConverter : IValueConverter - Behavior: Inverts boolean (via
bool.TryParse).null→false. Supports two-way binding.
EnumDescriptionTypeConverter
- Signature:
public class EnumDescriptionTypeConverter : EnumConverter - Behavior: Overrides
ConvertToto return localized enum descriptions (via `DescriptionAttribute