Files
DP44/enriched-qwen3-coder-next/DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.Graph/ViewModel.md
2026-04-17 14:55:32 -04:00

6.8 KiB

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.Graph/ViewModel/GraphViewModel.cs
2026-04-16T13:51:13.371255+00:00 zai-org/GLM-5-FP8 1 cd4107fac05f80cd

GraphViewModel Documentation

1. Purpose

GraphViewModel is a ViewModel within the DTS.Viewer.Graph module that manages graph visualization and coordinates data series display. It serves as a mediator between parent ViewModels (IViewerMainViewModel or IPSDReportMainViewModel) and the graph rendering components, handling event-driven communication for channel selection, test summaries, and data loading progress. The class follows the MVVM pattern using Prism and Unity, providing bindable properties for UI state management and interaction requests for user notifications.


2. Public Interface

Constructor

public GraphViewModel(
    IGraphView view, 
    IRegionManager regionManager, 
    IEventAggregator eventAggregator, 
    IUnityContainer unityContainer)

Initializes the ViewModel, sets the View's DataContext, and creates NotificationRequest and ConfirmationRequest instances.

Public Properties

Property Type Description
View IGraphView The associated graph view instance.
Parent IBaseViewModel (internal) Reference to the parent ViewModel.
DataSeriesView ITestDataSeriesView The data series view used for chart rendering.
NotificationRequest InteractionRequest<Notification> Interaction request for displaying notifications.
ConfirmationRequest InteractionRequest<Confirmation> Interaction request for displaying confirmations.
ContextGraphRegion object Gets/sets the content of the GraphRegion on the View.
MessageText string User-facing message text. Default: "Please select Event(s) to export data".
MessageVisibility bool Controls visibility of the message panel.
ProgressPercent double Progress percentage for data loading operations. Default: 0D.
ProgressText string Progress message text. Default: "Reading channel data...".
ProgressVisibility bool Controls visibility of the progress indicator.
GraphInfoVisibility bool Controls visibility of graph information.
GraphVisibility bool Computed as !MessageVisibility.
HeaderInfo string Returns constant "GraphRegion".
IsBusy bool Busy state indicator.
IsDirty bool Always returns false (read-only).

Public Methods

public override void Initialize()

Empty override; performs no initialization.

public override void Initialize(object parameter)

Performs context-specific initialization based on parameter type:

  • If parameter is IViewerMainViewModel: Calls Subscribe() and initializes DataSeriesView.
  • If parameter is Tuple<IBaseViewModel, string> where Item1 is IPSDReportMainViewModel: Calls SubscribeDataSelect() or SubscribeResult() based on Item2 value, and configures chart scrollbars/actions accordingly.

3. Invariants

  • IsDirty always returns false and cannot be modified.
  • HeaderInfo always returns the string "GraphRegion".
  • GraphVisibility is always the logical inverse of MessageVisibility.
  • Event handlers (OnTestSelectedCountChanged, OnGraphSelectedCountChanged, OnGraphChannelsReadCompleted, OnGraphChannelReadCalcProgressChangedEvent) check that Parent or this matches the event argument's source before processing.
  • OnGraphChannelsReadCompleted returns early if arg is null.
  • OnGraphChannelReadCalcProgressChangedEvent only updates ProgressPercent if the value is >= 0.

4. Dependencies

This Module Depends On

Namespace Purpose
C1.WPF.C1Chart ComponentOne charting controls (AxisScrollBar).
DTS.Common.Base Base classes (BaseViewModel<T>, IBaseModel, IBaseViewModel).
DTS.Common.Events Event types: RaiseNotification, GraphSelectedChannelCountNotification, TestSummaryCountNotification, TestModificationChangedEvent, GraphChannelsReadCompletedNotification, GraphChannelReadCalcProgressChangedEvent.
DTS.Common.Interactivity InteractionRequest<T>, Notification, Confirmation.
DTS.Common.Interface IGraphViewModel, ITestDataSeriesView, ITestDataSeriesViewModel, IViewerMainViewModel, IPSDReportMainViewModel.
Prism.Events IEventAggregator, ThreadOption.
Prism.Regions IRegionManager.
Unity IUnityContainer.

External Types Referenced (Not Defined Here)

  • GraphView - Concrete view type cast in ContextGraphRegion property.
  • TestDataSeriesView - Concrete data series view cast for chart configuration.
  • TestDataSeriesViewModel - Concrete ViewModel cast for calling SubscribePSD().
  • ITestModificationModel - Parameter type for OnTestModificationChanged.
  • Various event argument types: TestSummaryCountNotificationArg, GraphSelectedChannelCountNotificationArg, NotificationContentEventArgs, GraphChannelsReadCompletedNotificationArgs, GraphChannelReadCalcProgressChangedEventArgs.

5. Gotchas

  1. Member Hiding with new Keyword: The class uses new to hide multiple base class members (Model, ConfirmationRequest, PropertyChanged, OnPropertyChanged, IsBusy, IsDirty). This can cause unexpected behavior when casting to base types.

  2. Code Duplication in Subscribe Methods: Subscribe(), SubscribeDataSelect(), and SubscribeResult() have nearly identical implementations. The only difference is Subscribe() includes TestModificationChangedEvent subscription, while the others do not—but OnTestModificationChanged is an empty method body.

  3. Empty Event Handler: OnTestModificationChanged(ITestModificationModel obj) is subscribed but contains no implementation.

  4. Concrete Type Casting: The code casts interfaces to concrete types (GraphView, TestDataSeriesView, TestDataSeriesViewModel) which breaks abstraction and could cause runtime failures if implementations change:

    ((AxisScrollBar)((TestDataSeriesView)DataSeriesView).MainChart.View.AxisX.ScrollBar).Visibility = ...
    ((TestDataSeriesView)DataSeriesView).MainChart.Actions.Clear();
    ((TestDataSeriesViewModel)viewModel).SubscribePSD();
    
  5. Hardcoded String Comparisons: The Initialize(object parameter) method uses string literals ("DataSelect", "Graph") for control flow, which is fragile.

  6. Unused Private Field: The Model property is set but never accessed elsewhere in the visible code.

  7. ReSharper Suppressions: The file contains numerous ReSharper directive suppressions, suggesting known code quality issues that were disabled rather than addressed.