Kommentare
This commit is contained in:
parent
16fcf6ce53
commit
73bd118e8b
@ -3,15 +3,19 @@ using AquaCare.Persistence;
|
|||||||
|
|
||||||
namespace AquaCare.Controller
|
namespace AquaCare.Controller
|
||||||
{
|
{
|
||||||
|
// Controller-Klasse für die Verwaltung und Speicherung von Pflegemaßnahmen und Messwerten
|
||||||
public class PflegeController
|
public class PflegeController
|
||||||
{
|
{
|
||||||
|
// Referenz auf die Datenbank
|
||||||
private readonly Datenbank _db;
|
private readonly Datenbank _db;
|
||||||
|
|
||||||
|
// Konstruktor: Übergibt die Datenbankinstanz
|
||||||
public PflegeController(Datenbank db)
|
public PflegeController(Datenbank db)
|
||||||
{
|
{
|
||||||
_db = db;
|
_db = db;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Speichert einen neuen Pflege- bzw. Werte-Eintrag in der Datenbank
|
||||||
public bool SavePflegeTask(DateTime datum, bool gefuettert, bool filterReinigen,
|
public bool SavePflegeTask(DateTime datum, bool gefuettert, bool filterReinigen,
|
||||||
bool wasserWechseln, double temperatur, double phWert, double nitrat, double ammoniak)
|
bool wasserWechseln, double temperatur, double phWert, double nitrat, double ammoniak)
|
||||||
{
|
{
|
||||||
@ -29,15 +33,16 @@ namespace AquaCare.Controller
|
|||||||
Ammoniak = ammoniak
|
Ammoniak = ammoniak
|
||||||
};
|
};
|
||||||
|
|
||||||
_db.AddValue(wert);
|
_db.AddValue(wert); // Eintrag in die Datenbank speichern
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
return false;
|
return false; // Fehler beim Speichern
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Gibt alle gespeicherten Werte als Liste zurück
|
||||||
public List<Werte> GetAllWerte()
|
public List<Werte> GetAllWerte()
|
||||||
{
|
{
|
||||||
return _db.GetValuesAsObjects();
|
return _db.GetValuesAsObjects();
|
||||||
|
|||||||
@ -3,15 +3,19 @@ using AquaCare.Persistence;
|
|||||||
|
|
||||||
namespace AquaCare.Controller
|
namespace AquaCare.Controller
|
||||||
{
|
{
|
||||||
|
// Controller-Klasse für das Laden der gespeicherten Werte aus der Datenbank
|
||||||
public class WerteController
|
public class WerteController
|
||||||
{
|
{
|
||||||
|
// Referenz auf die Datenbank
|
||||||
private readonly Datenbank _db;
|
private readonly Datenbank _db;
|
||||||
|
|
||||||
|
// Konstruktor: Übergibt die Datenbankinstanz
|
||||||
public WerteController(Datenbank db)
|
public WerteController(Datenbank db)
|
||||||
{
|
{
|
||||||
_db = db;
|
_db = db;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Lädt alle gespeicherten Werte als Liste
|
||||||
public List<Werte> LoadWerte()
|
public List<Werte> LoadWerte()
|
||||||
{
|
{
|
||||||
return _db.GetValuesAsObjects();
|
return _db.GetValuesAsObjects();
|
||||||
|
|||||||
@ -1,14 +1,23 @@
|
|||||||
namespace AquaCare.Model
|
namespace AquaCare.Model
|
||||||
{
|
{
|
||||||
|
// Modellklasse für einen Messwert- bzw. Pflegeeintrag
|
||||||
public class Werte
|
public class Werte
|
||||||
{
|
{
|
||||||
|
// Datum und Uhrzeit des Eintrags
|
||||||
public DateTime Datum { get; set; }
|
public DateTime Datum { get; set; }
|
||||||
|
// Wurde gefüttert?
|
||||||
public bool Gefuettert { get; set; }
|
public bool Gefuettert { get; set; }
|
||||||
|
// Wurde der Filter gereinigt?
|
||||||
public bool FilterReinigen { get; set; }
|
public bool FilterReinigen { get; set; }
|
||||||
|
// Wurde Wasser gewechselt?
|
||||||
public bool WasserWechseln { get; set; }
|
public bool WasserWechseln { get; set; }
|
||||||
|
// Temperatur in °C
|
||||||
public double Temperatur { get; set; }
|
public double Temperatur { get; set; }
|
||||||
|
// pH-Wert
|
||||||
public double PhWert { get; set; }
|
public double PhWert { get; set; }
|
||||||
|
// Nitratwert in mg/l
|
||||||
public double Nitrat { get; set; }
|
public double Nitrat { get; set; }
|
||||||
|
// Ammoniakwert in mg/l
|
||||||
public double Ammoniak { get; set; }
|
public double Ammoniak { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,14 +1,20 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<!--
|
||||||
|
Projektdatei für das AquaCare.Persistence-Projekt.
|
||||||
|
Enthält Einstellungen für das Ziel-Framework, Nullable, Projektabhängigkeiten und NuGet-Pakete.
|
||||||
|
-->
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net9.0</TargetFramework>
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!-- Verweis auf das Model-Projekt -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\AquaCare.Model\AquaCare.Model.csproj" />
|
<ProjectReference Include="..\AquaCare.Model\AquaCare.Model.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!-- NuGet-Paket für SQLite-Datenbankzugriff -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Data.Sqlite" Version="8.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@ -6,24 +6,30 @@ using AquaCare.Model;
|
|||||||
|
|
||||||
namespace AquaCare.Persistence
|
namespace AquaCare.Persistence
|
||||||
{
|
{
|
||||||
|
// Klasse für den Datenbankzugriff (SQLite)
|
||||||
public class Datenbank
|
public class Datenbank
|
||||||
{
|
{
|
||||||
|
// Pfad zum Ordner, in dem die Datenbank liegt
|
||||||
private static readonly string PersistencePath = Path.GetDirectoryName(
|
private static readonly string PersistencePath = Path.GetDirectoryName(
|
||||||
typeof(Datenbank).Assembly.Location) ?? throw new InvalidOperationException("Assembly location not found");
|
typeof(Datenbank).Assembly.Location) ?? throw new InvalidOperationException("Assembly location not found");
|
||||||
|
|
||||||
|
// Pfad zur SQLite-Datenbankdatei
|
||||||
private static readonly string DbPath = Path.Combine(
|
private static readonly string DbPath = Path.Combine(
|
||||||
PersistencePath,
|
PersistencePath,
|
||||||
"..", "..", "..", "..",
|
"..", "..", "..", "..",
|
||||||
"AquaCare.Persistence",
|
"AquaCare.Persistence",
|
||||||
"AquaCareDatenbank.db");
|
"AquaCareDatenbank.db");
|
||||||
|
|
||||||
|
// Verbindungszeichenfolge für SQLite
|
||||||
private string ConnectionString => $"Data Source={DbPath}";
|
private string ConnectionString => $"Data Source={DbPath}";
|
||||||
|
|
||||||
|
// Konstruktor: Prüft, ob die Datenbank existiert, und legt sie ggf. an
|
||||||
public Datenbank()
|
public Datenbank()
|
||||||
{
|
{
|
||||||
EnsureDatabaseExists();
|
EnsureDatabaseExists();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Stellt sicher, dass die Datenbank und der Ordner existieren
|
||||||
private void EnsureDatabaseExists()
|
private void EnsureDatabaseExists()
|
||||||
{
|
{
|
||||||
var directory = Path.GetDirectoryName(DbPath);
|
var directory = Path.GetDirectoryName(DbPath);
|
||||||
@ -38,6 +44,7 @@ namespace AquaCare.Persistence
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Legt eine neue Datenbank mit der Tabelle "Werte" an
|
||||||
private void InitializeNewDatabase()
|
private void InitializeNewDatabase()
|
||||||
{
|
{
|
||||||
using var connection = new SqliteConnection(ConnectionString);
|
using var connection = new SqliteConnection(ConnectionString);
|
||||||
@ -58,6 +65,7 @@ namespace AquaCare.Persistence
|
|||||||
command.ExecuteNonQuery();
|
command.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fügt einen neuen Werte-Datensatz in die Datenbank ein
|
||||||
public void AddValue(Werte wert)
|
public void AddValue(Werte wert)
|
||||||
{
|
{
|
||||||
using var connection = new SqliteConnection(ConnectionString);
|
using var connection = new SqliteConnection(ConnectionString);
|
||||||
@ -85,6 +93,7 @@ namespace AquaCare.Persistence
|
|||||||
command.ExecuteNonQuery();
|
command.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Gibt alle Werte als Liste von Objekten zurück
|
||||||
public List<Werte> GetValuesAsObjects()
|
public List<Werte> GetValuesAsObjects()
|
||||||
{
|
{
|
||||||
var werte = new List<Werte>();
|
var werte = new List<Werte>();
|
||||||
|
|||||||
@ -4,15 +4,19 @@ using Avalonia.Markup.Xaml;
|
|||||||
|
|
||||||
namespace AquaCare.View;
|
namespace AquaCare.View;
|
||||||
|
|
||||||
|
// Einstiegspunkt für die Avalonia-Anwendung
|
||||||
public partial class App : Application
|
public partial class App : Application
|
||||||
{
|
{
|
||||||
|
// Initialisiert die Anwendung und lädt die XAML-Ressourcen
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
AvaloniaXamlLoader.Load(this);
|
AvaloniaXamlLoader.Load(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Wird nach Abschluss der Framework-Initialisierung aufgerufen
|
||||||
public override void OnFrameworkInitializationCompleted()
|
public override void OnFrameworkInitializationCompleted()
|
||||||
{
|
{
|
||||||
|
// Setzt das Hauptfenster, wenn die Anwendung als klassische Desktop-App läuft
|
||||||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||||
{
|
{
|
||||||
desktop.MainWindow = new MainWindow();
|
desktop.MainWindow = new MainWindow();
|
||||||
|
|||||||
@ -8,37 +8,34 @@
|
|||||||
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
|
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!-- NuGet-Pakete für Avalonia, Datenbank und MessageBox -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Avalonia" Version="11.3.0" />
|
<PackageReference Include="Avalonia" Version="11.3.0" />
|
||||||
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.3.0" />
|
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.3.0" />
|
||||||
<PackageReference Include="Avalonia.Desktop" Version="11.3.0" />
|
<PackageReference Include="Avalonia.Desktop" Version="11.3.0" />
|
||||||
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.3.0" />
|
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.3.0" />
|
||||||
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.3.0" />
|
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.3.0" />
|
||||||
<PackageReference Include="Avalonia.Diagnostics" Version="11.3.0">
|
<PackageReference Include="Avalonia.Diagnostics" Version="11.3.0">
|
||||||
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
|
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
|
||||||
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
|
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="MessageBox.Avalonia" Version="3.2.0" />
|
<PackageReference Include="MessageBox.Avalonia" Version="3.2.0" />
|
||||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="9.0.5" />
|
<PackageReference Include="Microsoft.Data.Sqlite" Version="9.0.5" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!-- Verweise auf andere Projekte der Lösung -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\AquaCare.Controller\AquaCare.Controller.csproj" />
|
<ProjectReference Include="..\AquaCare.Controller\AquaCare.Controller.csproj" />
|
||||||
<ProjectReference Include="..\AquaCare.Model\AquaCare.Model.csproj" />
|
<ProjectReference Include="..\AquaCare.Model\AquaCare.Model.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!-- Einbindung von Ressourcen (Bilder, Icons, etc.) -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<AvaloniaResource Include="Ressourcen\**" />
|
<AvaloniaResource Include="Ressourcen\**" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!-- Einbindung der zentralen Style-Datei -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<AvaloniaResource Include="Style.xaml" />
|
<AvaloniaResource Include="Style.xaml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@ -2,11 +2,13 @@ using Avalonia.Controls;
|
|||||||
|
|
||||||
namespace AquaCare.View
|
namespace AquaCare.View
|
||||||
{
|
{
|
||||||
|
// Fenster für die Einstellungen der Anwendung
|
||||||
public partial class EinstellungenWindow : Window
|
public partial class EinstellungenWindow : Window
|
||||||
{
|
{
|
||||||
|
// Konstruktor: Initialisiert das Einstellungsfenster
|
||||||
public EinstellungenWindow()
|
public EinstellungenWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent(); // Initialisiert die UI-Komponenten
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,7 @@
|
|||||||
|
<!--
|
||||||
|
Hauptfenster der Anwendung.
|
||||||
|
Zeigt einen Willkommensbildschirm mit Hintergrundbild, Einstellungen-Button und zentralen Navigationsbuttons.
|
||||||
|
-->
|
||||||
<Window xmlns="https://github.com/avaloniaui"
|
<Window xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
x:Class="AquaCare.View.MainWindow"
|
x:Class="AquaCare.View.MainWindow"
|
||||||
@ -6,12 +10,12 @@
|
|||||||
Icon="Ressourcen/Bilder/ProgrammIcon.ico">
|
Icon="Ressourcen/Bilder/ProgrammIcon.ico">
|
||||||
|
|
||||||
<Grid>
|
<Grid>
|
||||||
|
<!-- Hintergrundbild für das Hauptfenster -->
|
||||||
<Grid.Background>
|
<Grid.Background>
|
||||||
<ImageBrush Source="avares://AquaCare.View/Ressourcen/Bilder/WillkommenHintergrund.png" Stretch="UniformToFill"/>
|
<ImageBrush Source="avares://AquaCare.View/Ressourcen/Bilder/WillkommenHintergrund.png" Stretch="UniformToFill"/>
|
||||||
</Grid.Background>
|
</Grid.Background>
|
||||||
|
|
||||||
<!-- Grid-Aufteilung -->
|
<!-- Grid-Aufteilung für Layout -->
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
<RowDefinition Height="*"/>
|
<RowDefinition Height="*"/>
|
||||||
@ -21,35 +25,34 @@
|
|||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
<!-- Button oben links (Einstellungen)-->
|
<!-- Button oben links (Einstellungen) -->
|
||||||
<Button Classes="ImageButton" Click="buttonEinstellungenClick" Width="100" Height="100">
|
<Button Classes="ImageButton" Click="buttonEinstellungenClick" Width="100" Height="100">
|
||||||
<Image Source="avares://AquaCare.View/Ressourcen/Bilder/EinstellungenImage.png"
|
<Image Source="avares://AquaCare.View/Ressourcen/Bilder/EinstellungenImage.png"
|
||||||
HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="Fill"/>
|
HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="Fill"/>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<!-- Zentrierter Inhalt -->
|
<!-- Zentrierter Inhalt: Überschrift und Navigationsbuttons -->
|
||||||
<StackPanel Grid.Row="1" Grid.ColumnSpan="2"
|
<StackPanel Grid.Row="1" Grid.ColumnSpan="2"
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Spacing="30">
|
Spacing="30">
|
||||||
|
|
||||||
|
<!-- Überschrift -->
|
||||||
<TextBlock Text="Willkommen bei AquaCare" HorizontalAlignment="Center" Classes="ÜberschriftText"/>
|
<TextBlock Text="Willkommen bei AquaCare" HorizontalAlignment="Center" Classes="ÜberschriftText"/>
|
||||||
|
|
||||||
|
<!-- Button für Pflegemaßnahmen -->
|
||||||
<Button Classes="ImageButton" Click="buttonPflegeClick" Width="300" Height="100" HorizontalAlignment="Center">
|
<Button Classes="ImageButton" Click="buttonPflegeClick" Width="300" Height="100" HorizontalAlignment="Center">
|
||||||
<Image Source="avares://AquaCare.View/Ressourcen/Bilder/pflegebutton.png"
|
<Image Source="avares://AquaCare.View/Ressourcen/Bilder/pflegebutton.png"
|
||||||
HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="Fill"/>
|
HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="Fill"/>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
|
<!-- Button für Werteübersicht -->
|
||||||
|
|
||||||
|
|
||||||
<Button Classes="ImageButton" Click="buttonWerteClick" Width="300" Height="100" HorizontalAlignment="Center">
|
<Button Classes="ImageButton" Click="buttonWerteClick" Width="300" Height="100" HorizontalAlignment="Center">
|
||||||
<Image Source="avares://AquaCare.View/Ressourcen/Bilder/wertebutton.png"
|
<Image Source="avares://AquaCare.View/Ressourcen/Bilder/wertebutton.png"
|
||||||
HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="Fill"/>
|
HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="Fill"/>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
|
<!-- Button für Tutorials -->
|
||||||
<Button Classes="ImageButton" Click="buttonTutorialsClick" Width="300" Height="100" HorizontalAlignment="Center">
|
<Button Classes="ImageButton" Click="buttonTutorialsClick" Width="300" Height="100" HorizontalAlignment="Center">
|
||||||
<Image Source="avares://AquaCare.View/Ressourcen/Bilder/tutorialsbutton.png"
|
<Image Source="avares://AquaCare.View/Ressourcen/Bilder/tutorialsbutton.png"
|
||||||
HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="Fill"/>
|
HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="Fill"/>
|
||||||
|
|||||||
@ -5,37 +5,41 @@ using AquaCare.View;
|
|||||||
|
|
||||||
namespace AquaCare.View
|
namespace AquaCare.View
|
||||||
{
|
{
|
||||||
|
// Hauptfenster der Anwendung – Einstiegspunkt für den Nutzer
|
||||||
public partial class MainWindow : Window
|
public partial class MainWindow : Window
|
||||||
{
|
{
|
||||||
|
// Konstruktor: Initialisiert das Hauptfenster
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Öffnet das Fenster für Pflegemaßnahmen
|
||||||
private void buttonPflegeClick(object? sender, RoutedEventArgs e)
|
private void buttonPflegeClick(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var pflegeWindow = new PflegeWindow();
|
var pflegeWindow = new PflegeWindow();
|
||||||
pflegeWindow.ShowDialog(this);
|
pflegeWindow.ShowDialog(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Öffnet das Fenster zur Anzeige der Messwerte
|
||||||
private void buttonWerteClick(object? sender, RoutedEventArgs e)
|
private void buttonWerteClick(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var werteWindow = new WerteWindow(); // Neues Werte-Fenster instanziieren
|
var werteWindow = new WerteWindow(); // Neues Werte-Fenster instanziieren
|
||||||
werteWindow.ShowDialog(this); // Fenster als Dialog öffnen
|
werteWindow.ShowDialog(this); // Fenster als Dialog öffnen
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Öffnet das Fenster für Tutorials
|
||||||
private void buttonTutorialsClick(object? sender, RoutedEventArgs e)
|
private void buttonTutorialsClick(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var tutorialsWindow = new TutorialsWindow();
|
var tutorialsWindow = new TutorialsWindow();
|
||||||
tutorialsWindow.ShowDialog(this); // Dialog für Tutorial-Fenster
|
tutorialsWindow.ShowDialog(this); // Dialog für Tutorial-Fenster
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Öffnet ein einfaches Einstellungsfenster (Platzhalter)
|
||||||
private void buttonEinstellungenClick(object? sender, RoutedEventArgs e)
|
private void buttonEinstellungenClick(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var dialog = new Window { Title = "Einstellungen" };
|
var dialog = new Window { Title = "Einstellungen" };
|
||||||
dialog.ShowDialog(this);
|
dialog.ShowDialog(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,3 +1,7 @@
|
|||||||
|
<!--
|
||||||
|
Fenster zur Eingabe und Speicherung von Pflegemaßnahmen und Messwerten.
|
||||||
|
Enthält Felder für Datum, Checkboxen für Aktionen, Eingabefelder für Werte und einen Speichern-Button.
|
||||||
|
-->
|
||||||
<Window xmlns="https://github.com/avaloniaui"
|
<Window xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/express/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/express/blend/2008"
|
||||||
@ -7,54 +11,55 @@
|
|||||||
Width="600" Height="500"
|
Width="600" Height="500"
|
||||||
Icon="Ressourcen/Bilder/ProgrammIcon.ico">
|
Icon="Ressourcen/Bilder/ProgrammIcon.ico">
|
||||||
<Grid>
|
<Grid>
|
||||||
<!-- Hintergrundbild ins äußere Grid verschieben -->
|
<!-- Hintergrundbild für das Fenster -->
|
||||||
<Grid.Background>
|
<Grid.Background>
|
||||||
<ImageBrush Source="avares://AquaCare.View/Ressourcen/Bilder/PflegeHintergrund.png"
|
<ImageBrush Source="avares://AquaCare.View/Ressourcen/Bilder/PflegeHintergrund.png"
|
||||||
Stretch="Fill"/>
|
Stretch="Fill"/>
|
||||||
</Grid.Background>
|
</Grid.Background>
|
||||||
|
|
||||||
|
<!-- Haupt-Grid für die Eingabefelder und Buttons -->
|
||||||
<Grid RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto"
|
<Grid RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto"
|
||||||
ColumnDefinitions="Auto,*"
|
ColumnDefinitions="Auto,*"
|
||||||
Margin="20"
|
Margin="20"
|
||||||
RowSpacing="10"
|
RowSpacing="10"
|
||||||
ColumnSpacing="20">
|
ColumnSpacing="20">
|
||||||
|
|
||||||
<!-- Datum -->
|
<!-- Datumsauswahl -->
|
||||||
<TextBlock Text="Datum:" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center"/>
|
<TextBlock Text="Datum:" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center"/>
|
||||||
<DatePicker x:Name="DatumPicker" Width="300" Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
<DatePicker x:Name="DatumPicker" Width="300" Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||||
|
|
||||||
<!-- Gefüttert -->
|
<!-- Checkbox: Gefüttert -->
|
||||||
<TextBlock Text="Gefüttert:" Grid.Row="1" Grid.Column="0" VerticalAlignment="Center"/>
|
<TextBlock Text="Gefüttert:" Grid.Row="1" Grid.Column="0" VerticalAlignment="Center"/>
|
||||||
<CheckBox x:Name="GefuettertCheckBox" Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
<CheckBox x:Name="GefuettertCheckBox" Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||||
|
|
||||||
<!-- Filter reinigen -->
|
<!-- Checkbox: Filter gereinigt -->
|
||||||
<TextBlock Text="Filter gereinigt:" Grid.Row="2" Grid.Column="0" VerticalAlignment="Center"/>
|
<TextBlock Text="Filter gereinigt:" Grid.Row="2" Grid.Column="0" VerticalAlignment="Center"/>
|
||||||
<CheckBox x:Name="FilterReinigenCheckBox" Grid.Row="2" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
<CheckBox x:Name="FilterReinigenCheckBox" Grid.Row="2" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||||
|
|
||||||
<!-- Wasser wechseln -->
|
<!-- Checkbox: Wasser gewechselt -->
|
||||||
<TextBlock Text="Wasser gewechselt:" Grid.Row="3" Grid.Column="0" VerticalAlignment="Center"/>
|
<TextBlock Text="Wasser gewechselt:" Grid.Row="3" Grid.Column="0" VerticalAlignment="Center"/>
|
||||||
<CheckBox x:Name="WasserWechselnCheckBox" Grid.Row="3" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
<CheckBox x:Name="WasserWechselnCheckBox" Grid.Row="3" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||||
|
|
||||||
<!-- Temperatur -->
|
<!-- Eingabefeld: Temperatur -->
|
||||||
<TextBlock Text="Temperatur (°C):" Grid.Row="4" Grid.Column="0" VerticalAlignment="Center"/>
|
<TextBlock Text="Temperatur (°C):" Grid.Row="4" Grid.Column="0" VerticalAlignment="Center"/>
|
||||||
<TextBox x:Name="TemperaturBox" Height="30" Grid.Row="4" Grid.Column="1" Width="100"/>
|
<TextBox x:Name="TemperaturBox" Height="30" Grid.Row="4" Grid.Column="1" Width="100"/>
|
||||||
|
|
||||||
<!-- pH-Wert -->
|
<!-- Eingabefeld: pH-Wert -->
|
||||||
<TextBlock Text="pH-Wert:" Grid.Row="5" Grid.Column="0" VerticalAlignment="Center"/>
|
<TextBlock Text="pH-Wert:" Grid.Row="5" Grid.Column="0" VerticalAlignment="Center"/>
|
||||||
<TextBox x:Name="PhBox" Grid.Row="5" Grid.Column="1" Width="100"/>
|
<TextBox x:Name="PhBox" Grid.Row="5" Grid.Column="1" Width="100"/>
|
||||||
|
|
||||||
<!-- Nitrat -->
|
<!-- Eingabefeld: Nitrat -->
|
||||||
<TextBlock Text="Nitrat (mg/l):" Grid.Row="6" Grid.Column="0" VerticalAlignment="Center"/>
|
<TextBlock Text="Nitrat (mg/l):" Grid.Row="6" Grid.Column="0" VerticalAlignment="Center"/>
|
||||||
<TextBox x:Name="NitratBox" Grid.Row="6" Grid.Column="1" Width="100"/>
|
<TextBox x:Name="NitratBox" Grid.Row="6" Grid.Column="1" Width="100"/>
|
||||||
|
|
||||||
<!-- Ammoniak -->
|
<!-- Eingabefeld: Ammoniak -->
|
||||||
<TextBlock Text="Ammoniak (mg/l):" Grid.Row="7" Grid.Column="0" VerticalAlignment="Center"/>
|
<TextBlock Text="Ammoniak (mg/l):" Grid.Row="7" Grid.Column="0" VerticalAlignment="Center"/>
|
||||||
<TextBox x:Name="AmmoniakBox" Grid.Row="7" Grid.Column="1" Width="100"/>
|
<TextBox x:Name="AmmoniakBox" Grid.Row="7" Grid.Column="1" Width="100"/>
|
||||||
|
|
||||||
<!-- Speichern-Button -->
|
<!-- Speichern-Button -->
|
||||||
<Button Content="Speichern" Grid.Row="8" Grid.Column="1" Margin="0,20,0,0" HorizontalAlignment="Right" Click="SaveClick"/>
|
<Button Content="Speichern" Grid.Row="8" Grid.Column="1" Margin="0,20,0,0" HorizontalAlignment="Right" Click="SaveClick"/>
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<!-- Mindestbreite für die zweite Spalte -->
|
<!-- Mindestbreite für die zweite Spalte -->
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="Auto"/>
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
|||||||
@ -8,25 +8,31 @@ using System;
|
|||||||
|
|
||||||
namespace AquaCare.View
|
namespace AquaCare.View
|
||||||
{
|
{
|
||||||
|
// Fenster zur Eingabe und Speicherung von Pflegemaßnahmen und Messwerten
|
||||||
public partial class PflegeWindow : Window
|
public partial class PflegeWindow : Window
|
||||||
{
|
{
|
||||||
|
// Controller für die Logik und Datenzugriffe
|
||||||
private readonly PflegeController _controller;
|
private readonly PflegeController _controller;
|
||||||
|
|
||||||
|
// Konstruktor: Initialisiert das Fenster und den Controller
|
||||||
public PflegeWindow()
|
public PflegeWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent(); // Initialisiert die UI-Komponenten
|
||||||
_controller = new PflegeController(new Datenbank());
|
_controller = new PflegeController(new Datenbank()); // Erstellt Controller mit Datenbank
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Initialisiert die XAML-Komponenten
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
AvaloniaXamlLoader.Load(this);
|
AvaloniaXamlLoader.Load(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Event-Handler für den Speichern-Button
|
||||||
private void SaveClick(object? sender, RoutedEventArgs e)
|
private void SaveClick(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
// Prüft, ob alle Felder korrekt ausgefüllt sind und Werte gültig sind
|
||||||
if (DatumPicker.SelectedDate.HasValue &&
|
if (DatumPicker.SelectedDate.HasValue &&
|
||||||
double.TryParse(TemperaturBox.Text, out double temperatur) &&
|
double.TryParse(TemperaturBox.Text, out double temperatur) &&
|
||||||
double.TryParse(PhBox.Text, out double phWert) &&
|
double.TryParse(PhBox.Text, out double phWert) &&
|
||||||
@ -39,6 +45,7 @@ namespace AquaCare.View
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Speichert die Werte über den Controller
|
||||||
var success = _controller.SavePflegeTask(
|
var success = _controller.SavePflegeTask(
|
||||||
DatumPicker.SelectedDate.Value.DateTime,
|
DatumPicker.SelectedDate.Value.DateTime,
|
||||||
GefuettertCheckBox.IsChecked ?? false,
|
GefuettertCheckBox.IsChecked ?? false,
|
||||||
@ -54,7 +61,7 @@ namespace AquaCare.View
|
|||||||
{
|
{
|
||||||
Console.WriteLine("Erfolg: Werte erfolgreich gespeichert.");
|
Console.WriteLine("Erfolg: Werte erfolgreich gespeichert.");
|
||||||
|
|
||||||
// Eingabefelder zurücksetzen
|
// Setzt die Eingabefelder zurück
|
||||||
DatumPicker.SelectedDate = null;
|
DatumPicker.SelectedDate = null;
|
||||||
GefuettertCheckBox.IsChecked = false;
|
GefuettertCheckBox.IsChecked = false;
|
||||||
FilterReinigenCheckBox.IsChecked = false;
|
FilterReinigenCheckBox.IsChecked = false;
|
||||||
@ -80,9 +87,10 @@ namespace AquaCare.View
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Event-Handler für den Abbrechen-Button
|
||||||
private void CancelClick(object? sender, RoutedEventArgs e)
|
private void CancelClick(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
Close();
|
Close(); // Schließt das Fenster
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,6 +1,11 @@
|
|||||||
<Style xmlns="https://github.com/avaloniaui"
|
<Style xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Style.xaml: Zentrale Datei für das Aussehen der Anwendung.
|
||||||
|
Enthält globale Styles für Buttons, TextBlöcke und Fenster.
|
||||||
|
-->
|
||||||
|
|
||||||
<!-- Allgemeiner Button-Style -->
|
<!-- Allgemeiner Button-Style -->
|
||||||
<Style Selector="Button">
|
<Style Selector="Button">
|
||||||
<Setter Property="FontSize" Value="30"/>
|
<Setter Property="FontSize" Value="30"/>
|
||||||
@ -13,7 +18,7 @@
|
|||||||
<Setter Property="CornerRadius" Value="10"/> <!-- Fügt abgerundete Ecken hinzu -->
|
<Setter Property="CornerRadius" Value="10"/> <!-- Fügt abgerundete Ecken hinzu -->
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<!-- Image Button-Style -->
|
<!-- Style für Buttons, die nur ein Bild enthalten -->
|
||||||
<Style Selector="Button.ImageButton">
|
<Style Selector="Button.ImageButton">
|
||||||
<Setter Property="Background" Value="Transparent"/>
|
<Setter Property="Background" Value="Transparent"/>
|
||||||
<Setter Property="BorderThickness" Value="0"/>
|
<Setter Property="BorderThickness" Value="0"/>
|
||||||
@ -38,7 +43,7 @@
|
|||||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<!--Default Hintergrundfarbe-->
|
<!-- Standard-Hintergrundfarbe für Fenster -->
|
||||||
<Style Selector="Window">
|
<Style Selector="Window">
|
||||||
<Setter Property="Background" Value="#1E1E1E"/>
|
<Setter Property="Background" Value="#1E1E1E"/>
|
||||||
</Style>
|
</Style>
|
||||||
|
|||||||
@ -1,3 +1,7 @@
|
|||||||
|
<!--
|
||||||
|
Fenster zur Anzeige von Schritt-für-Schritt-Tutorials.
|
||||||
|
Enthält Auswahl-Buttons, ein Bildfeld, einen Hinweistext, Bildnavigation und einen Schließen-Button.
|
||||||
|
-->
|
||||||
<Window xmlns="https://github.com/avaloniaui"
|
<Window xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
x:Class="AquaCare.View.TutorialsWindow"
|
x:Class="AquaCare.View.TutorialsWindow"
|
||||||
@ -6,40 +10,43 @@
|
|||||||
Icon="Ressourcen/Bilder/ProgrammIcon.ico">
|
Icon="Ressourcen/Bilder/ProgrammIcon.ico">
|
||||||
|
|
||||||
<Grid>
|
<Grid>
|
||||||
|
<!-- Hintergrundbild für das Fenster -->
|
||||||
<Grid.Background>
|
<Grid.Background>
|
||||||
<ImageBrush Source="avares://AquaCare.View/Ressourcen/Bilder/TutorialsHintergrund.png" Stretch="UniformToFill"/>
|
<ImageBrush Source="avares://AquaCare.View/Ressourcen/Bilder/TutorialsHintergrund.png" Stretch="UniformToFill"/>
|
||||||
</Grid.Background>
|
</Grid.Background>
|
||||||
|
|
||||||
|
<!-- Zeilenaufteilung für Überschrift, Buttons und Inhalt -->
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/> <!-- Überschrift (optional) -->
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/> <!-- Buttons -->
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/> <!-- Hauptinhalt -->
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<!-- Buttons für Tutorials -->
|
<!-- Buttons für die Auswahl des Tutorials -->
|
||||||
<StackPanel Grid.Row="1"
|
<StackPanel Grid.Row="1"
|
||||||
Orientation="Horizontal"
|
Orientation="Horizontal"
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Margin="0,5,0,0"> <!-- Unteres Margin reduziert -->
|
Margin="0,5,0,0">
|
||||||
<Button Content="Fische füttern" Width="300" Height="50" Click="FischeFütternClick"/>
|
<Button Content="Fische füttern" Width="300" Height="50" Click="FischeFütternClick"/>
|
||||||
<Button Content="Wasser wechseln" Width="300" Height="50" Click="WasserWechselnClick"/>
|
<Button Content="Wasser wechseln" Width="300" Height="50" Click="WasserWechselnClick"/>
|
||||||
<Button Content="Filter reinigen" Width="300" Height="50" Click="FilterReinigenClick"/>
|
<Button Content="Filter reinigen" Width="300" Height="50" Click="FilterReinigenClick"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<!-- Inhalte mittig -->
|
<!-- Hauptinhalt: Bild, Text, Navigation -->
|
||||||
<StackPanel Grid.Row="2"
|
<StackPanel Grid.Row="2"
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
VerticalAlignment="Top"
|
VerticalAlignment="Top"
|
||||||
Spacing="2">
|
Spacing="2">
|
||||||
|
|
||||||
<!-- StackPanel für Tutorial-Inhalt -->
|
<!-- Tutorial-Inhalt: Bild und Hinweistext -->
|
||||||
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" Spacing="5">
|
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" Spacing="5">
|
||||||
<!-- Container für Bild und initialen Text -->
|
<Grid Height="450" Width="500" Margin="0,0,0,0">
|
||||||
<Grid Height="450" Width="500" Margin="0,0,0,0"> <!-- Höhe reduziert -->
|
<!-- Bildanzeige für das Tutorial -->
|
||||||
<Image x:Name="tutorialImage"
|
<Image x:Name="tutorialImage"
|
||||||
Stretch="Uniform"
|
Stretch="Uniform"
|
||||||
IsVisible="False"/>
|
IsVisible="False"/>
|
||||||
|
<!-- Hinweistext, wenn kein Tutorial ausgewählt ist -->
|
||||||
<TextBlock x:Name="initialText"
|
<TextBlock x:Name="initialText"
|
||||||
Text="Wähle oben, was du nicht kannst!"
|
Text="Wähle oben, was du nicht kannst!"
|
||||||
FontSize="30"
|
FontSize="30"
|
||||||
@ -48,19 +55,20 @@
|
|||||||
VerticalAlignment="Center"/>
|
VerticalAlignment="Center"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<!-- Bildindex-Text -->
|
<!-- Anzeige des aktuellen Bildindexes -->
|
||||||
<TextBlock x:Name="imageIndexTextBlock"
|
<TextBlock x:Name="imageIndexTextBlock"
|
||||||
Text=""
|
Text=""
|
||||||
FontSize="18"
|
FontSize="18"
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
Margin="0,2,0,2"/> <!-- Margins reduziert -->
|
Margin="0,2,0,2"/>
|
||||||
|
|
||||||
<!-- Navigation unter dem Bild -->
|
<!-- Navigations-Buttons unter dem Bild -->
|
||||||
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" Spacing="5">
|
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" Spacing="5">
|
||||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Spacing="10">
|
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Spacing="10">
|
||||||
<Button Content="Zurück" Click="PreviousImageClick" />
|
<Button Content="Zurück" Click="PreviousImageClick" />
|
||||||
<Button Content="Weiter" Click="NextImageClick" />
|
<Button Content="Weiter" Click="NextImageClick" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
<!-- Schließen-Button -->
|
||||||
<Button Content="Schließen"
|
<Button Content="Schließen"
|
||||||
Click="CloseClick"
|
Click="CloseClick"
|
||||||
Width="200"
|
Width="200"
|
||||||
|
|||||||
@ -6,13 +6,19 @@ using System;
|
|||||||
|
|
||||||
namespace AquaCare.View
|
namespace AquaCare.View
|
||||||
{
|
{
|
||||||
|
// Fenster zur Anzeige von Schritt-für-Schritt-Tutorials mit Bildern
|
||||||
public partial class TutorialsWindow : Window
|
public partial class TutorialsWindow : Window
|
||||||
{
|
{
|
||||||
|
// Liste der Bildpfade für das aktuelle Tutorial
|
||||||
private List<string> _images;
|
private List<string> _images;
|
||||||
|
// TextBlock zur Anzeige des aktuellen Bildindexes
|
||||||
private TextBlock? _imageIndexTextBlock;
|
private TextBlock? _imageIndexTextBlock;
|
||||||
|
// TextBlock für den Starttext
|
||||||
private TextBlock? _initialText;
|
private TextBlock? _initialText;
|
||||||
|
// Index des aktuell angezeigten Bildes
|
||||||
private int _currentImageIndex;
|
private int _currentImageIndex;
|
||||||
|
|
||||||
|
// Dictionary mit der Anzahl der Bilder pro Tutorial-Ordner
|
||||||
private readonly Dictionary<string, int> _imageCountPerFolder = new()
|
private readonly Dictionary<string, int> _imageCountPerFolder = new()
|
||||||
{
|
{
|
||||||
{"Fische füttern", 3},
|
{"Fische füttern", 3},
|
||||||
@ -20,17 +26,20 @@ namespace AquaCare.View
|
|||||||
{"Filter reinigen", 8}
|
{"Filter reinigen", 8}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Konstruktor: Initialisiert das Fenster und sucht die UI-Elemente
|
||||||
public TutorialsWindow()
|
public TutorialsWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent(); // Initialisiert die UI-Komponenten
|
||||||
_images = new List<string>();
|
_images = new List<string>();
|
||||||
|
|
||||||
|
// Sucht die Textblöcke anhand ihres Namens in der XAML
|
||||||
_imageIndexTextBlock = this.Find<TextBlock>("imageIndexTextBlock")
|
_imageIndexTextBlock = this.Find<TextBlock>("imageIndexTextBlock")
|
||||||
?? throw new InvalidOperationException("imageIndexTextBlock not found");
|
?? throw new InvalidOperationException("imageIndexTextBlock not found");
|
||||||
_initialText = this.Find<TextBlock>("initialText")
|
_initialText = this.Find<TextBlock>("initialText")
|
||||||
?? throw new InvalidOperationException("initialText not found");
|
?? throw new InvalidOperationException("initialText not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Lädt die Bilder für das gewählte Tutorial
|
||||||
private void LoadTutorialImages(string folderName)
|
private void LoadTutorialImages(string folderName)
|
||||||
{
|
{
|
||||||
if (_initialText == null || tutorialImage == null) return;
|
if (_initialText == null || tutorialImage == null) return;
|
||||||
@ -51,6 +60,7 @@ namespace AquaCare.View
|
|||||||
UpdateTutorialContent();
|
UpdateTutorialContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Aktualisiert das angezeigte Bild und den Index-Text
|
||||||
private void UpdateTutorialContent()
|
private void UpdateTutorialContent()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -77,6 +87,7 @@ namespace AquaCare.View
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Navigiert zum nächsten oder vorherigen Bild
|
||||||
private void NavigateImages(bool forward)
|
private void NavigateImages(bool forward)
|
||||||
{
|
{
|
||||||
if (forward)
|
if (forward)
|
||||||
@ -90,7 +101,7 @@ namespace AquaCare.View
|
|||||||
UpdateTutorialContent();
|
UpdateTutorialContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Event Handler
|
// Event Handler für die Tutorial-Auswahl
|
||||||
private void FischeFütternClick(object? sender, RoutedEventArgs e)
|
private void FischeFütternClick(object? sender, RoutedEventArgs e)
|
||||||
=> LoadTutorialImages("Fische füttern");
|
=> LoadTutorialImages("Fische füttern");
|
||||||
|
|
||||||
@ -100,12 +111,14 @@ namespace AquaCare.View
|
|||||||
private void FilterReinigenClick(object? sender, RoutedEventArgs e)
|
private void FilterReinigenClick(object? sender, RoutedEventArgs e)
|
||||||
=> LoadTutorialImages("Filter reinigen");
|
=> LoadTutorialImages("Filter reinigen");
|
||||||
|
|
||||||
|
// Event Handler für die Navigation durch die Bilder
|
||||||
private void NextImageClick(object? sender, RoutedEventArgs e)
|
private void NextImageClick(object? sender, RoutedEventArgs e)
|
||||||
=> NavigateImages(true);
|
=> NavigateImages(true);
|
||||||
|
|
||||||
private void PreviousImageClick(object? sender, RoutedEventArgs e)
|
private void PreviousImageClick(object? sender, RoutedEventArgs e)
|
||||||
=> NavigateImages(false);
|
=> NavigateImages(false);
|
||||||
|
|
||||||
|
// Event Handler zum Schließen des Fensters
|
||||||
private void CloseClick(object? sender, RoutedEventArgs e)
|
private void CloseClick(object? sender, RoutedEventArgs e)
|
||||||
=> Close();
|
=> Close();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,7 @@
|
|||||||
|
<!--
|
||||||
|
Fenster zur Anzeige der Messwerte.
|
||||||
|
Enthält eine Überschrift, Beispielwerte, eine Liste, ein DataGrid und einen Schließen-Button.
|
||||||
|
-->
|
||||||
<Window xmlns="https://github.com/avaloniaui"
|
<Window xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
x:Class="AquaCare.View.WerteWindow"
|
x:Class="AquaCare.View.WerteWindow"
|
||||||
@ -6,15 +10,16 @@
|
|||||||
Icon="Ressourcen/Bilder/ProgrammIcon.ico">
|
Icon="Ressourcen/Bilder/ProgrammIcon.ico">
|
||||||
|
|
||||||
<Grid>
|
<Grid>
|
||||||
|
<!-- Hintergrundbild für das Fenster -->
|
||||||
<Grid.Background>
|
<Grid.Background>
|
||||||
<ImageBrush Source="avares://AquaCare.View/Ressourcen/Bilder/WerteHintergrund.png" Stretch="UniformToFill"/>
|
<ImageBrush Source="avares://AquaCare.View/Ressourcen/Bilder/WerteHintergrund.png" Stretch="UniformToFill"/>
|
||||||
</Grid.Background>
|
</Grid.Background>
|
||||||
|
|
||||||
|
<!-- Zeilenaufteilung: Überschrift, Hauptinhalt, Schließen-Button -->
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto"/> <!-- Überschrift -->
|
<RowDefinition Height="Auto"/> <!-- Überschrift -->
|
||||||
<RowDefinition Height="*"/> <!-- Hauptinhalt -->
|
<RowDefinition Height="*"/> <!-- Hauptinhalt (Beispielwerte + DataGrid) -->
|
||||||
|
<RowDefinition Height="Auto"/> <!-- Schließen-Button -->
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<!-- Überschrift -->
|
<!-- Überschrift -->
|
||||||
@ -24,21 +29,24 @@
|
|||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
Margin="0,10,0,10"/>
|
Margin="0,10,0,10"/>
|
||||||
|
|
||||||
<!-- Hauptinhalt -->
|
<!-- Hauptinhalt: Beispielwerte und DataGrid -->
|
||||||
<StackPanel Grid.Row="1" Margin="20" Spacing="10">
|
<StackPanel Grid.Row="1" Margin="20" Spacing="10">
|
||||||
<ListBox x:Name="ValuesList" Grid.Row="1" Margin="20" />
|
|
||||||
<!-- Beispielwerte -->
|
<!-- Beispielwerte -->
|
||||||
<TextBlock Text="Temperatur: 25°C" FontSize="18"/>
|
<TextBlock Text="Temperatur: 25°C" FontSize="18"/>
|
||||||
<TextBlock Text="pH-Wert: 7.5" FontSize="18"/>
|
<TextBlock Text="pH-Wert: 7.5" FontSize="18"/>
|
||||||
<TextBlock Text="Nitrat: 10 mg/L" FontSize="18"/>
|
<TextBlock Text="Nitrat: 10 mg/L" FontSize="18"/>
|
||||||
<TextBlock Text="Ammoniak: 0 mg/L" FontSize="18"/>
|
<TextBlock Text="Ammoniak: 0 mg/L" FontSize="18"/>
|
||||||
|
<!-- DataGrid -->
|
||||||
<Grid>
|
<DataGrid x:Name="WerteDataGrid"
|
||||||
<DataGrid x:Name="WerteDataGrid" AutoGenerateColumns="True" />
|
AutoGenerateColumns="True"
|
||||||
</Grid>
|
Margin="0,10,0,0"/>
|
||||||
|
|
||||||
<!-- Schließen-Button -->
|
|
||||||
<Button Content="Schließen" HorizontalAlignment="Center" Width="100" Click="CloseWindowClick"/>
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
|
<!-- Schließen-Button immer ganz unten -->
|
||||||
|
<Button Grid.Row="2"
|
||||||
|
Content="Schließen"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
Margin="0,10,0,10"
|
||||||
|
Click="CloseWindowClick"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
@ -6,36 +6,42 @@ using System;
|
|||||||
|
|
||||||
namespace AquaCare.View
|
namespace AquaCare.View
|
||||||
{
|
{
|
||||||
|
// Fenster zur Anzeige und Verwaltung von Messwerten
|
||||||
public partial class WerteWindow : Window
|
public partial class WerteWindow : Window
|
||||||
{
|
{
|
||||||
|
// Controller für die Logik und Datenzugriffe
|
||||||
private readonly WerteController _controller;
|
private readonly WerteController _controller;
|
||||||
|
|
||||||
|
// Konstruktor: Initialisiert das Fenster und lädt die Daten
|
||||||
public WerteWindow()
|
public WerteWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent(); // Initialisiert die UI-Komponenten
|
||||||
_controller = new WerteController(new Datenbank());
|
_controller = new WerteController(new Datenbank()); // Erstellt Controller mit Datenbank
|
||||||
LoadData();
|
LoadData(); // Lädt die Messwerte
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Lädt die Messwerte aus der Datenbank und bindet sie an das DataGrid
|
||||||
private void LoadData()
|
private void LoadData()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var werte = _controller.LoadWerte();
|
var werte = _controller.LoadWerte(); // Holt die Werte aus dem Controller
|
||||||
WerteDataGrid.ItemsSource = werte; // Bindet die Werte an das DataGrid
|
WerteDataGrid.ItemsSource = werte; // Bindet die Werte an das DataGrid
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
// Gibt eine Fehlermeldung aus, falls das Laden fehlschlägt
|
||||||
Console.WriteLine($"Fehler beim Laden der Werte: {ex.Message}");
|
Console.WriteLine($"Fehler beim Laden der Werte: {ex.Message}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Event-Handler zum Schließen des Fensters
|
||||||
private void CloseWindowClick(object? sender, RoutedEventArgs e)
|
private void CloseWindowClick(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
// Direkte Benutzerinteraktion ohne MessageBox
|
// Hinweis für den Benutzer (hier nur Konsolenausgabe)
|
||||||
Console.WriteLine("Möchten Sie das Fenster wirklich schließen? (Ja/Nein)");
|
Console.WriteLine("Möchten Sie das Fenster wirklich schließen? (Ja/Nein)");
|
||||||
|
|
||||||
// Simuliere eine Benutzeraktion (z. B. durch eine UI-Komponente oder Konsoleninteraktion)
|
// Simuliert eine Benutzerbestätigung (hier immer 'Ja')
|
||||||
bool userConfirmed = true; // Setze dies basierend auf der Benutzeraktion
|
bool userConfirmed = true; // Setze dies basierend auf der Benutzeraktion
|
||||||
|
|
||||||
if (userConfirmed)
|
if (userConfirmed)
|
||||||
|
|||||||
Binary file not shown.
Loading…
Reference in New Issue
Block a user