Files
Nonemm/src/Nonemm.Session/StationPath.cs
T
erikbrockoandClaude Opus 5 1c118f9ce4 Lay the menu bar out the way N1MM lays it out, and fill in the Edit menu
The menu tree comes from N1MM's EntryWindow.Designer.cs: File, Edit, View,
Tools, Config, Window, with the items under the names N1MM gives them. The
window list moved out of View into Window; the call history file moved from
Config into File > Import. Ctrl+W, Ctrl+L and Ctrl+M now work, so the keys
printed in the menu are real. Two commands that had no menu item before:
the CW and SSB function key definitions, and the QTC setup area.

The rest of the Edit menu:

- Ctrl+N asks for a note and puts it in the comment of the contact in the
  boxes, or of the last logged contact when nothing is typed.
- Edit Current Contact opens the Edit Contact form over what is typed but
  not logged. Update hands the values back to the entry boxes.
- Ctrl+Q and Ctrl+A load a logged contact into the boxes and paint them
  pale yellow. Enter writes the change back, Esc puts back what was being
  typed, and stepping forward past the newest contact leaves quick edit.
- Ctrl+U raises the received serial, or a numeric exchange box when the
  contest has no serial.
- Ctrl+F shows the call being typed in the log window, then the next
  contact with that call.

RadioPosition is now OperatingPosition: it is the operator at one radio,
not a place on a band.

Looked at under Xvfb on a 3775-contact log: quick edit back and forward,
Esc, the note dialog, find, and Edit Current Contact putting a zone back
into the entry boxes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-28 12:18:37 +00:00

60 lines
2.5 KiB
C#

using Nonemm.Core;
using Nonemm.Core.Country;
namespace Nonemm.Session;
/// Where the station being worked is from here: the beam heading, the heading
/// the long way round, how far away it is, and when the sun rises and sets
/// there. N1MM writes the same line under its entry window.
///
/// The position comes from the grid square if the contest exchanges one and the
/// operator has copied it, and from the country file otherwise, which puts the
/// station in the middle of its country. That is close enough to point a beam
/// with, and it is what N1MM does.
public sealed record StationPath(
double Heading,
double DistanceKm,
DateTime? Sunrise,
DateTime? Sunset)
{
/// The heading the long way round, which a big antenna is sometimes better
/// off using.
public double LongPath => (Heading + 180.0) % 360.0;
/// Null when there is nothing to work out a path from: no station in the
/// callsign box, no country file, or no position for either end.
public static StationPath? For(OperatingPosition session, DateTime nowUtc)
{
if (Mine(session) is not { } here || Theirs(session) is not { } there)
{
return null;
}
(DateTime Rise, DateTime Set)? sun = SunTimes.For(there.Latitude, there.Longitude, nowUtc);
return new StationPath(
GridSquare.Bearing(here.Latitude, here.Longitude, there.Latitude, there.Longitude),
GridSquare.DistanceKm(here.Latitude, here.Longitude, there.Latitude, there.Longitude),
sun?.Rise,
sun?.Set);
}
private static (double Latitude, double Longitude)? Mine(OperatingPosition session) =>
Place(session.Me.GridSquare) ?? Place(session.Session.Countries?.Find(session.Me.Callsign));
private static (double Latitude, double Longitude)? Theirs(OperatingPosition session)
{
if (session.Entry.Call.Trim().Length == 0)
{
return null;
}
return Place(session.Entry.ValueOf(Contests.ExchangeSlot.GridSquare))
?? Place(session.Session.History.Find(session.Entry.Call)?.GridSquare ?? "")
?? Place(session.Country());
}
private static (double Latitude, double Longitude)? Place(string grid) =>
GridSquare.TryParse(grid, out GridSquare square) ? (square.Latitude, square.Longitude) : null;
private static (double Latitude, double Longitude)? Place(CountryLookup? country) =>
country is null ? null : (country.Latitude, country.Longitude);
}