[feat:] add filename label and update on file operations
This commit is contained in:
@@ -8,13 +8,17 @@
|
|||||||
<DockPanel Margin="10">
|
<DockPanel Margin="10">
|
||||||
<!-- Unterer Teil: Dateiverwaltung -->
|
<!-- Unterer Teil: Dateiverwaltung -->
|
||||||
<Border DockPanel.Dock="Top" Background="#232327" Height="60" Margin="0,0,0,10">
|
<Border DockPanel.Dock="Top" Background="#232327" Height="60" Margin="0,0,0,10">
|
||||||
|
<Grid>
|
||||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="10" VerticalAlignment="Center" Spacing="10">
|
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="10" VerticalAlignment="Center" Spacing="10">
|
||||||
<Button Content="Speichern" Click="OnSaveClick" />
|
<Button Content="Speichern" Click="OnSaveClick" />
|
||||||
<Button Content="Speichern unter..." Click="OnSaveAsClick" />
|
<Button Content="Speichern unter..." Click="OnSaveAsClick" />
|
||||||
<Button Content="Öffnen" Click="OnOpenClick" />
|
<Button Content="Öffnen" Click="OnOpenClick" />
|
||||||
<Button Content="Neu" Click="OnNewClick" />
|
<Button Content="Neu" Click="OnNewClick" />
|
||||||
<Button Content="Abgeben" Click="OnSubmitClick" />
|
<Button Content="Abgeben" Click="OnSubmitClick" />
|
||||||
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
<Label x:Name="LblFilename" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,0,0,10" Content="Ungespeichert *" />
|
||||||
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
<!-- Überoberer Teil: Title -->
|
<!-- Überoberer Teil: Title -->
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ using PdfSharp.Drawing.Layout;
|
|||||||
using PdfSharp.Fonts;
|
using PdfSharp.Fonts;
|
||||||
|
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using MigraDoc.DocumentObjectModel;
|
||||||
|
|
||||||
// ToDo
|
// ToDo
|
||||||
// - Rand [check]
|
// - Rand [check]
|
||||||
@@ -41,7 +42,7 @@ namespace PLG_Exam
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
InitializeBackupTimer();
|
InitializeBackupTimer();
|
||||||
AddNewTab();
|
//AddNewTab();
|
||||||
|
|
||||||
this.KeyDown += OnKeyDown;
|
this.KeyDown += OnKeyDown;
|
||||||
GlobalFontSettings.FontResolver = new CustomFontResolver();
|
GlobalFontSettings.FontResolver = new CustomFontResolver();
|
||||||
@@ -113,8 +114,8 @@ namespace PLG_Exam
|
|||||||
VerticalContentAlignment = Avalonia.Layout.VerticalAlignment.Center,
|
VerticalContentAlignment = Avalonia.Layout.VerticalAlignment.Center,
|
||||||
Width = 20,
|
Width = 20,
|
||||||
Height = 20,
|
Height = 20,
|
||||||
Background = new SolidColorBrush(Color.FromRgb(123,35,39)),
|
Background = new SolidColorBrush(Avalonia.Media.Color.FromRgb(123,35,39)),
|
||||||
Foreground = new SolidColorBrush(Color.FromRgb(0,0,0)),
|
Foreground = new SolidColorBrush(Avalonia.Media.Color.FromRgb(0,0,0)),
|
||||||
Padding = new Thickness(0),
|
Padding = new Thickness(0),
|
||||||
Margin = new Thickness(5, 0, 0, 0),
|
Margin = new Thickness(5, 0, 0, 0),
|
||||||
VerticalAlignment = Avalonia.Layout.VerticalAlignment.Center
|
VerticalAlignment = Avalonia.Layout.VerticalAlignment.Center
|
||||||
@@ -151,12 +152,16 @@ namespace PLG_Exam
|
|||||||
{
|
{
|
||||||
TabView.Items.Remove(tabItem);
|
TabView.Items.Remove(tabItem);
|
||||||
_isSaved = false;
|
_isSaved = false;
|
||||||
|
|
||||||
|
LblFilename.Content = (!_currentFilePath.IsValueNullOrEmpty() ? Path.GetFileName(_currentFilePath) : "Ungespeichert ") + " *";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TabView.Items.Add(tabItem);
|
TabView.Items.Add(tabItem);
|
||||||
TabView.SelectedItem = tabItem;
|
TabView.SelectedItem = tabItem;
|
||||||
_isSaved = false;
|
_isSaved = false;
|
||||||
|
|
||||||
|
LblFilename.Content = (!_currentFilePath.IsValueNullOrEmpty() ? Path.GetFileName(_currentFilePath) : "Ungespeichert ") + " *";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -171,6 +176,7 @@ namespace PLG_Exam
|
|||||||
{
|
{
|
||||||
TabView.Items.Remove(selectedTab);
|
TabView.Items.Remove(selectedTab);
|
||||||
_isSaved = false;
|
_isSaved = false;
|
||||||
|
LblFilename.Content = (!_currentFilePath.IsValueNullOrEmpty() ? Path.GetFileName(_currentFilePath) : "Ungespeichert ") + " *";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -243,6 +249,8 @@ namespace PLG_Exam
|
|||||||
|
|
||||||
_currentFilePath = filePath;
|
_currentFilePath = filePath;
|
||||||
_isSaved = true;
|
_isSaved = true;
|
||||||
|
|
||||||
|
LblFilename.Content = !_currentFilePath.IsValueNullOrEmpty() ? Path.GetFileName(_currentFilePath) : "Ungespeichert ";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Öffnen
|
// Öffnen
|
||||||
@@ -292,6 +300,8 @@ namespace PLG_Exam
|
|||||||
|
|
||||||
_currentFilePath = filePath;
|
_currentFilePath = filePath;
|
||||||
_isSaved = true;
|
_isSaved = true;
|
||||||
|
|
||||||
|
LblFilename.Content = !_currentFilePath.IsValueNullOrEmpty() ? Path.GetFileName(_currentFilePath) : "Ungespeichert ";
|
||||||
}
|
}
|
||||||
|
|
||||||
private StackPanel ReturnTabHeaderContent(string name, TabItem curr_tab){
|
private StackPanel ReturnTabHeaderContent(string name, TabItem curr_tab){
|
||||||
@@ -303,8 +313,8 @@ namespace PLG_Exam
|
|||||||
VerticalContentAlignment = Avalonia.Layout.VerticalAlignment.Center,
|
VerticalContentAlignment = Avalonia.Layout.VerticalAlignment.Center,
|
||||||
Width = 20,
|
Width = 20,
|
||||||
Height = 20,
|
Height = 20,
|
||||||
Background = new SolidColorBrush(Color.FromRgb(123,35,39)),
|
Background = new SolidColorBrush(Avalonia.Media.Color.FromRgb(123,35,39)),
|
||||||
Foreground = new SolidColorBrush(Color.FromRgb(0,0,0)),
|
Foreground = new SolidColorBrush(Avalonia.Media.Color.FromRgb(0,0,0)),
|
||||||
Padding = new Thickness(0),
|
Padding = new Thickness(0),
|
||||||
Margin = new Thickness(5, 0, 0, 0),
|
Margin = new Thickness(5, 0, 0, 0),
|
||||||
VerticalAlignment = Avalonia.Layout.VerticalAlignment.Center
|
VerticalAlignment = Avalonia.Layout.VerticalAlignment.Center
|
||||||
@@ -335,6 +345,7 @@ namespace PLG_Exam
|
|||||||
{
|
{
|
||||||
TabView.Items.Remove(curr_tab);
|
TabView.Items.Remove(curr_tab);
|
||||||
_isSaved = false;
|
_isSaved = false;
|
||||||
|
LblFilename.Content = (!_currentFilePath.IsValueNullOrEmpty() ? Path.GetFileName(_currentFilePath) : "Ungespeichert ") + " *";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -364,6 +375,8 @@ namespace PLG_Exam
|
|||||||
_tabCounter = 0;
|
_tabCounter = 0;
|
||||||
_currentFilePath = null;
|
_currentFilePath = null;
|
||||||
_isSaved = true;
|
_isSaved = true;
|
||||||
|
|
||||||
|
LblFilename.Content = (!_currentFilePath.IsValueNullOrEmpty() ? Path.GetFileName(_currentFilePath) : "Ungespeichert ") + " *";
|
||||||
}
|
}
|
||||||
|
|
||||||
private Grid CreateTabContent(string? aufgabennummer = null, string? ueberschrift = null, string? beschreibung = null)
|
private Grid CreateTabContent(string? aufgabennummer = null, string? ueberschrift = null, string? beschreibung = null)
|
||||||
@@ -399,11 +412,21 @@ namespace PLG_Exam
|
|||||||
VerticalContentAlignment = Avalonia.Layout.VerticalAlignment.Stretch,
|
VerticalContentAlignment = Avalonia.Layout.VerticalAlignment.Stretch,
|
||||||
Watermark = "Beschreibung",
|
Watermark = "Beschreibung",
|
||||||
Text = beschreibung ?? "",
|
Text = beschreibung ?? "",
|
||||||
|
TextWrapping = Avalonia.Media.TextWrapping.Wrap,
|
||||||
|
LineHeight = 21,
|
||||||
|
FontSize = 14,
|
||||||
|
Margin = new Thickness(0, 0, 0, 10)
|
||||||
};
|
};
|
||||||
|
|
||||||
// Event für dynamische Tab-Umbenennung
|
// Event für dynamische Tab-Umbenennung
|
||||||
aufgabenNummerTextBox.KeyUp += (s, e) => UpdateTabHeader(TabView.SelectedItem as TabItem, aufgabenNummerTextBox, ueberschriftTextBox);
|
aufgabenNummerTextBox.TextChanged += (s, e) => UpdateTabHeader(TabView.SelectedItem as TabItem, aufgabenNummerTextBox, ueberschriftTextBox);
|
||||||
ueberschriftTextBox.KeyUp += (s, e) => UpdateTabHeader(TabView.SelectedItem as TabItem, aufgabenNummerTextBox, ueberschriftTextBox);
|
ueberschriftTextBox.TextChanged += (s, e) => UpdateTabHeader(TabView.SelectedItem as TabItem, aufgabenNummerTextBox, ueberschriftTextBox);
|
||||||
|
|
||||||
|
beschreibungTextBox.TextChanged += (s, e) =>
|
||||||
|
{
|
||||||
|
_isSaved = false;
|
||||||
|
LblFilename.Content = (!_currentFilePath.IsValueNullOrEmpty() ? Path.GetFileName(_currentFilePath) : "Ungespeichert ") + " *";
|
||||||
|
};
|
||||||
|
|
||||||
headerGrid.Children.Add(aufgabenNummerTextBox);
|
headerGrid.Children.Add(aufgabenNummerTextBox);
|
||||||
headerGrid.Children.Add(ueberschriftTextBox);
|
headerGrid.Children.Add(ueberschriftTextBox);
|
||||||
@@ -428,6 +451,10 @@ namespace PLG_Exam
|
|||||||
tab.Header = ReturnTabHeaderContent(string.IsNullOrWhiteSpace(ueberschriftText)
|
tab.Header = ReturnTabHeaderContent(string.IsNullOrWhiteSpace(ueberschriftText)
|
||||||
? aufgabeText
|
? aufgabeText
|
||||||
: $"{aufgabeText} - {ueberschriftText}", tab);
|
: $"{aufgabeText} - {ueberschriftText}", tab);
|
||||||
|
|
||||||
|
|
||||||
|
_isSaved = false;
|
||||||
|
LblFilename.Content = (!_currentFilePath.IsValueNullOrEmpty() ? Path.GetFileName(_currentFilePath) : "Ungespeichert ") + " *";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user