4.4 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |
|---|---|---|---|---|---|
|
2026-04-17T16:15:47.040916+00:00 | zai-org/GLM-5-FP8 | 1 | 5648af1b9b10131b |
ViewModel
1. Purpose
This module provides the ViewModel component for the Power and Battery settings UI within the SystemSettings feature area. It follows the MVVM pattern using Prism and MEF, serving as a placeholder view model that integrates with the application's navigation, event aggregation, and dependency injection infrastructure. The module currently provides minimal domain-specific functionality but establishes the structural foundation for power and battery configuration management.
2. Public Interface
Class: PowerAndBatteryViewModel
- Inherits:
BasePropertyChanged - Implements:
IPowerAndBatteryViewModel - MEF Export:
[Export(typeof(IPowerAndBatteryView))]with[PartCreationPolicy(CreationPolicy.Shared)](singleton scope)
Constructor:
public PowerAndBatteryViewModel(IPowerAndBatteryView view, IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer)
Initializes the view model, sets the View's DataContext to itself, creates interaction requests, and subscribes to RaiseNotification and BusyIndicatorChangeNotification events.
Lifecycle Methods:
void Cleanup()- Empty implementationTask CleanupAsync()- ReturnsTask.CompletedTaskvoid Initialize()- Empty implementationvoid Initialize(object parameter)- Empty implementationvoid Initialize(object parameter, object model)- Empty implementationTask InitializeAsync()- ReturnsTask.CompletedTaskTask InitializeAsync(object parameter)- ReturnsTask.CompletedTaskvoid Activated()- Empty implementation
Properties:
IPowerAndBatteryView View { get; }- The associated view instanceInteractionRequest<Notification> NotificationRequest { get; }- For raising notification dialogsInteractionRequest<Confirmation> ConfirmationRequest { get; }- For raising confirmation dialogsbool IsDirty { get; private set; }- Tracks unsaved changes statebool IsBusy { get; set; }- Busy indicator state, bound to UIbool IsMenuIncluded { get; set; }- Menu inclusion flagbool IsNavigationIncluded { get; set; }- Navigation inclusion flagstring HeaderInfo { get; }- Returns hardcoded "MainRegion"
Private Event Handlers:
void OnBusyIndicatorNotification(bool eventArg)- SetsIsBusyproperty from eventvoid OnRaiseNotification(NotificationContentEventArgs eventArgsWithTitle)- Raises notification dialog viaNotificationRequest.Raise()
3. Invariants
- The
Viewproperty is set at construction and never reassigned. View.DataContextis always set tothis(the ViewModel instance) during construction.NotificationRequestandConfirmationRequestare initialized at construction and never null.- Event subscriptions use
ThreadOption.PublisherThreadforBusyIndicatorChangeNotificationwithkeepSubscriberReferenceAlive: true. HeaderInfoalways returns the literal string "MainRegion".
4. Dependencies
Imports (this module depends on):
DTS.Common.Base-BasePropertyChangedbase classDTS.Common.Events-RaiseNotification,BusyIndicatorChangeNotification,NotificationContentEventArgsDTS.Common.Interactivity-InteractionRequest<T>,Notification,ConfirmationDTS.Common.Interface-IPowerAndBatteryView,IPowerAndBatteryViewModelPrism.Events-IEventAggregator,ThreadOptionPrism.Regions-IRegionManagerUnity-IUnityContainerSystem.ComponentModel.Composition- MEF attributes
Dependents (inferred):
- The View component (
PowerAndBatteryView) which is injected via constructor - Shell/Bootstrapper that discovers and loads this MEF export
5. Gotchas
- Stale XML documentation: The constructor's XML comment references "TechnologyDomainEditViewModel" which appears to be a copy-paste error from another module.
- Empty lifecycle methods: All
InitializeandCleanupmethods are empty shells. The module does not perform any initialization or cleanup logic. - Unused
ConfirmationRequest: While instantiated,ConfirmationRequestis never raised anywhere in this class. - Hardcoded
HeaderInfo: Returns "MainRegion" which may be misleading as it suggests region identification but is a static string.