Projekt_SS25/Project_Periodensystem.View/MainWindow.axaml.cs

53 lines
1.4 KiB
C#

using Avalonia;
using Avalonia.Controls;
using Avalonia.Media;
using Project_Periodensystem.Model;
using System;
using System.Collections.Generic;
namespace Project_Periodensystem.View
{
public partial class MainWindow : Window
{
private ContentControl? mainContent;
public static AppTheme CurrentTheme { get; set; } = AppTheme.Dark;
public static Dictionary<AppTheme, string> ThemeColors { get; } = new()
{
{ AppTheme.Dark, "#5C5144" },
{ AppTheme.Light, "#E8DFD8" },
{ AppTheme.Classic, "#7B8B6F" }
};
public MainWindow()
{
InitializeComponent();
mainContent = this.FindControl<ContentControl>("MainContent");
ShowLandingPage();
}
public void ShowLandingPage()
{
mainContent!.Content = new LandingPage();
}
public void ShowPeriodicTable()
{
mainContent!.Content = new PeriodicTablePage();
}
public void ShowAboutPage()
{
mainContent!.Content = new AboutPage();
}
public void UpdateTheme(AppTheme theme)
{
CurrentTheme = theme;
if (mainContent?.Content is UserControl control)
{
control.Background = new SolidColorBrush(Color.Parse(ThemeColors[theme]));
}
}
}
}