Initial commit: ReminderOrganizer WPF app

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 13:44:02 +01:00
commit 5ca2770829
37 changed files with 3350 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
#nullable enable
using System;
using Microsoft.Win32;
namespace ReminderOrganizer.Services
{
public class AutostartService : IAutostartService
{
private const string RegistryKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Run";
private const string AppName = "ReminderOrganizer";
public bool IsAutostartEnabled
{
get
{
try
{
using var key = Registry.CurrentUser.OpenSubKey(RegistryKey, false);
var path = key?.GetValue(AppName) as string;
return path == Environment.ProcessPath;
}
catch
{
return false;
}
}
}
public void ToggleAutostart()
{
try
{
using var key = Registry.CurrentUser.OpenSubKey(RegistryKey, true);
if (key == null) return;
if (IsAutostartEnabled)
{
key.DeleteValue(AppName, false);
}
else
{
var path = Environment.ProcessPath;
if (!string.IsNullOrEmpty(path))
{
key.SetValue(AppName, path);
}
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"[AutostartService] Failed: {ex.Message}");
}
}
}
}

57
Services/DataService.cs Normal file
View File

@@ -0,0 +1,57 @@
#nullable enable
using System;
using System.IO;
using System.Text.Json;
using System.Threading.Tasks;
using ReminderOrganizer.Models;
namespace ReminderOrganizer.Services
{
public class DataService : IDataService
{
private static readonly JsonSerializerOptions _jsonOptions = new()
{
WriteIndented = true,
PropertyNameCaseInsensitive = true
};
public string DataFilePath { get; }
public DataService()
{
DataFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "tasks.json");
}
public async Task<AppData> LoadAsync()
{
if (!File.Exists(DataFilePath))
return new AppData();
try
{
var json = await File.ReadAllTextAsync(DataFilePath);
var data = JsonSerializer.Deserialize<AppData>(json, _jsonOptions);
return data ?? new AppData();
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"[DataService] Load failed: {ex.Message}");
return new AppData();
}
}
public async Task SaveAsync(AppData data)
{
try
{
var json = JsonSerializer.Serialize(data, _jsonOptions);
await File.WriteAllTextAsync(DataFilePath, json);
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"[DataService] Save failed: {ex.Message}");
throw;
}
}
}
}

36
Services/Interfaces.cs Normal file
View File

@@ -0,0 +1,36 @@
#nullable enable
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using ReminderOrganizer.Models;
namespace ReminderOrganizer.Services
{
public interface IDataService
{
Task<AppData> LoadAsync();
Task SaveAsync(AppData data);
string DataFilePath { get; }
}
public interface INotificationService
{
void ShowNotification(string title, string message);
}
public interface ILocalizationService
{
string GetString(string key);
void SetLanguage(string languageCode);
string CurrentLanguage { get; }
event EventHandler? LanguageChanged;
event EventHandler? StringsChanged;
void Initialize(AppData appData);
}
public interface IAutostartService
{
bool IsAutostartEnabled { get; }
void ToggleAutostart();
}
}

View File

