@using RobotNet10.Shared.Detection
@using RobotNet10.Shared.Enum
@using RobotNet10.Shared.Numbers
Create Markers Search Request
Marker Entries
@for (int i = 0; i < _entries.Count; i++)
{
var index = i;
Marker @(index + 1)
@foreach (var type in System.Enum.GetValues())
{
@type
}
Reference Points
@for (int j = 0; j < _entries[index].ReferencePoints.Count; j++)
{
var ptIndex = j;
}
}
Cancel
Create
@code {
[CascadingParameter] IMudDialogInstance Dialog { get; set; } = null!;
private MarkersSearchRequest _request = new()
{
X = -0.611,
Y = 5.063,
Yaw = 180.0,
Width = 0.3,
Length = 0.3,
MarkerSearchRequests = []
};
private readonly List _entries = [
new MarkerEntryModel(){
MarkerId = "trolley-legs",
DeviceId = "sick-lidar-001",
Priority = 1,
Type = MarkerType.ShapeReflective,
ReferencePoints = [
new Vector2Model(){ X=-1.13, Y = 0.55 },
new Vector2Model(){X=1.13, Y=0.55 }
]
},
new MarkerEntryModel(){
MarkerId = "trolley-qr",
DeviceId = "hik-qr-001",
Priority = 2,
Type = MarkerType.QRCode,
Code = "PHENIKAAX",
ReferencePoints = []
}
];
private void AddMarkerEntry()
{
_entries.Add(new MarkerEntryModel { Priority = _entries.Count + 1 });
}
private void RemoveMarkerEntry(int index)
{
_entries.RemoveAt(index);
}
private void AddReferencePoint(int entryIndex)
{
_entries[entryIndex].ReferencePoints.Add(new Vector2Model());
}
private void RemoveReferencePoint(int entryIndex, int ptIndex)
{
_entries[entryIndex].ReferencePoints.RemoveAt(ptIndex);
}
private void Submit()
{
_request.MarkerSearchRequests = _entries.Select(e => new MarkerEntry
{
MarkerId = e.MarkerId ?? string.Empty,
Type = e.Type,
Priority = e.Priority,
DeviceId = e.DeviceId ?? string.Empty,
Code = e.Code ?? string.Empty,
ReferencePoints = e.ReferencePoints.Select(p => new Vector2 { X = p.X, Y = p.Y }).ToArray()
}).ToArray();
Dialog.Close(DialogResult.Ok(_request));
}
private void Cancel() => Dialog.Cancel();
private class MarkerEntryModel
{
public string? MarkerId { get; set; }
public MarkerType Type { get; set; }
public int Priority { get; set; } = 1;
public string? DeviceId { get; set; }
public string? Code { get; set; }
public List ReferencePoints { get; set; } = [];
}
private class Vector2Model
{
public double X { get; set; }
public double Y { get; set; }
}
}