I think this question is specific to EditorX since I don’t see the same problem in TUI.
I have a dialog that requests the user to select a model number and enter a serial number.
I also allow both items to be populated automatically from a scanned QR code if it matches a specific pattern.
This all works, but the problem I see is if the user mistakenly enters or scans the wrong value into the SerialNumber field and attempts to delete it an re-enter or scan.
The SerialNumber ‘set’ is only be called the first time the user enters it. If they attempt to modify it, the ‘set’ method is never called again and they must cancel the operation and restart the test plan to be able to re-enter the proper serial number.
As mentioned, this works in TUI though it is very different because of its implementation of IDisplayAnnotation. I am not currently set up on Windows to try Editor instead of EditorX.
Is this expected behavior?
class DutSelectDialog: IDisplayAnnotation
{
public enum DialogResult
{
Cancel = 2, Ok = 1
}
public DutSelectDialog(List<string> partNumbers)
{
PartNumbers = partNumbers;
}
public List<string> PartNumbers {get; private set;}
private string _serialNumber;
[Display("Serial Number", Order:100)]
public string SerialNumber
{
get => _serialNumber;
set {
// Specific QR pattern that allows setting both the serial number and part number
var match = new Regex(@"\A(\d{8}).*(\d\.\d)(\d{11})\Z").Match(value);
if (match.Success && (match.Groups.Count == 4))
{
_serialNumber = match.Groups[3].Value;
string partnumber = match.Groups[1].Value + "REV-" + match.Groups[2].Value;
foreach(var pn in PartNumbers)
{
if (pn.StartsWith(partnumber))
{
PartNumber = pn;
break;
}
}
}
else
{
_serialNumber = value;
}
}
}
[AvailableValues(nameof(PartNumbers))]
[Display("Part Number", Order:102)]
public string PartNumber {get; set;}
[Layout(LayoutMode.FloatBottom | LayoutMode.FullRow)]
[Submit]
public DialogResult Response { get; set; }
public string Name { get => "Scan Board QR Code"; }
string IDisplayAnnotation.Description => string.Empty;
string[] IDisplayAnnotation.Group => Array.Empty<string>();
double IDisplayAnnotation.Order => -10000;
bool IDisplayAnnotation.Collapsed => false;
}
Thanks,
Wittrock