Skip to content

Commit

Permalink
Merge pull request #4 from Laim/feature-bf-2
Browse files Browse the repository at this point in the history
- Fixed User Settings not loading at the right time
- Removed placeholders for Feeder URL and Port
- Added - Update Available to GUI Title if an update is available
- Added FlightAlert based on Call Sign
- Added gif to readme.md
  • Loading branch information
Laim committed Feb 18, 2024
2 parents 63cdf23 + ebf20ec commit 0964f78
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 35 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -396,3 +396,4 @@ FodyWeavers.xsd

# JetBrains Rider
*.sln.iml
pi24gui/pi24gui - Backup.csproj
5 changes: 5 additions & 0 deletions HELP.md
Expand Up @@ -7,6 +7,11 @@ To access your pi24 web page from the application, click on the Local IP(s) in t

To go to a specific flight being shown under the Tracked Aircraft tab, double click on the aircrafts data row (anywhere you want) and it will open the aircraft on the FlightRadar24 website.

## FlightAlert
FlightAlert will send you a System Notification or System Beep (both if both are selected) every time a callsign you specify appears in the Tracked Aircraft list.

This feature requires the GUI to be open or running in the background.

## Options
This just explains what each setting does

Expand Down
4 changes: 1 addition & 3 deletions README.md
@@ -1,9 +1,7 @@
# pi24gui
This is GUI for pi24 (FlightRadar24) that you can leave open and it'll refresh automatically if configured.

![Overview Tab](https://github.com/Laim/pi24gui/assets/14845036/da1ae3c7-2534-4937-8a08-422a5e4ca1dd)

![Aircraft Tab](https://github.com/Laim/pi24gui/assets/14845036/8bd82c67-cbc1-4c40-aa19-61c3e546a69d)
![pi24gui-gif](https://github.com/Laim/pi24gui/assets/14845036/f8819acd-da41-433e-8ab4-250f828c972c)

# Usage
Download the latest release and open pi24gui.exe, enter your feeder URL and port (default port is 8754) and click connect.
Expand Down
2 changes: 1 addition & 1 deletion pi24gui/Models/UserSettings.cs
Expand Up @@ -6,7 +6,7 @@ public class UserSettings

public bool AutoRefreshEnabled { get; set; } = false;

public int AutoRefreshInterval { get; set; } = 5;
public int AutoRefreshInterval { get; set; } = 60;

public bool FlightAlertEnabled { get; set; } = false;

Expand Down
35 changes: 22 additions & 13 deletions pi24gui/frmMain.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

95 changes: 80 additions & 15 deletions pi24gui/frmMain.cs
Expand Up @@ -3,6 +3,8 @@
using System.Diagnostics;
using Newtonsoft.Json;
using pi24gui.Settings;
using Microsoft.Toolkit.Uwp.Notifications;
using System.ComponentModel;

namespace pi24gui
{
Expand All @@ -27,13 +29,23 @@ protected override async void OnLoad(EventArgs e)

if (new Updater.Updater().CheckForUpdate(Application.ProductVersion))
{
Text += $" - Update Available";
using frmUpdateNotice frm = new();
frm.ShowDialog();
}

lblVersion.Text = Application.ProductVersion;

_userSettings = await _settingsRepo.GetSettings();
LoadSettings();
}

protected override void OnClosing(CancelEventArgs e)
{
base.OnClosing(e);

// Clears notifications
ToastNotificationManagerCompat.Uninstall();
}

private void btnFeederConnectDisconnect_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -100,6 +112,33 @@ private void GetFlights(string feederData)
flight.Squawk
}
);

// Flight Alert
if (cbFlightAlert.Checked)
{
string alertCallSign = txtAlertCallSign.Text;

if (string.Equals(flight.Callsign, alertCallSign, StringComparison.CurrentCultureIgnoreCase))
{

if (cbFlightAlertNotification.Checked)
{
new ToastContentBuilder()
.AddText("FlightAlert")
.AddText($"{alertCallSign} being tracked.")
.SetToastScenario(ToastScenario.Default)
.Show();
}

if (cbFlightAlertBeep.Checked)
{
Console.Beep(650, 25);
Console.Beep(750, 25);
Console.Beep(850, 25);
}

}
}
}
}

