using Avalonia.Controls; using Avalonia.Markup.Xaml; using System; namespace Project_Periodensystem.View { public partial class MainWindow : Window { private readonly ContentControl? mainContent; public MainWindow() { InitializeComponent(); try { Console.WriteLine("MainWindow wird initialisiert..."); var content = this.Find("MainContent"); if (content == null) { Console.WriteLine("FEHLER: MainContent nicht gefunden!"); throw new Exception("MainContent control not found."); } mainContent = content; Console.WriteLine("Navigation zur Landing Page..."); ShowLanding(); } catch (Exception ex) { Console.WriteLine($"FEHLER in MainWindow Constructor: {ex.Message}"); } } public void ShowLanding() { try { Console.WriteLine("ShowLanding wird aufgerufen..."); if (mainContent != null) { mainContent.Content = new LandingPage(); } else { Console.WriteLine("FEHLER: mainContent ist null in ShowLanding!"); } } catch (Exception ex) { Console.WriteLine($"FEHLER in ShowLanding: {ex.Message}"); } } public void ShowPeriodicTable() { try { Logger.Log("ShowPeriodicTable wird aufgerufen..."); if (mainContent != null) { var periodicTablePage = new PeriodicTablePage(); mainContent.Content = periodicTablePage; Logger.Log("PeriodicTablePage wurde geladen"); } else { Logger.Log("FEHLER: mainContent ist null in ShowPeriodicTable!"); } } catch (Exception ex) { Logger.Log($"FEHLER in ShowPeriodicTable: {ex.Message}"); } } public void ShowAbout() { try { Console.WriteLine("ShowAbout wird aufgerufen..."); if (mainContent != null) { mainContent.Content = new AboutPage(); } else { Console.WriteLine("FEHLER: mainContent ist null in ShowAbout!"); } } catch (Exception ex) { Console.WriteLine($"FEHLER in ShowAbout: {ex.Message}"); } } private void InitializeComponent() { AvaloniaXamlLoader.Load(this); } } }