Files
DP44/docs/ai/DTS Viewer/DTS.Viewer/View/DockPanelHorizontal/ViewModel.md

62 lines
3.3 KiB
Markdown
Raw Normal View History

2026-04-17 14:55:32 -04:00
---
source_files:
- DTS Viewer/DTS.Viewer/View/DockPanelHorizontal/ViewModel/DockPanelHorizontalViewModel.cs
generated_at: "2026-04-17T16:29:26.445526+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "ce03b3583ccf9c32"
---
# ViewModel
### Purpose
This module provides the `DockPanelHorizontalViewModel` class, a Prism-based ViewModel for a horizontal dock panel UI component in the DTS Viewer application. It serves as a mediator between the view (`IDockPanelHorizontalView`) and the application infrastructure, handling notification requests via Prism's `InteractionRequest` pattern and subscribing to application-wide `RaiseNotification` events.
### Public Interface
**Class:** `DockPanelHorizontalViewModel` (extends `BaseViewModel<IDockPanelHorizontalViewModel>`, implements `IDockPanelHorizontalViewModel`)
**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, and subscribes to the `RaiseNotification` event.
**Properties:**
- `IDockPanelHorizontalView View { get; }` — The associated view instance.
- `InteractionRequest<Notification> NotificationRequest { get; }` — Used to raise notification dialogs.
- `InteractionRequest<Confirmation> ConfirmationRequest { get; }` — Used to raise confirmation dialogs.
- `bool IsMenuIncluded { get; set; }` — UI state flag.
- `bool IsNavigationIncluded { get; set; }` — UI state flag.
- `bool IsBusy { get; set; }` — Indicates busy state.
- `bool IsDirty { get; private set; }` — Indicates unsaved changes.
**Events:**
- `event PropertyChangedEventHandler PropertyChanged` — Declared but not explicitly invoked in visible code.
**Methods:**
- `void OnRaiseNotification(NotificationContentEventArgs eventArgsWithTitle)` — Private handler that raises `NotificationRequest` with title, message, details, and image from the event args.
- `override void Initialize()` — Throws `NotImplementedException`.
- `override void Initialize(object parameter)` — Throws `NotImplementedException`.
- `void Initialize(object parameter, object model)` — Throws `NotImplementedException` (hides base with `new`).
- `override void Activated()` — Throws `NotImplementedException`.
- `override void Cleanup()` — Throws `NotImplementedException`.
- `Task CleanupAsync()` — Throws `NotImplementedException` (hides base with `new`).
- `override Task InitializeAsync()` — Throws `NotImplementedException`.
- `override Task InitializeAsync(object parameter)` — Throws `NotImplementedException`.
### Invariants
- The View's `DataContext` is always set to the ViewModel instance upon construction.
- The ViewModel subscribes to `RaiseNotification` event via `EventAggregator` on construction.
- `IsDirty` is read-only externally (private setter).
### Dependencies
**Depends on:**
- `DTS.Common.Base` (`BaseViewModel<T>`)
- `DTS.Common.Events` (`RaiseNotification`, `NotificationContentEventArgs`, `NotificationContentEventArgsWithoutTitle` — inferred from usage)
- `DTS.Common.Interface` (`IViewModel`, `IDockPanelHorizontalViewModel`, `IDockPanelHorizontalView`)
- `Microsoft.Practices.Prism.Events` (`IEventAggregator