Files
APIToolkit/MainWindow.xaml.cs
2025-02-03 16:08:49 -08:00

55 lines
1.8 KiB
C#

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;
using Windows.Foundation;
using Windows.Foundation.Collections;
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
namespace APIToolkit
{
public sealed partial class MainWindow : Window
{
public MainWindow()
{
this.InitializeComponent();
this.ExtendsContentIntoTitleBar = true; // Set the apps titlebar to be defined in MainWindow.xaml
this.SetTitleBar(AppTitleBar);
ContentArea.Navigate(typeof(URLShortener)); // Set default page
}
private void NavigationView_ItemInvoked(NavigationView sender, NavigationViewItemInvokedEventArgs args)
{
if (args.IsSettingsInvoked)
{
ContentArea.Navigate(typeof(Settings));
}
else
{
// If the page set in MainWindow.xaml does not exist (is null), then show an error message
if (Type.GetType($"APIToolkit.{args.InvokedItemContainer.Tag}") == null)
{
UIFunctions.ShowError(MainWindow_MainGrid.XamlRoot, "Requested page is not implemented (Destination returned null)");
}
else // Otherwise, navigate to page based on tag set in MainWindow.xaml
{
ContentArea.Navigate(Type.GetType($"APIToolkit.{args.InvokedItemContainer.Tag}"));
}
}
}
}
}