dark, classic und bright theme korrekt eingefügt auf allen 3 seiten
This commit is contained in:
parent
53d3a39fa5
commit
fa43a710ab
@ -30,12 +30,10 @@
|
||||
HorizontalAlignment="Center">
|
||||
<TextBlock Text="Author: Oliver Träger"
|
||||
FontSize="20"
|
||||
Foreground="White"
|
||||
HorizontalAlignment="Center"
|
||||
Margin="0,0,0,10"/>
|
||||
<TextBlock Text="Klasse: ITFS2"
|
||||
FontSize="20"
|
||||
Foreground="White"
|
||||
HorizontalAlignment="Center"
|
||||
Margin="0,0,0,10"/>
|
||||
<TextBlock Text="SS2025"
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.VisualTree;
|
||||
using Project_Periodensystem.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using static Project_Periodensystem.Model.AppTheme;
|
||||
|
||||
namespace Project_Periodensystem.View
|
||||
{
|
||||
@ -11,11 +14,12 @@ namespace Project_Periodensystem.View
|
||||
{
|
||||
private ContentControl? mainContent;
|
||||
public static AppTheme CurrentTheme { get; set; } = AppTheme.Dark;
|
||||
public static Dictionary<AppTheme, string> ThemeColors { get; } = new()
|
||||
|
||||
public static Dictionary<AppTheme, (string Background, string Foreground)> ThemeColors { get; } = new()
|
||||
{
|
||||
{ AppTheme.Dark, "#5C5144" },
|
||||
{ AppTheme.Light, "#E8DFD8" },
|
||||
{ AppTheme.Classic, "#7B8B6F" }
|
||||
{ AppTheme.Dark, ("#2F2F2F", "#FFFFFF") }, // Dunkles Anthrazit & Weiß
|
||||
{ AppTheme.Light, ("#FFFFFF", "#000000") }, // Weiß & Schwarz
|
||||
{ AppTheme.Classic, ("#E8E8E8", "#000000") } // Stylisches Grau & Schwarz
|
||||
};
|
||||
|
||||
public MainWindow()
|
||||
@ -28,16 +32,19 @@ namespace Project_Periodensystem.View
|
||||
public void ShowLandingPage()
|
||||
{
|
||||
mainContent!.Content = new LandingPage();
|
||||
UpdateTheme(AppTheme.Dark);
|
||||
}
|
||||
|
||||
public void ShowPeriodicTable()
|
||||
{
|
||||
mainContent!.Content = new PeriodicTablePage();
|
||||
UpdateTheme(AppTheme.Dark);
|
||||
}
|
||||
|
||||
public void ShowAboutPage()
|
||||
{
|
||||
mainContent!.Content = new AboutPage();
|
||||
UpdateTheme(AppTheme.Dark);
|
||||
}
|
||||
|
||||
public void UpdateTheme(AppTheme theme)
|
||||
@ -45,7 +52,17 @@ namespace Project_Periodensystem.View
|
||||
CurrentTheme = theme;
|
||||
if (mainContent?.Content is UserControl control)
|
||||
{
|
||||
control.Background = new SolidColorBrush(Color.Parse(ThemeColors[theme]));
|
||||
var (background, foreground) = ThemeColors[theme];
|
||||
control.Background = new SolidColorBrush(Color.Parse(background));
|
||||
|
||||
// Update text colors for all direct TextBlocks
|
||||
foreach (var textBlock in control.GetVisualDescendants().OfType<TextBlock>())
|
||||
{
|
||||
if (textBlock.Parent is Button || textBlock.Parent.ToString().Contains("ElementTile"))
|
||||
continue;
|
||||
|
||||
textBlock.Foreground = new SolidColorBrush(Color.Parse(foreground));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user