7.6 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
2026-04-16T12:05:57.382273+00:00 | zai-org/GLM-5-FP8 | 1 | e520922d284c9033 |
Documentation: DTS.Common.Dialogs
1. Purpose
This module provides a custom dialog management infrastructure for WPF applications built on the Prism framework. It extends Prism's InteractionRequest patterns to support custom window styling (such as hiding the system close button), region management within popups, and specific dialog types like confirmations and notifications. Additionally, it provides a wrapper (BrowseForFolderDialog) around the Win32 API SHBrowseForFolder for folder selection capabilities not natively available in standard WPF dialogs.
2. Public Interface
Interfaces
IRegionManagerAware
IRegionManager RegionManager { get; set; }: Allows a view or view model to receive a scopedIRegionManagerwhen hosted inside a popup window.
IPopupWindowActionAware
Window HostWindow { get; set; }: Provides access to the hosting window instance.Notification HostNotification { get; set; }: Provides access to the notification context (e.g.,ConfirmationorNotificationobject) passed to the window.
Classes
ConfirmationEx (Inherits Confirmation)
MessageBoxButton Buttons { get; set; }: Defaults toMessageBoxButton.OKCancel. Defines buttons shown in the confirmation.MessageBoxImage Image { get; set; }: Defaults toMessageBoxImage.Question. Defines the icon shown.MessageBoxResult Result { get; set; }: Stores the result of the user interaction.
ConfirmationWindow (Inherits Window)
DataTemplate ConfirmationTemplate { get; set; }: Dependency property used to define the visual presentation of the confirmation content.void Connect(int connectionId, object target): ThrowsNotImplementedException.
NotificationWindow (Inherits Window)
DataTemplate NotificationTemplate { get; set; }: Dependency property for the notification content layout.Uri ImageUri { get; set; }: Dependency property for the notification icon. Defaults to a pack URI pointing towarning_48.png.void Connect(int connectionId, object target): Empty implementation.
PopupWindowAction (Inherits TriggerAction<FrameworkElement>)
- Properties:
FrameworkElement WindowContent: The root visual element to display in the popup.DataTemplate ContentTemplate: The template applied to the content.bool IsModal: Determines if the window blocks interaction with the owner.WindowPositions StartupPosition: Enum (CenterOwner,CenterScreen). Defaults toCenterScreen.bool AllowMultipleNotificationWindows: Prevents or allows concurrent notification windows.
- Methods:
protected override void Invoke(object parameter): Executes the trigger, creates the window, sets up region managers, and shows the dialog.protected Window GetWindow(Notification notification): Factory method returning the appropriateWindowwrapper.protected Window CreateWindow(Notification notification): Creates aConfirmationWindoworNotificationWindowifWindowContentis null.
BrowseForFolderDialog
- Properties:
string SelectedFolder: The path chosen by the user.string Title: The text displayed above the tree view.string InitialFolder: The path selected on startup.string InitialExpandedFolder: The path selected and expanded on startup.string OKButtonText: Custom text for the confirmation button.BrowseInfoFlags BrowserDialogFlags: Win32 flags controlling dialog behavior (defaults toBIF_NEWDIALOGSTYLE).
- Methods:
Nullable<bool> ShowDialog(): Shows the dialog modally.Nullable<bool> ShowDialog(Window owner): Shows the dialog modally with a WPF window owner.
3. Invariants
- Window System Menu Removal: Both
ConfirmationWindowandNotificationWindowmodify the window style upon initialization (SourceInitialized) to remove theWS_SYSMENUflag. This effectively hides the system menu and the close button from the title bar. - Region Management: When
PopupWindowActioninvokes a dialog withWindowContentset, it guarantees that a scopedIRegionManageris attached to that content if one is not already present. - Visual Tree Parenting:
PopupWindowAction.Invokewill exit immediately without showing a window ifWindowContentis already a child of another visual element (WindowContent.Parent != null). - Default Dialog Creation: If
PopupWindowAction.WindowContentis null, the action defaults to creating either aConfirmationWindow(if the notification isConfirmation) or aNotificationWindow(if the notification content isNotificationContentEventArgs).
4. Dependencies
Internal Dependencies (Inferred):
DTS.Common.Enums: Required forPopupWindowImageenum used inPopupWindowAction.GetImageUri.DTS.Common.Events: Required forNotificationContentEventArgsused inPopupWindowAction.CreateWindow.
External Dependencies:
Microsoft.Practices.Prism.Regions: Used forIRegionManagerand region scoping.Microsoft.Practices.Prism.Interactivity.InteractionRequest: Used forNotification,Confirmation,InteractionRequestedEventArgs, andTriggerAction.System.Windows.Interactivity: Used forTriggerAction<FrameworkElement>.System.Windows: Core WPF types.user32.dll: P/Invoke for window styling (SetWindowLong,GetWindowLong) and messaging.shell32.dll: P/Invoke for folder browsing (SHBrowseForFolderW,SHGetPathFromIDList).
5. Gotchas
- Hardcoded Clipboard Text:
NotificationWindowcontains an event handlerCoppyToClibord_Click(note the typo in method name) that sets the clipboard text to the hardcoded string "Hello, clipboard". This appears to be debug/test code left in the production source. - Inconsistent Image Paths:
NotificationWindowdefaults itsImageUrito a path containingRibbonControl/Images/warning_48.png.PopupWindowAction.GetImageUriconstructs paths pointing toImages/(withoutRibbonControl).- This inconsistency suggests a refactoring mismatch or missing resource files; developers adding new icons should verify the correct pack URI structure.
- Unimplemented Interface Method: The
Connectmethod inConfirmationWindowthrowsNotImplementedException. This method is typically associated with theIComponentConnectorinterface generated by the WPF compiler for XAML parsing. The manual implementation throwing an exception suggests the code-behind may be out of sync with the XAML or manually implementing an interface it shouldn't. - COM Initialization Requirement:
BrowseForFolderDialogdefaults toBIF_NEWDIALOGSTYLE. The Win32 documentation for this flag states thatOleInitializemust be called before using the API. This class does not callOleInitialize; the consuming application is responsible for COM initialization. - Commented Out Features: Both
ConfirmationExandPopupWindowActioncontain significant blocks of commented-out code related to "Timeout" functionality (auto-closing dialogs). This suggests unfinished or deprecated features that may confuse developers looking for timeout capabilities.