7.8 KiB
7.8 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |
|---|---|---|---|---|---|
|
2026-04-16T13:41:19.428606+00:00 | zai-org/GLM-5-FP8 | 1 | 280cd655454826b4 |
Documentation: PSDReportMainViewModel.cs
1. Purpose
The PSDReportMainViewModel class serves as the primary view model (controller) for the PSD (Power Spectral Density) Report module within the DTS Viewer application. It orchestrates the layout and lifecycle of multiple child views (graphs, tests, settings, navigation) by managing navigation regions and mediating communication via an event aggregator. This class is responsible for handling user interactions such as file selection, calibration settings, and zoom controls, while maintaining the state of the busy indicator and UI titles based on data loading events.
2. Public Interface
Constructor
PSDReportMainViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer)- Initializes the view model, creates interaction requests (
NotificationRequest,ConfirmationRequest), resolves the main view (IPSDReportMainViewGrid) via the Unity container, and sets the DataContext.
- Initializes the view model, creates interaction requests (
Properties
IBaseView View { get; set; }: Gets or sets the associated view.InteractionRequest<Notification> NotificationRequest { get; }: Request object for triggering notifications.InteractionRequest<Confirmation> ConfirmationRequest { get; }: Request object for triggering confirmation dialogs.- Region Context Properties (Manage content of specific regions on the View):
object ContextNavigationRegion: Maps toNavigationRegion.object ContextGraphsRegion: Maps toGraphListRegion.object ContextGraphListRegion: Maps toGraphListRegion.object ContextTestsRegion: Maps toTestsRegion.object ContextLegendRegion: Maps toLegendRegion.object ContextPropertyRegion: Standalone property (logic not fully visible).object ContextChartOptionsRegion: Maps toChartOptionsRegion.object ContextViewerSettingsRegion: Maps toSettingsRegion.object ContextReportDataSelectRegion: Maps toDataSelectRegion.object ContextGraphRegion: Maps toGraphRegion.object ContextReportChartOptionsRegion: Maps toReportChartOptionsRegion.object ContextReportResultsRegion: Maps toReportResultsRegion.
string ConfigPath { get; set; }: ThrowsNotImplementedException.string TitleTests { get; set; }: Title for the Tests section.int TotalSelectedTests { get; set; }: Count of selected tests; updatesTitleTests.int TotalLoadedTests { get; set; }: Count of loaded tests; updatesTitleTests.string TitleGraphs { get; set; }: Title for the Graphs section.int TotalSelectedGraphs { get; set; }: Count of selected graphs; updatesTitleGraphs.int TotalLoadedGraphs { get; set; }: Count of loaded graphs; updatesTitleGraphs.string SelectedDataFolder { get; set; }: Sets the data folder and publishesDataFolderChangedEvent.string SelectedDataFile { get; set; }: Sets the data file and publishesDataFolderChangedEvent.IsoViewMode ChannelCodeViewMode { get; set; }: Gets/sets channel code view mode; publishesChannelCodesViewChangedEvent.CalibrationBehaviors CalibrationBehaviorSetting { get; set; }: Gets/sets calibration behavior; publishesCalibrationBehaviorSettingChangedEvent.bool CalibrationBehaviorSettableInViewer { get; set; }: Determines if calibration is settable; publishes event and forces tab selection logic.Visibility SettingsVisibility { get; }: Controls visibility of settings.bool IsBusy { get; set; }: Controls busy indicator visibility.string IsBusyMessage { get; set; }: Text displayed when busy.bool IsMenuIncluded { get; set; }: Inherited behavior flag.bool IsNavigationIncluded { get; set; }: Inherited behavior flag.bool IsDirty { get; }: ThrowsNotImplementedException.
Methods
List<FrameworkElement> GetRegions(): Retrieves child elements named "Region" from theMainShell.void Initialize(): CallsSubscribe()to register event listeners.void Initialize(object parameter): Sets theParentwindow model and callsSubscribe().void LeftKeyPress(): ThrowsNotImplementedException.void RightKeyPress(): ThrowsNotImplementedException.void ZoomReset(): PublishesResetZoomChangedEventto reset zoom levels.void SelectAndIncludeDataFile(string value): Sets the selected data file and publishes aDataFolderChangedEventwithSetSelectedflag.
3. Invariants
- View Type Constraint: The
Viewproperty must resolve to aPSDReportMainViewGridtype (or compatible type) because the region properties explicitly castViewtoPSDReportMainViewGridto access named UI elements (e.g.,NavigationRegion,GraphListRegion). - Parent Type: The
Initialize(object parameter)method expectsparameterto be castable toIBaseWindowModel. - Event Aggregator Presence: The class relies heavily on
IEventAggregatorbeing injected; it will fail to function (specifically in property setters) if_eventAggregatoris null. - Setter Guards: Properties
SelectedDataFolderandSelectedDataFilewill return without action if the value is null or empty.
4. Dependencies
Internal Dependencies (Inferred from imports)
DTS.Common.Base:BaseViewModel,IBaseView,IBaseViewModel,IBaseWindowModel.DTS.Common.Enums:IsoViewMode,CalibrationBehaviors.DTS.Common.Events:DataFolderChangedEvent,LoadViewModulEvent,ChannelCodesViewChangedEvent,CalibrationBehaviorSettingChangedEvent,ResetZoomChangedEvent, etc.DTS.Common.Interface:IPSDReportMainViewModel,IGraphView,IChartOptionsView, etc.DTS.Common.Utils:Utilsclass (used forGetChildrenByName).DTS.Common.Interactivity:InteractionRequest,Notification,Confirmation.DTS.Viewer.PSDReport.Resources:StringResources.
External Dependencies
- Prism:
IEventAggregator,IRegionManager(Event driving and navigation). - Unity:
IUnityContainer(Dependency injection and view resolution). - System.Windows: WPF UI components (
FrameworkElement,Visibility).
5. Gotchas
- MVVM Violation in Properties: The region properties (e.g.,
ContextNavigationRegion) directly access and cast the View toPSDReportMainViewGridto manipulate UI elements (Contentproperties). This creates a tight coupling between the ViewModel and the specific View implementation, violating standard MVVM principles. - Duplicate Region Logic:
ContextGraphsRegionandContextGraphListRegionboth access((PSDReportMainViewGrid)View).GraphListRegion.Content. This appears to be a copy-paste error whereContextGraphsRegionshould likely target a different region. - Member Hiding: The class uses the
newkeyword to hide base members (e.g.,IsBusy,IsBusyMessage,ConfirmationRequest,OnPropertyChanged). This can lead to unexpected behavior if the object is accessed via a base class reference, as the base implementation will be called instead of the derived one. - Not Implemented Features: Several public members throw
NotImplementedException(ConfigPath,IsDirty,LeftKeyPress,RightKeyPress). These should not be relied upon in production code. - Direct Tab Manipulation: The setter for
CalibrationBehaviorSettableInViewerdirectly manipulates theIsSelectedandFocusableproperties of UI tabs (graphsTab,testsTab,chartResultsTab) found on the View. This logic references bug fix IDs (FB13946, FB14797) and implies fragile UI logic embedded in the ViewModel.