This commit is contained in:
2026-04-17 14:55:32 -04:00
commit bc3ac1d4c9
18017 changed files with 4371742 additions and 0 deletions

View File

@@ -0,0 +1,123 @@
---
source_files:
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.Graph/ViewModel/GraphViewModel.cs
generated_at: "2026-04-16T13:51:13.371255+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "cd4107fac05f80cd"
---
# GraphViewModel Documentation
## 1. Purpose
`GraphViewModel` is a ViewModel within the `DTS.Viewer.Graph` module that manages graph visualization and coordinates data series display. It serves as a mediator between parent ViewModels (`IViewerMainViewModel` or `IPSDReportMainViewModel`) and the graph rendering components, handling event-driven communication for channel selection, test summaries, and data loading progress. The class follows the MVVM pattern using Prism and Unity, providing bindable properties for UI state management and interaction requests for user notifications.
---
## 2. Public Interface
### Constructor
```csharp
public GraphViewModel(
IGraphView view,
IRegionManager regionManager,
IEventAggregator eventAggregator,
IUnityContainer unityContainer)
```
Initializes the ViewModel, sets the View's DataContext, and creates `NotificationRequest` and `ConfirmationRequest` instances.
### Public Properties
| Property | Type | Description |
|----------|------|-------------|
| `View` | `IGraphView` | The associated graph view instance. |
| `Parent` | `IBaseViewModel` (internal) | Reference to the parent ViewModel. |
| `DataSeriesView` | `ITestDataSeriesView` | The data series view used for chart rendering. |
| `NotificationRequest` | `InteractionRequest<Notification>` | Interaction request for displaying notifications. |
| `ConfirmationRequest` | `InteractionRequest<Confirmation>` | Interaction request for displaying confirmations. |
| `ContextGraphRegion` | `object` | Gets/sets the content of the `GraphRegion` on the View. |
| `MessageText` | `string` | User-facing message text. Default: `"Please select Event(s) to export data"`. |
| `MessageVisibility` | `bool` | Controls visibility of the message panel. |
| `ProgressPercent` | `double` | Progress percentage for data loading operations. Default: `0D`. |
| `ProgressText` | `string` | Progress message text. Default: `"Reading channel data..."`. |
| `ProgressVisibility` | `bool` | Controls visibility of the progress indicator. |
| `GraphInfoVisibility` | `bool` | Controls visibility of graph information. |
| `GraphVisibility` | `bool` | Computed as `!MessageVisibility`. |
| `HeaderInfo` | `string` | Returns constant `"GraphRegion"`. |
| `IsBusy` | `bool` | Busy state indicator. |
| `IsDirty` | `bool` | Always returns `false` (read-only). |
### Public Methods
```csharp
public override void Initialize()
```
Empty override; performs no initialization.
```csharp
public override void Initialize(object parameter)
```
Performs context-specific initialization based on `parameter` type:
- If `parameter` is `IViewerMainViewModel`: Calls `Subscribe()` and initializes `DataSeriesView`.
- If `parameter` is `Tuple<IBaseViewModel, string>` where `Item1` is `IPSDReportMainViewModel`: Calls `SubscribeDataSelect()` or `SubscribeResult()` based on `Item2` value, and configures chart scrollbars/actions accordingly.
---
## 3. Invariants
- **`IsDirty`** always returns `false` and cannot be modified.
- **`HeaderInfo`** always returns the string `"GraphRegion"`.
- **`GraphVisibility`** is always the logical inverse of `MessageVisibility`.
- Event handlers (`OnTestSelectedCountChanged`, `OnGraphSelectedCountChanged`, `OnGraphChannelsReadCompleted`, `OnGraphChannelReadCalcProgressChangedEvent`) check that `Parent` or `this` matches the event argument's source before processing.
- `OnGraphChannelsReadCompleted` returns early if `arg` is `null`.
- `OnGraphChannelReadCalcProgressChangedEvent` only updates `ProgressPercent` if the value is `>= 0`.
---
## 4. Dependencies
### This Module Depends On
| Namespace | Purpose |
|-----------|---------|
| `C1.WPF.C1Chart` | ComponentOne charting controls (`AxisScrollBar`). |
| `DTS.Common.Base` | Base classes (`BaseViewModel<T>`, `IBaseModel`, `IBaseViewModel`). |
| `DTS.Common.Events` | Event types: `RaiseNotification`, `GraphSelectedChannelCountNotification`, `TestSummaryCountNotification`, `TestModificationChangedEvent`, `GraphChannelsReadCompletedNotification`, `GraphChannelReadCalcProgressChangedEvent`. |
| `DTS.Common.Interactivity` | `InteractionRequest<T>`, `Notification`, `Confirmation`. |
| `DTS.Common.Interface` | `IGraphViewModel`, `ITestDataSeriesView`, `ITestDataSeriesViewModel`, `IViewerMainViewModel`, `IPSDReportMainViewModel`. |
| `Prism.Events` | `IEventAggregator`, `ThreadOption`. |
| `Prism.Regions` | `IRegionManager`. |
| `Unity` | `IUnityContainer`. |
### External Types Referenced (Not Defined Here)
- `GraphView` - Concrete view type cast in `ContextGraphRegion` property.
- `TestDataSeriesView` - Concrete data series view cast for chart configuration.
- `TestDataSeriesViewModel` - Concrete ViewModel cast for calling `SubscribePSD()`.
- `ITestModificationModel` - Parameter type for `OnTestModificationChanged`.
- Various event argument types: `TestSummaryCountNotificationArg`, `GraphSelectedChannelCountNotificationArg`, `NotificationContentEventArgs`, `GraphChannelsReadCompletedNotificationArgs`, `GraphChannelReadCalcProgressChangedEventArgs`.
---
## 5. Gotchas
1. **Member Hiding with `new` Keyword**: The class uses `new` to hide multiple base class members (`Model`, `ConfirmationRequest`, `PropertyChanged`, `OnPropertyChanged`, `IsBusy`, `IsDirty`). This can cause unexpected behavior when casting to base types.
2. **Code Duplication in Subscribe Methods**: `Subscribe()`, `SubscribeDataSelect()`, and `SubscribeResult()` have nearly identical implementations. The only difference is `Subscribe()` includes `TestModificationChangedEvent` subscription, while the others do not—but `OnTestModificationChanged` is an empty method body.
3. **Empty Event Handler**: `OnTestModificationChanged(ITestModificationModel obj)` is subscribed but contains no implementation.
4. **Concrete Type Casting**: The code casts interfaces to concrete types (`GraphView`, `TestDataSeriesView`, `TestDataSeriesViewModel`) which breaks abstraction and could cause runtime failures if implementations change:
```csharp
((AxisScrollBar)((TestDataSeriesView)DataSeriesView).MainChart.View.AxisX.ScrollBar).Visibility = ...
((TestDataSeriesView)DataSeriesView).MainChart.Actions.Clear();
((TestDataSeriesViewModel)viewModel).SubscribePSD();
```
5. **Hardcoded String Comparisons**: The `Initialize(object parameter)` method uses string literals (`"DataSelect"`, `"Graph"`) for control flow, which is fragile.
6. **Unused Private Field**: The `Model` property is set but never accessed elsewhere in the visible code.
7. **ReSharper Suppressions**: The file contains numerous ReSharper directive suppressions, suggesting known code quality issues that were disabled rather than addressed.