Files
DP44/enriched-partialglm/DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.ViewerSettings/ViewModel.md
2026-04-17 14:55:32 -04:00

6.2 KiB

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.ViewerSettings/ViewModel/ViewerSettingsViewModel.cs
2026-04-16T11:11:45.719644+00:00 zai-org/GLM-5-FP8 1 f93455d3d5a535ba

Documentation: ViewerSettingsViewModel

1. Purpose

ViewerSettingsViewModel is a Prism-based ViewModel responsible for managing viewer configuration settings within the DTS Viewer application. It provides UI binding for calibration behavior selection, handles visibility state for settings panels, and facilitates decoupled communication with other system components via event aggregation. The class serves as the data context for IViewerSettingsView and participates in the application's navigation/region management infrastructure.


2. Public Interface

Constructor

public ViewerSettingsViewModel(
    IViewerSettingsView view,
    IRegionManager regionManager,
    IEventAggregator eventAggregator,
    IUnityContainer unityContainer)

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


Properties

Property Type Description
View IViewerSettingsView Gets/sets the associated view interface.
Parent IBaseViewModel Gets/sets the parent ViewModel, set during initialization with parameter.
NotificationRequest InteractionRequest<Notification> Interaction request for notification dialogs.
ConfirmationRequest InteractionRequest<Confirmation> Interaction request for confirmation dialogs (declared with new keyword).
HeaderInfo string Returns "SettingsRegion".
IsBusy bool Busy state indicator (declared with new keyword).
IsDirty bool Dirty state flag (declared with new keyword).
IsNavigationIncluded bool Navigation inclusion flag (declared with new keyword).
CalibrationBehaviorSettingVisibility Visibility Controls visibility of calibration behavior setting UI. Publishes ViewerSettingsVisibilityChangedEvent when changed.
OverallSettingsVisibility Visibility Read-only computed property. Returns Visibility.Visible if CalibrationBehaviorSettingVisibility is visible; otherwise Visibility.Collapsed.
AvailableCalibrationBehaviors DisplayedCalibrationBehavior[] Lazily-initialized, thread-safe array of three options: _linearIfAvail, _nonLinearIfAvail, _useBothIfAvail.
CalibrationBehaviorSetting DisplayedCalibrationBehavior Gets/sets the selected calibration behavior. Publishes CalibrationBehaviorSettingChangedEvent on change.

Methods

public override void Initialize()

Empty override—no behavior.

public override void Initialize(object parameter)

Sets Parent to the provided parameter (cast to IBaseViewModel) and calls Subscribe().

public void PublishChanges()

Empty method body—behavior unclear from source.


Events

public new event PropertyChangedEventHandler PropertyChanged

Declared with new keyword, hiding the base class event.


3. Invariants

  • Default Calibration Behavior: _calibrationBehaviorSetting is initialized to CalibrationBehaviors.NonLinearIfAvailable.
  • Visibility Cascade: When any property ending in "Visibility" (except "OverallSettingsVisibility") changes, OnPropertyChanged automatically triggers a notification for "OverallSettingsVisibility".
  • Thread Safety: AvailableCalibrationBehaviors uses a lock (MyLock) to ensure thread-safe lazy initialization.
  • Event Subscription: Subscribe() is called only from Initialize(object parameter), requiring a non-null parameter for event subscriptions to be registered.
  • OverallSettingsVisibility Logic: Always mirrors CalibrationBehaviorSettingVisibility—there is no scenario where they differ.

4. Dependencies

This Module Depends On

Namespace Type(s) Used
DTS.Common.Base BaseViewModel<T>
DTS.Common.Classes.Sensors DisplayedCalibrationBehavior
DTS.Common.Enums.Sensors CalibrationBehaviors
DTS.Common.Events CalibrationBehaviorSettingChangedEvent, CalibrationBehaviorSettableInViewerChangedEvent, ViewerSettingsVisibilityChangedEvent
DTS.Common.Interactivity InteractionRequest<T>, Notification, Confirmation
DTS.Common.Interface IViewerSettingsViewModel, IBaseViewModel, IViewerSettingsView
Prism.Events IEventAggregator
Prism.Regions IRegionManager
Unity IUnityContainer
System.Windows Visibility
DTS.Viewer.ViewerSettings.Resources StringResources (localized display strings)

What Depends On This Module

Not determinable from source alone—depends on which modules reference IViewerSettingsViewModel or instantiate ViewerSettingsViewModel.


5. Gotchas

  1. new Keyword Hiding: Multiple members (PropertyChanged, OnPropertyChanged, IsBusy, IsDirty, IsNavigationIncluded, ConfirmationRequest) use the new keyword to hide base class members. This breaks polymorphism—if the object is cast to the base type, the base members will be used instead of these overrides.

  2. Copy-Paste Error in XML Comment: The constructor's XML documentation references "TestSummaryViewListModel"—incorrect for this class.

  3. Empty PublishChanges() Method: The method has no implementation. Its intended purpose is unclear from source alone.

  4. Non-Standard Naming Convention: The private lock object MyLock uses PascalCase rather than the conventional underscore-prefix or camelCase pattern used elsewhere in the class.

  5. Visibility Property Name Convention: The OnPropertyChanged method contains special logic that triggers on any property name ending with "Visibility" (except "OverallSettingsVisibility"). Adding new visibility properties will have this side effect automatically.

  6. CalibrationBehaviorSetting Getter Linear Search: The getter iterates through AvailableCalibrationBehaviors on every access to find the matching DisplayedCalibrationBehavior. This is O(n) for each get operation.