init
This commit is contained in:
@@ -0,0 +1,129 @@
|
||||
---
|
||||
source_files:
|
||||
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.ChartOptions/Model/ChartOptionsModel.cs
|
||||
generated_at: "2026-04-16T11:19:24.422198+00:00"
|
||||
model: "zai-org/GLM-5-FP8"
|
||||
schema_version: 1
|
||||
sha256: "a2e58408ee52b3f9"
|
||||
---
|
||||
|
||||
# Documentation: ChartOptionsModel.cs
|
||||
|
||||
## 1. Purpose
|
||||
|
||||
`ChartOptionsModel` is a state-bearing model class that encapsulates all configuration options for chart display within the DTS Viewer application. It manages chart unit types (EU, mV, V, PSD, FFT), time units, Y-axis scaling modes, filter selections, cursor behavior, and axis locking states. The class implements `INotifyPropertyChanged` (via `BasePropertyChanged`) to support data binding and coordinates with a parent `IChartOptionsViewModel` to publish changes and execute commands.
|
||||
|
||||
---
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
### Class Signature
|
||||
```csharp
|
||||
public class ChartOptionsModel : Common.Base.BasePropertyChanged, IChartOptionsModel
|
||||
```
|
||||
|
||||
### Properties
|
||||
|
||||
| Property | Type | Default | Description |
|
||||
|----------|------|---------|-------------|
|
||||
| `DisplayingVolts` | `bool` | `false` | Toggles between Volts (true) and millivolts (false) display. Raises `OnPropertyChanged` for `"MVOrV"` and `"UnitTypeDescription"` when changed. |
|
||||
| `MVOrV` | `string` | — | Read-only. Returns `"V"` if `DisplayingVolts` is true, otherwise `"mV"`. |
|
||||
| `IsDigitalChannel` | `bool` | `false` | Indicates whether the channel is digital. |
|
||||
| `SupportsADC` | `bool` | `true` | Indicates ADC support. |
|
||||
| `SupportsMV` | `bool` | `true` | Indicates millivolt support. |
|
||||
| `UnitType` | `ChartUnitTypeEnum` | `ChartUnitTypeEnum.EU` | The unit type for the chart. Changing this sets `ReadData = true` and auto-adjusts `Filter` based on unit type. |
|
||||
| `UnitTypeDescription` | `string` | — | Read-only. Returns `"V"` or `"mV"` for `ChartUnitTypeEnum.mV`, otherwise returns `UnitType.ToString()`. |
|
||||
| `TimeUnitType` | `TimeUnitTypeEnum` | `TimeUnitTypeEnum.MS` | Time unit for the X-axis. Sets `ReadData = true` on change. |
|
||||
| `TimeUnitTypeDescription` | `string` | `"MS"` | String representation of `TimeUnitType`. |
|
||||
| `SelectedFilter` | `IFilterClass` | `FilterClass(Unfiltered)` | The selected software filter. Sets `ReadData = true` on change. |
|
||||
| `MinFixedY` | `double` | `0.00` | Minimum Y-axis value for fixed range. |
|
||||
| `MaxFixedY` | `double` | `0.00` | Maximum Y-axis value for fixed range. |
|
||||
| `MinFixedT` | `double` | `0.00` | Minimum X-axis (time) value for fixed range. |
|
||||
| `MaxFixedT` | `double` | `0.00` | Maximum X-axis (time) value for fixed range. |
|
||||
| `FullScaleValues` | `List<double>` | — | Returns `_euValues` for EU/PSD unit types, otherwise `_fullScaleValues`. |
|
||||
| `SelectedFullScaleValue` | `double` | `100` | Currently selected full-scale value. |
|
||||
| `LockedT` | `bool` | `false` | Indicates if the X-axis is locked. |
|
||||
| `LockedY` | `bool` | `false` | Indicates if the Y-axis is locked. |
|
||||
| `ShowCursor` | `bool` | `false` | Cursor visibility. Calls `Parent?.ShowCusor(value)` on change. |
|
||||
| `CurrentCursorValues` | `string` | `""` | String representation of current cursor values. |
|
||||
| `YRange` | `YRangeScaleEnum` | `YRangeScaleEnum.AutoRange` | Y-axis range mode. Setting to `Fixed` automatically sets `LockedY = true`. |
|
||||
| `Filter` | `FilterOptionEnum` | `FilterOptionEnum.TestSetupDefault` | Filter option enum. Sets `ReadData = true` on change. |
|
||||
| `Parent` | `IChartOptionsViewModel` | `null` | Reference to parent view model. |
|
||||
| `CanPublishChanges` | `bool` | `true` | Controls whether property changes trigger `Parent?.PublishChanges()`. |
|
||||
| `IsCursorsAvailable` | `bool` | `false` | Indicates if cursors are available for the current context. |
|
||||
| `T0Cursor` | `bool` | `false` | T0 cursor flag. |
|
||||
| `MinMaxCursors` | `bool` | `false` | Min/Max cursors flag. |
|
||||
| `ReadData` | `bool` | `false` | Flag indicating data should be re-read. |
|
||||
| `IsSaved` | `bool` | — | Read-only auto-property (no setter visible). |
|
||||
| `DecimateData` | `bool` | `false` | Getter returns `false` if `UnitType` is `PSD` or `FFT`, otherwise returns backing field value. |
|
||||
| `WidthPoints` | `long` | `0` | Width points for decimation. |
|
||||
|
||||
### Commands
|
||||
|
||||
| Command | Type | Description |
|
||||
|---------|------|-------------|
|
||||
| `ResetZoomCommand` | `DelegateCommand` | Executes `ResetZoomMethod()`, which delegates to `Parent.ResetZoomMethod()`. |
|
||||
| `ResetTCommand` | `DelegateCommand` | Executes `ResetTMethod()`, which delegates to `Parent.ResetTMethod()`. |
|
||||
| `SaveToPDFCommand` | `DelegateCommand` | Executes `SaveToPDFMethod()`, which delegates to `Parent.SaveToPDFMethod()`. |
|
||||
|
||||
### Methods
|
||||
|
||||
| Method | Signature | Description |
|
||||
|--------|-----------|-------------|
|
||||
| `ChartOptionsModel` | `ctor()` | Empty parameterless constructor. |
|
||||
| `SetSelectedFilterToUnfilteredNoRead` | `void SetSelectedFilterToUnfilteredNoRead()` | Sets `_selectedFilter` to `FilterClass(Unfiltered)` with `ReadData = false`. Raises `OnPropertyChanged("SelectedFilter")`. |
|
||||
| `OnPropertyChanged` | `void OnPropertyChanged(string propertyName)` | Raises `PropertyChanged` event. Conditionally calls `Parent?.PublishChanges()` unless the property is in an exclusion list. |
|
||||
|
||||
### Events
|
||||
|
||||
| Event | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `PropertyChanged` | `PropertyChangedEventHandler` | Standard INotifyPropertyChanged event. |
|
||||
|
||||
---
|
||||
|
||||
## 3. Invariants
|
||||
|
||||
1. **UnitType → Filter coupling**: When `UnitType` is set to anything other than `EU` or `PSD`, `Filter` is automatically set to `FilterOptionEnum.Unfiltered`. When `UnitType` is `EU` or `PSD`, `Filter` is set to `FilterOptionEnum.TestSetupDefault`.
|
||||
|
||||
2. **YRange → LockedY coupling**: Setting `YRange` to `YRangeScaleEnum.Fixed` automatically sets `LockedY = true`.
|
||||
|
||||
3. **DecimateData conditional return**: The `DecimateData` getter always returns `false` when `UnitType` is `ChartUnitTypeEnum.PSD` or `ChartUnitTypeEnum.FFT`, regardless of the backing field `_decimateData`.
|
||||
|
||||
4. **FullScaleValues selection**: The property returns `_euValues` list when `UnitType` is `EU` or `PSD`; otherwise returns `_fullScaleValues`.
|
||||
|
||||
5. **Change publishing exclusion**: The following properties do not trigger `Parent?.PublishChanges()` when changed:
|
||||
- `CanPublishChanges`, `Parent`, `ReadData`, `UnitTypeDescription`, `ShowCursor`, `LockedT`, `LockedY`, `MVOrV`, `DisplayingVolts`, `DecimateData`, `WidthPoints`
|
||||
|
||||
---
|
||||
|
||||
## 4. Dependencies
|
||||
|
||||
### This Module Depends On
|
||||
- `System`, `System.Collections.Generic`, `System.ComponentModel` (BCL)
|
||||
- `DTS.Common` — Base namespace
|
||||
- `DTS.Common.Base.BasePropertyChanged` — Base class providing `SetProperty` method
|
||||
- `DTS.Common.Classes.Sensors` — `FilterClass` implementation
|
||||
- `DTS.Common.Enums.Viewer` — `ChartUnitTypeEnum`, `TimeUnitTypeEnum`, `FilterOptionEnum`, `YRangeScaleEnum`
|
||||
- `DTS.Common.Interface` — `IChartOptionsModel` (implied), `IChartOptionsViewModel`
|
||||
- `DTS.Common.Interface.Sensors.SoftwareFilters` — `IFilterClass`
|
||||
- `Prism.Commands` — `DelegateCommand`
|
||||
|
||||
### What Depends On This Module
|
||||
- **Unknown from source alone** — The `IChartOptionsViewModel` interface references this model via the `Parent` property, but concrete consumers are not visible in this file.
|
||||
|
||||
---
|
||||
|
||||
## 5. Gotchas
|
||||
|
||||
1. **Typo in method call**: In the `ShowCursor` setter, the code calls `Parent?.ShowCusor(_showCursor)` — note the spelling "Cusor" instead of "Cursor". This is either a typo in the method name on `IChartOptionsViewModel` or a historical naming quirk.
|
||||
|
||||
2. **SetSelectedFilterToUnfilteredNoRead exists as a workaround**: The method `SetSelectedFilterToUnfilteredNoRead()` specifically bypasses the automatic `ReadData = true` behavior that occurs when setting `SelectedFilter` via the property. This suggests the automatic data refresh is sometimes undesirable and requires explicit circumvention.
|
||||
|
||||
3. **Inconsistent property setter patterns**: Some properties use `SetProperty(ref _field, value, "PropertyName")` (e.g., `IsDigitalChannel`, `DisplayingVolts`), while others manually implement equality checks and `OnPropertyChanged` calls (e.g., `UnitType`, `MinFixedY`). This inconsistency may reflect different authors or refactoring over time.
|
||||
|
||||
4. **IsSaved is unassigned**: The `IsSaved` property has no setter and no initialization. The ReSharper annotation `// ReSharper disable UnassignedGetOnlyAutoProperty` at the top of the file suppresses warnings about this. Accessing this property will return `default(bool)` (`false`).
|
||||
|
||||
5. **ReadData side effects are implicit**: Setting `UnitType`, `TimeUnitType`, `SelectedFilter`, or `Filter` silently sets `ReadData = true`. Callers must be aware that these property changes have side effects beyond the property value itself.
|
||||
|
||||
6. **Historical comment FB 13120**: The comment `// FB 13120 does not need to set SelectedFilter any more since it's not using enum` and `// FB 13120 use filter class instead of cfc filter enum` reference a past bug/feature (likely FogBugz case 13120) where filter handling was refactored from an enum to a class-based approach.
|
||||
@@ -0,0 +1,44 @@
|
||||
---
|
||||
source_files:
|
||||
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.ChartOptions/Properties/AssemblyInfo.cs
|
||||
generated_at: "2026-04-16T11:18:39.805240+00:00"
|
||||
model: "zai-org/GLM-5-FP8"
|
||||
schema_version: 1
|
||||
sha256: "fddf8c3b00b320fd"
|
||||
---
|
||||
|
||||
# Documentation: DTS.Viewer.ChartOptions Assembly Configuration
|
||||
|
||||
## 1. Purpose
|
||||
This source file defines the assembly metadata and versioning information for the `DTS.Viewer.ChartOptions` module. It serves as the standard .NET assembly manifest configuration, controlling how the compiled DLL is identified, versioned, and exposed to COM components. This module appears to be a specific component within the larger "DTS Viewer" application suite, likely containing logic related to chart visualization options.
|
||||
|
||||
## 2. Public Interface
|
||||
This file does not contain executable classes, methods, or functions. It strictly defines assembly-level attributes using C# attribute syntax.
|
||||
|
||||
* **`AssemblyTitle`**: Set to `"DTS.Viewer.DTS.Viewer.ChartOptions"`. Provides a friendly name for the assembly.
|
||||
* **`AssemblyDescription`**: Set to an empty string.
|
||||
* **`AssemblyCompany`**: Set to an empty string.
|
||||
* **`AssemblyProduct`**: Set to `"DTS.Viewer.DTS.Viewer.ChartOptions"`.
|
||||
* **`AssemblyCopyright`**: Set to `"Copyright © 2017"`.
|
||||
* **`AssemblyCulture`**: Set to an empty string (neutral culture).
|
||||
* **`ComVisible`**: Set to `false`. Makes all types within the assembly invisible to COM components by default.
|
||||
* **`Guid`**: Set to `"9f161f2a-4fcd-438e-9768-ba96ba104d6c"`. Specifies a unique identifier for the assembly if exposed to COM.
|
||||
* **`AssemblyVersion`**: Set to `"1.0.0.0"`. Defines the version of the assembly used by the common language runtime.
|
||||
* **`AssemblyFileVersion`**: Set to `"1.0.0.0"`. Defines the file version number displayed on the file properties.
|
||||
|
||||
## 3. Invariants
|
||||
* **Versioning**: The assembly version is explicitly defined as `1.0.0.0`. It does not use wildcard characters (`*`), meaning the build and revision numbers will not auto-generate; they are fixed.
|
||||
* **COM Visibility**: By default, no types in this assembly are exposed to COM. To expose a specific type, that type must explicitly override this with `[ComVisible(true)]`.
|
||||
* **Identity**: The `Guid` `9f161f2a-4fcd-438e-9768-ba96ba104d6c` uniquely identifies this specific assembly in COM scenarios.
|
||||
|
||||
## 4. Dependencies
|
||||
* **Internal Dependencies**: None defined in this file.
|
||||
* **External Dependencies**:
|
||||
* `System.Reflection`: Required for the assembly attribute classes.
|
||||
* `System.Runtime.CompilerServices`: Imported but not actively used for `InternalsVisibleTo` or similar attributes in this snippet.
|
||||
* `System.Runtime.InteropServices`: Required for the `Guid` and `ComVisible` attributes.
|
||||
|
||||
## 5. Gotchas
|
||||
* **Naming Redundancy**: The `AssemblyTitle` and `AssemblyProduct` are set to `"DTS.Viewer.DTS.Viewer.ChartOptions"`. This appears to be a redundant duplication of the namespace (DTS.Viewer appearing twice). This may be a typo in the project configuration or a specific naming convention for this module.
|
||||
* **Legacy Format**: This file represents the legacy .NET Framework approach to assembly metadata. If this project has been migrated to the SDK-style `.csproj` format, these attributes may conflict with auto-generated attributes unless `<GenerateAssemblyInfo>` is set to `false` in the project file.
|
||||
* **Empty Metadata**: `AssemblyDescription` and `AssemblyCompany` are empty. While valid, this results in minimal metadata being embedded in the compiled binary, which can make library identification difficult for external tools or auditing processes.
|
||||
@@ -0,0 +1,72 @@
|
||||
---
|
||||
source_files:
|
||||
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.ChartOptions/Resources/TranslateExtension.cs
|
||||
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.ChartOptions/Resources/StringResources.Designer.cs
|
||||
generated_at: "2026-04-16T11:18:12.490923+00:00"
|
||||
model: "zai-org/GLM-5-FP8"
|
||||
schema_version: 1
|
||||
sha256: "8d340ea94a701586"
|
||||
---
|
||||
|
||||
# Documentation: DTS.Viewer.ChartOptions Resources
|
||||
|
||||
## 1. Purpose
|
||||
This module provides localization infrastructure for the `DTS.Viewer.ChartOptions` namespace. It consists of a XAML markup extension (`TranslateExtension`) enabling declarative binding to localized strings in UI layouts, and a strongly-typed resource accessor class (`StringResources`) that wraps the underlying `.resx` storage. It exists to decouple UI labels and chart-related text (e.g., "Save Chart", "Min/Max" labels) from the code logic, supporting potential multi-language deployments.
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
### Class: `TranslateExtension`
|
||||
**Namespace:** `DTS.Viewer.ChartOptions`
|
||||
**Inheritance:** `System.Windows.Markup.MarkupExtension`
|
||||
|
||||
This class allows XAML bindings to retrieve localized strings directly.
|
||||
|
||||
* **Constructor:** `TranslateExtension(string key)`
|
||||
* Initializes the extension with the resource key to be looked up.
|
||||
* **Method:** `public override object ProvideValue(IServiceProvider serviceProvider)`
|
||||
* Returns the localized string associated with `_key`.
|
||||
* Returns `#stringnotfound#` if the key is null or empty.
|
||||
* Returns `#stringnotfound# [key]` if the lookup fails (key not found in resources).
|
||||
|
||||
### Class: `StringResources`
|
||||
**Namespace:** `DTS.Viewer.ChartOptions.Resources`
|
||||
**Accessibility:** `internal`
|
||||
|
||||
A strongly-typed resource class generated by Visual Studio/ResGen. It provides static properties to access string values defined in the resource file.
|
||||
|
||||
* **Property:** `static global::System.Resources.ResourceManager ResourceManager`
|
||||
* Returns the cached `ResourceManager` instance for this assembly.
|
||||
* **Property:** `static global::System.Globalization.CultureInfo Culture`
|
||||
* Gets or sets the current UI culture for resource lookups.
|
||||
* **Resource Properties (Static Strings):**
|
||||
* `ChartUnitType`: Looks up "Chart Unit Type".
|
||||
* `FilterOptions_Title`: Looks up "Display Filter".
|
||||
* `LockT`: Looks up "Lock T".
|
||||
* `MaxT`: Looks up "Max:".
|
||||
* `MaxY`: Looks up "Max:".
|
||||
* `MinT`: Looks up "Min:".
|
||||
* `MinY`: Looks up "Min:".
|
||||
* `Range`: Looks up "Range".
|
||||
* `ResetAll`: Looks up "Reset All".
|
||||
* `ResetT`: Looks up "Reset T".
|
||||
* `SaveChart`: Looks up "Save Chart".
|
||||
* `SaveToPDF`: Looks up "Save to PDF".
|
||||
* `TimeUnitType`: Looks up "Time Unit Type".
|
||||
|
||||
## 3. Invariants
|
||||
* **Auto-generation:** `StringResources` is auto-generated; manual modifications to `StringResources.Designer.cs` will be overwritten if the tool regenerates the file. Changes must be made to the corresponding `.resx` file.
|
||||
* **Error Handling:** `TranslateExtension.ProvideValue` will never return `null`. It guarantees a string return, either the valid translation or a specific error constant.
|
||||
* **Key Requirement:** `TranslateExtension` requires a non-null, non-empty string key to attempt a valid lookup.
|
||||
|
||||
## 4. Dependencies
|
||||
* **Internal Dependencies:**
|
||||
* `TranslateExtension` depends on `DTS.Viewer.ChartOptions.Resources.StringResources` for the actual resource lookup logic.
|
||||
* **External Dependencies:**
|
||||
* `System.Windows.Markup`: Required for `MarkupExtension` and `MarkupExtensionReturnTypeAttribute` (WPF specific).
|
||||
* `System.Resources`: Used for `ResourceManager`.
|
||||
* `System.Globalization`: Used for `CultureInfo`.
|
||||
|
||||
## 5. Gotchas
|
||||
* **Missing Key Formatting:** If a resource key is passed to `TranslateExtension` but does not exist in the `.resx` file, the returned string includes the missing key name appended to the error token (e.g., `#stringnotfound# MyMissingKey`). This differs from the empty/null key behavior, which returns only the token `#stringnotfound#`.
|
||||
* **Duplicate Values:** The source indicates that `MaxT` and `MaxY` both map to the default value "Max:", and `MinT`/`MinY` map to "Min:". While likely intentional for localization reuse, context-specific nuances might be lost if the localization requirements for Time (T) vs Y-axis diverge in other languages.
|
||||
* **Internal Visibility:** The `StringResources` class is marked `internal`. It is not accessible outside the `DTS.Viewer.ChartOptions` assembly. External assemblies must rely on `TranslateExtension` (if public) or cannot access these resources directly.
|
||||
@@ -0,0 +1,60 @@
|
||||
---
|
||||
source_files:
|
||||
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.ChartOptions/View/ChartOptionsView.xaml.cs
|
||||
generated_at: "2026-04-16T11:18:57.795839+00:00"
|
||||
model: "zai-org/GLM-5-FP8"
|
||||
schema_version: 1
|
||||
sha256: "2fdf05f68ae69d8d"
|
||||
---
|
||||
|
||||
# Documentation: ChartOptionsView
|
||||
|
||||
## 1. Purpose
|
||||
|
||||
`ChartOptionsView` is a WPF view component implementing `IChartOptionsView` that provides user interface elements for configuring chart options. It serves as the visual layer for chart-related settings, specifically exposing available filter class options (CFC - likely "Channel Filter Classes" or "Calculated Filter Classes") to the UI for user selection.
|
||||
|
||||
---
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
### `ChartOptionsView()` (Constructor)
|
||||
**Signature:** `public ChartOptionsView()`
|
||||
|
||||
Initializes the view component by calling `InitializeComponent()`, which loads the associated XAML layout.
|
||||
|
||||
### `AvailableCFC` (Property)
|
||||
**Signature:** `public List<IFilterClass> AvailableCFC { get; }`
|
||||
|
||||
**Returns:** A `List<IFilterClass>` containing available filter class options.
|
||||
|
||||
**Behavior:** Creates a new instance of `AnalogSettingDefaults` on each access and returns its `FilterOptions` property. This property is read-only (getter only).
|
||||
|
||||
---
|
||||
|
||||
## 3. Invariants
|
||||
|
||||
- The `AvailableCFC` property will never return `null` (assuming `AnalogSettingDefaults.FilterOptions` never returns null, which is not verifiable from this source alone).
|
||||
- The view always implements `IChartOptionsView` interface contract.
|
||||
- `InitializeComponent()` must be called exactly once during construction (handled by WPF framework conventions).
|
||||
|
||||
---
|
||||
|
||||
## 4. Dependencies
|
||||
|
||||
### This module depends on:
|
||||
- `DTS.Common.Interface` - Provides `IChartOptionsView` interface
|
||||
- `DTS.Common.Interface.Sensors.SoftwareFilters` - Provides `IFilterClass` interface
|
||||
- `DTS.SensorDB` - Provides `AnalogSettingDefaults` class
|
||||
|
||||
### What depends on this module:
|
||||
- Not determinable from this source file alone. Consumers would be whatever module creates or references `ChartOptionsView` instances.
|
||||
|
||||
---
|
||||
|
||||
## 5. Gotchas
|
||||
|
||||
1. **Object allocation on every property access:** The `AvailableCFC` property instantiates a new `AnalogSettingDefaults` object every time it is read. If this property is data-bound in XAML and accessed frequently, it could create unnecessary object allocations and GC pressure. Consider whether this should be cached or lazy-loaded.
|
||||
|
||||
2. **FB 13120 reference:** The comment references "FB 13120" which appears to be an issue/feature tracking identifier. The context or resolution of this tracking item is not available from the source.
|
||||
|
||||
3. **Unknown interface contract:** The requirements of `IChartOptionsView` are not visible in this source, so it is unclear if `AvailableCFC` fulfills an interface member or is an additional public member.
|
||||
@@ -0,0 +1,167 @@
|
||||
---
|
||||
source_files:
|
||||
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.ChartOptions/ViewModel/ChartOptionsViewModel.cs
|
||||
generated_at: "2026-04-16T11:18:03.613000+00:00"
|
||||
model: "zai-org/GLM-5-FP8"
|
||||
schema_version: 1
|
||||
sha256: "7f2f2e90f6f17587"
|
||||
---
|
||||
|
||||
# Documentation: ChartOptionsViewModel
|
||||
|
||||
## 1. Purpose
|
||||
|
||||
`ChartOptionsViewModel` is a Prism-based view model that manages user-configurable chart display options within the DTS Viewer application. It serves as an intermediary between chart option UI controls and the underlying chart rendering system, handling unit type selection (EU, mV, ADC), axis range configuration, cursor visibility, and PDF export functionality. The module supports multiple parent contexts including `IViewerMainViewModel` and `IPSDReportMainViewModel`, with different default configurations based on the parent type.
|
||||
|
||||
---
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
### Constructor
|
||||
|
||||
```csharp
|
||||
public ChartOptionsViewModel(
|
||||
IChartOptionsView view,
|
||||
IRegionManager regionManager,
|
||||
IEventAggregator eventAggregator,
|
||||
IUnityContainer unityContainer)
|
||||
```
|
||||
Initializes the view model, sets up the view's DataContext, creates interaction requests, and subscribes to `ChartAxisChangedEvent`.
|
||||
|
||||
---
|
||||
|
||||
### Properties
|
||||
|
||||
| Property | Type | Access | Description |
|
||||
|----------|------|--------|-------------|
|
||||
| `Parent` | `IBaseViewModel` | get/set | Reference to the parent view model; used for event filtering. |
|
||||
| `NotificationRequest` | `InteractionRequest<Notification>` | get | Prism interaction request for notifications. |
|
||||
| `ConfirmationRequest` | `InteractionRequest<Confirmation>` | get | Prism interaction request for confirmations. |
|
||||
| `View` | `IBaseView` | get/set | The associated view interface. |
|
||||
| `Model` | `IChartOptionsModel` | get/set | The chart options model; resolves from container on set. Raises `OnPropertyChanged("Model")`. |
|
||||
| `ContextSearchRegion` | `object` | get/set | Unused in visible code. |
|
||||
| `IsMenuIncluded` | `bool` | get/set | Hides base property. |
|
||||
| `IsNavigationIncluded` | `bool` | get/set | Hides base property. |
|
||||
| `IsBusy` | `bool` | get/set | Hides base property. |
|
||||
| `IsDirty` | `bool` | get | Always returns default value; never assigned. |
|
||||
| `ChartOptionsVisability` | `bool` | get/set | Controls visibility of chart options UI. Raises property changed notification. |
|
||||
| `ClearMarkersCommand` | `DelegateCommand` | get | Lazy-initialized command that calls `ClearMarkersMethod()`. |
|
||||
|
||||
---
|
||||
|
||||
### Methods
|
||||
|
||||
```csharp
|
||||
public override void Initialize()
|
||||
```
|
||||
Empty override; performs no operations.
|
||||
|
||||
```csharp
|
||||
public override void Initialize(object parameter)
|
||||
```
|
||||
Initializes the view model with a parent context. Subscribes to events, resolves the model from Unity container, and configures defaults based on parameter type:
|
||||
- If `parameter is IViewerMainViewModel`: Sets `Model.DecimateData = true`
|
||||
- If `parameter is Tuple<IBaseViewModel, string>` where `Item1` is `IPSDReportMainViewModel`: Configures based on `chartType` string ("Graph" vs other)
|
||||
|
||||
```csharp
|
||||
public void ShowMinMaxCursor(bool value)
|
||||
```
|
||||
Publishes `CursorShowMinMaxChangedEvent` with the given boolean value.
|
||||
|
||||
```csharp
|
||||
public void ResetZoomMethod()
|
||||
```
|
||||
Sets `Model.YRange` to `YRangeScaleEnum.AutoRange` and publishes `ResetZoomChangedEvent` with `true`.
|
||||
|
||||
```csharp
|
||||
public void ResetTMethod()
|
||||
```
|
||||
Publishes `ResetZoomChangedEvent` with `false`.
|
||||
|
||||
```csharp
|
||||
public void SaveToPDFMethod()
|
||||
```
|
||||
Publishes `SaveToPDFRequestedEvent` with the stored `Directory` path.
|
||||
|
||||
```csharp
|
||||
public void PublishChanges()
|
||||
```
|
||||
Publishes `ChartOptionsChangedEvent` with a `ChartOptionsChangedEventArg` containing `ParentVM`, `Model`, and `ChartType`.
|
||||
|
||||
```csharp
|
||||
public void ShowCusor(bool value)
|
||||
```
|
||||
Publishes `CursorShowChangedEvent` with the given boolean value.
|
||||
|
||||
```csharp
|
||||
public new void OnPropertyChanged(string propertyName)
|
||||
```
|
||||
Raises the `PropertyChanged` event for the specified property name.
|
||||
|
||||
---
|
||||
|
||||
### Events
|
||||
|
||||
```csharp
|
||||
public new event PropertyChangedEventHandler PropertyChanged
|
||||
```
|
||||
Hides the base class event; raised by `OnPropertyChanged`.
|
||||
|
||||
---
|
||||
|
||||
## 3. Invariants
|
||||
|
||||
1. **Model Resolution**: `Model` must be resolved from `IUnityContainer` before use; it is not resolved in the constructor but in `Initialize(object parameter)`.
|
||||
|
||||
2. **Event Filtering**: All received events are filtered by comparing `args?.ParentVM` to `Parent`. Events from other parent contexts are ignored.
|
||||
|
||||
3. **Publish Guard Pattern**: When programmatically modifying `Model` properties in response to events (e.g., in `OnChartAxisChangedEvent`), `Model.CanPublishChanges` must be set to `false` before modifications and restored to `true` afterward to prevent recursive event publishing.
|
||||
|
||||
4. **Log Scale Constraint**: When `chartType == "Graph"`, `Model.MinFixedY` is set to `1e-12` because log scale cannot handle zero.
|
||||
|
||||
5. **Unit Type Fallback**: If channels do not support ADC or mV (determined by `AllChannelsSupportADC` / `AllChannelsSupportmV`), the `Model.UnitType` is automatically reset to `ChartUnitTypeEnum.EU`.
|
||||
|
||||
---
|
||||
|
||||
## 4. Dependencies
|
||||
|
||||
### This Module Depends On
|
||||
|
||||
| Namespace | Types Used |
|
||||
|-----------|------------|
|
||||
| `DTS.Common.Base` | `BaseViewModel<T>`, `IBaseViewModel` |
|
||||
| `DTS.Common.Enums.Viewer` | `ChartUnitTypeEnum`, `YRangeScaleEnum`, `FilterOptionEnum` |
|
||||
| `DTS.Common.Enums.Hardware` | `HardwareConstants.IsTSRAIRSerialNumber()` |
|
||||
| `DTS.Common.Events` | `ChartAxisChangedEvent`, `CursorsAlailableChangedEvent`, `GraphSelectedChannelsNotification`, `CursorShowMinMaxChangedEvent`, `ResetZoomChangedEvent`, `SaveToPDFRequestedEvent`, `ChartOptionsChangedEvent`, `CursorShowChangedEvent`, `CursorsClearChangedEvent` |
|
||||
| `DTS.Common.Interface` | `IChartOptionsViewModel`, `IChartOptionsModel`, `IChartOptionsView`, `IBaseView`, `IViewerMainViewModel`, `IPSDReportMainViewModel`, `ITestChannel` |
|
||||
| `DTS.Common.Interactivity` | `InteractionRequest<T>`, `Notification`, `Confirmation` |
|
||||
| `Prism.Events` | `IEventAggregator` |
|
||||
| `Prism.Regions` | `IRegionManager` |
|
||||
| `Prism.Commands` | `DelegateCommand` |
|
||||
| `Unity` | `IUnityContainer` |
|
||||
|
||||
### Modules That Depend On This Module
|
||||
|
||||
Cannot be determined from source alone; would require analysis of consumers of `IChartOptionsViewModel`.
|
||||
|
||||
---
|
||||
|
||||
## 5. Gotchas
|
||||
|
||||
1. **Copy-Paste Error in XML Comment**: The constructor's XML documentation states "Creates a new instance of the TestSummaryViewModel" — this is incorrect; the class is `ChartOptionsViewModel`.
|
||||
|
||||
2. **Typo: `ChartOptionsVisability`**: Property name should be `ChartOptionsVisibility`.
|
||||
|
||||
3. **Typo: `ShowCusor`**: Method name should be `ShowCursor`.
|
||||
|
||||
4. **Typo: `OnCursorsAlailableChanged`**: Event handler and event name `CursorsAlailableChangedEvent` should be `CursorsAvailableChanged`.
|
||||
|
||||
5. **Hidden Base Members**: Multiple properties (`IsMenuIncluded`, `IsNavigationIncluded`, `IsBusy`, `IsDirty`, `ConfirmationRequest`, `Model`, `PropertyChanged`, `OnPropertyChanged`) use the `new` keyword to hide base class members. This may cause unexpected behavior when casting to base types.
|
||||
|
||||
6. **Unused `IsDirty` Property**: The property has only a getter and is never assigned a value, making it perpetually `false` (default).
|
||||
|
||||
7. **Commented-Out Constructor Code**: Lines 55-57 are commented out, suggesting initialization logic was moved to `Initialize(object parameter)`.
|
||||
|
||||
8. **Hardcoded Magic Strings**: Axis comparison uses literal strings `"Y"` and `"X"` in `OnChartAxisChangedEvent`; `chartType` comparison uses literal `"Graph"`.
|
||||
|
||||
9. **ADC/mV Support Detection**: Both `AllChannelsSupportADC` and `AllChannelsSupportmV` use identical logic (checking for TSR AIR serial numbers). The comment indicates this is a temporary implementation that may need future refinement for calculated channels.
|
||||
Reference in New Issue
Block a user