6.0 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | ||||
|---|---|---|---|---|---|---|---|---|
|
2026-04-17T15:54:07.829323+00:00 | zai-org/GLM-5-FP8 | 1 | 3a91a38b574329b5 |
RegionOfInterestChannels View Module Documentation
1. Purpose
This module provides the WPF view layer for the Region of Interest Channels feature. It implements a dynamic, data-driven GridView system where columns are generated at runtime based on a source collection, with specialized column headers for searching (string columns) and select-all functionality (boolean columns). The module includes a DataTemplateSelector for rendering different cell types (text vs. checkbox), a multi-value converter for state lookup by index, and attached properties that enable declarative column configuration in XAML.
2. Public Interface
StateListIndexConverter
Implements: IMultiValueConverter
| Method | Signature | Behavior |
|---|---|---|
Convert |
object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) |
Expects exactly 2 values: values[0] as IEnumerable<State> and values[1] as int index. Returns the State element at that index, or null if validation fails. |
ConvertBack |
object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) |
Throws NotImplementedException. |
RegionOfInterestChannelsView
Implements: IRegionOfInterestChannelsView
| Method | Signature | Behavior |
|---|---|---|
| Constructor | RegionOfInterestChannelsView() |
Calls InitializeComponent(). |
GridViewColumnHeader_OnClick |
void GridViewColumnHeader_OnClick(object sender, RoutedEventArgs e) |
Extracts column tag from GridViewColumnHeaderSearchable or GridViewColumnHeaderSelectable (via sender or visual tree traversal), casts DataContext to IRegionOfInterestChannelsViewModel, and calls vm.Sort(columnTag, true). |
TextBlock_Loaded |
void TextBlock_Loaded(object sender, RoutedEventArgs e) |
Auto-expands column width if the loaded TextBlock is wider than the current column width. Forces re-measure by setting Width to ActualWidth then back to double.NaN. |
RegionOfInterestChannelsDataTemplateSelector
Inherits: DataTemplateSelector
| Property | Type | Description |
|---|---|---|
TextBlockDataTemplate |
DataTemplate |
Template for string-type cells. |
CheckBoxDataTemplate |
DataTemplate |
Template for boolean-type cells. |
| Method | Signature | Behavior |
|---|---|---|
SelectTemplate |
DataTemplate SelectTemplate(object item, DependencyObject container) |
For ChannelEnabler items: traverses the visual tree to find the column index, uses reflection to get the property type from the column header, and returns the appropriate template. Sets container.Tag to either the property value (for strings) or the column offset index (for booleans). Returns TextBlockDataTemplate for non-ChannelEnabler items. |
GridViewColumns (Static Class)
Provides attached properties for dynamic GridView column generation.
| Attached Property | Type | Target | Description |
|---|---|---|---|
ColumnsSource |
object |
GridView |
Source collection for dynamic column generation. Changes trigger column creation/removal. |
CellDataTemplateSelector |
DataTemplateSelector |
GridView |
Selector used to choose cell templates. Takes precedence over CellDataTemplate. |
CellDataTemplate |
DataTemplate |
GridView |
Default cell template. |
HeaderTextMember |
string |
GridView |
Property name on column source items to use for header text. |
DisplayMember |
string |
GridView |
Property name for display binding (currently commented out in implementation). |
| Private Method | Behavior |
|---|---|
ColumnsSourceChanged |
Clears existing columns, removes old handlers, adds new handlers, and creates columns from the new source. |
CreateColumn |
Creates a GridViewColumn with header type determined by MemberType: bool → GridViewColumnHeaderSelectable, string → GridViewColumnHeaderSearchable, default → plain string. Wires up SelectAll, Search, and ClickHandler events. |
ColumnsSource_CollectionChanged |
Handles Add, Move, Remove, Replace, Reset actions to synchronize GridView.Columns with the source collection. |
GetArrayIndex |
Parses an array index from a string in format ...[n].... Returns -1 on parse failure. |
3. Invariants
-
StateListIndexConverter input contract:
valuesmust be non-null, have length exactly 2,values[0]must beIEnumerable<State>,values[1]must beint, and the index must be within bounds of the collection. Violation returnsnull. -
GridViewColumns registration: The static dictionary
_gridViewsByColumnsSourcemaintains a mapping fromICollectionViewtoList<GridView>. AllGridViews sharing the sameColumnsSourcewill be synchronized on collection changes. -
Column header type mapping: Column headers are created based on
MemberTypeproperty of the column source:typeof(bool)→GridViewColumnHeaderSelectabletypeof(string)→GridViewColumnHeaderSearchable- Other → plain
stringheader
-
Template precedence: In
CreateColumn, the comment explicitly states:selector < template < displaymember(selector takes highest precedence). -
DataTemplateSelector column detection:
RegionOfInterestChannelsDataTemplateSelector.SelectTemplateassumes the column header'sToString()(with spaces removed) matches a property name onChannelEnabler.