8.3 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
2026-04-16T11:26:12.276849+00:00 | zai-org/GLM-5-FP8 | 1 | a7a3a3c725d7b68b |
DTS Viewer Main Views Documentation
1. Purpose
This module contains the WPF view code-behind files for the main window and viewer components of the DTS Viewer application. It provides multiple view variants (standard, lite, export, and viewer modes) that implement a view-first MVVM architecture using Prism. The views handle UI initialization, event subscription for graph loading notifications, and PDF/image export functionality. These views serve as the visual containers for the application's primary user interface elements.
2. Public Interface
MainView
public partial class MainView : IMainView
- Constructor:
MainView()- Initializes the WPF component viaInitializeComponent(). - Implements
IMainViewinterface fromDTS.Common.Interface.
ViewerShellView
public partial class ViewerShellView : IViewerShellView
- Constructor:
ViewerShellView()- Initializes the WPF component viaInitializeComponent(). - Implements
IViewerShellViewinterface fromDTS.Common.Interface.
MainViewLite
public partial class MainViewLite : IMainViewerView
- Constructor:
MainViewLite()- Initializes the WPF component viaInitializeComponent(). - Implements
IMainViewerViewinterface fromDTS.Common.Interface.
ExportMainView
public partial class ExportMainView : IExportMainView
- Constructor:
ExportMainView()- Initializes the WPF component viaInitializeComponent(). - Implements
IExportMainViewinterface fromDTS.Common.Interface.
ViewerMainView
public partial class ViewerMainView : IViewerMainView
- Constructor:
ViewerMainView()- Initializes the WPF component viaInitializeComponent(). - Implements
IViewerMainViewinterface fromDTS.Common.Interface. - Contains commented-out code for AvalonDock layout serialization/deserialization (referencing
DockManager,XmlLayoutSerializer, andDataProViewerAvalonDock.config).
ExportMainViewGrid
public partial class ExportMainViewGrid : IExportMainViewGrid
- Constructor:
ExportMainViewGrid()- Initializes component and subscribes toLoadedevent. - Implements
IExportMainViewGridinterface fromDTS.Common.Interface. - Public Method:
int SaveToPDF(string directory, string pdfFileName)- Renders the view to PDF and PNG files. Returns> 0on success,< 0on failure, or0ifMainShellis not yet rendered. - Private Property:
IEventAggregator _eventAggregator- Resolved from container on load. - Private Method:
void SetFocus()- Empty implementation (no operation). - Private Method:
void ExportMainViewGrid_Loaded(object sender, RoutedEventArgs e)- ResolvesIEventAggregatorand subscribes toGraphLoadedCountNotification. - Private Method:
void OnGraphLoadedCountNotification(GraphLoadedCountNotificationArg arg)- Delays 3 seconds then invokesSetFocusvia dispatcher.
ViewerMainViewGrid
public partial class ViewerMainViewGrid : IViewerMainViewGrid
- Constructor:
ViewerMainViewGrid()- Initializes component and subscribes toLoadedevent. - Implements
IViewerMainViewGridinterface fromDTS.Common.Interface. - Public Method:
int SaveToPDF(string directory, string pdfFileName)- Renders the view to PDF and PNG files. Returns> 0on success,< 0on failure, or0ifMainShellis not yet rendered. - Private Property:
IEventAggregator _eventAggregator- Resolved from container on load. - Private Method:
void SetFocus()- Selects and focuseschartOptTabelement. - Private Method:
void ViewerMainViewGrid_Loaded(object sender, RoutedEventArgs e)- ResolvesIEventAggregatorand subscribes toGraphLoadedCountNotification. - Private Method:
void OnGraphLoadedCountNotification(GraphLoadedCountNotificationArg arg)- ValidatesDataContextmatchesarg.ParentVM, delays 3 seconds, then invokesSetFocusvia dispatcher.
3. Invariants
- All views must call
InitializeComponent()in their constructor (WPF code-behind requirement). SaveToPDFrequirespdfFileNameto end with.pdfextension; otherwise returns-1.SaveToPDFrequires bothdirectoryandpdfFileNameto be non-null and non-empty; otherwise returns-1.SaveToPDFreturns0ifMainShell.DesiredSize.HeightorMainShell.DesiredSize.Widthis0(control not yet rendered).OnGraphLoadedCountNotificationonly processes the event ifDataContextis non-null and matchesarg.ParentVM(cast toIBaseViewModel).- Event subscription to
GraphLoadedCountNotificationoccurs only after theLoadedevent fires (ensuresIEventAggregatoris available). - PDF export renders at 300 DPI resolution.
- PNG export is generated alongside PDF with
.pdfextension replaced by.png.
4. Dependencies
External Dependencies
- Prism.Events -
IEventAggregatorfor pub/sub event messaging. - Prism.Ioc -
ContainerLocatorfor service location. - C1.WPF.Pdf -
C1PdfDocumentfor PDF generation (ComponentOne library). - System.Windows - WPF core types (
RoutedEventArgs,Visual,Dispatcher, etc.). - System.Windows.Media -
RenderTargetBitmap,WriteableBitmap,PixelFormats,VisualTreeHelper. - System.Windows.Media.Imaging - Bitmap rendering types.
Internal Dependencies
- DTS.Common.Interface - Interface definitions (
IMainView,IViewerShellView,IMainViewerView,IExportMainView,IViewerMainView,IExportMainViewGrid,IViewerMainViewGrid). - DTS.Common.Base -
IBaseViewModelbase interface. - DTS.Common.Events -
GraphLoadedCountNotificationevent andGraphLoadedCountNotificationArgargument class. - DTS.Common.Utilities.Logging -
APILogger.LogException(Exception)for error logging. - DTS.Common.Utils.PNGImageUtil -
SaveImage(FrameworkElement, string)static method for PNG export.
Consumers
- Unknown from source alone. These views are likely instantiated by a Prism bootstrapper or module initialization logic.
5. Gotchas
-
Hardcoded 3-second delay: Both
ExportMainViewGridandViewerMainViewGriduseThread.Sleep(TimeSpan.FromSeconds(3))before setting focus. This is a magic number with no configuration, potentially causing timing issues on slower systems. -
Empty SetFocus in ExportMainViewGrid: The
SetFocus()method inExportMainViewGridis empty, making the 3-second delayed focus operation a no-op. This may be intentional or dead code. -
Commented-out AvalonDock code:
ViewerMainViewcontains significant commented-out code for layout serialization usingXmlLayoutSerializerand aDockManagerelement. This suggests either incomplete feature implementation or removed functionality that wasn't cleaned up. -
Multiple ReSharper disable directives:
ExportMainView,ViewerMainView,ExportMainViewGrid, andViewerMainViewGridall suppress multiple ReSharper inspections, which may mask potential code quality issues. -
Namespace inconsistency: All files declare namespace
DTS.Viewerdespite residing in different subdirectories (e.g.,Modules/Main/View/). This is intentional but may cause confusion when locating files. -
Event subscription without unsubscription: Neither
ExportMainViewGridnorViewerMainViewGridunsubscribe fromGraphLoadedCountNotification. This could cause memory leaks if views are created/destroyed frequently. -
PDF return value semantics: The
SaveToPDFmethod uses a tri-state return value (>0,0,<0) which is documented but unconventional. Callers must check for> 0rather than a simple boolean. -
Silent exception handling:
SaveToPDFcatches all exceptions, logs them viaAPILogger.LogException, and returns-1. The caller receives no exception details.