Files
2026-04-17 14:55:32 -04:00

6.4 KiB

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
DataPRO/Modules/Groups/GroupChannelList/View/GroupChannelListView.xaml.cs
2026-04-16T04:46:59.687984+00:00 Qwen/Qwen3-Coder-Next-FP8 1 a7a7f5755050a82e

View

Purpose

GroupChannelListView is the WPF view implementation for displaying and interacting with a list of channels associated with a test group or test setup. It provides UI controls for channel management—including reordering, deletion, clearing, filtering, and drag-and-drop assignment of sensors and hardware—while dynamically adjusting column visibility and layout based on the current view mode (IsoViewMode), group/test context, and global settings (e.g., ShowGroups). It acts as the presentation layer for GroupChannelListViewModel, synchronizing UI state with the view model via data binding and event-driven interactions.


Public Interface

The class implements IGroupChannelListView (inferred from partial class GroupChannelListView : IGroupChannelListView) and exposes the following public members:

  1. bool ReadOnlyChannelsMode { get; }
    Returns true if user input controls in the channel list should be read-only. Delegates to IGroupChannelListViewModel.ReadOnlyChannelsMode, returning false if DataContext is unset or not a IGroupChannelListViewModel.

  2. void HandleColumns(IsoViewMode viewMode)
    Dynamically configures the columns of ChannelListListView (an AutoSizedGridView) based on viewMode and global settings (ShowGroups, UseTestSetupOrder, ShowDallasIdColumn). Adds/removes columns for:

    • Group order (GroupColumn, GroupOrderColumn)
    • Test setup order (TestSetupOrderColumn)
    • User code/name (UserCodeColumn, UserChannelNameColumn)
    • ISO code/name (ISOCodeColumn, ISOChannelNameColumn)
    • Dallas ID (DallasIdColumn)
      Ensures column ordering respects usingTestSetup context.

Invariants

The following must hold during operation:

  • ChannelListListView must be initialized before HandleColumns() is called, as all column operations assume ChannelListListView.View is an AutoSizedGridView.
  • DataContext must be set to a GroupChannelListViewModel (or IGroupChannelListViewModel) for most functionality. If DataContext is null or of the wrong type, methods silently return (e.g., OnListViewEvent, Clear_Click, Delete_Click, MoveUp_Click, etc.).
  • Drag-and-drop operations require e.Data to be non-null and contain supported formats (e.g., DragAndDropPayload.FORMAT, DTS.Common.Classes.Hardware.DragAndDropPayload.FORMAT). Unsupported formats result in DragDropEffects.None.
  • Channel deletion for blank channels requires valid ordering:
    • If UseTestSetupOrder, channel.TestSetupOrder > 0 must hold.
    • Otherwise, channel.GroupChannelOrder > 0 must hold.
      (Per issue #14546 comment in Delete_Click.)
  • ReadOnlyChannelsMode is false if DataContext is null or not a IGroupChannelListViewModel.
  • Column insertion/removal preserves ordering:
    • TestSetupOrderColumn/GroupOrderColumn are always first (index 0).
    • User/ISO columns are inserted at indices 0 or 1 depending on usingTestSetup.

Dependencies

Imports/References (from source):

  • DTS.Common.*: Core domain classes (Groups, Sensors, Controls, Enums, Events, Interface, Settings, Utils).
  • Prism.Ioc, Prism.Events: For IEventAggregator, ContainerLocator, and event publication/subscription (ListViewStatusEvent, GroupChannelDeleteRequestEvent, PageNavigationRequestEvent).
  • WPF namespaces (System.Windows.*): For ListView, DragEventArgs, Hyperlink, etc.

Key External Dependencies (inferred):

  • GroupChannelListViewModel: Required as DataContext for all interactive logic.
  • IGroupChannel: Interface implemented by channel objects (e.g., GroupChannel).
  • AutoSizedGridView: Custom WPF control (from DTS.Common.Controls) used as ChannelListListView.View.
  • MouseUtilities: Used in IsMouseOverTarget() for drag-drop hit-testing (from DTS.Common.Utils).
  • DTS.SensorDB.SoftwareFilter: Used in ISOCode_LostFocus to fetch filter classes.
  • Global settings via SettingsDB.GetGlobalValueBool("ShowGroups", true).

Depended upon by:

  • GroupChannelListViewModel (via IGroupChannelListView interface).
  • Event handlers (ListViewStatusEvent, GroupChannelDeleteRequestEvent, PageNavigationRequestEvent) suggest integration with broader Prism-based navigation and state management.

Gotchas

  • Silent failures: Most event handlers and property getters return early if DataContext is null or of incorrect type (e.g., Clear_Click, Delete_Click, MoveUp_Click, HandleColumns). No exceptions or logging occur—debugging requires inspecting call stacks.
  • Drag-drop modifier key handling is fragile:
    • ALT/CTRL key states are checked via bitwise operations on DragDropKeyStates, but formats are mutated in-place (e.g., "ALT_FORMAT"), which may cause issues if e.Data.GetFormats() is called multiple times.
    • TextBox_Drop and ChannelList_Drop duplicate logic for format handling—risk of divergence if updated in one place but not the other.
  • ReadOnlyChannelsMode is read-only and computed: It does not raise change notifications; UI consumers must re-query it when DataContext changes.
  • HandleColumns assumes ChannelListListView.View is always AutoSizedGridView: If the view is changed (e.g., to GridView), column operations will silently fail.
  • MoveUp/MoveDown via keyboard (Alt+↑/↓) uses ChannelListListView.SelectedItems order, but GetSelectedChannelsOrdered() sorts by view index—this may differ from selection order if items are selected non-contiguously.
  • ISOCode_LostFocus mutates FilterClass based on ISO code, but only if UseISOCodeFilterMapping is true. No fallback or error handling if GetFilterClassFromISOCode fails.
  • Delete_Click allows deletion of blank channels with valid orders (per issue #14546), but blocks deletion if order ≤ 0—this may confuse users expecting blank channels to be deletable unconditionally.
  • TextBoxSourceUpdated handles group name changes, but the comment implies complex group reorganization logic in GroupNameChanged—behavior is not visible in this file.

None identified from source alone.