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

5.0 KiB
Raw Blame History

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
DataPRO/Modules/Realtime/RealtimeModule/View/RealtimeChannelSelectView.xaml.cs
2026-04-16T04:48:08.293076+00:00 Qwen/Qwen3-Coder-Next-FP8 1 6ca4c92ee0b7d299

View

Documentation: RealtimeChannelSelectView

1. Purpose

RealtimeChannelSelectView is a WPF UI view responsible for rendering and managing user interaction with a channel selection control in the Realtime module. It implements the IRealtimeChannelSelectView interface and coordinates with its associated view model (IRealtimeChannelSelectViewModel) to handle search input and channel selection. Its role is to translate user actions (text input and selection changes in a ComboBox) into corresponding view model operations, enabling users to search for and select a real-time data channel.

2. Public Interface

The class itself is not a public API in the traditional sense (it is partial and tied to XAML), but it implements the IRealtimeChannelSelectView interface (from DTS.Common.Interface.Realtime). Since the interface definition is not provided in the source, only the publicly exposed behavior (via event handlers) is documented:

  • RealtimeChannelSelectView()
    Constructor. Initializes the component by calling InitializeComponent() to wire up XAML-defined elements.

  • private void Search_TextChanged(object sender, TextChangedEventArgs e)
    Event handler for TextBox.TextChanged (or equivalent ComboBox.Text change). Updates the view models search text via vm.SetSearchText(cb.Text), ensures the dropdown remains open (cb.IsDropDownOpen = true), and does not modify selection state directly.

  • private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
    Event handler for ComboBox.SelectionChanged. When an item is selected:

    • Casts the selected item to IRealtimeChannel.
    • Informs the view model via vm.SetRealtimeChannel(channel).
    • Clears the selection (cb.SelectedItem = null), resets the search text (vm.SetSearchText("")), and closes the dropdown (cb.IsDropDownOpen = false).

⚠️ Note: No other public methods or properties are defined in this file. All logic resides in private event handlers.

3. Invariants

  • The DataContext of the ComboBox must always be an instance implementing IRealtimeChannelSelectViewModel.
  • The selected item in the ComboBox must be an instance of IRealtimeChannel.
  • After a channel is selected, the view model is guaranteed to receive:
    1. SetRealtimeChannel(channel)
    2. SetSearchText("")
  • The ComboBox dropdown is explicitly kept open during text input (Search_TextChanged) and closed after selection (ComboBox_SelectionChanged).
  • Selection is cleared (SelectedItem = null) after handling to prevent re-triggering on the same item.

4. Dependencies

  • External Interfaces:
    • DTS.Common.Interface.Realtime.IRealtimeChannel — Represents a real-time channel.
    • DTS.Common.Interface.Realtime.IRealtimeChannelSelectView — The interface this class implements (inferred from inheritdoc).
    • DTS.Common.Interface.Realtime.IRealtimeChannelSelectViewModel — The expected type of DataContext.
  • WPF Framework:
    • System.Windows.Controls.ComboBox, System.Windows.Controls.TextChangedEventArgs, System.Windows.Controls.SelectionChangedEventArgs.
  • Inferred Usage:
    • This view is consumed by XAML (likely RealtimeChannelSelectView.xaml) and bound to a view model implementing IRealtimeChannelSelectViewModel.
    • The view model likely depends on other parts of the Realtime module (e.g., channel discovery, data subscription logic), but those are not visible here.

5. Gotchas

  • Selection clearing side effect: cb.SelectedItem = null is set after calling vm.SetRealtimeChannel(channel), which may be necessary to avoid re-selection loops, but could cause issues if the view model expects the selection to persist during its processing.
  • Search text reset: vm.SetSearchText("") is called after channel selection, not during text input. This means the search text is cleared only upon selection, not on every keystroke.
  • Commented-out state flag: A volatile bool _bHandleSelection field is commented out, suggesting a past attempt to prevent re-entrancy or double-handling of selection events. Its absence may indicate unresolved reentrancy risks or legacy tech debt.
  • No null-safety for cb.SelectedItem beyond null check: The handler assumes cb.SelectedItem is castable to IRealtimeChannel if non-null; no validation is performed.
  • Assumes cb.DataContext is always IRealtimeChannelSelectViewModel: No null-check on vm is performed before calling methods on it, risking NullReferenceException if binding is misconfigured.
  • No explicit handling of deselection: If SelectedItem becomes null via external means (e.g., programmatic reset), the handler does nothing — this may be intentional, but is not documented.

None identified beyond the above.