108 lines
6.2 KiB
Markdown
108 lines
6.2 KiB
Markdown
|
|
---
|
||
|
|
source_files:
|
||
|
|
- Common/DTS.Common/Dialogs/IRegionManagerAware.cs.cs
|
||
|
|
- Common/DTS.Common/Dialogs/IPopupWindowActionAware.cs
|
||
|
|
- Common/DTS.Common/Dialogs/ConfirmationEx.cs
|
||
|
|
- Common/DTS.Common/Dialogs/ConfirmationWindow.xaml.cs
|
||
|
|
- Common/DTS.Common/Dialogs/NotificationWindow.xaml.cs
|
||
|
|
- Common/DTS.Common/Dialogs/PopupWindowAction.cs
|
||
|
|
- Common/DTS.Common/Dialogs/BrowseForFolderDialog.cs
|
||
|
|
generated_at: "2026-04-17T15:34:29.121125+00:00"
|
||
|
|
model: "zai-org/GLM-5-FP8"
|
||
|
|
schema_version: 1
|
||
|
|
sha256: "49bfef2ac994b629"
|
||
|
|
---
|
||
|
|
|
||
|
|
# Dialogs
|
||
|
|
|
||
|
|
## Purpose
|
||
|
|
|
||
|
|
The `DTS.Common.Dialogs` namespace provides infrastructure for displaying modal and non-modal dialogs within a WPF application, specifically designed to work with the Prism framework's `InteractionRequest` patterns. It bridges the gap between view-model interaction requests and actual window display via `PopupWindowAction`, supports region management within popups through `IRegionManagerAware`, and offers specialized window implementations for confirmations and notifications. Additionally, it provides a managed wrapper around the Win32 `SHBrowseForFolder` API for folder selection dialogs.
|
||
|
|
|
||
|
|
## Public Interface
|
||
|
|
|
||
|
|
### Interfaces
|
||
|
|
|
||
|
|
* **`IRegionManagerAware`**
|
||
|
|
* **Property:** `IRegionManager RegionManager { get; set; }`
|
||
|
|
* **Behavior:** Allows a view or data context to receive a scoped `IRegionManager` when hosted inside a popup window created by `PopupWindowAction`.
|
||
|
|
|
||
|
|
* **`IPopupWindowActionAware`**
|
||
|
|
* **Properties:**
|
||
|
|
* `Window HostWindow { get; set; }`
|
||
|
|
* `Notification HostNotification { get; set; }`
|
||
|
|
* **Behavior:** Allows a view or data context to access the host window instance and the notification context that triggered the popup.
|
||
|
|
|
||
|
|
### Classes
|
||
|
|
|
||
|
|
* **`ConfirmationEx`** (inherits `Confirmation`)
|
||
|
|
* **Properties:**
|
||
|
|
* `MessageBoxButton Buttons { get; set; }` (Default: `MessageBoxButton.OKCancel`)
|
||
|
|
* `MessageBoxImage Image { get; set; }` (Default: `MessageBoxImage.Question`)
|
||
|
|
* `MessageBoxResult Result { get; set; }`
|
||
|
|
* **Behavior:** Extends the standard `Confirmation` class to include specific button configurations, image types, and a result property for dialog outcomes.
|
||
|
|
|
||
|
|
* **`ConfirmationWindow`**
|
||
|
|
* **Constructors:** `public ConfirmationWindow()`
|
||
|
|
* **Properties:**
|
||
|
|
* `DataTemplate ConfirmationTemplate` (Dependency Property)
|
||
|
|
* **Methods:**
|
||
|
|
* `public void Connect(int connectionId, object target)` — *Implementation throws `NotImplementedException`.*
|
||
|
|
|
||
|
|
* **`NotificationWindow`** (inherits `Window`)
|
||
|
|
* **Constructors:** `public NotificationWindow()`
|
||
|
|
* **Properties:**
|
||
|
|
* `DataTemplate NotificationTemplate` (Dependency Property)
|
||
|
|
* `Uri ImageUri` (Dependency Property; Default: `pack://application:,,,/.../warning_48.png`)
|
||
|
|
* **Methods:**
|
||
|
|
* `public void Connect(int connectionId, object target)` — *Implementation is empty.*
|
||
|
|
|
||
|
|
* **`PopupWindowAction`** (inherits `TriggerAction<FrameworkElement>`)
|
||
|
|
* **Nested Types:** `enum WindowPositions` (`CenterOwner`, `CenterScreen`)
|
||
|
|
* **Properties (Dependency Properties):**
|
||
|
|
* `FrameworkElement WindowContent`
|
||
|
|
* `DataTemplate ContentTemplate`
|
||
|
|
* `bool IsModal`
|
||
|
|
* `WindowPositions StartupPosition` (Default: `CenterScreen`)
|
||
|
|
* `bool CenterOverAssociatedObject` — *Note: Usage appears commented out in logic.*
|
||
|
|
* `bool AllowMultipleNotificationWindows`
|
||
|
|
* **Methods:**
|
||
|
|
* `protected override void Invoke(object parameter)`: Executes the trigger, creates the window, sets up positioning, and shows it (modal or non-modal).
|
||
|
|
* `protected void PrepareContentForWindow(Notification notification, Window wrapperWindow)`: Injects `RegionManager`, `HostWindow`, and `HostNotification` into the view if the view or its DataContext implements the aware interfaces.
|
||
|
|
* `protected Window GetWindow(Notification notification)`: Factory method returning a generic window or a specific `ConfirmationWindow`/`NotificationWindow`.
|
||
|
|
* `protected Window CreateWindow(Notification notification)`: Creates the specific window instance based on notification type.
|
||
|
|
|
||
|
|
* **`BrowseForFolderDialog`**
|
||
|
|
* **Constructors:** `public BrowseForFolderDialog()` (Sets default flags to `BIF_NEWDIALOGSTYLE`)
|
||
|
|
* **Properties:**
|
||
|
|
* `string SelectedFolder`
|
||
|
|
* `string Title`
|
||
|
|
* `string InitialFolder`
|
||
|
|
* `string InitialExpandedFolder`
|
||
|
|
* `string OKButtonText`
|
||
|
|
* `BROWSEINFOW BrowseInfo`
|
||
|
|
* `BrowseInfoFlags BrowserDialogFlags`
|
||
|
|
* **Methods:**
|
||
|
|
* `public Nullable<bool> ShowDialog()`
|
||
|
|
* `public Nullable<bool> ShowDialog(Window owner)`
|
||
|
|
* **Nested Types:**
|
||
|
|
* `enum BrowseInfoFlags` (Flags enum for `BIF_*` constants)
|
||
|
|
* `class BROWSEINFOW` (Win32 structure wrapper)
|
||
|
|
* `enum MessageFromBrowser`
|
||
|
|
* `enum MessageToBrowser`
|
||
|
|
* `delegate int BrowseCallbackProc(...)`
|
||
|
|
|
||
|
|
## Invariants
|
||
|
|
|
||
|
|
1. **Window System Menu Removal:** Both `ConfirmationWindow` and `NotificationWindow` will always have the `WS_SYSMENU` style bit removed during `SourceInitialized`. This effectively hides the system menu and the close button on the title bar.
|
||
|
|
2. **Region Management:** If `PopupWindowAction` creates a window with `WindowContent`, and that content does not already have a `RegionManager`, a new scoped `RegionManager` is automatically created and attached.
|
||
|
|
3. **Parent Check:** `PopupWindowAction.Invoke` will return and do nothing if `WindowContent` is already part of a visual tree (i.e., `WindowContent.Parent` is not null).
|
||
|
|
4. **Notification Content Requirement:** When `PopupWindowAction` creates a `NotificationWindow` (no `WindowContent` provided), the `Notification.Content` property must be castable to `NotificationContentEventArgs`; otherwise, the method returns `null` and no window is displayed.
|
||
|
|
5. **Modal vs Non-Modal:** If `IsModal` is true, `ShowDialog()` is called; otherwise, `Show()` is called.
|
||
|
|
|
||
|
|
## Dependencies
|
||
|
|
|
||
|
|
* **Internal Dependencies:**
|
||
|
|
* `DTS.Common.Interactivity` (for `Notification`, `Confirmation`, `InteractionRequestedEventArgs`).
|
||
|
|
* `DTS.Common.Enums` (for `PopupWindowImage`).
|
||
|
|
* `
|