136 lines
7.2 KiB
Markdown
136 lines
7.2 KiB
Markdown
|
|
---
|
|||
|
|
source_files:
|
|||
|
|
- DataPRO/Modules/SystemSettings/RealtimeSettings/ViewModel/RealtimeSettingsViewModel.cs
|
|||
|
|
generated_at: "2026-04-16T04:42:47.252875+00:00"
|
|||
|
|
model: "Qwen/Qwen3-Coder-Next-FP8"
|
|||
|
|
schema_version: 1
|
|||
|
|
sha256: "2371d547d8ea5652"
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
# ViewModel
|
|||
|
|
|
|||
|
|
## Documentation: `RealtimeSettingsViewModel`
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
### **1. Purpose**
|
|||
|
|
|
|||
|
|
The `RealtimeSettingsViewModel` class serves as the view model for the Realtime Settings UI module within the application. It implements the `IRealtimeSettingsViewModel` interface and is exported as an `IRealtimeSettingsView` using MEF, enabling Prism-based MVVM integration. Its primary responsibilities include managing UI state for real-time configuration settings (e.g., sample rate, delay), handling interaction requests for notifications and confirmations, and responding to global events—specifically `RaiseNotification` and `BusyIndicatorChangeNotification`. It acts as a bridge between the view (`IRealtimeSettingsView`) and underlying system events, without containing business logic itself.
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
### **2. Public Interface**
|
|||
|
|
|
|||
|
|
#### **Constructor**
|
|||
|
|
```csharp
|
|||
|
|
public RealtimeSettingsViewModel(
|
|||
|
|
IRealtimeSettingsView view,
|
|||
|
|
IRegionManager regionManager,
|
|||
|
|
IEventAggregator eventAggregator,
|
|||
|
|
IUnityContainer unityContainer)
|
|||
|
|
```
|
|||
|
|
- Initializes the view model, sets up the view context, registers event subscriptions, and initializes interaction requests.
|
|||
|
|
|
|||
|
|
#### **Methods**
|
|||
|
|
- `void Cleanup()`
|
|||
|
|
No-op stub; intended for cleanup logic but currently does nothing.
|
|||
|
|
|
|||
|
|
- `Task CleanupAsync()`
|
|||
|
|
Returns `Task.CompletedTask`; no-op async stub.
|
|||
|
|
|
|||
|
|
- `void Initialize()`
|
|||
|
|
No-op stub.
|
|||
|
|
|
|||
|
|
- `void Initialize(object parameter)`
|
|||
|
|
No-op stub.
|
|||
|
|
|
|||
|
|
- `void Initialize(object parameter, object model)`
|
|||
|
|
No-op stub.
|
|||
|
|
|
|||
|
|
- `Task InitializeAsync()`
|
|||
|
|
Returns `Task.CompletedTask`; no-op async stub.
|
|||
|
|
|
|||
|
|
- `Task InitializeAsync(object parameter)`
|
|||
|
|
Returns `Task.CompletedTask`; no-op async stub.
|
|||
|
|
|
|||
|
|
- `void Activated()`
|
|||
|
|
No-op stub; likely part of Prism’s `INavigationAware` or region lifecycle, but unimplemented.
|
|||
|
|
|
|||
|
|
#### **Properties**
|
|||
|
|
- `IRealtimeSettingsView View { get; }`
|
|||
|
|
Reference to the associated view instance.
|
|||
|
|
|
|||
|
|
- `InteractionRequest<Notification> NotificationRequest { get; }`
|
|||
|
|
Prism interaction request used to trigger notification popups.
|
|||
|
|
|
|||
|
|
- `InteractionRequest<Confirmation> ConfirmationRequest { get; }`
|
|||
|
|
Prism interaction request used to trigger confirmation dialogs.
|
|||
|
|
|
|||
|
|
- `string RealtimeSampleRate { get; set; }`
|
|||
|
|
Binds to the currently selected sample rate string (e.g., `"48 kHz"`). Triggers property change notification.
|
|||
|
|
|
|||
|
|
- `string RealtimeSampleRates { get; set; }`
|
|||
|
|
Binds to a list or set of available sample rates (e.g., `"44.1 kHz, 48 kHz"`). On change, also raises `OnPropertyChanged("RealtimeSampleRate")`.
|
|||
|
|
|
|||
|
|
- `string RealtimeDelayText { get; set; }`
|
|||
|
|
Binds to the delay value display text (e.g., `"12.5 ms"`).
|
|||
|
|
|
|||
|
|
- `bool IsDirty { get; }`
|
|||
|
|
Read-only flag indicating whether the view model state has unsaved changes. Currently always `false`; no logic to update it.
|
|||
|
|
|
|||
|
|
- `bool IsBusy { get; set; }`
|
|||
|
|
Controls busy indicator visibility. Set via `OnBusyIndicatorNotification(bool)` event handler.
|
|||
|
|
|
|||
|
|
- `bool IsMenuIncluded { get; set; }`
|
|||
|
|
Controls whether the menu is visible in the view.
|
|||
|
|
|
|||
|
|
- `bool IsNavigationIncluded { get; set; }`
|
|||
|
|
Controls whether navigation controls are visible in the view.
|
|||
|
|
|
|||
|
|
- `string HeaderInfo { get; }`
|
|||
|
|
Returns the constant `"MainRegion"`; likely used for region naming or header labeling.
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
### **3. Invariants**
|
|||
|
|
|
|||
|
|
- `View.DataContext` is always set to `this` during construction.
|
|||
|
|
- `_eventAggregator` subscriptions are established in the constructor and never unsubscribed (potential memory leak risk).
|
|||
|
|
- `RealtimeSampleRates` setter *always* triggers `OnPropertyChanged("RealtimeSampleRate")`, implying that `RealtimeSampleRate` is derived or dependent on `RealtimeSampleRates`.
|
|||
|
|
- `IsDirty` is declared but never updated—its value is *always* `false`.
|
|||
|
|
- `IsBusy` is updated *only* via the `OnBusyIndicatorNotification(bool)` handler, which is subscribed to `BusyIndicatorChangeNotification`.
|
|||
|
|
- `NotificationRequest` is raised *only* via `OnRaiseNotification(NotificationContentEventArgs)`, which wraps the incoming `eventArgsWithTitle` into a `Notification` object with a `NotificationContentEventArgs` (with empty title and footer fields) and a `Title` taken from the event args.
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
### **4. Dependencies**
|
|||
|
|
|
|||
|
|
#### **Imports / Dependencies**
|
|||
|
|
- **MEF**: `[Export(typeof(IRealtimeSettingsView))]` and `[PartCreationPolicy(CreationPolicy.Shared)]` indicate this class is a shared MEF component.
|
|||
|
|
- **Prism**: Uses `IEventAggregator`, `IRegionManager`, `InteractionRequest<T>`, and likely `INavigationAware` (via `Activated()`).
|
|||
|
|
- **Unity**: `IUnityContainer` is injected for dependency resolution.
|
|||
|
|
- **Custom Types**:
|
|||
|
|
- `IRealtimeSettingsView` (view interface)
|
|||
|
|
- `BasePropertyChanged` (base class for `INotifyPropertyChanged`)
|
|||
|
|
- `RaiseNotification`, `BusyIndicatorChangeNotification` (event types from `DTS.Common.Events`)
|
|||
|
|
- `NotificationContentEventArgs`, `Notification`, `NotificationContentEventArgsWithoutTitle` (from `DTS.Common.Interactivity`)
|
|||
|
|
- `NotificationWindow`, `PopupWindowAction` (referenced in comments, likely in `DTS.Common.Interface` or `.Infrastructure`)
|
|||
|
|
|
|||
|
|
#### **Depended Upon**
|
|||
|
|
- The module is exported as `IRealtimeSettingsView`, so it is consumed by the shell or region manager when the `RealtimeSettings` view is requested.
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
### **5. Gotchas**
|
|||
|
|
|
|||
|
|
- **No-op lifecycle methods**: `Initialize()`, `InitializeAsync()`, `Activated()`, `Cleanup()`, and `CleanupAsync()` are all empty stubs. Any initialization or cleanup logic must be added manually—no behavior is implemented.
|
|||
|
|
- **`IsDirty` is never set**: The property exists but is never updated; it remains `false` for the lifetime of the object. If dirty tracking is required, this must be implemented.
|
|||
|
|
- **Event subscriptions are never unsubscribed**: `_eventAggregator.GetEvent<...>().Subscribe(...)` calls lack `Unsubscribe()` calls, which may cause memory leaks or unexpected behavior if the view model is disposed but events continue firing.
|
|||
|
|
- **`RealtimeSampleRates` setter triggers `RealtimeSampleRate` change**: This implies `RealtimeSampleRate` is *logically* derived from `RealtimeSampleRates`, but no parsing or validation is done in the setter. Consumers must ensure `RealtimeSampleRate` is a valid value from `RealtimeSampleRates`.
|
|||
|
|
- **`NotificationContentEventArgs` constructor usage is non-obvious**: The `OnRaiseNotification` method constructs a new `NotificationContentEventArgs(...)` with empty strings for title and footer, then wraps it in a `Notification` object. This suggests a mismatch between event payload structure and popup expectation—potential source of confusion or UI misrendering.
|
|||
|
|
- **No validation on sample rate/delay fields**: `RealtimeSampleRate` and `RealtimeDelayText` are plain strings with no validation or formatting logic in the view model.
|
|||
|
|
- **Comments reference outdated/incorrect types**: The `OnRaiseNotification` comment mentions `NotificationContentEventArgsWithoutTitle`, but the code instantiates `NotificationContentEventArgs` directly. This may indicate legacy or incomplete documentation.
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
*No additional behavior is evident from the source beyond what is described.*
|