using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; namespace LumaTunnel.Client.Views; public sealed partial class ConnectionsPage : Page { private DispatcherTimer? _timer; public ConnectionsPage() => InitializeComponent(); private void OnLoaded(object sender, RoutedEventArgs e) { _timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1) }; _timer.Tick += (_, _) => Refresh(); _timer.Start(); Refresh(); } private void OnUnloaded(object sender, RoutedEventArgs e) => _timer?.Stop(); private void Refresh() => ConnectionList.ItemsSource = AppServices.ProxyEngine.Connections .OrderByDescending(static item => item.StartedAtUtc) .Select(item => $"{item.Protocol,-7} {item.Target,-40} {item.Route,-7} ↑ {item.UploadBytes} ↓ {item.DownloadBytes}") .ToArray(); }