10 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||||
|---|---|---|---|---|---|---|---|---|---|
|
2026-04-17T15:52:42.813402+00:00 | zai-org/GLM-5-FP8 | 1 | d5b4057c745da02a |
DTS.Viewer ViewModel Module Documentation
1. Purpose
This module provides the core ViewModel layer for the DTS Viewer WPF application, implementing the MVVM pattern with Prism framework integration. It contains the shell-level view models (ShellViewModel, ViewerShellViewModel), navigation components (NavigationViewModel), menu handling (MenuViewModel), and main content orchestration (MainViewModel). These ViewModels manage view lifecycle, region navigation, event aggregation for decoupled communication, and dependency injection registration for their associated views.
2. Public Interface
NavigationViewModel
Signature: public class NavigationViewModel : BaseViewModel<INavigationViewModel>, INavigationViewModel
| Member | Signature | Description |
|---|---|---|
| Constructor | NavigationViewModel(INavigationView view, IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer) |
Initializes the view model, sets DataContext on view, creates interaction requests, and subscribes to RaiseNotification event. |
| NavigationView | public INavigationView NavigationView { get; private set; } |
Holds reference to the associated navigation view. |
| ContextNavigationRegion | public object ContextNavigationRegion { get; set; } |
Gets/sets content of the NavigationRegion from the NavigationView. Raises OnPropertyChanged on set. |
| HeaderInfo | public string HeaderInfo { get; } |
Returns constant string "NavigationRegion". |
| Initialize | public override void Initialize() |
Empty implementation. |
| Initialize | public override void Initialize(object parameter) |
Casts parameter to IShellViewModel and assigns to Parent field. |
| NotificationRequest | public InteractionRequest<Notification> NotificationRequest { get; private set; } |
Prism interaction request for notifications. |
| ConfirmationRequest | public InteractionRequest<Confirmation> ConfirmationRequest { get; private set; } |
Prism interaction request for confirmations. |
Methods throwing NotImplementedException: IsBusy (getter/setter), Activated(), IsDirty (getter), Cleanup(), CleanupAsync(), InitializeAsync(), InitializeAsync(object parameter)
MenuViewModel
Signature: public class MenuViewModel : BaseViewModel<IMenuViewModel>, IMenuViewModel
| Member | Signature | Description |
|---|---|---|
| Constructor | MenuViewModel(IMenuView view, IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer) |
Initializes view model, sets DataContext, creates interaction requests, subscribes to RaiseNotification event. |
| View | public IMenuView View { get; private set; } |
Reference to the associated menu view. |
| HeaderInfo | public string HeaderInfo { get; } |
Returns constant string "MainRegion". |
| Initialize | public override void Initialize() |
Contains placeholder code (int i = 10;). |
| Initialize | public override void Initialize(object parameter) |
Casts parameter to IShellViewModel and assigns to Parent. |
| CreateViews | private void CreateViews(Boolean initialize) |
Creates a ViewDefinition for RegionNames.MainRegion with IBaseView/IBaseViewModel types. Currently incomplete - view definition is not added to region manager. |
Methods throwing NotImplementedException: Same pattern as NavigationViewModel.
ShellViewModel
Signature: public class ShellViewModel : NotificationObject, IViewerShellViewModel
| Member | Signature | Description |
|---|---|---|
| Constructor | ShellViewModel(IViewerShellView view, IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer) |
Initializes view model, subscribes to RaiseNotification, registers IMainView→MainView and IMainViewModel→MainViewModel (singleton) with Unity container. |
| View | public IViewerShellView View { get; private set; } |
Reference to shell view. |
| ContextMainRegion | public Object ContextMainRegion { get; set; } |
Gets/sets content of MainRegion from ShellView. Raises OnPropertyChanged on set. |
| 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". |
| GetRegions | public List<FrameworkElement> GetRegions() |
Uses Utils.GetChildrenByName to find elements named "Region" in MainShell. |
| Initialize | public void Initialize() |
Placeholder implementation (int i = 10;). |
| Initialize | public void Initialize(object parameter) |
Placeholder implementation (int i = 22;). |
| Initialize | public void Initialize(object parameter, object model) |
Empty implementation. |
| Activated | public void Activated() |
Creates empty string variable. |
Methods throwing NotImplementedException: IsBusy (getter), IsDirty (getter), Cleanup(), CleanupAsync(), InitializeAsync(), InitializeAsync(object parameter)
ViewerShellViewModel
Signature: public class ViewerShellViewModel : NotificationObject, IViewerShellViewModel
| Member | Signature | Description |
|---|---|---|
| Constructor | ViewerShellViewModel(IViewerShellView view, IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer) |
Initializes view model, subscribes to RaiseNotification, registers IViewerMainView→ViewerMainView and IViewerMainViewModel→ViewerMainViewModel (singleton). |
| ContextMainRegion | public Object ContextMainRegion { get; set; } |
Gets/sets content of MainRegion from ViewerShellView. |
| IsMenuIncluded | public bool IsMenuIncluded { get; set; } |
Property with change notification. |
| IsNavigationIncluded | public bool IsNavigationIncluded { get; set; } |
Property with change notification. |
| IsBusy | public bool IsBusy { get; set; } |
Implemented - unlike ShellViewModel, this has working getter/setter with backing field _isBusy. |
| GetRegions | public List<FrameworkElement> GetRegions() |
Uses Utils.GetChildrenByName on ViewerShellView.MainShell. |
Methods throwing NotImplementedException: IsDirty (getter), Cleanup(), CleanupAsync(), InitializeAsync(), InitializeAsync(object parameter), IBasePropertyChanged.OnPropertyChanged(string propertyName)
MainViewModel
Signature: public class MainViewModel : BaseViewModel<IMainViewModel>, IMainViewModel
| Member | Signature | Description |
|---|---|---|
| Constructor | MainViewModel(IMainView view, IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer) |
Initializes view model, subscribes to RaiseNotification and AssemblyListNotification events. Registers IMenuView/MenuView, IMenuViewModel/MenuViewModel, INavigationView/NavigationView, INavigationViewModel/NavigationViewModel with Unity. |
| View | public IMainView View { get; private set; } |
Reference to main view. |
| Initialize | public override void Initialize() |
Empty implementation. |
| Initialize | public override void Initialize(object parameter) |
Casts parameter to IViewerShellViewModel, sets Parent.IsMenuIncluded and Parent.IsNavigationIncluded, subscribes to AssemblyListNotification event. |
| ContextMainRegion | public object ContextMainRegion { get; set; } |
Getter returns null. Setter raises OnPropertyChanged only. |
| IsMenuIncluded | public new bool IsMenuIncluded { get; set; } |
Property with backing field _isMenuIncluded. Marked new. |
| IsNavigationIncluded | public new bool IsNavigationIncluded { get; set; } |
Property with backing field _isNavigationIncluded. Marked new. |
| OnAssemblyListChange | private void OnAssemblyListChange(AssemblyListInfo e) |
Handler for AssemblyListNotification event. Entire implementation is commented out. |
3. Invariants
- Constructor Initialization Order: All view models set
View.DataContext = thisin the constructor before any other initialization. - Event Subscription Pattern: All view models subscribe to
RaiseNotificationevent viaEventAggregator.GetEvent<RaiseNotification>().Subscribe(OnRaiseNotification)in the constructor. - Notification Transformation:
OnRaiseNotificationhandlers always transformNotificationContentEventArgsto a new instance containing onlyMessage,MessageDetails, andImage(excludingTitlefrom content object, passing it separately toNotification.Title). - Parent Assignment:
Initialize(object parameter)expectsparameterto be castable to the appropriate parent interface (IShellViewModelorIViewerShellViewModel). - MEF Export:
ShellViewModelandViewerShellViewModelare exported asIShellViewwithCreationPolicy.Shared. - Unity Registration Timing: Type registrations (
RegisterType) occur in constructors, meaning they execute before any view model methods.
4. Dependencies
External Dependencies (from imports):
Microsoft.Practices.Prism.Events-IEventAggregator, event infrastructureMicrosoft.Practices.Prism.Interactivity.InteractionRequest-InteractionRequest<T>,Notification,ConfirmationMicrosoft.Practices.Prism.Regions-IRegionManagerMicrosoft.Practices.Prism.ViewModel-NotificationObjectMicrosoft.Practices.Unity-IUnityContainer,ContainerControlledLifetimeManagerSystem.ComponentModel.Composition- MEF attributes (Export,PartCreationPolicy,CreationPolicy)System.Windows-FrameworkElement
Internal Dependencies:
DTS.Common.Base-BaseViewModel<T>, `IBaseViewModel