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>
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
<!-- PropertyGroup enthält verschiedene Projekteinstellungen -->
|
||||
<PropertyGroup>
|
||||
<!-- 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 -->
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<!-- 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"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="Project_Periodensystem.View.App"
|
||||
RequestedThemeVariant="Light">
|
||||
x:Class="Project_Periodensystem.View.App">
|
||||
<Application.Styles>
|
||||
<FluentTheme />
|
||||
</Application.Styles>
|
||||
|
||||
@ -7,12 +7,16 @@ namespace Project_Periodensystem.View
|
||||
public partial class App : Application
|
||||
{
|
||||
public override void Initialize()
|
||||
=> AvaloniaXamlLoader.Load(this);
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
public override void OnFrameworkInitializationCompleted()
|
||||
{
|
||||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
{
|
||||
desktop.MainWindow = new MainWindow();
|
||||
}
|
||||
|
||||
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"
|
||||
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"
|
||||
Title="Periodensystem"
|
||||
Width="900" Height="650"
|
||||
CanResize="True"
|
||||
Background="#111111">
|
||||
|
||||
<!-- 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>
|
||||
Width="900" Height="650">
|
||||
<Grid>
|
||||
<ContentControl x:Name="MainContent"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
@ -1,46 +1,41 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Project_Periodensystem.Controller;
|
||||
using Project_Periodensystem.View.Components;
|
||||
|
||||
namespace Project_Periodensystem.View
|
||||
{
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private readonly PeriodensystemController _controller;
|
||||
private readonly ContentControl mainContent;
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
_controller = new PeriodensystemController();
|
||||
DataContext = _controller;
|
||||
PopulateCanvas();
|
||||
var content = this.Find<ContentControl>("MainContent");
|
||||
if (content == null)
|
||||
throw new System.Exception("MainContent control not found.");
|
||||
|
||||
mainContent = content;
|
||||
ShowLanding(); // Show initial page
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
=> AvaloniaXamlLoader.Load(this);
|
||||
|
||||
private void PopulateCanvas()
|
||||
{
|
||||
// Holt den Canvas aus dem XAML (muss existieren!)
|
||||
var canvas = this.FindControl<Canvas>("PeriodicCanvas");
|
||||
if (canvas == null)
|
||||
return;
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
foreach (var element in _controller.Elements)
|
||||
{
|
||||
// Neues Tile für jedes Element
|
||||
var tile = new ElementTile
|
||||
{
|
||||
DataContext = element
|
||||
};
|
||||
public void ShowLanding()
|
||||
{
|
||||
mainContent.Content = new LandingPage();
|
||||
}
|
||||
|
||||
// Position setzen: Column × 80px, Row × 80px
|
||||
Canvas.SetLeft(tile, element.Column * 80);
|
||||
Canvas.SetTop(tile, element.Row * 80);
|
||||
public void ShowPeriodicTable()
|
||||
{
|
||||
mainContent.Content = new PeriodicTablePage();
|
||||
}
|
||||
|
||||
canvas.Children.Add(tile);
|
||||
}
|
||||
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,18 +1,19 @@
|
||||
using System;
|
||||
using Avalonia;
|
||||
using Avalonia;
|
||||
|
||||
namespace Project_Periodensystem.View
|
||||
{
|
||||
class Program
|
||||
internal static class Program
|
||||
{
|
||||
[STAThread]
|
||||
[System.STAThread] // <-- Das ist korrekt!
|
||||
public static void Main(string[] args)
|
||||
=> BuildAvaloniaApp()
|
||||
.StartWithClassicDesktopLifetime(args);
|
||||
{
|
||||
BuildAvaloniaApp()
|
||||
.StartWithClassicDesktopLifetime(args);
|
||||
}
|
||||
|
||||
public static AppBuilder BuildAvaloniaApp()
|
||||
=> AppBuilder.Configure<App>()
|
||||
.UsePlatformDetect()
|
||||
.LogToTrace();
|
||||
.UsePlatformDetect()
|
||||
.LogToTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,32 +1,25 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
|
||||
<!-- Wichtig: Sagt MSBuild, dass Avalonia benutzt wird -->
|
||||
<UseAvalonia>true</UseAvalonia>
|
||||
|
||||
<!-- Optional, für bessere Performance bei Bindings -->
|
||||
<AvaloniaUseCompiledBindingsByDefault>false</AvaloniaUseCompiledBindingsByDefault>
|
||||
<UseWPF>false</UseWPF>
|
||||
<UseWindowsForms>false</UseWindowsForms>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia" Version="11.2.6" />
|
||||
<PackageReference Include="Avalonia.Desktop" Version="11.2.6" />
|
||||
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.2.6" />
|
||||
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.2.6" />
|
||||
<PackageReference Include="Avalonia.Diagnostics" Version="11.2.6">
|
||||
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
|
||||
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Avalonia" Version="11.0.0" />
|
||||
<PackageReference Include="Avalonia.Desktop" Version="11.0.0" />
|
||||
<PackageReference Include="Avalonia.Diagnostics" Version="11.0.0" />
|
||||
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0" />
|
||||
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<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>
|
||||
|
||||
</Project>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user