diff --git a/App.axaml b/App.axaml
index f1e306f..6e26636 100644
--- a/App.axaml
+++ b/App.axaml
@@ -1,14 +1,11 @@
+ RequestedThemeVariant="Light">
-
-
-
-
- 10
- 1000
-
+
+
+
+
\ No newline at end of file
diff --git a/App.axaml.cs b/App.axaml.cs
index 613c6f1..7c0efdf 100644
--- a/App.axaml.cs
+++ b/App.axaml.cs
@@ -1,6 +1,8 @@
using Avalonia;
+using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
+using Avalonia.Styling;
namespace PLG_Exam;
@@ -11,6 +13,13 @@ public partial class App : Application
AvaloniaXamlLoader.Load(this);
}
+ public void ToggleTheme()
+ {
+ RequestedThemeVariant = RequestedThemeVariant == ThemeVariant.Dark
+ ? ThemeVariant.Light
+ : ThemeVariant.Dark;
+ }
+
public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
diff --git a/MainWindow.axaml b/MainWindow.axaml
index 9a88d35..d21106b 100644
--- a/MainWindow.axaml
+++ b/MainWindow.axaml
@@ -7,9 +7,9 @@
Title="PLG Exam">
-
+
-
+
@@ -17,22 +17,23 @@
-
+
+
-
+
-
+
-
+
@@ -40,22 +41,22 @@
-
+
-
+
-
+
-
+
diff --git a/MainWindow.axaml.cs b/MainWindow.axaml.cs
index b473df1..830c4fa 100644
--- a/MainWindow.axaml.cs
+++ b/MainWindow.axaml.cs
@@ -19,9 +19,8 @@ using PdfSharp.Fonts;
using System.Globalization;
using MigraDoc.DocumentObjectModel;
using System.Net.NetworkInformation;
-
-// ToDo
-// - White Mode Access
+using Avalonia.Styling;
+using Avalonia.Themes.Fluent;
namespace PLG_Exam
@@ -41,6 +40,41 @@ namespace PLG_Exam
this.KeyDown += OnKeyDown;
GlobalFontSettings.FontResolver = new CustomFontResolver();
+
+ RenewColors();
+ this.Closing += MainWindow_Closing;
+
+ }
+
+ private void OnDarkModeClick(object? sender, RoutedEventArgs e)
+ {
+ if (Application.Current is App app)
+ {
+ app.ToggleTheme();
+ RenewColors();
+ }
+
+
+ }
+
+ private void RenewColors(){
+ if(Application.Current.ActualThemeVariant == ThemeVariant.Dark){
+ BrdMid.Background = new SolidColorBrush(Avalonia.Media.Color.FromRgb(35,35,39)); // #232327
+ //BrdTop.Background = new SolidColorBrush(Avalonia.Media.Color.FromRgb(35,35,39)); // #232327
+ BrdTitle.Background = new SolidColorBrush(Avalonia.Media.Color.FromRgb(35,35,39)); // #232327
+ BrdName.Background = new SolidColorBrush(Avalonia.Media.Color.FromRgb(35,35,39)); // #232327
+ } else {
+ BrdMid.Background = new SolidColorBrush(Avalonia.Media.Color.FromRgb(230,230,230)); // #232327
+ //BrdTop.Background = new SolidColorBrush(Avalonia.Media.Color.FromRgb(230,230,230)); // #232327
+ BrdTitle.Background = new SolidColorBrush(Avalonia.Media.Color.FromRgb(230,230,230)); // #232327
+ BrdName.Background = new SolidColorBrush(Avalonia.Media.Color.FromRgb(230,230,230)); // #232327
+ }
+
+ if(Application.Current.ActualThemeVariant == ThemeVariant.Dark){
+ BtnTheme.Content="🌞";
+ } else {
+ BtnTheme.Content="🌙";
+ }
}
// Event für "Neuen Tab hinzufügen"
@@ -296,7 +330,9 @@ namespace PLG_Exam
_currentFilePath = filePath;
_isSaved = true;
- LblFilename.Content = !_currentFilePath.IsValueNullOrEmpty() ? Path.GetFileName(_currentFilePath) : "Ungespeichert ";
+ LblFilename.Content = !_currentFilePath.IsValueNullOrEmpty() ? Path.GetFileName(_currentFilePath) : "Ungespeichert *";
+
+ SaveToFile(filePath);
}
private StackPanel ReturnTabHeaderContent(string name, TabItem curr_tab){
@@ -347,6 +383,30 @@ namespace PLG_Exam
return headerStackPanel;
}
+ private async void MainWindow_Closing(object? sender, System.ComponentModel.CancelEventArgs e)
+ {
+ e.Cancel = true;
+ if (!_isSaved)
+ {
+ MessageBoxResult result = await MessageBox.Show(this, "Möchten Sie die aktuellen Änderungen speichern?",
+ "Nicht gespeicherte Änderungen", MessageBoxButton.YesNoCancel);
+ if (result == MessageBoxResult.Cancel) {
+ e.Cancel = true;
+ return;
+ }
+ if (result == MessageBoxResult.Yes) {
+ //SaveToFile(_currentFilePath);
+ OnSaveClick(null,null);
+ if(_isSaved == false){
+ e.Cancel = true;
+ return;
+ }
+ }
+ }
+ e.Cancel = false;
+ Environment.Exit(0);
+ }
+
// Neu
private async void OnNewClick(object? sender, RoutedEventArgs e)
{
@@ -371,7 +431,7 @@ namespace PLG_Exam
_currentFilePath = null;
_isSaved = true;
- LblFilename.Content = (!_currentFilePath.IsValueNullOrEmpty() ? Path.GetFileName(_currentFilePath) : "Ungespeichert ") + " *";
+ LblFilename.Content = !_currentFilePath.IsValueNullOrEmpty() ? Path.GetFileName(_currentFilePath) : "Ungespeichert *";
}
private Grid CreateTabContent(string? aufgabennummer = null, string? ueberschrift = null, string? beschreibung = null)
diff --git a/MessageBox.axaml.cs b/MessageBox.axaml.cs
index 44f95f3..b12a297 100644
--- a/MessageBox.axaml.cs
+++ b/MessageBox.axaml.cs
@@ -42,12 +42,12 @@ public partial class MessageBox : Window
AddButton("Ok", MessageBoxResult.Ok, true);
if (buttons == MessageBoxButton.YesNo || buttons == MessageBoxButton.YesNoCancel)
{
- AddButton("Yes", MessageBoxResult.Yes);
- AddButton("No", MessageBoxResult.No, true);
+ AddButton("Ja", MessageBoxResult.Yes);
+ AddButton("Nein", MessageBoxResult.No, true);
}
if (buttons == MessageBoxButton.OkCancel || buttons == MessageBoxButton.YesNoCancel)
- AddButton("Cancel", MessageBoxResult.Cancel, true);
+ AddButton("Abbrechen", MessageBoxResult.Cancel, true);
diff --git a/ThemeManager.cs b/ThemeManager.cs
new file mode 100644
index 0000000..dfa21a8
--- /dev/null
+++ b/ThemeManager.cs
@@ -0,0 +1,16 @@
+using System;
+using Avalonia;
+
+namespace PLG_Exam;
+
+public static class ThemeManager
+{
+ public static string CurrentBackgroundColor
+ {
+ get
+ {
+ return nameof(Application.RequestedThemeVariant) + "ModeBackground";
+ //return isDarkMode ? "DarkModeBackground" : "LightModeBackground";
+ }
+ }
+}
diff --git a/obj/PLG-Exam.csproj.nuget.dgspec.json b/obj/PLG-Exam.csproj.nuget.dgspec.json
index b35078f..299a8fe 100644
--- a/obj/PLG-Exam.csproj.nuget.dgspec.json
+++ b/obj/PLG-Exam.csproj.nuget.dgspec.json
@@ -54,6 +54,8 @@
"version": "[11.2.1, )"
},
"Avalonia.Diagnostics": {
+ "include": "None",
+ "suppressParent": "All",
"target": "Package",
"version": "[11.2.1, )"
},
diff --git a/obj/project.assets.json b/obj/project.assets.json
index 0a659ee..13e8bdb 100644
--- a/obj/project.assets.json
+++ b/obj/project.assets.json
@@ -114,12 +114,12 @@
"Avalonia.Remote.Protocol": "11.2.1"
},
"compile": {
- "lib/net8.0/Avalonia.Controls.ColorPicker.dll": {
+ "lib/net8.0/_._": {
"related": ".xml"
}
},
"runtime": {
- "lib/net8.0/Avalonia.Controls.ColorPicker.dll": {
+ "lib/net8.0/_._": {
"related": ".xml"
}
}
@@ -131,12 +131,12 @@
"Avalonia.Remote.Protocol": "11.2.1"
},
"compile": {
- "lib/net8.0/Avalonia.Controls.DataGrid.dll": {
+ "lib/net8.0/_._": {
"related": ".xml"
}
},
"runtime": {
- "lib/net8.0/Avalonia.Controls.DataGrid.dll": {
+ "lib/net8.0/_._": {
"related": ".xml"
}
}
@@ -170,12 +170,12 @@
"Avalonia.Themes.Simple": "11.2.1"
},
"compile": {
- "lib/net8.0/Avalonia.Diagnostics.dll": {
+ "lib/net8.0/_._": {
"related": ".xml"
}
},
"runtime": {
- "lib/net8.0/Avalonia.Diagnostics.dll": {
+ "lib/net8.0/_._": {
"related": ".xml"
}
}
@@ -292,12 +292,12 @@
"Avalonia": "11.2.1"
},
"compile": {
- "lib/net8.0/Avalonia.Themes.Simple.dll": {
+ "lib/net8.0/_._": {
"related": ".xml"
}
},
"runtime": {
- "lib/net8.0/Avalonia.Themes.Simple.dll": {
+ "lib/net8.0/_._": {
"related": ".xml"
}
}
@@ -6388,6 +6388,8 @@
"version": "[11.2.1, )"
},
"Avalonia.Diagnostics": {
+ "include": "None",
+ "suppressParent": "All",
"target": "Package",
"version": "[11.2.1, )"
},
diff --git a/obj/project.nuget.cache b/obj/project.nuget.cache
index fa50ff6..3a607e4 100644
--- a/obj/project.nuget.cache
+++ b/obj/project.nuget.cache
@@ -1,6 +1,6 @@
{
"version": 2,
- "dgSpecHash": "YIPRJ6ABhso=",
+ "dgSpecHash": "mnXgl9Kb58w=",
"success": true,
"projectFilePath": "/home/fierke/Nextcloud/Documents/source/repos/PLG_Exam/PLG-Exam/PLG-Exam.csproj",
"expectedPackageFiles": [