#nullable enable using System; using System.Drawing; using System.Windows.Forms; public class TrayApp : ApplicationContext { private NotifyIcon trayIcon; private Telemetry telemetry; public TrayApp() { telemetry = new Telemetry(); telemetry.Initialize(); trayIcon = new NotifyIcon() { Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath), Visible = true, Text = "Telemetry Running (UDP)" }; var menu = new ContextMenuStrip(); menu.Items.Add("Exit", null, OnExit); trayIcon.ContextMenuStrip = menu; var timer = new System.Windows.Forms.Timer(); timer.Interval = 1000; timer.Tick += (s, e) => telemetry.UpdateAndSend(); timer.Start(); } private void OnExit(object? sender, EventArgs e) { telemetry.Dispose(); trayIcon.Visible = false; Application.Exit(); } }