60 lines
1.9 KiB
C#
60 lines
1.9 KiB
C#
using Avalonia;
|
|
using Avalonia.Controls;
|
|
using Project_Periodensystem.Model;
|
|
using Project_Periodensystem.Controller;
|
|
|
|
namespace Project_Periodensystem.View
|
|
{
|
|
/// <summary>
|
|
/// MainWindow mit sauberem MVC-Pattern und Interface-basierter Navigation
|
|
/// </summary>
|
|
public partial class MainWindow : Window
|
|
{
|
|
private ContentControl? mainContent;
|
|
private readonly PeriodensystemController _dataController;
|
|
private readonly NavigationService _navigationService;
|
|
|
|
public MainWindow()
|
|
{
|
|
InitializeComponent();
|
|
mainContent = this.FindControl<ContentControl>("MainContent");
|
|
|
|
// Erstelle Navigation Service
|
|
_navigationService = new NavigationService(this);
|
|
|
|
// Controller mit Navigation Service initialisieren (Dependency Injection)
|
|
_dataController = new PeriodensystemController(_navigationService);
|
|
|
|
// Data Controller an Navigation Service setzen
|
|
_navigationService.SetDataController(_dataController);
|
|
|
|
// Landing Page anzeigen
|
|
ShowLandingPage();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Zeigt die Landing Page an
|
|
/// </summary>
|
|
public void ShowLandingPage()
|
|
{
|
|
if (mainContent != null)
|
|
{
|
|
var landingPage = new LandingPage();
|
|
landingPage.SetController(_dataController);
|
|
|
|
mainContent.Content = landingPage;
|
|
Logger.Log("Landing Page angezeigt (mit Interface-basierter Navigation)");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Cleanup beim Schließen
|
|
/// </summary>
|
|
protected override void OnClosed(System.EventArgs e)
|
|
{
|
|
// NavigationService implementiert kein IDisposable mehr (keine Events)
|
|
base.OnClosed(e);
|
|
}
|
|
}
|
|
}
|