diff --git a/ChronoFlow.Controller/LoginController.cs b/ChronoFlow.Controller/LoginController.cs
new file mode 100644
index 0000000..e10bdb9
--- /dev/null
+++ b/ChronoFlow.Controller/LoginController.cs
@@ -0,0 +1,29 @@
+// Datei: Controller/LoginController.cs
+using ChronoFlow.Model;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace ChronoFlow.Controller;
+
+///
+/// Verwaltet die Authentifizierung von Benutzern.
+///
+
+public class LoginController
+{
+ //Beispielhafte Benutzerliste (später DB)
+ private List _users = new()
+ {
+ new User { Username = "admin", Password = "admin123", Role = "Admin" },
+ new User { Username = "max", Password = "max123", Role = "Mitarbeiter" }
+ };
+
+ ///
+ /// Prüft, ob ein Benutzer mit den eingegebenen Daten existiert.
+ ///
+
+ public User? Authenticate(string username, string password)
+ {
+ return _users.FirstOrDefault(u => u.Username == username && u.Password == password);
+ }
+}
diff --git a/ChronoFlow.Model/User.cs b/ChronoFlow.Model/User.cs
new file mode 100644
index 0000000..27c19ca
--- /dev/null
+++ b/ChronoFlow.Model/User.cs
@@ -0,0 +1,14 @@
+namespace ChronoFlow.Model
+{
+
+ ///
+ /// Repräsentiert einen Benutzer mit Benutzernamen, Passwort und Rolle.
+ ///
+
+ public class User
+ {
+ public string Username { get; set; }
+ public string Password { get; set; } //vorerst im Klartext, wird später geändert
+ public string Role { get; set; } //"Admin" oder "Mitarbeiter"
+ }
+}
\ No newline at end of file
diff --git a/ChronoFlow.View/App.axaml b/ChronoFlow.View/App.axaml
index c69542f..dafeae2 100644
--- a/ChronoFlow.View/App.axaml
+++ b/ChronoFlow.View/App.axaml
@@ -1,6 +1,6 @@
diff --git a/ChronoFlow.View/App.axaml.cs b/ChronoFlow.View/App.axaml.cs
index 728091e..e27c051 100644
--- a/ChronoFlow.View/App.axaml.cs
+++ b/ChronoFlow.View/App.axaml.cs
@@ -1,8 +1,9 @@
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
+using ChronoFlow.View;
-namespace ChronoFlow.View;
+namespace ChronoFlow;
public partial class App : Application
{
@@ -15,7 +16,8 @@ public partial class App : Application
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
- desktop.MainWindow = new MainWindow();
+ // Starte das Programm mit dem Login-Fenster
+ desktop.MainWindow = new LoginWindow();
}
base.OnFrameworkInitializationCompleted();
diff --git a/ChronoFlow.View/ChronoFlow.View.csproj b/ChronoFlow.View/ChronoFlow.View.csproj
index f058610..1797e5c 100644
--- a/ChronoFlow.View/ChronoFlow.View.csproj
+++ b/ChronoFlow.View/ChronoFlow.View.csproj
@@ -24,4 +24,14 @@
+
+
+
+
+
+
+
+ ZeiterfassungView.axaml
+
+
diff --git a/ChronoFlow.View/LoginWindow.axaml b/ChronoFlow.View/LoginWindow.axaml
new file mode 100644
index 0000000..15c7f6c
--- /dev/null
+++ b/ChronoFlow.View/LoginWindow.axaml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ChronoFlow.View/LoginWindow.axaml.cs b/ChronoFlow.View/LoginWindow.axaml.cs
new file mode 100644
index 0000000..d732ab1
--- /dev/null
+++ b/ChronoFlow.View/LoginWindow.axaml.cs
@@ -0,0 +1,46 @@
+using Avalonia.Controls;
+using Avalonia.Interactivity;
+using ChronoFlow.Controller;
+
+namespace ChronoFlow.View
+{
+ ///
+ /// Das Fenster für den Benutzer-Login.
+ ///
+ public partial class LoginWindow : Window
+ {
+ private LoginController _loginController;
+
+ public LoginWindow()
+ {
+ InitializeComponent(); // Verbindet XAML mit diesem Code
+ _loginController = new LoginController(); // Unsere "Logik-Klasse"
+ }
+
+ ///
+ /// Wird ausgeführt, wenn der Benutzer auf "Anmelden" klickt.
+ ///
+ private void LoginButton_Click(object? sender, RoutedEventArgs e)
+ {
+ // Holt Benutzername und Passwort aus den Eingabefeldern
+ string username = UsernameBox?.Text ?? string.Empty;
+ string password = PasswordBox?.Text ?? string.Empty;
+ // Übergibt die Eingaben an den LoginController
+ var user = _loginController.Authenticate(username, password);
+
+ if (user != null)
+ {
+ // Wenn erfolgreich: öffne das MainWindow
+ var main = new MainWindow(user);
+ main.Show();
+ this.Close(); // Schließe das Login-Fenster
+ }
+ else
+ {
+ // Wenn fehlgeschlagen: Fehlermeldung anzeigen
+ ErrorText.Text = "Login fehlgeschlagen. Bitte prüfen Sie Ihre Eingaben.";
+ ErrorText.IsVisible = true;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/ChronoFlow.View/MainWindow.axaml b/ChronoFlow.View/MainWindow.axaml
index c4795b0..89be531 100644
--- a/ChronoFlow.View/MainWindow.axaml
+++ b/ChronoFlow.View/MainWindow.axaml
@@ -5,5 +5,21 @@
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="ChronoFlow.View.MainWindow"
Title="ChronoFlow.View">
- Welcome to Avalonia!
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ChronoFlow.View/MainWindow.axaml.cs b/ChronoFlow.View/MainWindow.axaml.cs
index 312046d..ebde96a 100644
--- a/ChronoFlow.View/MainWindow.axaml.cs
+++ b/ChronoFlow.View/MainWindow.axaml.cs
@@ -1,11 +1,48 @@
using Avalonia.Controls;
+using Avalonia.Interactivity;
+using ChronoFlow.Model;
namespace ChronoFlow.View;
public partial class MainWindow : Window
{
- public MainWindow()
+ private readonly ViewManager _viewManager;
+ private readonly User _loggedInUser;
+
+ public MainWindow(User user)
{
InitializeComponent();
+
+ _loggedInUser = user;
+
+ // ✅ Workaround: Lokale Kopie für Lambda-Nutzung im Register
+ var currentUser = _loggedInUser;
+
+ _viewManager = new ViewManager(ContentArea);
+
+ // ✅ Register-Aufruf mit stabiler local variable
+ _viewManager.Register("Zeiterfassung", () => new ZeiterfassungView(currentUser));
+
+ // Begrüßungsanzeige
+ ContentArea.Content = new TextBlock
+ {
+ Text = $"Willkommen bei ChronoFlow, {currentUser.Username}!",
+ FontSize = 24,
+ HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Center,
+ VerticalAlignment = Avalonia.Layout.VerticalAlignment.Center
+ };
+
+ // Fenstertitel dynamisch setzen
+ this.Title = $"ChronoFlow - Willkommen {currentUser.Username} ({currentUser.Role})";
+ }
+
+ private void PaneOpenClose_Click(object sender, RoutedEventArgs e)
+ {
+ PaneView.IsPaneOpen = !PaneView.IsPaneOpen;
+ }
+
+ private void Zeiterfassung_Click(object? sender, RoutedEventArgs e)
+ {
+ _viewManager.Show("Zeiterfassung");
}
}
\ No newline at end of file
diff --git a/ChronoFlow.View/ViewManager.cs b/ChronoFlow.View/ViewManager.cs
new file mode 100644
index 0000000..3d06aff
--- /dev/null
+++ b/ChronoFlow.View/ViewManager.cs
@@ -0,0 +1,48 @@
+using System;
+using System.Collections.Generic;
+using Avalonia.Collections;
+using Avalonia.Controls;
+
+namespace ChronoFlow.View
+{
+ ///
+ /// Verwaltet alle Views der Anwendung und wechselt sie bei Bedarf.
+ ///
+
+ public class ViewManager
+ {
+ private readonly ContentControl _targetControl;
+ private readonly Dictionary> _registieredViews = new();
+
+ public ViewManager(ContentControl targetControl)
+ {
+ _targetControl = targetControl;
+ }
+
+ ///
+ /// Registriert eine View mit einem Namen
+ ///
+
+ public void Show(string name, Func viewFactory)
+ {
+ _registieredViews[name] = viewFactory;
+ }
+
+ ///
+ /// Zeigt die View mit dem gegebenen Namen an.
+ ///
+ public void Show(string name)
+ {
+ if(_registieredViews.TryGetValue(name, out var factory))
+ _targetControl.Content = factory();
+ else
+ {
+ throw new InvalidOperationException($"View {name} is not registered");
+ }
+ }
+ public void Register(string name, Func viewFactory)
+ {
+ _registieredViews[name] = viewFactory;
+ }
+ }
+}
\ No newline at end of file