[fix:] fixed several issues and improved performance as well as ux
This commit is contained in:
13
App.axaml
13
App.axaml
@@ -1,14 +1,11 @@
|
||||
<Application xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="PLG_Exam.App"
|
||||
RequestedThemeVariant="Dark">
|
||||
RequestedThemeVariant="Light">
|
||||
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
|
||||
|
||||
<Application.Styles>
|
||||
<FluentTheme />
|
||||
</Application.Styles>
|
||||
<Application.Resources>
|
||||
<x:Double x:Key="DatePickerThemeMinWidth">10</x:Double>
|
||||
<x:Double x:Key="DatePickerThemeMaxWidth">1000</x:Double>
|
||||
</Application.Resources>
|
||||
<Application.Styles>
|
||||
<FluentTheme />
|
||||
</Application.Styles>
|
||||
|
||||
</Application>
|
||||
@@ -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)
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
Title="PLG Exam">
|
||||
<DockPanel Margin="10">
|
||||
<!-- Unterer Teil: Dateiverwaltung -->
|
||||
<Border DockPanel.Dock="Top" Background="#232327" Height="60" Margin="0,0,0,10">
|
||||
<Border DockPanel.Dock="Top" x:Name="BrdTop" Height="30" Margin="0,0,0,10">
|
||||
<Grid>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="10" VerticalAlignment="Center" Spacing="10">
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Center" Spacing="10">
|
||||
<Button Content="Speichern" Click="OnSaveClick" />
|
||||
<Button Content="Speichern unter..." Click="OnSaveAsClick" />
|
||||
<Button Content="Öffnen" Click="OnOpenClick" />
|
||||
@@ -17,22 +17,23 @@
|
||||
<Button Content="Abgeben" Click="OnSubmitClick" />
|
||||
|
||||
</StackPanel>
|
||||
<Label x:Name="LblFilename" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,0,0,10" Content="Ungespeichert *" />
|
||||
<Label x:Name="LblFilename" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,0,0,0" Content="Ungespeichert *" />
|
||||
<Button Content="Dark Mode" Click="OnDarkModeClick" x:Name="BtnTheme" HorizontalAlignment="Right" Margin="0,0,0,0" />
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<!-- Überoberer Teil: Title -->
|
||||
<Border DockPanel.Dock="Top" Background="#232327" Height="82" Margin="0,0,0,10">
|
||||
<Border DockPanel.Dock="Top" x:Name="BrdTitle" Height="82" Margin="0,0,0,10">
|
||||
<Grid Margin="10">
|
||||
<StackPanel Grid.Column="0" Margin="5" Spacing="5">
|
||||
<TextBlock Text="Titel der Arbeit" FontWeight="Bold" Foreground="White" />
|
||||
<TextBlock Text="Titel der Arbeit" FontWeight="Bold" />
|
||||
<TextBox Name="TitleField" Height="33"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<!-- Oberer Teil: Name, Vorname, Datum -->
|
||||
<Border DockPanel.Dock="Top" Background="#232327" Height="82" Margin="0,0,0,10">
|
||||
<Border DockPanel.Dock="Top" x:Name="BrdName" Height="82" Margin="0,0,0,10">
|
||||
<Grid Margin="10">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
@@ -40,22 +41,22 @@
|
||||
<ColumnDefinition Width="350" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Grid.Column="0" Margin="5" Spacing="5">
|
||||
<TextBlock Text="Name" FontWeight="Bold" Foreground="White" />
|
||||
<TextBlock Text="Name" FontWeight="Bold" />
|
||||
<TextBox Name="NameField" Height="33"/>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="1" Margin="5" Spacing="5">
|
||||
<TextBlock Text="Vorname" FontWeight="Bold" Foreground="White" />
|
||||
<TextBlock Text="Vorname" FontWeight="Bold" />
|
||||
<TextBox Name="VornameField" Height="33"/>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="2" Margin="5" Spacing="5">
|
||||
<TextBlock Text="Datum" HorizontalAlignment="Stretch" FontWeight="Bold" Foreground="White" />
|
||||
<TextBlock Text="Datum" HorizontalAlignment="Stretch" FontWeight="Bold" />
|
||||
<DatePicker Name="DatumField" Width="340" Height="33" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<!-- Mittlerer Teil: Tabansicht -->
|
||||
<Border Background="#232327" Margin="0,0,0,0">
|
||||
<Border x:Name="BrdMid" Margin="0,0,0,0">
|
||||
<DockPanel>
|
||||
<Button Content="Weitere Aufgabenlösung hinzufügen" DockPanel.Dock="Top" HorizontalAlignment="Center" Margin="10,10,10,0" Click="OnAddTabClick" />
|
||||
<TabControl Name="TabView" Margin="10">
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
|
||||
|
||||
16
ThemeManager.cs
Normal file
16
ThemeManager.cs
Normal file
@@ -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";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,8 @@
|
||||
"version": "[11.2.1, )"
|
||||
},
|
||||
"Avalonia.Diagnostics": {
|
||||
"include": "None",
|
||||
"suppressParent": "All",
|
||||
"target": "Package",
|
||||
"version": "[11.2.1, )"
|
||||
},
|
||||
|
||||
@@ -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, )"
|
||||
},
|
||||
|
||||
@@ -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": [
|
||||
|
||||
Reference in New Issue
Block a user