Add the Broadcast Data dialog and send N1MM's score breakdown
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="Nonemm.App.Dialogs.BroadcastDataDialog"
|
||||
Title="Broadcast Data" Width="680" SizeToContent="Height"
|
||||
WindowStartupLocation="CenterOwner" CanResize="False">
|
||||
<StackPanel Margin="14" Spacing="6">
|
||||
<TextBlock TextWrapping="Wrap" FontSize="11" Opacity="0.75"
|
||||
Text="Select the type of data you wish to broadcast, and the IP address(es) and port(s) for the receiver(s) of the data. Use 127.0.0.1 for the local machine. Use 12060 as the port unless the receiving application requires a different port. 255 in the low order octet will broadcast to your current subnet." />
|
||||
<TextBlock Text="Type of data IP Addr:Port IP Addr:Port..."
|
||||
FontSize="11" Opacity="0.7" Margin="0,6,0,0" />
|
||||
<Grid ColumnDefinitions="150,8,*" RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto" RowSpacing="6">
|
||||
<CheckBox Name="AppInfoCheck" Content="Application Info" />
|
||||
<TextBox Name="AppInfoBox" Grid.Column="2" />
|
||||
<CheckBox Name="RadioCheck" Grid.Row="1" Content="Radio" />
|
||||
<TextBox Name="RadioBox" Grid.Row="1" Grid.Column="2" />
|
||||
<CheckBox Name="ContactsCheck" Grid.Row="2" Content="Contacts" />
|
||||
<TextBox Name="ContactsBox" Grid.Row="2" Grid.Column="2"
|
||||
PlaceholderText="empty: broadcast to the whole network" />
|
||||
<CheckBox Name="AllComputersCheck" Grid.Row="3" Content="All Computers" Margin="20,0,0,0" />
|
||||
<CheckBox Name="SpotsCheck" Grid.Row="4" Content="Spots" />
|
||||
<TextBox Name="SpotsBox" Grid.Row="4" Grid.Column="2" />
|
||||
<CheckBox Name="RotorCheck" Grid.Row="5" Content="Rotor" />
|
||||
<TextBox Name="RotorBox" Grid.Row="5" Grid.Column="2" />
|
||||
<CheckBox Name="ScoreCheck" Grid.Row="6" Content="Score" />
|
||||
<TextBox Name="ScoreBox" Grid.Row="6" Grid.Column="2" />
|
||||
<CheckBox Name="LookupCheck" Grid.Row="7" Content="External Callsign Lookup" />
|
||||
<TextBox Name="LookupBox" Grid.Row="7" Grid.Column="2" />
|
||||
</Grid>
|
||||
<TextBlock Name="ProblemText" TextWrapping="Wrap" Foreground="OrangeRed" IsVisible="False" />
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Spacing="6" Margin="0,8,0,0">
|
||||
<Button Content="Cancel" Click="OnCancel" />
|
||||
<Button Content="Save" Click="OnSave" IsDefault="True" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Window>
|
||||
@@ -0,0 +1,82 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Nonemm.App.Configuration;
|
||||
using Nonemm.Network;
|
||||
|
||||
namespace Nonemm.App.Dialogs;
|
||||
|
||||
/// N1MM's Broadcast Data tab: what is sent to other programs, and where.
|
||||
public sealed partial class BroadcastDataDialog : Window
|
||||
{
|
||||
private readonly Settings settings;
|
||||
|
||||
public BroadcastDataDialog(Settings settings)
|
||||
{
|
||||
this.settings = settings;
|
||||
InitializeComponent();
|
||||
Fill(AppInfoCheck, AppInfoBox, BroadcastKind.AppInfo, settings.BroadcastAppInfo);
|
||||
Fill(RadioCheck, RadioBox, BroadcastKind.Radio, settings.BroadcastRadio);
|
||||
Fill(SpotsCheck, SpotsBox, BroadcastKind.Spots, settings.BroadcastSpots);
|
||||
Fill(RotorCheck, RotorBox, BroadcastKind.Rotor, settings.BroadcastRotor);
|
||||
Fill(ScoreCheck, ScoreBox, BroadcastKind.Score, settings.BroadcastScore);
|
||||
Fill(LookupCheck, LookupBox, BroadcastKind.Lookup, settings.BroadcastLookup);
|
||||
ContactsCheck.IsChecked = settings.NetworkEnabled;
|
||||
ContactsBox.Text = string.Join(' ', settings.NetworkPeers);
|
||||
AllComputersCheck.IsChecked = settings.BroadcastAllComputers;
|
||||
}
|
||||
|
||||
/// An empty list shows the default, as N1MM does.
|
||||
private static void Fill(CheckBox check, TextBox box, BroadcastKind kind, BroadcastChannel channel)
|
||||
{
|
||||
check.IsChecked = channel.IsEnabled;
|
||||
box.Text = channel.Addresses.Count > 0
|
||||
? string.Join(' ', channel.Addresses)
|
||||
: BroadcastTargets.DefaultFor(kind).ToString();
|
||||
}
|
||||
|
||||
private void OnSave(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
List<string> problems = [];
|
||||
BroadcastChannel Read(string name, CheckBox check, TextBox box, int defaultPort)
|
||||
{
|
||||
string text = (box.Text ?? "").Trim();
|
||||
if (BroadcastTargets.Parse(text, defaultPort, out string problem) is null)
|
||||
{
|
||||
problems.Add($"{name}: {problem}");
|
||||
}
|
||||
return new BroadcastChannel
|
||||
{
|
||||
IsEnabled = check.IsChecked == true,
|
||||
Addresses = text.Split([' ', ',', ';', '\t', '\r', '\n'], StringSplitOptions.RemoveEmptyEntries),
|
||||
};
|
||||
}
|
||||
|
||||
BroadcastChannel appInfo = Read("Application Info", AppInfoCheck, AppInfoBox, BroadcastTargets.DefaultPort);
|
||||
BroadcastChannel radio = Read("Radio", RadioCheck, RadioBox, BroadcastTargets.DefaultPort);
|
||||
BroadcastChannel contacts = Read("Contacts", ContactsCheck, ContactsBox, settings.NetworkPort);
|
||||
BroadcastChannel spots = Read("Spots", SpotsCheck, SpotsBox, BroadcastTargets.DefaultPort);
|
||||
BroadcastChannel rotor = Read("Rotor", RotorCheck, RotorBox, BroadcastTargets.RotorPort);
|
||||
BroadcastChannel score = Read("Score", ScoreCheck, ScoreBox, BroadcastTargets.ScorePort);
|
||||
BroadcastChannel lookup = Read("External Callsign Lookup", LookupCheck, LookupBox, BroadcastTargets.DefaultPort);
|
||||
if (problems.Count > 0)
|
||||
{
|
||||
ProblemText.Text = string.Join("\n", problems);
|
||||
ProblemText.IsVisible = true;
|
||||
return;
|
||||
}
|
||||
Close(settings with
|
||||
{
|
||||
BroadcastAppInfo = appInfo,
|
||||
BroadcastRadio = radio,
|
||||
NetworkEnabled = contacts.IsEnabled,
|
||||
NetworkPeers = contacts.Addresses,
|
||||
BroadcastAllComputers = AllComputersCheck.IsChecked == true,
|
||||
BroadcastSpots = spots,
|
||||
BroadcastRotor = rotor,
|
||||
BroadcastScore = score,
|
||||
BroadcastLookup = lookup,
|
||||
});
|
||||
}
|
||||
|
||||
private void OnCancel(object? sender, RoutedEventArgs e) => Close(null);
|
||||
}
|
||||
@@ -5,16 +5,13 @@
|
||||
WindowStartupLocation="CenterOwner" CanResize="False">
|
||||
<StackPanel Margin="14" Spacing="6">
|
||||
<TextBlock TextWrapping="Wrap" FontSize="11" Opacity="0.75"
|
||||
Text="Each contact is sent to the other stations of the entry as it is logged, in N1MM's contact message, so an N1MM station on the same network sees them too. With no addresses listed the contacts are broadcast." />
|
||||
Text="This computer's name on the network and the port it listens on for contacts. Where contacts are sent is set in Config ▸ Configure Broadcast Data." />
|
||||
<Grid ColumnDefinitions="*,8,110" RowDefinitions="Auto,Auto">
|
||||
<TextBlock Text="This station's name" FontSize="11" Opacity="0.7" Margin="0,6,0,1" />
|
||||
<TextBox Name="NameBox" Grid.Row="1" />
|
||||
<TextBlock Grid.Column="2" Text="Port" FontSize="11" Opacity="0.7" Margin="0,6,0,1" />
|
||||
<TextBox Name="PortBox" Grid.Row="1" Grid.Column="2" />
|
||||
</Grid>
|
||||
<TextBlock Text="Other stations, one address per line" FontSize="11" Opacity="0.7" Margin="0,6,0,1" />
|
||||
<TextBox Name="PeersBox" AcceptsReturn="True" Height="90" PlaceholderText="192.168.1.11" />
|
||||
<CheckBox Name="EnabledBox" Content="Broadcast contacts to other programs (port 12060)" Margin="0,6,0,0" />
|
||||
<TextBlock Text="The other logging computers" FontWeight="Bold" Margin="0,12,0,0" />
|
||||
<TextBlock TextWrapping="Wrap" FontSize="11" Opacity="0.75"
|
||||
Text="This is N1MM's own link between the computers of one entry, on port 12070: contacts, edits, deletes and chat, over a connection to each station. Stations are found by broadcast, so nothing has to be listed." />
|
||||
|
||||
@@ -16,8 +16,6 @@ public sealed partial class NetworkDialog : Window
|
||||
? settings.NetworkStationName
|
||||
: Environment.MachineName;
|
||||
PortBox.Text = settings.NetworkPort.ToString();
|
||||
PeersBox.Text = string.Join("\n", settings.NetworkPeers);
|
||||
EnabledBox.IsChecked = settings.NetworkEnabled;
|
||||
StationNumberBox.Text = settings.StationNumber.ToString();
|
||||
LinkPortBox.Text = settings.StationLinkPort.ToString();
|
||||
VersionBox.Text = settings.StationLinkVersion;
|
||||
@@ -30,12 +28,6 @@ public sealed partial class NetworkDialog : Window
|
||||
{
|
||||
NetworkStationName = (NameBox.Text ?? "").Trim(),
|
||||
NetworkPort = int.TryParse(PortBox.Text, out int port) ? port : 12060,
|
||||
NetworkPeers = (PeersBox.Text ?? "")
|
||||
.Split('\n', StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(l => l.Trim())
|
||||
.Where(l => l.Length > 0)
|
||||
.ToList(),
|
||||
NetworkEnabled = EnabledBox.IsChecked == true,
|
||||
StationNumber = int.TryParse(StationNumberBox.Text, out int number)
|
||||
? Math.Clamp(number, 1, 99)
|
||||
: settings.StationNumber,
|
||||
|
||||
Reference in New Issue
Block a user