Infotexte sind jetzt DAAAAAA GEIL
This commit is contained in:
@ -103,11 +103,41 @@
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowImageInfo(string imagePath)
|
||||
private async void ShowImageInfo(string imagePath)
|
||||
{
|
||||
selectedImage = imagePath;
|
||||
infoText = "Info Text"; // Hier kannst du den gewünschten Infotext setzen
|
||||
popupStyle = "display: block;";
|
||||
infoText = await GetInfoTextForImageAsync(imagePath);
|
||||
}
|
||||
|
||||
|
||||
private async Task<string> GetInfoTextForImageAsync(string imagePath)
|
||||
{
|
||||
// Bestimme den Ordnerpfad, in dem sich die Bilder und die info_texts.txt Datei befinden
|
||||
string folderPath = Path.Combine(_environment.WebRootPath, "generated_images");
|
||||
|
||||
// Bestimme den Pfad zur info_texts.txt Datei
|
||||
string infoTextsFilePath = Path.Combine(folderPath, "info_texts.txt");
|
||||
|
||||
// Überprüfe, ob die Datei existiert
|
||||
if (!File.Exists(infoTextsFilePath))
|
||||
return $"Kein Infotext für {imagePath} gefunden.";
|
||||
|
||||
// Lies alle Zeilen der Datei
|
||||
var lines = await File.ReadAllLinesAsync(infoTextsFilePath);
|
||||
string adaptedImagePath = imagePath.Substring(1) + ":";
|
||||
|
||||
// Durchsuche jede Zeile nach dem gegebenen imagePath
|
||||
foreach (var line in lines)
|
||||
{
|
||||
if (line.StartsWith(adaptedImagePath)) // Überprüft, ob die Zeile mit dem Dateinamen des Bildes beginnt
|
||||
{
|
||||
// Trenne den Dateinamen und den Infotext und gib den Infotext zurück
|
||||
return line.Split(new[] { ':' }, 2).LastOrDefault()?.Trim();
|
||||
}
|
||||
}
|
||||
|
||||
return $"Kein Infotext für {imagePath} gefunden.";
|
||||
}
|
||||
|
||||
private void CloseImageInfo()
|
||||
|
||||
Reference in New Issue
Block a user