106 lines
3.4 KiB
C#
106 lines
3.4 KiB
C#
using System;
|
|
using Avalonia;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Interactivity;
|
|
using Project_Periodensystem.Model;
|
|
using Project_Periodensystem.Persistence;
|
|
|
|
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 (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 (Exception ex)
|
|
{
|
|
Logger.Log($"Fehler bei Navigation zu About: {ex.Message}");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Event-Handler für Theme-Button (MIT SETTINGS-SPEICHERUNG)
|
|
/// </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}");
|
|
|
|
// NEUE FUNKTION: Theme-Einstellung speichern
|
|
var settings = DataManager.LoadSettings();
|
|
settings.LastTheme = newTheme.ToString();
|
|
settings.LastUsed = DateTime.Now;
|
|
DataManager.SaveSettings(settings);
|
|
Logger.Log("Theme-Einstellung gespeichert");
|
|
}
|
|
else
|
|
{
|
|
Logger.Log("Application.Current ist null!");
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Logger.Log($"EXCEPTION in ThemeButton_Click: {ex.Message}");
|
|
}
|
|
}
|
|
}
|
|
}
|