343 lines
15 KiB
Markdown
343 lines
15 KiB
Markdown
|
|
---
|
||
|
|
source_files:
|
||
|
|
- Common/DTS.CommonCore/Controls/RoundedBox.xaml.cs
|
||
|
|
- Common/DTS.CommonCore/Controls/TestIDView.xaml.cs
|
||
|
|
- Common/DTS.CommonCore/Controls/checkbox.xaml.cs
|
||
|
|
- Common/DTS.CommonCore/Controls/GridLengthAnimation.cs
|
||
|
|
- Common/DTS.CommonCore/Controls/ISOPopup.xaml.cs
|
||
|
|
- Common/DTS.CommonCore/Controls/LookupPopup.xaml.cs
|
||
|
|
- Common/DTS.CommonCore/Controls/TestIdPreFixSuffixHelper.cs
|
||
|
|
- Common/DTS.CommonCore/Controls/AutoSizedGridView.cs
|
||
|
|
- Common/DTS.CommonCore/Controls/DynamicGrid.cs
|
||
|
|
- Common/DTS.CommonCore/Controls/TestIDViewModel.cs
|
||
|
|
- Common/DTS.CommonCore/Controls/TestIDControl.xaml.cs
|
||
|
|
- Common/DTS.CommonCore/Controls/GridViewColumnHeaderSelectable.xaml.cs
|
||
|
|
- Common/DTS.CommonCore/Controls/GridViewColumnHeaderSearchable.xaml.cs
|
||
|
|
- Common/DTS.CommonCore/Controls/GridViewColumnHeaderSearchableCheckBox.xaml.cs
|
||
|
|
generated_at: "2026-04-16T12:02:29.779799+00:00"
|
||
|
|
model: "zai-org/GLM-5-FP8"
|
||
|
|
schema_version: 1
|
||
|
|
sha256: "1aa96c65b3ed084a"
|
||
|
|
---
|
||
|
|
|
||
|
|
# DTS.Common.Controls Documentation
|
||
|
|
|
||
|
|
## 1. Purpose
|
||
|
|
|
||
|
|
This module provides a collection of custom WPF controls and helpers for the DTS application. It includes specialized controls for test ID generation and display, animated grid layouts, popup-based lookup and ISO input validation, and enhanced GridView column headers with search, selection, and filtering capabilities. The controls integrate with the Prism EventAggregator for cross-component communication and support data binding through dependency properties and `INotifyPropertyChanged`.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 2. Public Interface
|
||
|
|
|
||
|
|
### RoundedBox
|
||
|
|
```csharp
|
||
|
|
public partial class RoundedBox : UserControl
|
||
|
|
public RoundedBox() // Constructor
|
||
|
|
public void Connect(int connectionId, object target) // Stub method (implementation commented out)
|
||
|
|
```
|
||
|
|
A simple UserControl. The `Connect` method is defined but its implementation is commented out.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### TestIDView
|
||
|
|
```csharp
|
||
|
|
public partial class TestIDView : UserControl
|
||
|
|
public TestIDView() // Constructor
|
||
|
|
```
|
||
|
|
A simple UserControl with no additional public members beyond the constructor.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### checkbox
|
||
|
|
```csharp
|
||
|
|
public partial class checkbox
|
||
|
|
public void ToolTipEventHandler(object sender, ToolTipEventArgs e)
|
||
|
|
```
|
||
|
|
Handles tooltip events by publishing a `HelpTextEvent` via the `IEventAggregator`. Sets `e.Handled = true` and forwards the event arguments to subscribers.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### GridLengthAnimation
|
||
|
|
```csharp
|
||
|
|
public class GridLengthAnimation : AnimationTimeline
|
||
|
|
public GridLengthAnimation() // Constructor
|
||
|
|
|
||
|
|
public GridLength From { get; set; } // Dependency property
|
||
|
|
public static readonly DependencyProperty FromProperty
|
||
|
|
|
||
|
|
public GridLength To { get; set; } // Dependency property
|
||
|
|
public static readonly DependencyProperty ToProperty
|
||
|
|
|
||
|
|
public override Type TargetPropertyType // Returns typeof(GridLength)
|
||
|
|
public override object GetCurrentValue(object defaultOriginValue, object defaultDestinationValue, AnimationClock animationClock)
|
||
|
|
protected override Freezable CreateInstanceCore() // Returns new GridLengthAnimation()
|
||
|
|
```
|
||
|
|
Custom animation timeline for animating `GridLength` values. Supports both pixel and star-based grid units, preserving the `GridUnitType` from the `To` property.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### ISOPopup
|
||
|
|
```csharp
|
||
|
|
public partial class ISOPopup : Popup
|
||
|
|
public ISOPopup() // Constructor
|
||
|
|
|
||
|
|
// Private event handlers (wired via XAML):
|
||
|
|
private void ISOPart_OnPreviewKeyUp(object sender, KeyEventArgs e) // Filters input to alphanumeric and control keys only
|
||
|
|
private void ISOPart_OnGotMouseCapture(object sender, MouseEventArgs e) // Selects all text in TextBox
|
||
|
|
private void ISOPart_OnGotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) // Selects all text in TextBox
|
||
|
|
```
|
||
|
|
A Popup control that restricts input to letters (A-Z), digits (0-9, NumPad0-9), and control keys (Enter, Tab, Delete, Back, Home, End, OemQuestion, OemBackTab).
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### LookupPopup
|
||
|
|
```csharp
|
||
|
|
public partial class LookupPopup : Popup
|
||
|
|
public LookupPopup() // Constructor
|
||
|
|
|
||
|
|
public IEnumerable<IChannelCode> AllChannelCodes { get; private set; }
|
||
|
|
|
||
|
|
public delegate void ChannelCodeSelectedEventHandler(object sender, string code, string name);
|
||
|
|
public event ChannelCodeSelectedEventHandler ChannelCodeSelected
|
||
|
|
|
||
|
|
public static readonly DependencyProperty PossibleChannelsProperty
|
||
|
|
public IList PossibleChannels { get; set; } // Default: empty list with anonymous objects
|
||
|
|
|
||
|
|
// Private event handlers:
|
||
|
|
private void LookupPopup_OnOpenedClosed(object sender, EventArgs e) // Commented-out implementation
|
||
|
|
private void PossibleChannels_OnMouseDoubleClick(object sender, MouseButtonEventArgs e) // Raises ChannelCodeSelected
|
||
|
|
```
|
||
|
|
A Popup for selecting channel codes from a DataGrid. Uses reflection to extract `Code` and `Name` properties from items.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### TestIdPreFixSuffixHelper & Related Classes
|
||
|
|
```csharp
|
||
|
|
public enum TestIdFixedPrefixSuffixValues
|
||
|
|
{
|
||
|
|
NotFixed = -1,
|
||
|
|
None = 0,
|
||
|
|
TimeStamp = 1,
|
||
|
|
TestSetupName = 2
|
||
|
|
}
|
||
|
|
|
||
|
|
public class TestIdPreFixSuffix
|
||
|
|
public TestIdPreFixSuffix(TestIdFixedPrefixSuffixValues fixedPrefixSuffix)
|
||
|
|
public TestIdPreFixSuffix(string dbPrefixSuffix)
|
||
|
|
public TestIdFixedPrefixSuffixValues FixedValue { get; } // Default: NotFixed
|
||
|
|
public override string ToString() // Returns "TESTID_PREFIX_SUFFIX_{value}" or the db string
|
||
|
|
|
||
|
|
public class TestIdPreFixSuffixHelper : BasePropertyChanged
|
||
|
|
public TestIdPreFixSuffixHelper(string testIdPreFixSuffix)
|
||
|
|
public TestIdPreFixSuffixHelper(TestIdFixedPrefixSuffixValues testIdPreFixSuffix)
|
||
|
|
public TestIdPreFixSuffix TestIdPreFixSuffix { get; }
|
||
|
|
public override string ToString() // Looks up localized string via ResourceManager
|
||
|
|
public override bool Equals(object obj)
|
||
|
|
```
|
||
|
|
Helper classes for managing test ID prefix/suffix values with support for both fixed enumerated values and database-defined strings.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### AutoSizedGridView
|
||
|
|
```csharp
|
||
|
|
public class AutoSizedGridView : GridView
|
||
|
|
protected override void PrepareItem(ListViewItem item)
|
||
|
|
```
|
||
|
|
A GridView that automatically resizes columns marked with `Width="Auto"` and restores lost width bindings. Tracks columns via hash codes.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### DynamicGrid
|
||
|
|
```csharp
|
||
|
|
public class DynamicGrid : Grid, INotifyPropertyChanged
|
||
|
|
public DynamicGrid() // Constructor, calls Refresh()
|
||
|
|
|
||
|
|
public byte GridColumns { get; set; } // Default: 2
|
||
|
|
public void Refresh()
|
||
|
|
|
||
|
|
// INotifyPropertyChanged implementation:
|
||
|
|
public event PropertyChangedEventHandler PropertyChanged
|
||
|
|
protected bool SetProperty<T>(ref T storage, T value, string propertyName = null)
|
||
|
|
protected void OnPropertyChanged(string propertyName = null)
|
||
|
|
```
|
||
|
|
A Grid that automatically arranges children in a configurable number of columns. All columns except the last use `Auto` width; the last uses `Star`. Adds a final `Star`-height row at the bottom.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### TestIDViewModel
|
||
|
|
```csharp
|
||
|
|
public class TestIDViewModel : INotifyPropertyChanged
|
||
|
|
public string TestSetupLabel { get; set; } // Default: string.Empty
|
||
|
|
public Visibility TestSetupLabelVisibility { get; } // Collapsed if label is empty
|
||
|
|
public string TestIdEditableText { get; set; } // Default: string.Empty
|
||
|
|
public string TestName { get; set; }
|
||
|
|
|
||
|
|
public void PopulateAllTestIdPrefixSuffixValues(string[] serializedValues)
|
||
|
|
public TestIdPreFixSuffixHelper[] AllTestIdPrefixSuffixValues { get; }
|
||
|
|
public TestIdPreFixSuffixHelper SelectedTestIdPrefixValueItem { get; set; } // Default: None
|
||
|
|
public TestIdPreFixSuffixHelper SelectedTestIdSuffixValueItem { get; set; } // Default: TimeStamp
|
||
|
|
|
||
|
|
public string GetTestId()
|
||
|
|
public string GetTestIdTimestamp() // Format: "YYYY_MM_DD HH_MM"
|
||
|
|
```
|
||
|
|
ViewModel for constructing test IDs from prefix, label, editable text, and suffix components.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### TestIdControl
|
||
|
|
```csharp
|
||
|
|
public partial class TestIdControl : UserControl, INotifyPropertyChanged
|
||
|
|
public TestIdControl() // Constructor
|
||
|
|
|
||
|
|
// Same public interface as TestIDViewModel:
|
||
|
|
public string TestSetupLabel { get; set; }
|
||
|
|
public Visibility TestSetupLabelVisibility { get; }
|
||
|
|
public string TestIdEditableText { get; set; }
|
||
|
|
public string TestName { get; set; }
|
||
|
|
public void PopulateAllTestIdPrefixSuffixValues(string[] serializedValues)
|
||
|
|
public TestIdPreFixSuffixHelper[] AllTestIdPrefixSuffixValues { get; }
|
||
|
|
public TestIdPreFixSuffixHelper SelectedTestIdPrefixValueItem { get; set; }
|
||
|
|
public TestIdPreFixSuffixHelper SelectedTestIdSuffixValueItem { get; set; }
|
||
|
|
public string GetTestId()
|
||
|
|
public string GetTestIdTimestamp()
|
||
|
|
```
|
||
|
|
**Note:** Comment indicates this control should be removed after TTS module deletion and migration to new test setup wizard.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### GridViewColumnHeaderSelectable
|
||
|
|
```csharp
|
||
|
|
public partial class GridViewColumnHeaderSelectable : UserControl, IBasePropertyChanged
|
||
|
|
public GridViewColumnHeaderSelectable() // Constructor, subscribes to ListViewStatusEvent
|
||
|
|
|
||
|
|
public string ListviewId { get; set; } // Dependency property, default: ""
|
||
|
|
public string HeaderTitle { get; set; } // Dependency property, default: "Awesome"
|
||
|
|
public bool ToggleButtonIsChecked { get; set; } // Default: false
|
||
|
|
|
||
|
|
// Routed events:
|
||
|
|
public static readonly RoutedEvent OpenChangedEvent
|
||
|
|
public event RoutedEventHandler OpenChanged
|
||
|
|
|
||
|
|
public static readonly RoutedEvent ClickEvent
|
||
|
|
public event RoutedEventHandler ClickHandler
|
||
|
|
|
||
|
|
public static readonly RoutedEvent SelectAllEvent
|
||
|
|
public event RoutedEventHandler SelectAll
|
||
|
|
```
|
||
|
|
A column header with a toggle button popup for selection. Raises `OpenChanged`, `ClickHandler`, and `SelectAll` routed events.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### GridViewColumnHeaderSearchable
|
||
|
|
```csharp
|
||
|
|
public partial class GridViewColumnHeaderSearchable : UserControl, IBasePropertyChanged
|
||
|
|
public GridViewColumnHeaderSearchable() // Constructor, subscribes to ListViewStatusEvent
|
||
|
|
|
||
|
|
public string ListviewId { get; set; } // Dependency property
|
||
|
|
public string HeaderTitle { get; set; } // Dependency property, default: "Awesome"
|
||
|
|
public bool ToggleButtonIsChecked { get; set; }
|
||
|
|
public string HeaderSearchTerm { get; set; } // Dependency property, default: ""
|
||
|
|
public Geometry ToggleIconGeometry { get; } // Returns DownArrowIconGeometry or FilterIconGeometry
|
||
|
|
|
||
|
|
// Routed events:
|
||
|
|
public static readonly RoutedEvent OpenChangedEvent
|
||
|
|
public event RoutedEventHandler OpenChanged
|
||
|
|
|
||
|
|
public static readonly RoutedEvent ClickEvent
|
||
|
|
public event RoutedEventHandler ClickHandler
|
||
|
|
|
||
|
|
public static readonly RoutedEvent SearchEvent
|
||
|
|
public event RoutedEventHandler Search
|
||
|
|
|
||
|
|
// Converter:
|
||
|
|
public class BoolToInvertedBoolConverter : IValueConverter
|
||
|
|
```
|
||
|
|
A searchable column header with a popup. Displays different icons based on whether a search term is active.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
### GridViewColumnHeaderSearchableCheckBox
|
||
|
|
```csharp
|
||
|
|
public partial class GridViewColumnHeaderSearchableCheckBox : UserControl, IBasePropertyChanged
|
||
|
|
public GridViewColumnHeaderSearchableCheckBox() // Constructor, subscribes to ListViewStatusEvent
|
||
|
|
|
||
|
|
public string ListviewId { get; set; } // Dependency property
|
||
|
|
public string HeaderTitle { get; set; } // Dependency property, default: "Awesome"
|
||
|
|
public bool ToggleButtonIsChecked { get; set; }
|
||
|
|
public string HeaderSearchTerm { get; set; } // Dependency property
|
||
|
|
public Geometry ToggleIconGeometry { get; }
|
||
|
|
|
||
|
|
// Routed events:
|
||
|
|
public static readonly RoutedEvent OpenChangedEvent
|
||
|
|
public event RoutedEventHandler OpenChanged
|
||
|
|
|
||
|
|
public static readonly RoutedEvent ClickEvent
|
||
|
|
public event RoutedEventHandler ClickHandler
|
||
|
|
|
||
|
|
public static readonly RoutedEvent SearchEvent
|
||
|
|
public event RoutedEventHandler Search
|
||
|
|
|
||
|
|
public static readonly RoutedEvent FilterEvent
|
||
|
|
public event RoutedEventHandler Filter // Raised with "All", "True", or "False"
|
||
|
|
```
|
||
|
|
A column header combining search and boolean filtering with All/True/False buttons.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 3. Invariants
|
||
|
|
|
||
|
|
- **GridLengthAnimation**: The `GridUnitType` (Star or Pixel) is always taken from the `To` property, not `From`.
|
||
|
|
- **ISOPopup**: Input is restricted to alphanumeric characters and specific control keys; all other keys set `e.Handled = true`.
|
||
|
|
- **DynamicGrid**: The last column always has `GridUnitType.Star`; all others have `GridUnitType.Auto`. A final row with `Star` height is always appended.
|
||
|
|
- **AutoSizedGridView**: Column tracking uses `GetHashCode()`; if column collection changes, internal caches are rebuilt.
|
||
|
|
- **LookupPopup**: Items in `PossibleChannels` must have `Code` and `Name` properties accessible via reflection.
|
||
|
|
- **TestIdPreFixSuffixHelper.Equals**: Two helpers are equal if they have the same `FixedValue` (when not `NotFixed`), or if both are `NotFixed` and their string representations match.
|
||
|
|
- **TestIDViewModel/TestIdControl**: `GetTestId()` joins non-empty components with underscores in order: prefix → TestSetupLabel → TestIdEditableText → suffix.
|
||
|
|
- **GridViewColumnHeader* controls**: All subscribe to `ListViewStatusEvent` and clear state when receiving `Unloaded` status matching their `ListviewId`.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 4. Dependencies
|
||
|
|
|
||
|
|
### This module depends on:
|
||
|
|
- `System.Windows` (WPF core)
|
||
|
|
- `System.Windows.Controls`
|
||
|
|
- `System.Windows.Controls.Primitives`
|
||
|
|
- `System.Windows.Data`
|
||
|
|
- `System.Windows.Input`
|
||
|
|
- `System.Windows.Media.Animation`
|
||
|
|
- `Microsoft.Practices.ServiceLocation` (ServiceLocator)
|
||
|
|
- `Microsoft.Practices.Prism.Events` (IEventAggregator, ThreadOption)
|
||
|
|
- `DTS.Common.Base` (BasePropertyChanged, IBasePropertyChanged)
|
||
|
|
- `DTS.Common.Events` (HelpTextEvent, HelpTextEventArg, ListViewStatusEvent, ListViewStatusArg)
|
||
|
|
- `DTS.Common.Interface.Channels.ChannelCodes` (IChannelCode)
|
||
|
|
- `DTS.Common.Utilities.Logging` (imported but usage not visible in provided source)
|
||
|
|
- `DTS.Strings.Strings` (ResourceManager for localization)
|
||
|
|
|
||
|
|
### What depends on this module:
|
||
|
|
- Cannot be determined from source alone; these are UI controls likely used by various modules throughout the DTS application.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 5. Gotchas
|
||
|
|
|
||
|
|
1. **TestIdControl is deprecated**: The source explicitly states "Remove this control after deleting the TTS module and migrating to new test setup wizard." New code should use `TestIDViewModel` instead.
|
||
|
|
|
||
|
|
2. **LookupPopup uses reflection**: `PossibleChannels_OnMouseDoubleClick` uses `GetProperty("Code")` and `GetProperty("Name")` via reflection on anonymous-type-like objects. This is fragile and will fail silently (returning null) if properties don't exist.
|
||
|
|
|
||
|
|
3. **RoundedBox.Connect is a stub**: The method throws `NotImplementedException` (commented out). Its purpose is unclear from source.
|
||
|
|
|
||
|
|
4. **GridViewColumnHeaderSelectable.OnListviewStatusEvent has empty body**: When `arg.Id == ListviewId`, there's no actual logic executed—just an empty if block.
|
||
|
|
|
||
|
|
5. **AutoSizedGridView uses hash codes for column identity**: Column tracking relies on `GetHashCode()`, which could theoretically collide (though unlikely in practice).
|
||
|
|
|
||
|
|
6. **checkbox class lacks constructor**: The partial class `checkbox` has no constructor shown; `InitializeComponent()` must be called from the XAML-generated part.
|
||
|
|
|
||
|
|
7. **BoolToInvertedBoolConverter.ConvertBack throws**: The `ConvertBack` method throws `NotImplementedException`, making it unsuitable for two-way bindings.
|
||
|
|
|
||
|
|
8. **GridLengthAnimation doesn't validate animationClock.CurrentProgress**: `GetCurrentValue` accesses `animationClock.CurrentProgress.Value` without null checking; could throw if progress is null.
|
||
|
|
|
||
|
|
9. **DynamicGrid.Refresh clears and rebuilds all definitions**: Called on every `GridColumns` change and every visual child change; may have performance implications for grids with many children.
|
||
|
|
|
||
|
|
10. **TestIDViewModel.TestIdEditableText property notification missing**: The property setter doesn't raise `PropertyChanged`, unlike other properties.
|