155 lines
13 KiB
Markdown
155 lines
13 KiB
Markdown
|
|
---
|
||
|
|
source_files:
|
||
|
|
- DTS Viewer/DTS.Viewer/Modules/Main/ViewModel/ViewerShellViewModel.cs
|
||
|
|
- DTS Viewer/DTS.Viewer/Modules/Main/ViewModel/MainViewModel.cs
|
||
|
|
- DTS Viewer/DTS.Viewer/Modules/Main/ViewModel/ExportMainViewModel.cs
|
||
|
|
generated_at: "2026-04-17T15:54:03.993512+00:00"
|
||
|
|
model: "zai-org/GLM-5-FP8"
|
||
|
|
schema_version: 1
|
||
|
|
sha256: "1f3db03ef2ae0f10"
|
||
|
|
---
|
||
|
|
|
||
|
|
# DTS Viewer Main Module ViewModels Documentation
|
||
|
|
|
||
|
|
## 1. Purpose
|
||
|
|
|
||
|
|
This module contains the core ViewModel layer for the DTS Viewer application's main shell and content regions. It implements the MVVM pattern using Microsoft Prism and Unity IoC, providing three primary ViewModels: `ViewerShellViewModel` serves as the application shell container, `MainViewModel` manages the primary viewer interface with multiple regions (navigation, graph, property panels), and `ExportMainViewModel` extends functionality for data export operations including PDF generation and layout persistence. The module orchestrates view composition through region management and pub/sub event aggregation for loosely-coupled inter-component communication.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 2. Public Interface
|
||
|
|
|
||
|
|
### ViewerShellViewModel
|
||
|
|
|
||
|
|
**Signature:** `public class ViewerShellViewModel : NotificationObject, IViewerShellViewModel`
|
||
|
|
|
||
|
|
| Member | Signature | Description |
|
||
|
|
|--------|-----------|-------------|
|
||
|
|
| Constructor | `ViewerShellViewModel(IViewerShellView view, IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer)` | Initializes the shell, sets up DataContext, creates interaction requests, subscribes to `RaiseNotification` event, and registers `IMainView`/`IMainViewModel` types with Unity. |
|
||
|
|
| View | `public IViewerShellView View { get; private set; }` | Holds reference to the associated view. |
|
||
|
|
| NotificationRequest | `public InteractionRequest<Notification> NotificationRequest { get; private set; }` | Prism interaction request for displaying notifications. |
|
||
|
|
| ConfirmationRequest | `public InteractionRequest<Confirmation> ConfirmationRequest { get; private set; }` | Prism interaction request for confirmation dialogs. |
|
||
|
|
| Initialize | `public void Initialize()` | No-op implementation (assigns local variable `i = 10`). |
|
||
|
|
| Initialize | `public void Initialize(object parameter)` | No-op implementation (assigns local variable `i = 22`). |
|
||
|
|
| Initialize | `public void Initialize(object parameter, object model)` | Empty implementation. |
|
||
|
|
| Activated | `public void Activated()` | No-op (assigns empty string to local variable). |
|
||
|
|
| IsBusy | `bool IBaseViewModel.IsBusy { get; set; }` | Explicit interface implementation. |
|
||
|
|
| GetRegions | `public List<FrameworkElement> GetRegions()` | Returns all elements named "Region" from `MainShell` using `Utils.GetChildrenByName`. |
|
||
|
|
| ContextMainRegion | `public Object ContextMainRegion { get; set; }` | Gets/sets content of the `MainRegion` on the view. |
|
||
|
|
| IsMenuIncluded | `public bool IsMenuIncluded { get; set; }` | Bound property with `OnPropertyChanged` notification. |
|
||
|
|
| IsNavigationIncluded | `public bool IsNavigationIncluded { get; set; }` | Bound property with `OnPropertyChanged` notification. |
|
||
|
|
| HeaderInfo | `public string HeaderInfo { get; }` | Returns constant string `"MainRegion"`. |
|
||
|
|
| IsBusy | `public bool IsBusy { get; }` | **Throws `NotImplementedException`.** |
|
||
|
|
| IsDirty | `public bool IsDirty { get; }` | **Throws `NotImplementedException`.** |
|
||
|
|
| Cleanup | `public void Cleanup()` | **Throws `NotImplementedException`.** |
|
||
|
|
| CleanupAsync | `public Task CleanupAsync()` | **Throws `NotImplementedException`.** |
|
||
|
|
| InitializeAsync | `public Task InitializeAsync()` | **Throws `NotImplementedException`.** |
|
||
|
|
| InitializeAsync | `public Task InitializeAsync(object parameter)` | **Throws `NotImplementedException`.** |
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### MainViewModel
|
||
|
|
|
||
|
|
**Signature:** `public class MainViewModel : BaseViewModel<IMainViewModel>, IMainViewModel`
|
||
|
|
|
||
|
|
| Member | Signature | Description |
|
||
|
|
|--------|-----------|-------------|
|
||
|
|
| Constructor | `MainViewModel(IMainView view, IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer)` | Initializes view, DataContext, interaction requests, and subscribes to `RaiseNotification` event. |
|
||
|
|
| View | `public IBaseView View { get; private set; }` | Reference to the associated view. |
|
||
|
|
| NotificationRequest | `public InteractionRequest<Notification> NotificationRequest { get; private set; }` | Interaction request for notifications. |
|
||
|
|
| ConfirmationRequest | `public new InteractionRequest<Confirmation> ConfirmationRequest { get; private set; }` | Interaction request for confirmations (hides base member). |
|
||
|
|
| Initialize | `public override void Initialize()` | Empty override. |
|
||
|
|
| Initialize | `public override void Initialize(object parameter)` | Casts parameter to `IBaseWindowModel`, sets parent menu/navigation flags, subscribes to `AssemblyListNotification` and `BusyIndicatorChangeNotification` events. |
|
||
|
|
| Activated | `public override void Activated()` | Empty override. |
|
||
|
|
| ContextNavigationRegion | `public object ContextNavigationRegion { get; set; }` | Gets/sets `NavigationRegion.Content` from `MainView`. |
|
||
|
|
| ContextGraphRegion | `public object ContextGraphRegion { get; set; }` | Gets/sets `GraphRegion.Content` from `MainView`. |
|
||
|
|
| ContextTestsRegion | `public object ContextTestsRegion { get; set; }` | Gets/sets `TestsRegion.Content` from `MainView`. |
|
||
|
|
| ContextGraphsRegion | `public object ContextGraphsRegion { get; set; }` | Gets/sets `GraphsRegion.Content` from `MainView`. |
|
||
|
|
| ContextLegendRegion | `public object ContextLegendRegion { get; set; }` | Gets/sets `LegendRegion.Content` from `MainView`. |
|
||
|
|
| ContextDiagRegion | `public object ContextDiagRegion { get; set; }` | Gets/sets `DiagRegion.Content` from `MainView`. |
|
||
|
|
| ContextStatsRegion | `public object ContextStatsRegion { get; set; }` | Gets/sets `StatsRegion.Content` from `MainView`. |
|
||
|
|
| ContextCursorRegion | `public object ContextCursorRegion { get; set; }` | Gets/sets `CursorRegion.Content` from `MainView`. |
|
||
|
|
| ContextPropertyRegion | `public object ContextPropertyRegion { get; set; }` | Gets/sets `PropertyRegion.Content` from `MainView`. |
|
||
|
|
| GetRegions | `public List<FrameworkElement> GetRegions()` | Returns all elements named "Region" from `MainShell`. |
|
||
|
|
| IsBusy | `public new bool IsBusy { get; set; }` | Busy indicator state with notification. |
|
||
|
|
| IsBusyMessage | `public new string IsBusyMessage { get; set; }` | Message for busy indicator. |
|
||
|
|
| IsMenuIncluded | `public new bool IsMenuIncluded { get; set; }` | Menu inclusion flag. |
|
||
|
|
| IsNavigationIncluded | `public new bool IsNavigationIncluded { get; set; }` | Navigation inclusion flag. |
|
||
|
|
| HeaderInfo | `public string HeaderInfo { get; }` | Returns `"MainRegion"`. |
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### ExportMainViewModel
|
||
|
|
|
||
|
|
**Signature:** `public class ExportMainViewModel : BaseViewModel<IExportMainViewModel>, IExportMainViewModel`
|
||
|
|
|
||
|
|
| Member | Signature | Description |
|
||
|
|
|--------|-----------|-------------|
|
||
|
|
| Constructor | `ExportMainViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer)` | Initializes interaction requests, resolves `IExportMainViewGrid` as View, sets DataContext. |
|
||
|
|
| View | `public IBaseView View { get; set; }` | Reference to the associated view. |
|
||
|
|
| Standalone | `public bool Standalone { get; set; }` | Determines which view type to cast to (`ExportMainView` vs `ExportMainViewGrid`). |
|
||
|
|
| SelectedTest | `public string SelectedTest { get; set; }` | Currently selected test identifier. |
|
||
|
|
| SelectedDTSFile | `public string SelectedDTSFile { get; set; }` | Currently selected DTS file. |
|
||
|
|
| SelectedEventList | `public List<ITestEvent> SelectedEventList { get; set; }` | List of selected test events. |
|
||
|
|
| AvailableTestIds | `public List<string> AvailableTestIds { get; set; }` | Available test IDs. |
|
||
|
|
| AddSelectedEvents | `public void AddSelectedEvents(string groupName, List<ITestEvent> events)` | Publishes busy indicator, adds events to `SelectedEventList`, then clears busy indicator. |
|
||
|
|
| SelectAndIncludeDataFile | `public void SelectAndIncludeDataFile(string value)` | Sets `_selectedDataFile` and publishes `DataFolderChangedEvent`. |
|
||
|
|
| Initialize | `public override void Initialize()` | Calls `Subscribe()` to register event handlers. |
|
||
|
|
| Initialize | `public override void Initialize(object parameter)` | Sets parent, menu/navigation flags, calls `Subscribe()`, sets DataContext. |
|
||
|
|
| Activated | `public override void Activated()` | Empty override. |
|
||
|
|
| ZoomReset | `public void ZoomReset()` | Publishes `ResetZoomChangedEvent` with `true`. |
|
||
|
|
| LeftKeyPress | `public void LeftKeyPress()` | Publishes `ShiftT0Event` with step `-1`. |
|
||
|
|
| RightKeyPress | `public void RightKeyPress()` | Publishes `ShiftT0Event` with step `1`. |
|
||
|
|
| LoadLayoutCommand | `public ICommand LoadLayoutCommand { get; }` | Loads AvalonDock layout from `.\DataProViewerAvalonDock.config`. |
|
||
|
|
| SaveLayoutCommand | `public ICommand SaveLayoutCommand { get; }` | Saves AvalonDock layout to `.\AvalonDock.config`. |
|
||
|
|
| ContextNavigationRegion | `public object ContextNavigationRegion { get; set; }` | Region content accessor; behavior varies by `Standalone` flag. |
|
||
|
|
| ContextGraphRegion | `public object ContextGraphRegion { get; set; }` | Region content accessor; behavior varies by `Standalone` flag. |
|
||
|
|
| ContextGraphListRegion | `public object ContextGraphListRegion { get; set; }` | Region content accessor; behavior varies by `Standalone` flag. |
|
||
|
|
| ContextTestsRegion | `public object ContextTestsRegion { get; set; }` | Region content accessor; behavior varies by `Standalone` flag. |
|
||
|
|
| ContextGraphsRegion | `public object ContextGraphsRegion { get; set; }` | Maps to `GraphListRegion` content. |
|
||
|
|
| ContextPropertyRegion | `public object ContextPropertyRegion { get; set; }` | Property region content. |
|
||
|
|
| SettingsVisibility | `public Visibility SettingsVisibility { get; private set; }` | Controls settings panel visibility. |
|
||
|
|
| TotalSelectedTests | `public int TotalSelectedTests { get; set; }` | Count with title update side effect. |
|
||
|
|
| TotalLoadedTests | `public int TotalLoadedTests { get; set; }` | Count with title update side effect. |
|
||
|
|
| TotalSelectedGraphs | `public int TotalSelectedGraphs { get; set; }` | Count with title update side effect. |
|
||
|
|
| TotalLoadedGraphs | `public int TotalLoadedGraphs { get; set; }` | Count with title update side effect. |
|
||
|
|
| SelectedDataFolder | `public string SelectedDataFolder { get; set; }` | Publishes `DataFolderChangedEvent` on set. |
|
||
|
|
| SelectedDataFile | `public string SelectedDataFile { get; set; }` | Publishes `DataFolderChangedEvent` on set. |
|
||
|
|
| ShowModifications | `public bool ShowModifications { get; set; }` | Set to `true` when T0 shift occurs. |
|
||
|
|
| ChannelCodeViewMode | `public IsoViewMode ChannelCodeViewMode { get; set; }` | Publishes `ChannelCodesViewChangedEvent` on set. |
|
||
|
|
| CalibrationBehaviorSetting | `public CalibrationBehaviors CalibrationBehaviorSetting { get; set; }` | Publishes `ExportCalibrationBehaviorSettingChangedEvent` on set. |
|
||
|
|
| CalibrationBehaviorSettableInViewer | `public bool CalibrationBehaviorSettableInViewer { get; set; }` | Publishes event and selects graphs tab on set. |
|
||
|
|
| IsBusy | `public new bool IsBusy { get; set; }` | Busy indicator state. |
|
||
|
|
| IsBusyMessage | `public new string IsBusyMessage { get; set; }` | Busy indicator message. |
|
||
|
|
| HeaderInfo | `public string HeaderInfo { get; }` | Returns `"MainRegion"`. |
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 3. Invariants
|
||
|
|
|
||
|
|
1. **MEF Singleton Shell**: `ViewerShellViewModel` is exported with `CreationPolicy.Shared`, ensuring a single shell instance per application.
|
||
|
|
|
||
|
|
2. **Region Naming Convention**: All regions are accessed via properties named `Context*Region` and are retrieved from view controls with corresponding `*Region` property names.
|
||
|
|
|
||
|
|
3. **Event Subscription Pattern**: All ViewModels subscribe to events in their constructors or `Initialize` methods; no unsubscription logic is visible in the source.
|
||
|
|
|
||
|
|
4. **Parent-Child Relationship**: `MainViewModel` and `ExportMainViewModel` expect `Initialize(object parameter)` to receive an `IBaseWindowModel` castable object.
|
||
|
|
|
||
|
|
5. **Standalone Mode Switching**: `ExportMainViewModel` region accessors must check `Standalone` boolean to determine correct view type (`ExportMainView` vs `ExportMainViewGrid`).
|
||
|
|
|
||
|
|
6. **Busy Indicator Pairing**: `IsBusy` and `IsBusyMessage` are intended to be used together for UI feedback during operations.
|
||
|
|
|
||
|
|
7. **Layout File Dependencies**: `LoadLayoutCommand` requires `.\DataProViewerAvalonDock.config` to exist; `SaveLayoutCommand` writes to `.\AvalonDock.config`.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 4. Dependencies
|
||
|
|
|
||
|
|
### External Dependencies (from imports)
|
||
|
|
- `Microsoft.Practices.Prism.Events` - Event aggregation (`IEventAggregator`, `ThreadOption`)
|
||
|
|
- `Microsoft.Practices.Prism.Interactivity.InteractionRequest` - `InteractionRequest<T>`, `Notification`, `Confirmation`
|
||
|
|
- `Microsoft.Practices.Prism.Regions` - `IRegionManager`
|
||
|
|
- `Microsoft.Practices.Prism.ViewModel` - `NotificationObject`
|
||
|
|
- `Microsoft.Practices.Unity` - `IUnityContainer`, `ContainerControlledLifetimeManager`
|
||
|
|
- `System.ComponentModel.Composition` - MEF attributes (`Export`, `PartCreationPolicy`, `CreationPolicy`)
|
||
|
|
- `Xceed.Wpf.A
|