Expand Down Expand Up @@ -388,7 +427,7 @@ private void LoadSettings()
numRefreshTime.Value = _userSettings.AutoRefreshInterval;

cbFlightAlert.Checked = _userSettings.FlightAlertEnabled;
txtCallSign.Text = _userSettings.FlightAlertCallSign;
txtAlertCallSign.Text = _userSettings.FlightAlertCallSign;
cbFlightAlertNotification.Checked = _userSettings.FlightAlertNotification;
cbFlightAlertBeep.Checked = _userSettings.FlightAlertBeep;
}
Expand All @@ -406,19 +445,21 @@ private async void SaveSettings()

try
{
_userSettings = new();
_userSettings.FeederURL = txtFeederUrl.Text;
_userSettings.FeederPort = Convert.ToInt32(txtFeederPort.Text);
_userSettings = new()
{
FeederURL = txtFeederUrl.Text,
FeederPort = Convert.ToInt32(txtFeederPort.Text),

_userSettings.AppendLog = cbAppendLog.Checked;
AppendLog = cbAppendLog.Checked,

_userSettings.AutoRefreshEnabled = cbRefresh.Checked;
_userSettings.AutoRefreshInterval = Convert.ToInt32(numRefreshTime.Value);
AutoRefreshEnabled = cbRefresh.Checked,
AutoRefreshInterval = Convert.ToInt32(numRefreshTime.Value),

_userSettings.FlightAlertEnabled = cbFlightAlert.Checked;
_userSettings.FlightAlertCallSign = txtCallSign.Text;
_userSettings.FlightAlertNotification = cbFlightAlertNotification.Checked;
_userSettings.FlightAlertBeep = cbFlightAlertBeep.Checked;
FlightAlertEnabled = cbFlightAlert.Checked,
FlightAlertCallSign = txtAlertCallSign.Text,
FlightAlertNotification = cbFlightAlertNotification.Checked,
FlightAlertBeep = cbFlightAlertBeep.Checked
};

await _settingsRepo.SaveSettings(_userSettings);

Expand All @@ -433,13 +474,27 @@ private async void SaveSettings()

private void btnOptionsSave_Click(object sender, EventArgs e)
{
SaveSettings();
bool canSave = true;

if (cbRefresh.Checked)
if (cbFlightAlert.Checked)
{
if (_autoRefreshTimer != null)
if (!cbFlightAlertBeep.Checked && !cbFlightAlertNotification.Checked)
{
_autoRefreshTimer.Interval = Convert.ToInt32(numRefreshTime.Value * 1000);
MessageBox.Show("At least one alert option must be enabled if FlightAlert is enabled.", "Save Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
canSave = false;
}
}

if (canSave)
{
SaveSettings();

if (cbRefresh.Checked)
{
if (_autoRefreshTimer != null)
{
_autoRefreshTimer.Interval = Convert.ToInt32(numRefreshTime.Value * 1000);
}
}
}
}
Expand Down Expand Up @@ -510,5 +565,15 @@ private void lblLocalIpsValue_Click(object sender, EventArgs e)
}
);
}

private void lblAlertHelp_Click(object sender, EventArgs e)
{
MessageBox.Show(
$"Every time the Callsign appears in the Tracked Aircraft list, " +
$"you will get a Notification or Beep (depending on what you've selected)." +
$"\r\n \r\n" +
$"If you have a 15 second refresh, it will alert you every 15 seconds.",
Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
4 changes: 2 additions & 2 deletions pi24gui/frmUpdateNotice.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pi24gui/pi24gui.csproj
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<TargetFramework>net8.0-windows10.0.22000.0</TargetFramework>
<RootNamespace>pi24gui</RootNamespace>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
Expand All @@ -14,6 +14,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.1.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

Expand Down

0 comments on commit 0964f78

Please sign in to comment.