6.5 KiB
6.5 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | ||
|---|---|---|---|---|---|---|
|
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 Prism’s 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 upNotificationRequestandConfirmationRequestinteraction triggers, and subscribes toProgressBarEventwith handlerOnStatusAndProgressBarEvent.Visibility ProgressBarVisiblity { get; set; }
Binds to the visibility of the progress bar in the footer view. Note: Property name contains a typo (Visiblityinstead ofVisibility).int ProgressBarValue { get; set; }
Current progress percentage (0–100).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 toStatusAndProgressBarEvent(withThreadOption.PublisherThread), and initializes_searchButtonVisability = false.override void Initialize(object parameter)
Overrides base initialization. StoresparameterasParentand subscribes toProgressBarEvent(withThreadOption.UIThread).string AggregateStatusText { get; set; }
Combined status text (e.g.,"Processing", or"Processing - Error occurred"ifErrorTextis present).Color AggregateStatusColor { get; set; }
Status color (e.g.,Colors.AliceBlueby default).Visibility ProgressBarVisibility { get; set; }
Visibility of the main progress bar.int ProgressBarValue { get; set; }
Current progress percentage (0–100).bool SearchButtonVisability { get; set; }
Controls visibility of a search button (note: typo in property name; should beSearchButtonVisibility).Visibility AlertVisibility { get; set; }
Controls visibility of an alert indicator (defaultVisibility.Hidden).
3. Invariants
- Event Filtering by Name/Requester:
StatusAndProgressFooterViewModel.OnStatusAndProgressBarEventonly processes events whereargs.ProgressBarName == "Footer".StatusAndProgressBarViewModel.OnUpdateonly processes events whereargs.Requester == Parent.
- Progress Value Range:
ProgressBarValueis set viaConvert.ToInt32(args.ProgressBarPercentage), implying values are expected to be numeric (though no explicit validation is present). - Thread Safety:
StatusAndProgressBarViewModelsubscribes toStatusAndProgressBarEventonPublisherThread, butProgressBarEventinInitialize(object)onUIThread.StatusAndProgressFooterViewModelsubscribes toProgressBarEventwithout specifyingThreadOption(defaults toUIThreadper Prism).
- Property Change Notifications:
Properties useOnPropertyChanged(orSetPropertyforStatusAndProgressBarViewModel), but only for explicitly named properties—no automaticINotifyPropertyChangedimplementation beyond overrides.
4. Dependencies
Imports/References
- Prism Libraries:
Prism.Events.IEventAggregator,Prism.Regions.IRegionManager,Prism.Interactivity.InteractionRequest. - Unity Container:
Unity.IUnityContainerfor 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) andStatusAndProgressBarEvent(e.g., context-aware status updates).
5. Gotchas
- Typo in Property Names:
ProgressBarVisiblity(missing 'i' inVisibility) inStatusAndProgressFooterViewModel.SearchButtonVisability(same typo) inStatusAndProgressBarViewModel.
Risk: Binding failures if XAML uses correct spelling.
- Event Subscription Overlap:
StatusAndProgressBarViewModelsubscribes to two events:StatusAndProgressBarEventin constructor (for general status updates).ProgressBarEventinInitialize(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 inCleanup()orDispose, risking memory leaks if instances outlive their lifecycle. - Assumed Event Payload Structure:
ProgressBarEventArgis assumed to have properties likeProgressBarName,SetPercentage,ProgressBarPercentage, etc., but their exact contract is not defined here. - Color Handling:
AggregateStatusColoris set directly fromargs.ProgressBarColorwithout validation—invalidColorvalues may cause rendering issues. - Missing
IsDirtyImplementation:
IsDirtyis declared as a read-only property (public new bool IsDirty { get; }) but has no setter or backing field—its value is alwaysfalse.
None identified beyond these.