Files
Nonemm/src/Nonemm.App/Dialogs/ChangeOperatorDialog.axaml.cs
T
erikbrockoandClaude Opus 5 836624376e Change the operator of the contacts picked in the log
A multi-operator station logs a whole shift under whoever was at the
radio, so a shift logged under the wrong callsign had to be put right a
contact at a time. "Change Operator…" in the log's right-click menu asks
for one callsign and writes it against every contact picked in the grid.

The dialog offers the operators the program already knows in a drop-down
and takes any other callsign typed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0157i7PiZyqBkquxS9A6FTdQ
2026-09-10 16:56:04 +00:00

50 lines
1.6 KiB
C#

using Avalonia.Controls;
using Avalonia.Interactivity;
namespace Nonemm.App.Dialogs;
/// Which callsign to write against the contacts picked in the log. It closes
/// with the callsign, or with null when nothing is to change. The operators
/// already known to the program are in the drop-down; any other callsign is
/// typed.
public sealed partial class ChangeOperatorDialog : Window
{
public ChangeOperatorDialog(int contacts, string callsign, IReadOnlyList<string> known)
{
InitializeComponent();
AboutText.Text = contacts == 1
? "Operator callsign for the contact picked in the log"
: $"Operator callsign for the {contacts} contacts picked in the log";
CallBox.Text = callsign;
KnownBox.ItemsSource = known;
// the callsign is all this dialog asks for, so the cursor starts in it
// and the operator types over what is there
Opened += (_, _) =>
{
CallBox.Focus();
CallBox.SelectAll();
};
}
private void OnPickedKnown(object? sender, SelectionChangedEventArgs e)
{
if (KnownBox.SelectedItem is string callsign)
{
CallBox.Text = callsign;
}
}
/// An empty box leaves the dialog open: clearing the operator of a contact
/// is not what this dialog is for.
private void OnOk(object? sender, RoutedEventArgs e)
{
string callsign = (CallBox.Text ?? "").Trim().ToUpperInvariant();
if (callsign.Length > 0)
{
Close(callsign);
}
}
private void OnCancel(object? sender, RoutedEventArgs e) => Close(null);
}