Show the cluster's solar weather in a bandmap status bar
The reader follows N1MM's rules for WWV and WCY lines and the sh/wwv table. The bar is hidden until the cluster has sent some. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -914,6 +914,7 @@ public sealed partial class AppSession : IDisposable
|
||||
public void ConnectCluster()
|
||||
{
|
||||
cluster?.Dispose();
|
||||
SetSolar("");
|
||||
cluster = new ClusterClient(
|
||||
Settings.ClusterHost,
|
||||
Settings.ClusterPort,
|
||||
@@ -923,14 +924,28 @@ public sealed partial class AppSession : IDisposable
|
||||
autoLogon: Settings.ClusterAutoLogon,
|
||||
keepAliveInterval: TimeSpan.FromMinutes(Math.Max(1, Settings.ClusterKeepAliveMinutes)));
|
||||
cluster.SpotArrived += (_, spot) => TakeSpot(spot);
|
||||
cluster.SolarArrived += (_, text) => SetSolar(text);
|
||||
cluster.ConnectionChanged += (_, _) => Changed?.Invoke(this, EventArgs.Empty);
|
||||
cluster.Start();
|
||||
}
|
||||
|
||||
/// The latest solar weather the cluster sent, or empty when it has sent
|
||||
/// none on this connection.
|
||||
public string Solar { get; private set; } = "";
|
||||
|
||||
public event EventHandler? SolarChanged;
|
||||
|
||||
private void SetSolar(string text)
|
||||
{
|
||||
Solar = text;
|
||||
SolarChanged?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
public void DisconnectCluster()
|
||||
{
|
||||
cluster?.Dispose();
|
||||
cluster = null;
|
||||
SetSolar("");
|
||||
Changed?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,10 @@
|
||||
<ComboBox Name="SpanBox" FontSize="11" Width="96" />
|
||||
<CheckBox Name="CentreBox" Content="Centre on VFO" FontSize="11" Margin="8,0,0,0" />
|
||||
</DockPanel>
|
||||
<Border Name="SolarBar" DockPanel.Dock="Bottom" IsVisible="False" Padding="6,2"
|
||||
BorderThickness="0,1,0,0" BorderBrush="Gray">
|
||||
<TextBlock Name="SolarText" FontSize="11" TextWrapping="Wrap" />
|
||||
</Border>
|
||||
<local:BandmapView Name="View" />
|
||||
</DockPanel>
|
||||
</local:RefreshableWindow>
|
||||
|
||||
@@ -76,9 +76,21 @@ public sealed partial class BandmapWindow : RefreshableWindow
|
||||
};
|
||||
View.FrequencyPicked += (_, frequency) => tune(frequency, "");
|
||||
session.Bandmap.Changed += (_, _) => Dispatcher.UIThread.Post(Refresh);
|
||||
EventHandler solarChanged = (_, _) => Dispatcher.UIThread.Post(ShowSolar);
|
||||
session.SolarChanged += solarChanged;
|
||||
Closed += (_, _) => session.SolarChanged -= solarChanged;
|
||||
ShowSolar();
|
||||
Refresh();
|
||||
}
|
||||
|
||||
/// The status bar holds the solar weather the cluster sent, and is hidden
|
||||
/// while there is none.
|
||||
private void ShowSolar()
|
||||
{
|
||||
SolarText.Text = session.Solar;
|
||||
SolarBar.IsVisible = session.Solar.Length > 0;
|
||||
}
|
||||
|
||||
private void SaveView()
|
||||
{
|
||||
session.Save(session.Settings with
|
||||
|
||||
Reference in New Issue
Block a user