using System; using System.Collections.Generic; using System.IO; using System.Text.Json; namespace LanDiscovery.Services { public class UserSettings { public string? LastNicId { get; set; } public List LastRanges { get; set; } = new List(); public bool DarkMode { get; set; } = false; } public class SettingsService { private const string FileName = "settings.json"; public void Save(UserSettings settings) { try { var json = JsonSerializer.Serialize(settings); File.WriteAllText(FileName, json); } catch { } } public UserSettings Load() { try { if (File.Exists(FileName)) { var json = File.ReadAllText(FileName); return JsonSerializer.Deserialize(json) ?? new UserSettings(); } } catch { } return new UserSettings(); } } }