using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using RblxTool.Interop; using RblxTool.Services; namespace RblxTool.Views; public sealed partial class DashboardPage : Page { private DispatcherTimer? _timer; public DashboardPage() { InitializeComponent(); Loaded += OnLoaded; Unloaded += (_, _) => _timer?.Stop(); } private void OnLoaded(object sender, RoutedEventArgs e) { VersionText.Text = $"rblxtool core {RblxEngine.Version()}"; _timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1) }; _timer.Tick += (_, _) => RefreshMetrics(); _timer.Start(); RefreshMetrics(); _ = RefreshOverviewAsync(); } private void RefreshMetrics() { var metrics = AppState.Current.Engine.Metrics(); RequestsText.Text = metrics.Requests.ToString("N0"); LatencyText.Text = $"{metrics.AverageLatencyMs:F0} ms"; RetriesText.Text = metrics.Retries.ToString("N0"); ThrottledText.Text = metrics.RateLimited.ToString("N0"); BytesText.Text = FormatBytes(metrics.BytesIn); } private async Task RefreshOverviewAsync() { if (AppState.Current.Active is null) { return; } var overview = await Task.Run(() => AppState.Current.Engine.Overview()); if (overview is null) { return; } RobuxText.Text = overview.Robux.ToString("N0"); CollectiblesText.Text = overview.Collectibles.ToString("N0"); RapText.Text = overview.TotalRap.ToString("N0"); FriendsText.Text = overview.Friends.ToString("N0"); FollowersText.Text = overview.Followers.ToString("N0"); } private static string FormatBytes(ulong value) { double size = value; string[] units = { "B", "KB", "MB", "GB" }; var index = 0; while (size >= 1024 && index < units.Length - 1) { size /= 1024; index++; } return $"{size:F1} {units[index]}"; } }