Projekt_SS25/Project_Periodensystem.View/AboutPage.axaml.cs

53 lines
1.4 KiB
C#

using System;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using Avalonia.VisualTree;
using Project_Periodensystem.Model;
namespace Project_Periodensystem.View
{
public partial class AboutPage : UserControl
{
public AboutPage()
{
InitializeComponent();
}
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
{
base.OnAttachedToVisualTree(e);
if (this.GetVisualRoot() is MainWindow mainWindow)
{
mainWindow.UpdateTheme(MainWindow.CurrentTheme);
}
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
private void BackButton_Click(object? sender, RoutedEventArgs e)
{
if (MainWindow.Instance != null)
{
MainWindow.Instance.ShowLandingPage();
}
}
private void ThemeButton_Click(object? sender, RoutedEventArgs e)
{
var themes = Enum.GetValues<AppTheme>();
MainWindow.CurrentTheme = themes[(Array.IndexOf(themes, MainWindow.CurrentTheme) + 1) % themes.Length];
if (MainWindow.Instance != null)
{
MainWindow.Instance.UpdateTheme(MainWindow.CurrentTheme);
}
}
}
}