114 lines
6.3 KiB
Markdown
114 lines
6.3 KiB
Markdown
---
|
|
source_files:
|
|
- DTS Viewer/DTS.Viewer/View/DockPanelHorizontal/ViewModel/DockPanelHorizontalViewModel.cs
|
|
generated_at: "2026-04-16T11:24:34.196995+00:00"
|
|
model: "zai-org/GLM-5-FP8"
|
|
schema_version: 1
|
|
sha256: "6bc81faa835eebdc"
|
|
---
|
|
|
|
# DockPanelHorizontalViewModel Documentation
|
|
|
|
## 1. Purpose
|
|
|
|
`DockPanelHorizontalViewModel` is a ViewModel component within a WPF/Prism-based application that manages the state and behavior of a horizontal dock panel UI element. It inherits from `BaseViewModel<IDockPanelHorizontalViewModel>` and implements `IDockPanelHorizontalViewModel`, serving as a coordinator between the view layer and the application's event system. The class provides notification/confirmation dialog support via Prism's `InteractionRequest` pattern and subscribes to application-wide `RaiseNotification` events.
|
|
|
|
---
|
|
|
|
## 2. Public Interface
|
|
|
|
### Constructor
|
|
|
|
```csharp
|
|
public DockPanelHorizontalViewModel(
|
|
IDockPanelHorizontalView view,
|
|
IRegionManager regionManager,
|
|
IEventAggregator eventAggregator,
|
|
IUnityContainer unityContainer)
|
|
```
|
|
Initializes the ViewModel, sets the View's `DataContext` to itself, creates `NotificationRequest` and `ConfirmationRequest` instances, stores dependencies, and subscribes to the `RaiseNotification` event via the `EventAggregator`.
|
|
|
|
### Properties
|
|
|
|
| Property | Type | Access | Description |
|
|
|----------|------|--------|-------------|
|
|
| `View` | `IDockPanelHorizontalView` | `public get; private set` | Reference to the associated view instance. |
|
|
| `NotificationRequest` | `InteractionRequest<Notification>` | `public get; private set` | Prism interaction request for displaying notifications. |
|
|
| `ConfirmationRequest` | `InteractionRequest<Confirmation>` | `public get; private set` | Prism interaction request for displaying confirmation dialogs. |
|
|
| `IsMenuIncluded` | `bool` | `public get; set` | Flag indicating whether a menu is included. |
|
|
| `IsNavigationIncluded` | `bool` | `public get; set` | Flag indicating whether navigation is included. |
|
|
| `IsBusy` | `bool` | `public get; set` | Flag indicating busy/loading state. |
|
|
| `IsDirty` | `bool` | `public get; private set` | Flag indicating unsaved changes state. |
|
|
|
|
### Events
|
|
|
|
```csharp
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
```
|
|
Standard `INotifyPropertyChanged` event declaration.
|
|
|
|
### Methods
|
|
|
|
| Method | Return Type | Behavior |
|
|
|--------|-------------|----------|
|
|
| `Initialize()` | `void` | Throws `NotImplementedException`. |
|
|
| `Initialize(object parameter)` | `void` | Throws `NotImplementedException`. |
|
|
| `Activated()` | `void` | Throws `NotImplementedException`. |
|
|
| `Cleanup()` | `void` | Throws `NotImplementedException`. |
|
|
| `CleanupAsync()` | `Task` | Throws `NotImplementedException`. Marked with `new` keyword. |
|
|
| `Initialize(object parameter, object model)` | `void` | Throws `NotImplementedException`. Marked with `new` keyword. |
|
|
| `InitializeAsync()` | `Task` | Throws `NotImplementedException`. |
|
|
| `InitializeAsync(object parameter)` | `Task` | Throws `NotImplementedException`. |
|
|
|
|
### Private Methods
|
|
|
|
```csharp
|
|
private void OnRaiseNotification(NotificationContentEventArgs eventArgsWithTitle)
|
|
```
|
|
Event handler for `RaiseNotification` events. Extracts `Message`, `MessageDetails`, `Image`, and `Title` from the received `NotificationContentEventArgs`, constructs a new `NotificationContentEventArgs` (without title), and raises the `NotificationRequest` with a `Notification` containing the reconstructed content and separate title.
|
|
|
|
---
|
|
|
|
## 3. Invariants
|
|
|
|
- The `View.DataContext` is set to `this` (the ViewModel instance) upon construction and is never changed.
|
|
- `NotificationRequest` and `ConfirmationRequest` are always non-null after construction.
|
|
- The `RaiseNotification` event subscription is established during construction and remains active for the lifetime of the ViewModel (no unsubscription is visible in the source).
|
|
- `IsDirty` can only be modified internally (private setter).
|
|
- The `_regionManager` field hides a base class member with the same name (via `new` keyword).
|
|
|
|
---
|
|
|
|
## 4. Dependencies
|
|
|
|
### This Module Depends On
|
|
|
|
| Namespace | Type(s) Used |
|
|
|-----------|--------------|
|
|
| `DTS.Common.Base` | `BaseViewModel<T>` |
|
|
| `DTS.Common.Events` | `RaiseNotification`, `NotificationContentEventArgs` |
|
|
| `DTS.Common.Interface` | `IViewModel`, `IDockPanelHorizontalViewModel` |
|
|
| `Microsoft.Practices.Prism.Events` | `IEventAggregator` |
|
|
| `Microsoft.Practices.Prism.Interactivity.InteractionRequest` | `InteractionRequest<T>`, `Notification`, `Confirmation` |
|
|
| `Microsoft.Practices.Prism.Regions` | `IRegionManager` |
|
|
| `Microsoft.Practices.Unity` | `IUnityContainer` |
|
|
|
|
### What Depends On This Module
|
|
|
|
Not determinable from source alone. The module implements `IDockPanelHorizontalViewModel`, suggesting consumers depend on that interface rather than the concrete class directly.
|
|
|
|
---
|
|
|
|
## 5. Gotchas
|
|
|
|
1. **Most lifecycle methods are unimplemented**: `Initialize()`, `Initialize(object)`, `Activated()`, `Cleanup()`, `CleanupAsync()`, `Initialize(object, object)`, `InitializeAsync()`, and `InitializeAsync(object)` all throw `NotImplementedException`. This class appears to be a partial implementation or stub.
|
|
|
|
2. **Method hiding with `new` keyword**: `CleanupAsync()` and `Initialize(object parameter, object model)` use `new` rather than `override`, potentially hiding base class implementations. This may indicate a design inconsistency or versioning artifact.
|
|
|
|
3. **Field hiding**: The `_regionManager` field is declared with `new`, hiding a base class member. The implications of this depend on the base class implementation.
|
|
|
|
4. **Redundant object construction in `OnRaiseNotification`**: The handler constructs a new `NotificationContentEventArgs` from the received one, passing `Message`, `MessageDetails`, and `Image` to the constructor. The comment indicates this is intentional ("expects a NotificationContentEventArgsWithoutTitle object"), but the type used is `NotificationContentEventArgs`. Whether this is correct or a bug is unclear from source alone.
|
|
|
|
5. **No event unsubscription**: There is no visible unsubscription from `RaiseNotification` in any cleanup method. Since `Cleanup()` throws `NotImplementedException`, memory leaks via event subscription are possible if the base class does not handle this.
|
|
|
|
6. **Unused `Parent` property**: The `Parent` property (type `IViewModel`) is declared but never assigned or used in the visible source. |