Add Sonic container scan with manual multi-select after system setup.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -381,7 +381,9 @@ public sealed class SetupWizardForm : Form
|
||||
|
||||
Panel toolbar = CreateToolbar(
|
||||
"+ Container hinzufügen",
|
||||
async () => await AddContainerAsync());
|
||||
async () => await AddContainerAsync(),
|
||||
secondaryText: "Von Sonic scannen",
|
||||
onSecondary: async () => await ScanContainersForSelectedSystemAsync());
|
||||
|
||||
_lvContainers = SettingsUi.CreateListView();
|
||||
_lvContainers.Dock = DockStyle.Fill;
|
||||
@@ -418,7 +420,9 @@ public sealed class SetupWizardForm : Form
|
||||
|
||||
private Panel CreateToolbar(
|
||||
string addButtonText,
|
||||
Func<Task> onAdd)
|
||||
Func<Task> onAdd,
|
||||
string? secondaryText = null,
|
||||
Func<Task>? onSecondary = null)
|
||||
{
|
||||
Panel toolbar = new()
|
||||
{
|
||||
@@ -433,6 +437,16 @@ public sealed class SetupWizardForm : Form
|
||||
add.Width = 230;
|
||||
add.Click += async (_, _) => await onAdd();
|
||||
|
||||
if (secondaryText is not null && onSecondary is not null)
|
||||
{
|
||||
Button secondary = SettingsUi.CreateGhostButton(secondaryText);
|
||||
secondary.Dock = DockStyle.Left;
|
||||
secondary.Width = 180;
|
||||
secondary.Margin = new Padding(8, 0, 0, 0);
|
||||
secondary.Click += async (_, _) => await onSecondary();
|
||||
toolbar.Controls.Add(secondary);
|
||||
}
|
||||
|
||||
toolbar.Controls.Add(add);
|
||||
return toolbar;
|
||||
}
|
||||
@@ -692,6 +706,78 @@ public sealed class SetupWizardForm : Form
|
||||
"Prüfung OK",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information);
|
||||
|
||||
SonicSystemOption? createdSystem = _systems
|
||||
.FirstOrDefault(system =>
|
||||
system.SonicConnectionId == createdId);
|
||||
|
||||
if (createdSystem is null
|
||||
&& _lvSystems.SelectedItems.Count > 0)
|
||||
{
|
||||
createdSystem =
|
||||
_lvSystems.SelectedItems[0].Tag as SonicSystemOption;
|
||||
}
|
||||
|
||||
if (createdSystem is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
DialogResult next = MessageBox.Show(
|
||||
this,
|
||||
"Container jetzt per Sonic-Scan oder manuell zuordnen?",
|
||||
"Container",
|
||||
MessageBoxButtons.YesNo,
|
||||
MessageBoxIcon.Question);
|
||||
|
||||
if (next != DialogResult.Yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using SelectContainersForm selectForm =
|
||||
new(_coordinator, createdSystem);
|
||||
|
||||
if (selectForm.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
await LoadContainersListAsync();
|
||||
await RefreshAllAsync();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ScanContainersForSelectedSystemAsync()
|
||||
{
|
||||
SonicSystemOption? system = null;
|
||||
|
||||
if (_lvSystems.SelectedItems.Count > 0)
|
||||
{
|
||||
system = _lvSystems.SelectedItems[0].Tag as SonicSystemOption;
|
||||
}
|
||||
|
||||
system ??= _systems.FirstOrDefault();
|
||||
|
||||
if (system is null)
|
||||
{
|
||||
// Systeme-Liste ggf. nachladen
|
||||
await LoadSystemsListAsync();
|
||||
system = _systems.FirstOrDefault();
|
||||
}
|
||||
|
||||
if (system is null)
|
||||
{
|
||||
ShowWarning(
|
||||
"Bitte zuerst ein Sonic-System anlegen oder auswählen.");
|
||||
return;
|
||||
}
|
||||
|
||||
using SelectContainersForm selectForm =
|
||||
new(_coordinator, system);
|
||||
|
||||
if (selectForm.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
await LoadContainersListAsync();
|
||||
await RefreshAllAsync();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task AddContainerAsync()
|
||||
|
||||
Reference in New Issue
Block a user