Files
2026-04-17 14:55:32 -04:00

53 lines
3.2 KiB
Markdown

---
source_files:
- DTS Viewer/DTS.Viewer.Loader/ViewModel/ShellViewModel.cs
generated_at: "2026-04-17T16:14:09.333450+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "25896deb08ecc534"
---
# ViewModel
### Purpose
This module contains the `ShellViewModel` class, which serves as the ViewModel for the main application shell in a WPF application built using the Prism framework. It acts as the orchestration layer for the UI, managing the view's DataContext, handling interaction requests (notifications/confirmations), and coordinating region navigation via the `IRegionManager`. It bridges the view (`IShellView`) and the backend services via dependency injection (`IUnityContainer`) and event aggregation (`IEventAggregator`).
### Public Interface
* **`ShellViewModel(IShellView view, IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer)`**
* Constructor that initializes the ViewModel, sets the View's DataContext to itself, instantiates `InteractionRequest` objects, and subscribes to the `RaiseNotification` event.
* **`void Initialize()` / `void Initialize(object parameter)`**
* Empty initialization methods.
* **`void Activated()`**
* Empty activation method.
* **`void Cleanup()`**
* Throws `NotImplementedException`.
* **`Task CleanupAsync()` / `Task InitializeAsync()` / `Task InitializeAsync(object parameter)`**
* Asynchronous lifecycle methods that currently throw `NotImplementedException`.
* **`List<FrameworkElement> GetRegions()`**
* Returns a list of framework elements named "Region" within the `MainShell` grid of the view.
* **`Object ContextMainRegion`**
* Property that gets or sets the content of the `MainRegion` ContentControl in the View. Triggers `OnPropertyChanged` on set.
* **`InteractionRequest<Notification> NotificationRequest`**
* Property used to raise popup notifications in the UI.
* **`InteractionRequest<Confirmation> ConfirmationRequest`**
* Property used to raise confirmation dialogs in the UI.
* **Properties**: `Width`, `Height`, `IsMenuIncluded`, `IsNavigationIncluded`, `HeaderInfo` (returns "MainRegion"), `IsBusy`, `IsDirty` (read-only).
### Invariants
* The `View` property is assigned in the constructor and is never expected to be null during the object's lifetime.
* `NotificationRequest` and `ConfirmationRequest` are initialized immediately in the constructor and are never null.
* The `HeaderInfo` property always returns the string "MainRegion".
* `IsDirty` is a read-only property (effectively always false/default unless logic exists elsewhere).
### Dependencies
* **Dependencies:**
* `DTS.Common.Events` (for `RaiseNotification`, `NotificationContentEventArgs`)
* `DTS.Common.Interface` (for `IShellView`, `IViewerShellView`, `IViewerShellViewModel`)
* `DTS.Common.Utils` (for `Utils.GetChildrenByName`)
* `DTS.Common.Base`
* `Microsoft.Practices.Prism.Events` (for `IEventAggregator`)
* `Microsoft.Practices.Prism.Regions` (for `IRegionManager`)
* `Microsoft.Practices.Prism.Interactivity.InteractionRequest`
* `Microsoft.Practices.Unity` (for `IUnityContainer`)
* `System.ComponentModel.Composition`
* **