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

7.3 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-17T15:58:43.555476+00:00 zai-org/GLM-5-FP8 1 d3939bb26e2af959

GroupChannelListView Documentation

1. Purpose

GroupChannelListView is a WPF UserControl (code-behind) that provides the view layer for displaying and managing a list of group channels in a tabular format. It handles user interactions including drag-and-drop sensor/hardware assignment, channel reordering, column visibility management based on view modes, and navigation events. This view implements IGroupChannelListView and serves as the UI component within the Groups module for configuring channel assignments in test setups and group configurations.

2. Public Interface

Properties

Signature Description
bool ReadOnlyChannelsMode { get; } Returns whether user input controls should be read-only. Delegates to IGroupChannelListViewModel.ReadOnlyChannelsMode if DataContext is valid; otherwise returns false.

Methods

Signature Description
void HandleColumns(IsoViewMode viewMode) Dynamically configures column visibility based on the specified IsoViewMode. Manages Group, ISO Code, User Code, Dallas ID, and Test Setup Order columns. Reads global setting "ShowGroups" to determine group column visibility.

Constructor

Signature Description
GroupChannelListView() Initializes the component and subscribes to ListViewStatusEvent via IEventAggregator to handle scroll-to-bottom requests.

Event Handlers (Private, wired to XAML)

Method Trigger Behavior
Clear_Click(object sender, RoutedEventArgs e) Clear button click Calls viewModel.Clear(channel) and viewModel.NotifyChannelsChanged() for the affected IGroupChannel.
Delete_Click(object sender, RoutedEventArgs e) Delete button click Publishes GroupChannelDeleteRequestEvent with GroupChannelDeleteRequestEventArgs. Special handling for blank channels with order values (bug fix 14546).
MoveTop_Click, MoveUp_Click, MoveDown_Click, MoveBottom_Click Move button clicks Calls corresponding vm.MoveTop(), vm.MoveUp(), vm.MoveDown(), vm.MoveBottom() methods. Supports multi-selection via GetSelectedChannelsOrdered().
ChannelList_Drop(object sender, DragEventArgs e) Drop operation Handles DragAndDropPayload.FORMAT for sensor assignment and DTS.Common.Classes.Hardware.DragAndDropPayload.FORMAT for hardware assignment via vm.DoSensorAssignment() and vm.DoHardwareAssignment().
TextBox_Drop(object sender, DragEventArgs e) Drop on text box Same drop handling as ChannelList_Drop, but extracts IGroupChannel from Control.DataContext or TextBlock.DataContext.
ChannelCodeBuilder_OnChannelCodeSelected(object sender, string code, string name, ChannelEnumsAndConstants.ChannelCodeType codeType) Channel code selection Sets IsoCode/IsoChannelName or UserCode/UserChannelName based on codeType. Calls viewModel.MarkModified(channel).
ChannelNameBuilder_OnChannelCodeSelected(...) Channel name selection Similar to above but sets name first, then code.
ISOCode_LostFocus(object sender, RoutedEventArgs e) ISO Code field loses focus If UseISOCodeFilterMapping is true, retrieves software filters and calls channel.GetFilterClassFromISOCode() to set FilterClass.
Hyperlink_Click(object sender, RoutedEventArgs e) Hyperlink click Publishes PageNavigationRequestEvent with destination Sensor for navigation.

3. Invariants

  • DataContext Contract: Most operations assume DataContext is either IGroupChannelListViewModel or GroupChannelListViewModel. Operations silently return if this contract is violated.
  • Column Management: ChannelListListView.View must be of type DTS.Common.Controls.AutoSizedGridView for column manipulation methods to function.
  • Drag-Drop Payload Formats: The view recognizes specific format strings:
    • DragAndDropPayload.FORMAT and DragAndDropPayload.ALT_FORMAT for sensor payloads
    • DTS.Common.Classes.Hardware.DragAndDropPayload.FORMAT for hardware payloads
  • Selection Ordering: GetSelectedChannelsOrdered() returns channels sorted by their index in ChannelListListView.Items, preserving visual order.
  • Order Column Exclusivity: Either TestSetupOrderColumn or GroupOrderColumn is displayed at index 0, never both simultaneously.

4. Dependencies

Imports (This module depends on)

Namespace Purpose
DTS.Common.Classes.Groups GroupChannel entity
DTS.Common.Classes.Sensors.SensorsList Sensor-related types
DTS.Common.Controls AutoSizedGridView, GridViewColumnHeaderSearchable
DTS.Common.Enums IsoViewMode enum
DTS.Common.Enums.Channels ChannelEnumsAndConstants
DTS.Common.Events PageNavigationRequestEvent, PageNavigationRequest
DTS.Common.Events.Groups.GroupChannelList ListViewStatusEvent, ListViewStatusArg, GroupChannelDeleteRequestEvent, GroupChannelDeleteRequestEventArgs
DTS.Common.Interface.Channels IHardwareChannel
DTS.Common.Interface.DataRecorders Data recorder interfaces
DTS.Common.Interface.Groups.GroupChannelList IGroupChannelListView, IGroupChannelListViewModel, IGroupChannel
DTS.Common.Settings SettingsDB.GetGlobalValueBool()
DTS.Common.Utils MouseUtilities for drag-drop coordinate handling
Prism.Ioc ContainerLocator for service resolution
Prism.Events IEventAggregator for pub/sub messaging
DTS.SensorDB SoftwareFilter.GetSoftwareFilters() (referenced in ISOCode_LostFocus)

Known Dependents

Not determinable from this source file alone.

5. Gotchas

  1. Drag-Drop Mouse Position: The code explicitly uses MouseUtilities.GetMousePosition(target) instead of standard WPF mechanisms because "during a drag-drop operation, the WPF mechanisms for getting the coordinates behave strangely."

  2. Blank Channel Deletion (Bug 14546): Blank channels may still have TestSetupOrder or GroupChannelOrder assigned. The delete logic allows deletion of blank channels only if their order value is greater than 0, depending on UseTestSetupOrder mode.

  3. Modifier Key Format Mutation: During drag operations, the code mutates format strings by prepending "ALT_" or "CTRL_" based on DragDropKeyStates. This creates format strings like "ALT_FORMAT" that must match expected payload constants.

  4. Inconsistent Drag-Over Behavior: ChannelList_DragOver allows DragAndDropPayload.ALT_FORMAT but TextBox_DragOver handles it differently—some formats that are allowed in list-level drag-over are rejected in text-box drag-over.

  5. Hardcoded Column Dependencies: AddDallasIdColumn() relies on HardwareColumn existing to determine insertion index. If HardwareColumn is not in the view, the insertion logic may fail or insert at an unexpected position.

  6. Empty Event Handler: ChannelListListView_SelectionChanged is wired but contains no implementation.

  7. Global Setting Dependency: HandleColumns reads "ShowGroups" global setting via SettingsDB.GetGlobalValueBool() with default true. This creates implicit runtime configuration dependency.