Implement PC/SC-based NFC card reader monitoring application with WPF UI. Features include: - System tray integration with single-click to open main window - Dynamic reader detection and management with enable/disable per reader - NDEF payload extraction supporting Type 2 and Type 4 tags - Auto-detection of block sizes (4-byte vs 16-byte) for different reader types - Configurable actions: copy to clipboard, launch URLs, keyboard input simulation - URI record type detection - only launches browser for actual URI records - Real-time activity logging with color-coded levels (Debug, Info, Warning, Error) - File-based debug logging for troubleshooting - Settings persistence between sessions - Dangerous Things branding with custom icons and clickable logo 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
54 lines
1.3 KiB
C#
54 lines
1.3 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Text.Json;
|
|
using NfcActions.Models;
|
|
|
|
namespace NfcActions.Services;
|
|
|
|
public class SettingsService
|
|
{
|
|
private readonly string _settingsPath;
|
|
|
|
public SettingsService()
|
|
{
|
|
var appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
|
var appFolder = Path.Combine(appDataPath, "NfcActions");
|
|
Directory.CreateDirectory(appFolder);
|
|
_settingsPath = Path.Combine(appFolder, "settings.json");
|
|
}
|
|
|
|
public AppSettings Load()
|
|
{
|
|
try
|
|
{
|
|
if (File.Exists(_settingsPath))
|
|
{
|
|
var json = File.ReadAllText(_settingsPath);
|
|
return JsonSerializer.Deserialize<AppSettings>(json) ?? new AppSettings();
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
// Failed to load settings, return defaults
|
|
}
|
|
|
|
return new AppSettings();
|
|
}
|
|
|
|
public void Save(AppSettings settings)
|
|
{
|
|
try
|
|
{
|
|
var json = JsonSerializer.Serialize(settings, new JsonSerializerOptions
|
|
{
|
|
WriteIndented = true
|
|
});
|
|
File.WriteAllText(_settingsPath, json);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
// Failed to save settings
|
|
}
|
|
}
|
|
}
|