init
This commit is contained in:
134
docs/ai/DTS Viewer/DTS.Viewer/ViewModel.md
Normal file
134
docs/ai/DTS Viewer/DTS.Viewer/ViewModel.md
Normal file
@@ -0,0 +1,134 @@
|
||||
---
|
||||
source_files:
|
||||
- DTS Viewer/DTS.Viewer/ViewModel/NavigationViewModel.cs
|
||||
- DTS Viewer/DTS.Viewer/ViewModel/MenuViewModel.cs
|
||||
- DTS Viewer/DTS.Viewer/ViewModel/ShellViewModel.cs
|
||||
- DTS Viewer/DTS.Viewer/ViewModel/ViewerShellViewModel.cs
|
||||
- DTS Viewer/DTS.Viewer/ViewModel/MainViewModel.cs
|
||||
generated_at: "2026-04-17T15:52:42.813402+00:00"
|
||||
model: "zai-org/GLM-5-FP8"
|
||||
schema_version: 1
|
||||
sha256: "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
|
||||
|
||||
1. **Constructor Initialization Order:** All view models set `View.DataContext = this` in the constructor before any other initialization.
|
||||
2. **Event Subscription Pattern:** All view models subscribe to `RaiseNotification` event via `EventAggregator.GetEvent<RaiseNotification>().Subscribe(OnRaiseNotification)` in the constructor.
|
||||
3. **Notification Transformation:** `OnRaiseNotification` handlers always transform `NotificationContentEventArgs` to a new instance containing only `Message`, `MessageDetails`, and `Image` (excluding `Title` from content object, passing it separately to `Notification.Title`).
|
||||
4. **Parent Assignment:** `Initialize(object parameter)` expects `parameter` to be castable to the appropriate parent interface (`IShellViewModel` or `IViewerShellViewModel`).
|
||||
5. **MEF Export:** `ShellViewModel` and `ViewerShellViewModel` are exported as `IShellView` with `CreationPolicy.Shared`.
|
||||
6. **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 infrastructure
|
||||
- `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`)
|
||||
- `System.Windows` - `FrameworkElement`
|
||||
|
||||
### Internal Dependencies:
|
||||
- `DTS.Common.Base` - `BaseViewModel<T>`, `IBaseViewModel
|
||||
Reference in New Issue
Block a user