@@ -0,0 +1,136 @@
#nullable enable
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.Json;
using ReminderOrganizer.Models;
using ReminderOrganizer.Services;
namespace ReminderOrganizer.Services
{
public class LocalizationService : ILocalizationService
{
private Dictionary<string, string> _strings = new();
private string _currentLanguage = "en";
private AppData? _appData;
private readonly IDataService _dataService;
public string CurrentLanguage => _currentLanguage;
public event EventHandler? LanguageChanged;
public event EventHandler? StringsChanged;
public LocalizationService(IDataService dataService)
{
_dataService = dataService;
LoadLanguage(_currentLanguage);
}
public void SetLanguage(string languageCode)
{
if (_currentLanguage == languageCode) return;
_currentLanguage = languageCode;
LoadLanguage(languageCode);
if (_appData != null)
{
_appData.Language = languageCode;
_ = _dataService.SaveAsync(_appData);
}
LanguageChanged?.Invoke(this, EventArgs.Empty);
StringsChanged?.Invoke(this, EventArgs.Empty);
}
public void Initialize(AppData appData)
{
_appData = appData;
if (!string.IsNullOrEmpty(appData.Language))
{
SetLanguage(appData.Language);
}
}
public string GetString(string key)
{
return _strings.TryGetValue(key, out var value) ? value : key;
}
private void LoadLanguage(string languageCode)
{
var basePath = AppDomain.CurrentDomain.BaseDirectory;
var filePath = Path.Combine(basePath, "Locales", $"{languageCode}.json");
if (File.Exists(filePath))
{
try
{
var json = File.ReadAllText(filePath);
_strings = JsonSerializer.Deserialize<Dictionary<string, string>>(json) ?? new();
return;
}
catch { }
}
_strings = GetDefaultStrings(languageCode);
}
private static Dictionary<string, string> GetDefaultStrings(string lang)
{
return lang switch
{
"en" => new Dictionary<string, string>
{
["AppTitle"] = "Reminder Organizer",
["File"] = "File",
["Exit"] = "Exit",
["Settings"] = "Settings",
["Language"] = "Language",
["German"] = "German",
["English"] = "English",
["AddFolder"] = "+ Folder",
["AddTask"] = "+ Task",
["Welcome"] = "Welcome",
["NoFolderSelected"] = "No folder selected",
["Name"] = "Name",
["Description"] = "Description",
["Date"] = "Date",
["Save"] = "Save",
["Cancel"] = "Cancel",
["OK"] = "OK",
["SelectFolder"] = "Please select a folder first",
["AutostartEnabled"] = "Autostart enabled",
["AutostartDisabled"] = "Autostart disabled",
["SaveError"] = "Error saving data",
["Open"] = "Open",
["Delete"] = "Delete",
["Rename"] = "Rename"
},
_ => new Dictionary<string, string>
{
["AppTitle"] = "Reminder Organizer",
["File"] = "Datei",
["Exit"] = "Beenden",
["Settings"] = "Einstellungen",
["Language"] = "Sprache",
["German"] = "Deutsch",
["English"] = "Englisch",
["AddFolder"] = "+ Ordner",
["AddTask"] = "+ Task",
["Welcome"] = "Willkommen",
["NoFolderSelected"] = "Kein Ordner ausgewählt",
["Name"] = "Name",
["Description"] = "Beschreibung",
["Date"] = "Datum",
["Save"] = "Speichern",
["Cancel"] = "Abbrechen",
["OK"] = "OK",
["SelectFolder"] = "Bitte erst einen Ordner auswählen",
["AutostartEnabled"] = "Autostart aktiviert",
["AutostartDisabled"] = "Autostart deaktiviert",
["SaveError"] = "Fehler beim Speichern",
["Open"] = "Öffnen",
["Delete"] = "Löschen",
["Rename"] = "Umbenennen"
}
};
}
}
}

View File

@@ -0,0 +1,50 @@
#nullable enable
using System;
using System.Windows.Forms;
namespace ReminderOrganizer.Services
{
public class NotificationService : INotificationService
{
private readonly object _lock = new();
public static NotifyIcon? SharedTrayIcon { get; set; }
public void ShowNotification(string title, string message)
{
try
{
System.Diagnostics.Debug.WriteLine($"[NotificationService] ShowNotification: {title} - {message}");
System.Diagnostics.Debug.WriteLine($"[NotificationService] SharedTrayIcon is null: {SharedTrayIcon == null}");
ShowBalloonTip(title, message);
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"[NotificationService] Error: {ex.Message}");
}
}
private void ShowBalloonTip(string title, string message)
{
lock (_lock)
{
if (SharedTrayIcon != null)
{
SharedTrayIcon.BalloonTipTitle = title;
SharedTrayIcon.BalloonTipText = message;
SharedTrayIcon.BalloonTipIcon = ToolTipIcon.Info;
SharedTrayIcon.ShowBalloonTip(5000);
System.Diagnostics.Debug.WriteLine("[NotificationService] BalloonTip shown!");
}
else
{
System.Diagnostics.Debug.WriteLine("[NotificationService] SharedTrayIcon is null, cannot show balloon tip!");
}
}
}
public void Dispose()
{
}
}
}