97 lines
3.0 KiB
C#
97 lines
3.0 KiB
C#
using Avalonia;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Interactivity;
|
|
using Project_Periodensystem.Model;
|
|
|
|
namespace Project_Periodensystem.View
|
|
{
|
|
/// <summary>
|
|
/// Code-Behind für die Landing Page
|
|
/// </summary>
|
|
public partial class LandingPage : UserControl
|
|
{
|
|
/// <summary>
|
|
/// Konstruktor
|
|
/// </summary>
|
|
public LandingPage()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Event-Handler für Periodensystem-Button
|
|
/// </summary>
|
|
private void PeriodicTableButton_Click(object? sender, RoutedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
var mainWindow = TopLevel.GetTopLevel(this) as Window;
|
|
if (mainWindow != null)
|
|
{
|
|
var periodicTablePage = new PeriodicTablePage();
|
|
mainWindow.Content = periodicTablePage;
|
|
Logger.Log("Navigation zum Periodensystem");
|
|
}
|
|
}
|
|
catch (System.Exception ex)
|
|
{
|
|
Logger.Log($"Fehler bei Navigation zum Periodensystem: {ex.Message}");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Event-Handler für About-Button
|
|
/// </summary>
|
|
private void AboutButton_Click(object? sender, RoutedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
var mainWindow = TopLevel.GetTopLevel(this) as Window;
|
|
if (mainWindow != null)
|
|
{
|
|
var aboutPage = new AboutPage();
|
|
mainWindow.Content = aboutPage;
|
|
Logger.Log("Navigation zur About-Seite");
|
|
}
|
|
}
|
|
catch (System.Exception ex)
|
|
{
|
|
Logger.Log($"Fehler bei Navigation zu About: {ex.Message}");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Event-Handler für Theme-Button
|
|
/// </summary>
|
|
private void ThemeButton_Click(object? sender, RoutedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
Logger.Log("Theme-Button geklickt");
|
|
|
|
var app = Application.Current;
|
|
if (app != null)
|
|
{
|
|
var currentTheme = app.ActualThemeVariant;
|
|
Logger.Log($"Aktuelles Theme: {currentTheme}");
|
|
|
|
var newTheme = currentTheme == Avalonia.Styling.ThemeVariant.Dark
|
|
? Avalonia.Styling.ThemeVariant.Light
|
|
: Avalonia.Styling.ThemeVariant.Dark;
|
|
|
|
app.RequestedThemeVariant = newTheme;
|
|
Logger.Log($"Theme gewechselt zu: {newTheme}");
|
|
}
|
|
else
|
|
{
|
|
Logger.Log("Application.Current ist null!");
|
|
}
|
|
}
|
|
catch (System.Exception ex)
|
|
{
|
|
Logger.Log($"Fehler beim Theme-Wechsel: {ex.Message}");
|
|
}
|
|
}
|
|
}
|
|
}
|