| 1 | using Microsoft.UI.Xaml; |
| 2 | using Microsoft.UI.Xaml.Controls; |
| 3 | using Microsoft.UI.Xaml.Media.Animation; |
| 4 | using RblxTool.Services; |
| 5 | using RblxTool.Views; |
| 6 | |
| 7 | namespace RblxTool; |
| 8 | |
| 9 | public sealed partial class MainWindow : Window |
| 10 | { |
| 11 | public MainWindow() |
| 12 | { |
| 13 | InitializeComponent(); |
| 14 | ExtendsContentIntoTitleBar = true; |
| 15 | SetTitleBar(TitleBarArea); |
| 16 | Title = "rblxtool"; |
| 17 | AppState.Current.AccountsChanged += RefreshActiveAccount; |
| 18 | RefreshActiveAccount(); |
| 19 | Nav.SelectedItem = Nav.MenuItems[0]; |
| 20 | } |
| 21 | |
| 22 | private void RefreshActiveAccount() |
| 23 | { |
| 24 | var active = AppState.Current.Active; |
| 25 | ActiveAccountText.Text = active is null |
| 26 | ? "no account selected" |
| 27 | : $"{active.Username} ({active.UserId})"; |
| 28 | } |
| 29 | |
| 30 | private void OnNavSelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args) |
| 31 | { |
| 32 | if (args.SelectedItem is not NavigationViewItem item || item.Tag is not string tag) |
| 33 | { |
| 34 | return; |
| 35 | } |
| 36 | var target = tag switch |
| 37 | { |
| 38 | "accounts" => typeof(AccountsPage), |
| 39 | "sweep" => typeof(SweepPage), |
| 40 | "sniper" => typeof(SniperPage), |
| 41 | "groups" => typeof(GroupsPage), |
| 42 | _ => typeof(DashboardPage), |
| 43 | }; |
| 44 | if (ContentFrame.CurrentSourcePageType != target) |
| 45 | { |
| 46 | ContentFrame.Navigate(target, null, new EntranceNavigationTransitionInfo()); |
| 47 | } |
| 48 | } |
| 49 | } |