151 lines
8.2 KiB
Markdown
151 lines
8.2 KiB
Markdown
---
|
|
source_files:
|
|
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.AddCalculatedChannel/Resources/TranslateExtension.cs
|
|
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.AddCalculatedChannel/Resources/StringResources.Designer.cs
|
|
generated_at: "2026-04-16T11:20:45.009025+00:00"
|
|
model: "zai-org/GLM-5-FP8"
|
|
schema_version: 1
|
|
sha256: "5726c0d4d71935f1"
|
|
---
|
|
|
|
# Documentation: DTS.Viewer.AddCalculatedChannel.Resources
|
|
|
|
## 1. Purpose
|
|
|
|
This module provides localization infrastructure for the "Add Calculated Channel" feature within the DTS Viewer application. It consists of a WPF XAML markup extension (`TranslateExtension`) that enables declarative resource lookups in XAML bindings, and a strongly-typed resource accessor class (`StringResources`) that wraps a `.resx` file containing localized strings for UI elements, calculation types, error messages, and IR-TRACC measurement labels. The module supports the crash test data analysis domain, providing terminology for head injury criterion (HIC), 3D IR-TRACC calculations, and various mathematical operations.
|
|
|
|
---
|
|
|
|
## 2. Public Interface
|
|
|
|
### TranslateExtension (DTS.Viewer.AddCalculatedChannel)
|
|
|
|
A WPF markup extension for performing localized string lookups in XAML.
|
|
|
|
```csharp
|
|
[MarkupExtensionReturnType(typeof(string))]
|
|
public class TranslateExtension : MarkupExtension
|
|
```
|
|
|
|
**Constructor:**
|
|
- `TranslateExtension(string key)` — Initializes the extension with the resource key to look up. The key is stored in a private readonly field `_key`.
|
|
|
|
**Methods:**
|
|
- `public override object ProvideValue(IServiceProvider serviceProvider)` — Returns the localized string for the stored key. Returns `#stringnotfound#` if `_key` is null or empty. Returns `#stringnotfound# {key}` if the resource manager returns null for the given key.
|
|
|
|
**Constants:**
|
|
- `private const string NotFound = "#stringnotfound#"` — Fallback string used when a resource lookup fails.
|
|
|
|
---
|
|
|
|
### StringResources (DTS.Viewer.AddCalculatedChannel.Resources)
|
|
|
|
An auto-generated, strongly-typed resource accessor class. This class is `internal`.
|
|
|
|
```csharp
|
|
internal class StringResources
|
|
```
|
|
|
|
**Static Properties:**
|
|
|
|
| Property | Type | Description |
|
|
|----------|------|-------------|
|
|
| `ResourceManager` | `global::System.Resources.ResourceManager` | Lazily-initialized cached ResourceManager instance for the `DTS.Viewer.AddCalculatedChannel.Resources.StringResources` resource bundle. |
|
|
| `Culture` | `global::System.Globalization.CultureInfo` | Gets or sets the current thread's UI culture for resource lookups. |
|
|
|
|
**Resource String Properties (static, read-only):**
|
|
|
|
The following localized string properties are exposed. All return `string`:
|
|
|
|
- `AddCalculatedChannel` — "Add Calculated Channel"
|
|
- `CalculatedChannel_Average` — "Average"
|
|
- `CalculatedChannel_IRTRACC3D` — "3D IR-TRACC (upper thorax)"
|
|
- `CalculatedChannel_IRTRACC3D_Abdomen` — "3D IR-TRACC (abdomen)"
|
|
- `CalculatedChannel_IRTRACC3D_LowerThorax` — "3D IR-TRACC (lower thorax)"
|
|
- `CalculatedChannel_IRTRACC3D_Thorax` — "3D IR-TRACC (thorax)"
|
|
- `CalculatedChannel_IRTRACC3DAbdomen` — "3D IR-TRACC (abdomen)"
|
|
- `CalculatedChannel_IRTRACC3DLowerThorax` — "3D IR-TRACC (lower thorax)"
|
|
- `CalculatedChannel_Sum` — "Sum"
|
|
- `Calculation` — "Calculation"
|
|
- `CALCULATION_Cos` — "Cosine"
|
|
- `CALCULATION_Derivative` — "Derivative"
|
|
- `CALCULATION_DoubleIntegral` — "Double integral"
|
|
- `CALCULATION_Integral` — "Integral"
|
|
- `CALCULATION_Sin` — "Sine"
|
|
- `CALCULATION_ThreeDIRTracc` — "3D IR-TRACC (upper thorax)"
|
|
- `CALCULATION_ThreeDIRTraccAbdomen` — "3D IR-TRACC (abdomen)"
|
|
- `CALCULATION_ThreeDIRTraccLowerThorax` — "3D IR-TRACC (lower thorax)"
|
|
- `CalculationInputChannel` — "Calculation Input Channel"
|
|
- `Channel` — "Channel"
|
|
- `ChannelName` — "Channel Name"
|
|
- `ClipLengthMS` — "Clip length (ms)"
|
|
- `Description` — "Description"
|
|
- `HICAccelerationX` — "Acceleration X"
|
|
- `HICAccelerationY` — "Acceleration Y"
|
|
- `HICAccelerationZ` — "AccelerationZ"
|
|
- `HICRequires3Channels` — "Error: Head injury criterion requires 3 channels."
|
|
- `InputChannels` — "Input channels"
|
|
- `ISOCode` — "ISO Code"
|
|
- `NoChannelsIncluded` — "Error: No channels included."
|
|
- `ResultantUnitsDontMatch` — "Error: Units don't match for all input channels."
|
|
- `SampleRatesDontMatch` — "Error: Sample rates don't match for all input channels."
|
|
- `SuperSamplingWarning` — "Calculation contains multiple sample rates. Input will be resampled to the highest sample rate using linear interpolation."
|
|
- `ThreeD_IRTracc` — "IR-TRACC"
|
|
- `ThreeD_RotPot1` — "R. Pot Y"
|
|
- `ThreeD_RotPot2` — "R. Pot Z"
|
|
|
|
---
|
|
|
|
## 3. Invariants
|
|
|
|
1. **TranslateExtension always returns a non-null string.** The `ProvideValue` method guarantees a string return value—either the localized resource, `#stringnotfound#`, or `#stringnotfound# {key}`.
|
|
|
|
2. **Empty/null key handling differs from missing key handling.** When `_key` is null or empty, the return is exactly `#stringnotfound#`. When `_key` is valid but the resource is missing, the return is `#stringnotfound# {key}` (includes the key name).
|
|
|
|
3. **StringResources.ResourceManager is lazily initialized and thread-safe.** The property uses a null-check pattern with a temporary variable before assignment.
|
|
|
|
4. **StringResources is auto-generated.** The class bears `GeneratedCodeAttribute`, `DebuggerNonUserCodeAttribute`, and `CompilerGeneratedAttribute`. Manual modifications will be lost on regeneration.
|
|
|
|
5. **StringResources.Culture defaults to null.** If not explicitly set, resource lookups will use the current thread's UI culture.
|
|
|
|
6. **All resource string properties are internal.** They are only accessible within the `DTS.Viewer.AddCalculatedChannel.Resources` namespace or via friend assemblies.
|
|
|
|
---
|
|
|
|
## 4. Dependencies
|
|
|
|
### This module depends on:
|
|
|
|
- `System` — Core .NET types
|
|
- `System.Windows.Markup` — `MarkupExtension` base class and `MarkupExtensionReturnTypeAttribute`
|
|
- `System.Resources` — `ResourceManager` for resource lookups
|
|
- `System.Globalization` — `CultureInfo` for culture-specific lookups
|
|
- `System.CodeDom.Compiler` — `GeneratedCodeAttribute` (auto-generated code)
|
|
- `System.Diagnostics` — `DebuggerNonUserCodeAttribute`
|
|
- `System.Runtime.CompilerServices` — `CompilerGeneratedAttribute`
|
|
- `System.ComponentModel` — `EditorBrowsableAttribute`
|
|
|
|
### What depends on this module:
|
|
|
|
**Inferred from context:** The `TranslateExtension` class is designed for use in XAML files within the `DTS.Viewer.AddCalculatedChannel` namespace. The resource strings reference calculation types, IR-TRACC measurements, and HIC (Head Injury Criterion) parameters, suggesting this module supports a crash test data analysis UI.
|
|
|
|
**Note:** The actual XAML consumers and other code-behind files that reference `StringResources` are not present in the provided source files.
|
|
|
|
---
|
|
|
|
## 5. Gotchas
|
|
|
|
1. **Duplicate/overlapping resource keys exist.** There appear to be semantically duplicate keys with slightly different naming conventions:
|
|
- `CalculatedChannel_IRTRACC3D_Abdomen` and `CalculatedChannel_IRTRACC3DAbdomen` both return "3D IR-TRACC (abdomen)"
|
|
- `CalculatedChannel_IRTRACC3D_LowerThorax` and `CalculatedChannel_IRTRACC3DLowerThorax` both return "3D IR-TRACC (lower thorax)"
|
|
- `CalculatedChannel_IRTRACC3D` and `CALCULATION_ThreeDIRTracc` both return "3D IR-TRACC (upper thorax)"
|
|
|
|
This may indicate a naming convention shift or migration artifact. Developers should verify which key is intended for use in new code.
|
|
|
|
2. **Inconsistent naming conventions.** Some keys use underscores with prefixes (`CALCULATION_*`), others use different patterns (`CalculatedChannel_*`). The rationale for this is unclear from source alone.
|
|
|
|
3. **HICAccelerationZ lacks a space.** The value is "AccelerationZ" while X and Y variants are "Acceleration X" and "Acceleration Y". This may be a typo in the `.resx` file.
|
|
|
|
4. **TranslateExtension does not use the Culture property.** The extension calls `StringResources.ResourceManager.GetString(_key)` without passing a culture, meaning it uses the current thread's UI culture. If `StringResources.Culture` has been set to a different value, the extension will not respect it.
|
|
|
|
5. **IServiceProvider parameter is unused.** The `serviceProvider` parameter in `ProvideValue` is accepted but never used, which is typical for simple markup extensions but worth noting if advanced target-aware behavior is ever needed. |