7.5 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
2026-04-16T14:05:18.299277+00:00 | zai-org/GLM-5-FP8 | 1 | a7a3a3c725d7b68b |
Documentation: DTS.Viewer Main View Module
1. Purpose
This module contains the main view components for the DTS Viewer application, implementing a WPF-based UI with multiple view variants (standard, lite, export, and viewer modes). The views serve as code-behind files for XAML-defined user interfaces, handling view initialization, event subscription via Prism's event aggregator, and PDF/PNG export functionality. These views implement interfaces from DTS.Common.Interface to enable loose coupling with view models in what appears to be a MVVM architecture.
2. Public Interface
MainView
public partial class MainView : IMainView
- Constructor:
MainView()— Initializes the component viaInitializeComponent(). - Role: Primary main window view implementation.
ViewerShellView
public partial class ViewerShellView : IViewerShellView
- Constructor:
ViewerShellView()— Initializes the component viaInitializeComponent(). - Role: Shell container view for the viewer mode.
MainViewLite
public partial class MainViewLite : IMainViewerView
- Constructor:
MainViewLite()— Initializes the component viaInitializeComponent(). - Role: Lightweight version of the main viewer view.
ExportMainView
public partial class ExportMainView : IExportMainView
- Constructor:
ExportMainView()— Initializes the component viaInitializeComponent(). - Role: Main view for export functionality.
ViewerMainView
public partial class ViewerMainView : IViewerMainView
- Constructor:
ViewerMainView()— Initializes the component viaInitializeComponent(). - Role: Main view for viewer mode. Contains commented-out AvalonDock layout serialization/deserialization logic.
ExportMainViewGrid
public partial class ExportMainViewGrid : IExportMainViewGrid
- Constructor:
ExportMainViewGrid()— Initializes component and subscribes toLoadedevent. - Methods:
public int SaveToPDF(string directory, string pdfFileName)— RendersMainShellto a PDF and PNG file. Returns> 0on success,< 0on failure,0ifMainShellis not ready.
- Event Handlers:
ExportMainViewGrid_Loaded— ResolvesIEventAggregatorand subscribes toGraphLoadedCountNotification.OnGraphLoadedCountNotification(GraphLoadedCountNotificationArg arg)— Triggers focus setting after 3-second delay ifDataContextmatchesarg.ParentVM.SetFocus()— Empty implementation (no-op).
ViewerMainViewGrid
public partial class ViewerMainViewGrid : IViewerMainViewGrid
- Constructor:
ViewerMainViewGrid()— Initializes component and subscribes toLoadedevent. - Methods:
public int SaveToPDF(string directory, string pdfFileName)— RendersMainShellto a PDF and PNG file. Returns> 0on success,< 0on failure,0ifMainShellis not ready.
- Event Handlers:
ViewerMainViewGrid_Loaded— ResolvesIEventAggregatorand subscribes toGraphLoadedCountNotification.OnGraphLoadedCountNotification(GraphLoadedCountNotificationArg arg)— Triggers focus setting after 3-second delay ifDataContextmatchesarg.ParentVM.SetFocus()— SetschartOptTab.IsSelected = true, makes it focusable, and callsFocus().
3. Invariants
-
Interface Implementation: All view classes implement their respective interfaces from
DTS.Common.Interface(IMainView,IViewerShellView,IMainViewerView,IExportMainView,IViewerMainView,IExportMainViewGrid,IViewerMainViewGrid). -
SaveToPDF Preconditions:
directorymust be non-null and non-empty.pdfFileNamemust be non-null, non-empty, and end with.pdf.MainShell.DesiredSize.HeightandMainShell.DesiredSize.Widthmust be> 0for export to proceed.
-
Event Subscription Timing:
IEventAggregatoris resolved and event subscriptions occur in theLoadedevent handler, not the constructor (per FB 14797). -
Focus Timing: Focus is set via
Dispatcher.BeginInvokeafter a 3-secondThread.SleepfollowingGraphLoadedCountNotification. -
DataContext Matching:
OnGraphLoadedCountNotificationonly proceeds ifDataContextis non-null and equalsarg.ParentVMcast toIBaseViewModel.
4. Dependencies
External Dependencies (Imports)
| Namespace | Purpose |
|---|---|
DTS.Common.Interface |
View interfaces (IMainView, IViewerShellView, IMainViewerView, IExportMainView, IViewerMainView, IExportMainViewGrid, IViewerMainViewGrid) |
DTS.Common.Base |
IBaseViewModel interface |
DTS.Common.Events |
GraphLoadedCountNotification event, GraphLoadedCountNotificationArg argument class |
DTS.Common.Utilities.Logging |
APILogger.LogException() for error logging |
DTS.Common.Utils |
PNGImageUtil.SaveImage() for PNG export |
Prism.Events |
IEventAggregator for pub/sub messaging |
Prism.Ioc |
ContainerLocator for service location |
C1.WPF.Pdf |
C1PdfDocument for PDF generation (ComponentOne library) |
System.Windows.Media |
VisualTreeHelper, PixelFormats for visual rendering |
System.Windows.Media.Imaging |
RenderTargetBitmap, WriteableBitmap for bitmap rendering |
Downstream Dependencies
- Unknown from source alone. These views are likely referenced by view models or a bootstrapper/module initializer that resolves them via dependency injection.
5. Gotchas
-
Hardcoded 3-Second Delay: Both
ExportMainViewGridandViewerMainViewGriduseThread.Sleep(TimeSpan.FromSeconds(3))before setting focus. This is a timing-based workaround (FB 14797) that may be unreliable on slower systems. -
Empty SetFocus() in ExportMainViewGrid:
ExportMainViewGrid.SetFocus()is empty whileViewerMainViewGrid.SetFocus()has actual implementation. This appears to be intentional (perhaps thechartOptTabelement doesn't exist in the export view), but is non-obvious. -
Side Effect in SaveToPDF: The
SaveToPDFmethod also generates a PNG file as a side effect viaPNGImageUtil.SaveImage(), which may not be expected from the method name alone. -
Service Locator Pattern:
IEventAggregatoris resolved viaContainerLocator.Container.Resolve<IEventAggregator>()rather than constructor injection, making the dependency implicit. -
Commented-Out AvalonDock Code:
ViewerMainViewcontains significant commented-out code for AvalonDock layout serialization (XmlLayoutSerializer,DockManager). This suggests either deprecated functionality or a feature that was intentionally disabled. -
Return Value Ambiguity in SaveToPDF: The method returns
1for success but the documentation states> 0. Callers should check> 0rather than== 1for forward compatibility. -
ReSharper Disable Directives: Multiple files contain
// ReSharper disablecomments, indicating suppressed static analysis warnings. This may mask potential issues.