ok, Fenster ist da, ich komme auf die main und auf die about page und auch von da zurück zur main; Inhalt main page fehlt
This commit is contained in:
parent
e6836f2a81
commit
11dccc04cb
@ -6,7 +6,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net9.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net9.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
<!-- PropertyGroup enthält verschiedene Projekteinstellungen -->
|
<!-- PropertyGroup enthält verschiedene Projekteinstellungen -->
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<!-- Gibt die Ziel-.NET-Framework-Version an -->
|
<!-- Gibt die Ziel-.NET-Framework-Version an -->
|
||||||
<TargetFramework>net9.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<!-- Aktiviert implizite Verwendungen, die automatisch häufig verwendete Namespaces importieren -->
|
<!-- Aktiviert implizite Verwendungen, die automatisch häufig verwendete Namespaces importieren -->
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<!-- Aktiviert nullable Referenztypen zur Unterstützung der Nullsicherheitsprüfung -->
|
<!-- Aktiviert nullable Referenztypen zur Unterstützung der Nullsicherheitsprüfung -->
|
||||||
|
|||||||
12
Project_Periodensystem.View/AboutPage.axaml
Normal file
12
Project_Periodensystem.View/AboutPage.axaml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<!-- Datei: Project_Periodensystem.View/AboutPage.axaml -->
|
||||||
|
<UserControl xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:i="using:Avalonia.Interactivity"
|
||||||
|
x:Class="Project_Periodensystem.View.AboutPage">
|
||||||
|
<Grid>
|
||||||
|
<Button x:Name="BackButton"
|
||||||
|
Click="BackButton_Click">
|
||||||
|
Back
|
||||||
|
</Button>
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
||||||
27
Project_Periodensystem.View/AboutPage.axaml.cs
Normal file
27
Project_Periodensystem.View/AboutPage.axaml.cs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Interactivity;
|
||||||
|
using Avalonia.Markup.Xaml;
|
||||||
|
using Avalonia.VisualTree;
|
||||||
|
|
||||||
|
namespace Project_Periodensystem.View
|
||||||
|
{
|
||||||
|
public partial class AboutPage : UserControl
|
||||||
|
{
|
||||||
|
public AboutPage()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitializeComponent()
|
||||||
|
=> AvaloniaXamlLoader.Load(this);
|
||||||
|
|
||||||
|
private void BackButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
var window = this.GetVisualRoot() as MainWindow;
|
||||||
|
if (window != null)
|
||||||
|
{
|
||||||
|
window.ShowLanding();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,7 +1,6 @@
|
|||||||
<Application xmlns="https://github.com/avaloniaui"
|
<Application 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="Project_Periodensystem.View.App"
|
x:Class="Project_Periodensystem.View.App">
|
||||||
RequestedThemeVariant="Light">
|
|
||||||
<Application.Styles>
|
<Application.Styles>
|
||||||
<FluentTheme />
|
<FluentTheme />
|
||||||
</Application.Styles>
|
</Application.Styles>
|
||||||
|
|||||||
@ -7,12 +7,16 @@ namespace Project_Periodensystem.View
|
|||||||
public partial class App : Application
|
public partial class App : Application
|
||||||
{
|
{
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
=> AvaloniaXamlLoader.Load(this);
|
{
|
||||||
|
AvaloniaXamlLoader.Load(this);
|
||||||
|
}
|
||||||
|
|
||||||
public override void OnFrameworkInitializationCompleted()
|
public override void OnFrameworkInitializationCompleted()
|
||||||
{
|
{
|
||||||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||||
|
{
|
||||||
desktop.MainWindow = new MainWindow();
|
desktop.MainWindow = new MainWindow();
|
||||||
|
}
|
||||||
|
|
||||||
base.OnFrameworkInitializationCompleted();
|
base.OnFrameworkInitializationCompleted();
|
||||||
}
|
}
|
||||||
|
|||||||
22
Project_Periodensystem.View/LandingPage.axaml
Normal file
22
Project_Periodensystem.View/LandingPage.axaml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<UserControl xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
x:Class="Project_Periodensystem.View.LandingPage">
|
||||||
|
<Grid>
|
||||||
|
<TextBlock Text="Welcome to the periodic table of elements!"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
FontSize="32"
|
||||||
|
Foreground="Red"
|
||||||
|
Margin="0,0,0,60"/>
|
||||||
|
<Button x:Name="StartButton"
|
||||||
|
Content="Start"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Margin="0,60,0,0"
|
||||||
|
Width="160"
|
||||||
|
Height="50"
|
||||||
|
Background="Red"
|
||||||
|
Foreground="White"
|
||||||
|
Click="StartButton_Click"/>
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
||||||
29
Project_Periodensystem.View/LandingPage.axaml.cs
Normal file
29
Project_Periodensystem.View/LandingPage.axaml.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Interactivity;
|
||||||
|
using Avalonia.Markup.Xaml;
|
||||||
|
using Avalonia.VisualTree;
|
||||||
|
|
||||||
|
namespace Project_Periodensystem.View
|
||||||
|
{
|
||||||
|
public partial class LandingPage : UserControl
|
||||||
|
{
|
||||||
|
public LandingPage()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
AvaloniaXamlLoader.Load(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void StartButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
var window = this.GetVisualRoot() as MainWindow;
|
||||||
|
if (window != null)
|
||||||
|
{
|
||||||
|
window.ShowPeriodicTable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,23 +1,9 @@
|
|||||||
<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:vm="clr-namespace:Project_Periodensystem.Controller;assembly=Project_Periodensystem.Controller"
|
|
||||||
xmlns:components="clr-namespace:Project_Periodensystem.View.Components;assembly=Project_Periodensystem.View"
|
|
||||||
x:Class="Project_Periodensystem.View.MainWindow"
|
x:Class="Project_Periodensystem.View.MainWindow"
|
||||||
Title="Periodensystem"
|
Title="Periodensystem"
|
||||||
Width="900" Height="650"
|
Width="900" Height="650">
|
||||||
CanResize="True"
|
<Grid>
|
||||||
Background="#111111">
|
<ContentControl x:Name="MainContent"/>
|
||||||
|
</Grid>
|
||||||
<!-- DataContext auf den Controller setzen -->
|
|
||||||
<Window.DataContext>
|
|
||||||
<vm:PeriodensystemController />
|
|
||||||
</Window.DataContext>
|
|
||||||
|
|
||||||
<ScrollViewer HorizontalScrollBarVisibility="Auto"
|
|
||||||
VerticalScrollBarVisibility="Auto">
|
|
||||||
<!-- Canvas mit fester Größe: 18 Spalten × 80px = 1440px, 10 Zeilen × 80px = 800px -->
|
|
||||||
<Canvas x:Name="PeriodicCanvas"
|
|
||||||
Width="1440"
|
|
||||||
Height="800" />
|
|
||||||
</ScrollViewer>
|
|
||||||
</Window>
|
</Window>
|
||||||
|
|||||||
@ -1,46 +1,41 @@
|
|||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
using Project_Periodensystem.Controller;
|
|
||||||
using Project_Periodensystem.View.Components;
|
|
||||||
|
|
||||||
namespace Project_Periodensystem.View
|
namespace Project_Periodensystem.View
|
||||||
{
|
{
|
||||||
public partial class MainWindow : Window
|
public partial class MainWindow : Window
|
||||||
{
|
{
|
||||||
private readonly PeriodensystemController _controller;
|
private readonly ContentControl mainContent;
|
||||||
|
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_controller = new PeriodensystemController();
|
var content = this.Find<ContentControl>("MainContent");
|
||||||
DataContext = _controller;
|
if (content == null)
|
||||||
PopulateCanvas();
|
throw new System.Exception("MainContent control not found.");
|
||||||
|
|
||||||
|
mainContent = content;
|
||||||
|
ShowLanding(); // Show initial page
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
=> AvaloniaXamlLoader.Load(this);
|
|
||||||
|
|
||||||
private void PopulateCanvas()
|
|
||||||
{
|
{
|
||||||
// Holt den Canvas aus dem XAML (muss existieren!)
|
AvaloniaXamlLoader.Load(this);
|
||||||
var canvas = this.FindControl<Canvas>("PeriodicCanvas");
|
|
||||||
if (canvas == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
foreach (var element in _controller.Elements)
|
|
||||||
{
|
|
||||||
// Neues Tile für jedes Element
|
|
||||||
var tile = new ElementTile
|
|
||||||
{
|
|
||||||
DataContext = element
|
|
||||||
};
|
|
||||||
|
|
||||||
// Position setzen: Column × 80px, Row × 80px
|
|
||||||
Canvas.SetLeft(tile, element.Column * 80);
|
|
||||||
Canvas.SetTop(tile, element.Row * 80);
|
|
||||||
|
|
||||||
canvas.Children.Add(tile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ShowLanding()
|
||||||
|
{
|
||||||
|
mainContent.Content = new LandingPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ShowPeriodicTable()
|
||||||
|
{
|
||||||
|
mainContent.Content = new PeriodicTablePage();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ShowAbout()
|
||||||
|
{
|
||||||
|
mainContent.Content = new AboutPage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
11
Project_Periodensystem.View/PeriodicTablePage.axaml
Normal file
11
Project_Periodensystem.View/PeriodicTablePage.axaml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<!-- PeriodicTablePage.axaml -->
|
||||||
|
<UserControl xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
x:Class="Project_Periodensystem.View.PeriodicTablePage">
|
||||||
|
<Grid>
|
||||||
|
<Button Name="AboutButton"
|
||||||
|
Click="AboutButton_Click">
|
||||||
|
About
|
||||||
|
</Button>
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
||||||
29
Project_Periodensystem.View/PeriodicTablePage.axaml.cs
Normal file
29
Project_Periodensystem.View/PeriodicTablePage.axaml.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Interactivity;
|
||||||
|
using Avalonia.Markup.Xaml;
|
||||||
|
using Avalonia.VisualTree;
|
||||||
|
|
||||||
|
namespace Project_Periodensystem.View
|
||||||
|
{
|
||||||
|
public partial class PeriodicTablePage : UserControl
|
||||||
|
{
|
||||||
|
public PeriodicTablePage()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
AvaloniaXamlLoader.Load(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AboutButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
var window = this.GetVisualRoot() as MainWindow;
|
||||||
|
if (window != null)
|
||||||
|
{
|
||||||
|
window.ShowAbout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,14 +1,15 @@
|
|||||||
using System;
|
using Avalonia;
|
||||||
using Avalonia;
|
|
||||||
|
|
||||||
namespace Project_Periodensystem.View
|
namespace Project_Periodensystem.View
|
||||||
{
|
{
|
||||||
class Program
|
internal static class Program
|
||||||
{
|
{
|
||||||
[STAThread]
|
[System.STAThread] // <-- Das ist korrekt!
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
=> BuildAvaloniaApp()
|
{
|
||||||
|
BuildAvaloniaApp()
|
||||||
.StartWithClassicDesktopLifetime(args);
|
.StartWithClassicDesktopLifetime(args);
|
||||||
|
}
|
||||||
|
|
||||||
public static AppBuilder BuildAvaloniaApp()
|
public static AppBuilder BuildAvaloniaApp()
|
||||||
=> AppBuilder.Configure<App>()
|
=> AppBuilder.Configure<App>()
|
||||||
|
|||||||
@ -1,32 +1,25 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>net9.0</TargetFramework>
|
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
<UseWPF>false</UseWPF>
|
||||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
<UseWindowsForms>false</UseWindowsForms>
|
||||||
|
|
||||||
<!-- Wichtig: Sagt MSBuild, dass Avalonia benutzt wird -->
|
|
||||||
<UseAvalonia>true</UseAvalonia>
|
|
||||||
|
|
||||||
<!-- Optional, für bessere Performance bei Bindings -->
|
|
||||||
<AvaloniaUseCompiledBindingsByDefault>false</AvaloniaUseCompiledBindingsByDefault>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Avalonia" Version="11.2.6" />
|
<PackageReference Include="Avalonia" Version="11.0.0" />
|
||||||
<PackageReference Include="Avalonia.Desktop" Version="11.2.6" />
|
<PackageReference Include="Avalonia.Desktop" Version="11.0.0" />
|
||||||
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.2.6" />
|
<PackageReference Include="Avalonia.Diagnostics" Version="11.0.0" />
|
||||||
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.2.6" />
|
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0" />
|
||||||
<PackageReference Include="Avalonia.Diagnostics" Version="11.2.6">
|
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.0" />
|
||||||
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
|
|
||||||
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
|
|
||||||
</PackageReference>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Project_Periodensystem.Controller\Project_Periodensystem.Controller.csproj" />
|
<ProjectReference Include="..\Project_Periodensystem.Controller\Project_Periodensystem.Controller.csproj" />
|
||||||
|
<ProjectReference Include="..\Project_Periodensystem.Model\Project_Periodensystem.Model.csproj" />
|
||||||
|
<ProjectReference Include="..\Project_Periodensystem.Persistence\Project_Periodensystem.Persistence.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user