App icon; language/theme follow Windows on first run; flush save on exit

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 14:52:25 +01:00
parent 5a8eba836b
commit 90898d7040
16 changed files with 107 additions and 36 deletions

View File

@@ -5,7 +5,14 @@
"PowerShell(cd d:\\\\Oculusquest\\\\Projekt\\\\ReminderOrganizer; git rm -q --cached tasks.json docs/screenshots/1.png; Remove-Item tasks.json, docs\\\\screenshots\\\\1.png; Add-Content .gitignore \"tasks.json\"; Get-ChildItem bin -Recurse -Filter tasks.json | Remove-Item; dotnet build ReminderOrganizer.csproj -nologo -v q 2>&1 | Select-String \"Fehler|error\" ; Test-Path \"$env:APPDATA\\\\ReminderOrganizer\")",
"PowerShell(Get-ChildItem \"$env:TEMP\\\\.net\\\\ReminderOrganizer\" -Recurse -Filter tasks.json -ErrorAction SilentlyContinue | select FullName,Length,LastWriteTime)",
"PowerShell(cd d:\\\\Oculusquest\\\\Projekt\\\\ReminderOrganizer; if \\(-not \\(Select-String -Path ServiceLocator.cs -Pattern \"using System.Linq\" -Quiet\\)\\) { \\(Get-Content -Raw ServiceLocator.cs\\) -replace \"using System;\",\"using System;`r`nusing System.Linq;\" | Set-Content -Encoding utf8 ServiceLocator.cs }; dotnet build ReminderOrganizer.csproj -nologo -v q 2>&1 | Select-String \"Fehler|error\"; git commit -qam \"Migrate tasks.json from v1.0 single-file extract dir`n`nCo-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>\"; node D:\\\\Oculusquest\\\\Projekt\\\\_Tools\\\\Library\\\\tools\\\\project-check.mjs \"d:\\\\Oculusquest\\\\Projekt\\\\ReminderOrganizer\")",
"PowerShell(cd d:\\\\Oculusquest\\\\Projekt\\\\ReminderOrganizer; cmd /c \"release.bat x\" 2>&1 | Select-String \"FERTIG|FEHLER|Bestanden|Fehler:\" ; Get-Item publish\\\\ReminderOrganizer.exe, ReminderOrganizer.zip | select Name,@{n='MB';e={[math]::Round\\($_.Length/1MB,1\\)}},LastWriteTime; git add -A; git commit -qm \"Compact task list and tighter spacing`n`nCo-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>\"; git log --oneline -1)"
"PowerShell(cd d:\\\\Oculusquest\\\\Projekt\\\\ReminderOrganizer; cmd /c \"release.bat x\" 2>&1 | Select-String \"FERTIG|FEHLER|Bestanden|Fehler:\" ; Get-Item publish\\\\ReminderOrganizer.exe, ReminderOrganizer.zip | select Name,@{n='MB';e={[math]::Round\\($_.Length/1MB,1\\)}},LastWriteTime; git add -A; git commit -qm \"Compact task list and tighter spacing`n`nCo-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>\"; git log --oneline -1)",
"PowerShell(cd d:\\\\Oculusquest\\\\Projekt\\\\ReminderOrganizer; Remove-Item -Recurse -Force publish, ReminderOrganizer.zip -ErrorAction SilentlyContinue; dotnet publish ReminderOrganizer.csproj -c Release -r win-x64 --self-contained true -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -p:EnableCompressionInSingleFile=true -p:DebugType=none -o publish -nologo -v q 2>&1 | Select-String \"error|Fehler\"; Compress-Archive publish\\\\ReminderOrganizer.exe ReminderOrganizer.zip -Force; Get-Item publish\\\\ReminderOrganizer.exe, ReminderOrganizer.zip | select Name,@{n='MB';e={[math]::Round\\($_.Length/1MB,1\\)}},LastWriteTime)",
"PowerShell(Get-Process ReminderOrganizer -ErrorAction SilentlyContinue)",
"PowerShell(cd d:\\\\Oculusquest\\\\Projekt\\\\ReminderOrganizer; if \\(Get-Process ReminderOrganizer -ErrorAction SilentlyContinue\\) { \"LAEUFT NOCH\" } else { Remove-Item -Recurse -Force publish -ErrorAction SilentlyContinue; dotnet publish ReminderOrganizer.csproj -c Release -r win-x64 --self-contained true -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -p:EnableCompressionInSingleFile=true -p:DebugType=none -o publish -nologo -v q 2>&1 | Select-String \"error|Fehler\"; Compress-Archive publish\\\\ReminderOrganizer.exe ReminderOrganizer.zip -Force; Get-Item publish\\\\ReminderOrganizer.exe, ReminderOrganizer.zip | select Name,@{n='MB';e={[math]::Round\\($_.Length/1MB,1\\)}},LastWriteTime; \\(Get-Item publish\\\\ReminderOrganizer.exe\\).VersionInfo | select CompanyName,LegalCopyright,ProductVersion })",
"PowerShell(cd d:\\\\Oculusquest\\\\Projekt\\\\ReminderOrganizer; $v=\\(Get-Item publish\\\\ReminderOrganizer.exe\\).VersionInfo; \"$\\($v.CompanyName\\) | $\\($v.LegalCopyright\\) | $\\($v.ProductVersion\\)\"; Start-Process publish\\\\ReminderOrganizer.exe; Start-Sleep 3; Get-ChildItem \"$env:APPDATA\\\\ReminderOrganizer\" | select Name,Length,LastWriteTime)",
"PowerShell(Get-Content \"$env:APPDATA\\\\ReminderOrganizer\\\\tasks.json\" -Raw; Get-ChildItem \"$env:APPDATA\\\\ReminderOrganizer\" | select Name,LastWriteTime)",
"PowerShell(& \"d:\\\\Oculusquest\\\\Projekt\\\\ReminderOrganizer\\\\sprite-generator\\\\gen.cmd\" generate icon 2>&1 | Select -Last 8)",
"PowerShell(cd d:\\\\Oculusquest\\\\Projekt\\\\ReminderOrganizer; py -3.12 -I $env:TEMP\\\\mkico.py Assets\\\\Sprites\\\\icon.png Assets\\\\app.ico; Get-ChildItem Assets | select Name,Length)"
]
}
}

