nitai/projects
rblxtool / src / ui / RblxTool / MainWindow.xaml.cs
49 lines · 1.4 KB Raw
1using Microsoft.UI.Xaml;
2using Microsoft.UI.Xaml.Controls;
3using Microsoft.UI.Xaml.Media.Animation;
4using RblxTool.Services;
5using RblxTool.Views;
6
7namespace RblxTool;
8
9public 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}