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

6.5 KiB
Raw Blame History

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
DataPRO/Modules/StatusAndProgressBar/ViewModel/StatusAndProgressFooterViewModel.cs
DataPRO/Modules/StatusAndProgressBar/ViewModel/StatusAndProgressBarViewModel.cs
2026-04-16T04:48:57.785641+00:00 Qwen/Qwen3-Coder-Next-FP8 1 8cccc53a0c9317e7

ViewModel

Documentation: StatusAndProgressBar Module ViewModels


1. Purpose

This module provides shared UI state management for progress tracking and status reporting across the application. It exposes two distinct view models—StatusAndProgressBarViewModel (for main/status-bar contexts) and StatusAndProgressFooterViewModel (for footer-level progress)—that listen to ProgressBarEvent and StatusAndProgressBarEvent events respectively, and update corresponding UI properties (ProgressText, ProgressBarValue, ProgressBarVisibility, etc.). The module decouples progress producers from consumers via Prisms IEventAggregator, enabling modular, event-driven progress updates without tight coupling.


2. Public Interface

StatusAndProgressFooterViewModel

  • StatusAndProgressFooterViewModel(IStatusAndProgressFooterView view, IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer)
    Constructor. Initializes view binding, sets up NotificationRequest and ConfirmationRequest interaction triggers, and subscribes to ProgressBarEvent with handler OnStatusAndProgressBarEvent.
  • Visibility ProgressBarVisiblity { get; set; }
    Binds to the visibility of the progress bar in the footer view. Note: Property name contains a typo (Visiblity instead of Visibility).
  • int ProgressBarValue { get; set; }
    Current progress percentage (0100).
  • string ProgressText { get; set; }
    Human-readable status text (e.g., "Saving changes...").

StatusAndProgressBarViewModel

  • StatusAndProgressBarViewModel(IStatusAndProgressBarView view, IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer)
    Constructor. Binds view to view model, subscribes to StatusAndProgressBarEvent (with ThreadOption.PublisherThread), and initializes _searchButtonVisability = false.
  • override void Initialize(object parameter)
    Overrides base initialization. Stores parameter as Parent and subscribes to ProgressBarEvent (with ThreadOption.UIThread).
  • string AggregateStatusText { get; set; }
    Combined status text (e.g., "Processing", or "Processing - Error occurred" if ErrorText is present).
  • Color AggregateStatusColor { get; set; }
    Status color (e.g., Colors.AliceBlue by default).
  • Visibility ProgressBarVisibility { get; set; }
    Visibility of the main progress bar.
  • int ProgressBarValue { get; set; }
    Current progress percentage (0100).
  • bool SearchButtonVisability { get; set; }
    Controls visibility of a search button (note: typo in property name; should be SearchButtonVisibility).
  • Visibility AlertVisibility { get; set; }
    Controls visibility of an alert indicator (default Visibility.Hidden).

3. Invariants

  • Event Filtering by Name/Requester:
    • StatusAndProgressFooterViewModel.OnStatusAndProgressBarEvent only processes events where args.ProgressBarName == "Footer".
    • StatusAndProgressBarViewModel.OnUpdate only processes events where args.Requester == Parent.
  • Progress Value Range:
    ProgressBarValue is set via Convert.ToInt32(args.ProgressBarPercentage), implying values are expected to be numeric (though no explicit validation is present).
  • Thread Safety:
    • StatusAndProgressBarViewModel subscribes to StatusAndProgressBarEvent on PublisherThread, but ProgressBarEvent in Initialize(object) on UIThread.
    • StatusAndProgressFooterViewModel subscribes to ProgressBarEvent without specifying ThreadOption (defaults to UIThread per Prism).
  • Property Change Notifications:
    Properties use OnPropertyChanged (or SetProperty for StatusAndProgressBarViewModel), but only for explicitly named properties—no automatic INotifyPropertyChanged implementation beyond overrides.

4. Dependencies

Imports/References

  • Prism Libraries: Prism.Events.IEventAggregator, Prism.Regions.IRegionManager, Prism.Interactivity.InteractionRequest.
  • Unity Container: Unity.IUnityContainer for DI.
  • Common Infrastructure:
    • DTS.Common.Base.BaseViewModel<T> (base class).
    • DTS.Common.Events.ProgressBarEvent, ProgressBarEventArg.
    • DTS.Common.Events.StatusAndProgressBarEvent, StatusAndProgressBarEventArgs.
    • DTS.Common.Interface.IStatusAndProgressBarFooterView, IStatusAndProgressBarView, IBaseView, IBaseViewModel.

Consumed By

  • View layers (IStatusAndProgressBarFooterView, IStatusAndProgressBarView) bind to these view models.
  • Other modules publish ProgressBarEvent (e.g., long-running operations) and StatusAndProgressBarEvent (e.g., context-aware status updates).

5. Gotchas

  • Typo in Property Names:
    • ProgressBarVisiblity (missing 'i' in Visibility) in StatusAndProgressFooterViewModel.
    • SearchButtonVisability (same typo) in StatusAndProgressBarViewModel.
      Risk: Binding failures if XAML uses correct spelling.
  • Event Subscription Overlap:
    StatusAndProgressBarViewModel subscribes to two events:
    • StatusAndProgressBarEvent in constructor (for general status updates).
    • ProgressBarEvent in Initialize(object) (for named progress bars).
      This may cause redundant updates if both events are published for the same operation.
  • No Cleanup of Event Subscriptions:
    Neither view model unsubscribes from events in Cleanup() or Dispose, risking memory leaks if instances outlive their lifecycle.
  • Assumed Event Payload Structure:
    ProgressBarEventArg is assumed to have properties like ProgressBarName, SetPercentage, ProgressBarPercentage, etc., but their exact contract is not defined here.
  • Color Handling:
    AggregateStatusColor is set directly from args.ProgressBarColor without validation—invalid Color values may cause rendering issues.
  • Missing IsDirty Implementation:
    IsDirty is declared as a read-only property (public new bool IsDirty { get; }) but has no setter or backing field—its value is always false.

None identified beyond these.