View File

@@ -17,7 +17,10 @@ namespace ReminderOrganizer
base.OnStartup(e);
// Only one instance: a second start would show duplicate reminders and race on tasks.json.
_singleInstance = new System.Threading.Mutex(true, "MichaelMedia.ReminderOrganizer", out var isFirst);
// Test runs with their own data folder (REMINDER_ORGANIZER_DATA) get their own lock.
var mutexName = "MichaelMedia.ReminderOrganizer" +
(Environment.GetEnvironmentVariable("REMINDER_ORGANIZER_DATA") is { Length: > 0 } d ? "." + d.GetHashCode() : "");
_singleInstance = new System.Threading.Mutex(true, mutexName, out var isFirst);
if (!isFirst)
{
Shutdown();
@@ -40,6 +43,7 @@ namespace ReminderOrganizer
protected override void OnExit(ExitEventArgs e)
{
(MainWindow as MainWindow)?.OnAppExit();
Services.NotificationService.SharedTrayIcon?.Dispose();
_singleInstance?.Dispose();
base.OnExit(e);

BIN
Assets/Sprites/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 KiB

BIN
Assets/app.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

BIN
Assets/app.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

26
Core/SystemPrefs.cs Normal file
View File

@@ -0,0 +1,26 @@
#nullable enable
using System.Globalization;
using Microsoft.Win32;
namespace ReminderOrganizer.Core
{
/// <summary>Defaults taken from Windows until the user picks something in the app.</summary>
public static class SystemPrefs
{
public static string Language(CultureInfo? culture = null) =>
(culture ?? CultureInfo.CurrentUICulture).TwoLetterISOLanguageName == "de" ? "de" : "en";
public static bool IsDarkMode()
{
try
{
using var key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize");
return key?.GetValue("AppsUseLightTheme") is int v && v == 0;
}
catch
{
return true;
}
}
}
}

View File

@@ -388,12 +388,7 @@
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<!-- App Icon and Title -->
<StackPanel Orientation="Horizontal" Margin="8,0,20,0" VerticalAlignment="Center">
<Border Width="28" Height="28" CornerRadius="6" Background="{DynamicResource PrimaryBrush}" Margin="0,0,10,0">
<Border.Effect>
<DropShadowEffect BlurRadius="10" ShadowDepth="0" Opacity="0.5" Color="#6366F1"/>
</Border.Effect>
<TextBlock Text="&#xEA8F;" FontFamily="Segoe MDL2 Assets" FontSize="14" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<Image Source="/Assets/app.png" Width="26" Height="26" Margin="0,0,10,0" RenderOptions.BitmapScalingMode="HighQuality"/>
<TextBlock Text="{Binding AppTitleText}" FontSize="14" FontWeight="SemiBold"
Foreground="{DynamicResource TextPrimaryBrush}" VerticalAlignment="Center"/>
</StackPanel>

View File

@@ -57,6 +57,13 @@ namespace ReminderOrganizer
SyncTreeSelection();
}
public void OnAppExit()
{
if (!_initialized) return;
_viewModel.Cleanup();
_viewModel.FlushSave();
}
private void TrySetWindowIcon()
{
try

View File

@@ -167,7 +167,9 @@ namespace ReminderOrganizer.Models
public class AppData
{
public ObservableCollection<Folder> Folders { get; set; } = new();
public string Language { get; set; } = "en";
public bool IsDarkMode { get; set; } = true;
/// <summary>"de"/"en"; empty = not chosen yet → Windows display language.</summary>
public string Language { get; set; } = "";
/// <summary>null = not chosen yet → Windows app theme.</summary>
public bool? IsDarkMode { get; set; }
}
}

View File

@@ -18,7 +18,7 @@
<Version>1.1.0</Version>
</PropertyGroup>
<PropertyGroup Condition="Exists('Assets\app.ico')">
<PropertyGroup>
<ApplicationIcon>Assets\app.ico</ApplicationIcon>
</PropertyGroup>
@@ -37,7 +37,8 @@
<ItemGroup>
<EmbeddedResource Include="Locales\*.json" LogicalName="Locales.%(Filename).json" />
<Resource Include="Assets\app.ico" Condition="Exists('Assets\app.ico')" />
<Resource Include="Assets\app.ico" />
<Resource Include="Assets\app.png" />
</ItemGroup>
<ItemGroup>

View File

@@ -21,6 +21,8 @@ namespace ReminderOrganizer
services.AddSingleton<IDataService>(_ =>
{
var ds = new DataService();
if (Environment.GetEnvironmentVariable("REMINDER_ORGANIZER_DATA") is { Length: > 0 })
return ds; // isolated test/screenshot run: never pull in real data
// Older versions stored tasks.json next to the exe (or in the single-file extract dir).
ds.MigrateFrom(System.IO.Path.GetDirectoryName(Environment.ProcessPath));
ds.MigrateFrom(AppContext.BaseDirectory);

View File

@@ -84,6 +84,29 @@ namespace ReminderOrganizer.Services
catch { }
}
public void Save(AppData data)
{
_writeLock.Wait();
try
{
var tmp = DataFilePath + ".tmp";
File.WriteAllText(tmp, JsonSerializer.Serialize(data, _jsonOptions));
Commit(tmp);
}
finally
{
_writeLock.Release();
}
}
private void Commit(string tmp)
{
if (File.Exists(DataFilePath))
File.Replace(tmp, DataFilePath, DataFilePath + ".bak");
else
File.Move(tmp, DataFilePath);
}
public async Task SaveAsync(AppData data)
{
await _writeLock.WaitAsync();
@@ -92,10 +115,7 @@ namespace ReminderOrganizer.Services
var json = JsonSerializer.Serialize(data, _jsonOptions);
var tmp = DataFilePath + ".tmp";
await File.WriteAllTextAsync(tmp, json);
if (File.Exists(DataFilePath))
File.Replace(tmp, DataFilePath, DataFilePath + ".bak");
else
File.Move(tmp, DataFilePath);
Commit(tmp);
}
catch (Exception ex)
{

View File

@@ -10,6 +10,7 @@ namespace ReminderOrganizer.Services
{
Task<AppData> LoadAsync();
Task SaveAsync(AppData data);
void Save(AppData data);
string DataFilePath { get; }
}

View File

@@ -57,9 +57,15 @@ namespace ReminderOrganizer.Services
public void Initialize(AppData appData)
{
_appData = appData;
if (!string.IsNullOrEmpty(appData.Language))
var lang = string.IsNullOrEmpty(appData.Language) ? Core.SystemPrefs.Language() : appData.Language;
if (lang == _currentLanguage)
{
SetLanguage(appData.Language);
appData.Language = lang;
StringsChanged?.Invoke(this, EventArgs.Empty);
}
else
{
SetLanguage(lang);
}
}

View File

@@ -216,15 +216,16 @@ namespace ReminderOrganizer.ViewModels
{
IsLoading = true;
_appData = await _dataService.LoadAsync();
_localizationService.Initialize(_appData);
bool firstRun = string.IsNullOrEmpty(_appData.Language) || _appData.IsDarkMode == null || _appData.Folders.Count == 0;
_appData.IsDarkMode ??= SystemPrefs.IsDarkMode();
_localizationService.Initialize(_appData); // fills Language from Windows if empty
if (_appData.Folders.Count == 0)
{
_appData.Folders.Add(new Folder(L("MyTasks")));
if (firstRun)
await SaveAsync();
}
_isDarkMode = _appData.IsDarkMode;
_isDarkMode = _appData.IsDarkMode.Value;
OnPropertyChanged(nameof(IsDarkMode));
OnPropertyChanged(nameof(Folders));
SelectedFolder = _appData.Folders.FirstOrDefault();
@@ -433,5 +434,12 @@ namespace ReminderOrganizer.ViewModels
{
_reminderTimer.Stop();
}
/// <summary>Synchronous last save on exit – an async save still running would be cut off.</summary>
public void FlushSave()
{
try { _dataService.Save(_appData); }
catch (Exception ex) { System.Diagnostics.Debug.WriteLine($"[FlushSave] {ex.Message}"); }
}
}
}

View File

@@ -1,18 +1,10 @@
"""Was generate.py erzeugt.
PROMPTS = [(name, positive)] oder [(name, positive, negative)]
SIZES = {name: (breite, höhe)} optional, sonst Größe des Workflows (1024x1024)
Immer "plain solid black background" verlangen, nie "transparent": cutout.py/adopt.py
stellen den schwarzen Hintergrund deterministisch frei.
"""
_STYLE = (
"game sprite, clean outline, bold colours, soft shading, "
"centred single subject, plain solid black background"
)
"""Was generate.py erzeugt. Immer "plain solid black background", nie "transparent"."""
PROMPTS = [
("example_coin", f"a shiny gold coin, {_STYLE}"),
("icon",
"app icon, a friendly rounded bell with a small green checkmark badge at the lower right, "
"indigo #6366F1 and white, soft gradient, glossy modern flat style, thick clean shapes, "
"readable at small size, centred single subject, plain solid black background"),
]
SIZES = {}
SIZES = {"icon": (1024, 1024)}