5.6 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |
|---|---|---|---|---|---|
|
2026-04-16T11:00:01.546105+00:00 | zai-org/GLM-5-FP8 | 1 | 9dcac2937b5c346b |
Documentation: PSDReportSettingsViewModel.cs
1. Purpose
This module provides a ViewModel for configuring PSD (Power Spectral Density) report settings within the DTS Viewer application. It acts as a mediator between the view layer and the data model, responding to graph-related events (channel selection, axis changes, graph clearing) and publishing setting changes to other system components via an event aggregator. The class follows the MVVM pattern using Prism framework conventions.
2. Public Interface
Class: PSDReportSettingsViewModel
Namespace: DTS.Viewer.PSDReportSettings
Inherits from: BaseViewModel<IPSDReportSettingsModel>
Implements: IPSDReportSettingsViewModel
Properties
| Property | Type | Access | Description |
|---|---|---|---|
View |
IBaseView |
get/set | Reference to the associated view; DataContext is set to this in constructor. |
Parent |
IBaseViewModel |
get/set | Parent ViewModel reference, passed during initialization. |
Model |
IPSDReportSettingsModel |
get/set | Hides base Model property. Backed by private _model field; raises OnPropertyChanged("Model") on set. |
NotificationRequest |
InteractionRequest<Notification> |
get | Used to raise notification dialogs. |
ConfirmationRequest |
InteractionRequest<Confirmation> |
get | Hides base property. Used to raise confirmation dialogs. |
Constructor
public PSDReportSettingsViewModel(
IPSDReportSettingsView view,
IRegionManager regionManager,
IEventAggregator eventAggregator,
IUnityContainer unityContainer)
Initializes the ViewModel, sets the View's DataContext, creates interaction requests, and stores references to the event aggregator and Unity container.
Methods
| Method | Signature | Description |
|---|---|---|
Initialize |
override void Initialize() |
Empty override. No initialization logic. |
Initialize |
override void Initialize(object parameter) |
Sets Parent from parameter, calls Subscribe(), resolves IPSDReportSettingsModel from container, and sets Model.Parent = this. |
PublishChanges |
void PublishChanges() |
Publishes a PSDReportSettingsChangedEvent with a PSDReportSettingsChangedEventArg containing the current Model and Parent. |
3. Invariants
-
Parent-Child Relationship: The
Parentproperty must be anIBaseViewModeltype; it is cast directly from theobject parameterinInitialize(object parameter)without null checking. -
Event Filtering: Event handlers (
OnChartAxisChanged,OnGraphSelectedChannelsChanged) filter events by checkingarg?.ParentVM != Parent. Events not matching the parent are ignored. -
Model Resolution: The
Modelis resolved from the Unity container duringInitialize(object parameter), not injected via constructor. -
Publish Control: During X-axis changes in
OnChartAxisChanged,Model.CanPublishChangesis set tofalsebefore modifyingDataStart/DataEnd, then restored totruebefore callingPublishChanges(). -
DataContext Assignment: The View's DataContext is assigned to
this(the ViewModel) in the constructor, not to the Model (a commented line suggests this was previously different).
4. Dependencies
Imports (this module depends on):
DTS.Common.Base- ProvidesBaseViewModel<T>DTS.Common.Events- Provides event args:ChartAxisChangedEventArg,GraphClearNotificationArg,GraphSelectedChannelsNotificationArg,PSDReportSettingsChangedEvent,PSDReportSettingsChangedEventArgDTS.Common.Interactivity- ProvidesInteractionRequest<T>,Notification,ConfirmationDTS.Common.Interface- Provides interfaces:IBaseView,IBaseViewModel,IPSDReportSettingsModel,IPSDReportSettingsView,IPSDReportSettingsViewModelPrism.Events- ProvidesIEventAggregatorPrism.Regions- ProvidesIRegionManagerUnity- ProvidesIUnityContainer
Consumers (what depends on this module):
- Not determinable from this source file alone. Likely consumed by View classes and/or registered in a module initialization or DI container configuration.
5. Gotchas
-
Member Hiding: Both
ModelandConfirmationRequestproperties use thenewkeyword, hiding inherited members fromBaseViewModel<T>. This could lead to unexpected behavior if the base class is accessed polymorphically. -
Commented-Out Code: Several code blocks are commented out, including:
- A
Standaloneproperty - Y-axis handling in
OnChartAxisChanged(lines settingMinFixedY/MaxFixedY) PublishChanges()call inOnGraphSelectedChannelsChanged- A subscription to
CursorsAlailableChangedEventinSubscribe()
This suggests incomplete features or work-in-progress that may cause confusion.
- A
-
Empty
Initialize()Override: The parameterlessInitialize()method is empty. If base class calls this method, no initialization occurs. -
Direct Cast Without Validation: In
Initialize(object parameter), the parameter is cast directly toIBaseViewModelwithout null or type checking, which could throwInvalidCastExceptionor result in null. -
Unused
OnRaiseNotificationMethod: TheOnRaiseNotificationmethod is private with no apparent callers within this class. It may be dead code or intended for future use.