105 lines
5.5 KiB
Markdown
105 lines
5.5 KiB
Markdown
---
|
|
source_files:
|
|
- DTS Viewer/DTS.Viewer/View/DockPanelHorizontal/ViewModel/DockPanelHorizontalViewModel.cs
|
|
generated_at: "2026-04-16T14:03:50.492383+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 MVVM architecture, responsible for managing the state and behavior of a horizontal dock panel view. It serves as a mediator between the view (`IDockPanelHorizontalView`) and the application's infrastructure (region navigation, event aggregation, dependency injection). The class currently provides a functional notification system while the majority of its lifecycle methods remain unimplemented stubs.
|
|
|
|
---
|
|
|
|
## 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 interaction requests, and subscribes to the `RaiseNotification` event.
|
|
|
|
### Properties
|
|
|
|
| Property | Type | Access | Description |
|
|
|----------|------|--------|-------------|
|
|
| `View` | `IDockPanelHorizontalView` | `get` | The associated view instance. |
|
|
| `NotificationRequest` | `InteractionRequest<Notification>` | `get` | Prism interaction request for displaying notifications. |
|
|
| `ConfirmationRequest` | `InteractionRequest<Confirmation>` | `get` | Prism interaction request for displaying confirmations. |
|
|
| `IsMenuIncluded` | `bool` | `get; set` | Flag indicating whether a menu is included. |
|
|
| `IsNavigationIncluded` | `bool` | `get; set` | Flag indicating whether navigation is included. |
|
|
| `IsBusy` | `bool` | `get; set` | Indicates if the ViewModel is in a busy state. |
|
|
| `IsDirty` | `bool` | `get; private set` | Indicates if there are unsaved changes. |
|
|
|
|
### Events
|
|
```csharp
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
```
|
|
Standard property-changed event for data binding.
|
|
|
|
### Methods (Override/New)
|
|
|
|
| Method | Signature | Implementation Status |
|
|
|--------|-----------|----------------------|
|
|
| `Initialize` | `override void Initialize()` | **Throws `NotImplementedException`** |
|
|
| `Initialize` | `override void Initialize(object parameter)` | **Throws `NotImplementedException`** |
|
|
| `Initialize` | `new void Initialize(object parameter, object model)` | **Throws `NotImplementedException`** |
|
|
| `InitializeAsync` | `override Task InitializeAsync()` | **Throws `NotImplementedException`** |
|
|
| `InitializeAsync` | `override Task InitializeAsync(object parameter)` | **Throws `NotImplementedException`** |
|
|
| `Activated` | `override void Activated()` | **Throws `NotImplementedException`** |
|
|
| `Cleanup` | `override void Cleanup()` | **Throws `NotImplementedException`** |
|
|
| `CleanupAsync` | `new Task CleanupAsync()` | **Throws `NotImplementedException`** |
|
|
|
|
---
|
|
|
|
## 3. Invariants
|
|
|
|
- **DataContext Binding**: The `View.DataContext` is always set to `this` upon construction.
|
|
- **Event Subscription**: The `RaiseNotification` event subscription is established in the constructor and remains active for the lifetime of the ViewModel.
|
|
- **IsDirty Encapsulation**: The `IsDirty` property can only be modified internally (private setter).
|
|
- **Base Class Contract**: Inherits from `BaseViewModel<IDockPanelHorizontalViewModel>` and implements `IDockPanelHorizontalViewModel`.
|
|
|
|
---
|
|
|
|
## 4. Dependencies
|
|
|
|
### External Dependencies (from imports)
|
|
- **`Microsoft.Practices.Prism.Events`** - `IEventAggregator` for pub/sub event handling
|
|
- **`Microsoft.Practices.Prism.Interactivity.InteractionRequest`** - `InteractionRequest<T>`, `Notification`, `Confirmation` for UI dialogs
|
|
- **`Microsoft.Practices.Prism.Regions`** - `IRegionManager` for region-based navigation
|
|
- **`Microsoft.Practices.Unity`** - `IUnityContainer` for dependency injection
|
|
|
|
### Internal Dependencies
|
|
- **`DTS.Common.Base`** - Provides `BaseViewModel<T>`
|
|
- **`DTS.Common.Events`** - Provides `RaiseNotification` event and `NotificationContentEventArgs`
|
|
- **`DTS.Common.Interface`** - Provides `IViewModel`, `IDockPanelHorizontalViewModel`, `IDockPanelHorizontalView`
|
|
|
|
### Dependents
|
|
- Cannot be determined from this source file alone.
|
|
|
|
---
|
|
|
|
## 5. Gotchas
|
|
|
|
1. **Incomplete Implementation**: All lifecycle methods (`Initialize`, `InitializeAsync`, `Activated`, `Cleanup`, `CleanupAsync`) throw `NotImplementedException`. Calling these will crash the application.
|
|
|
|
2. **Method Hiding with `new` Keyword**:
|
|
- `CleanupAsync()` and `Initialize(object, object)` use `new` rather than `override`, meaning they hide base class members. Calls through a base class reference will invoke the base implementation, not these methods.
|
|
|
|
3. **Field Hiding**: The `_regionManager` field is declared with `new`, hiding any base class field of the same name. This may cause confusion about which instance is being used.
|
|
|
|
4. **Redundant PropertyChanged Event**: The class declares `PropertyChanged` event, but `BaseViewModel` likely already implements `INotifyPropertyChanged`. This could cause issues if the base relies on its own event declaration.
|
|
|
|
5. **Legacy Prism Version**: Uses `Microsoft.Practices.Prism` namespace, indicating an older version of Prism (pre-6.x). Modern Prism uses `Prism` namespace.
|
|
|
|
6. **Unused ConfirmationRequest**: `ConfirmationRequest` is instantiated but never raised anywhere in this class. Its intended usage is unclear from this source.
|
|
|
|
7. **Unused Private Members**: `Parent`, `_regionManager`, and `UnityContainer` are stored but never used in any implemented method. |