mirror of
https://github.com/k1tbyte/Wand-Enhancer.git
synced 2026-08-30 22:01:23 +00:00
e04e313fa3
Introduce IShellView and IFileDialogs so MainWindowVm no longer holds the concrete window or reaches through MainWindow.Instance, and file pickers are injectable. Run Restore off the UI thread like Patch and gate both buttons on IsBusy. Gate the log commands on a non-empty log. Move runtime log messages into the locale dictionaries and add the 14 new keys to all 12 languages. Track the injected locale dictionary so switching language replaces it instead of appending a new one each time. Remove the unused InfoItem control, ToVisibilityInvertedConverter, mw_title and the popup placeholder title.
48 lines
1.3 KiB
C#
48 lines
1.3 KiB
C#
using System;
|
|
using System.IO;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace WandEnhancer.Core.Services
|
|
{
|
|
public class AppSettings
|
|
{
|
|
public string Language { get; set; }
|
|
}
|
|
|
|
public static class SettingsManager
|
|
{
|
|
private static readonly string SettingsPath = Path.Combine(
|
|
AppDomain.CurrentDomain.BaseDirectory,
|
|
Constants.AppSettingsFileName);
|
|
|
|
public static AppSettings LoadSettings()
|
|
{
|
|
try
|
|
{
|
|
if (File.Exists(SettingsPath))
|
|
{
|
|
var json = File.ReadAllText(SettingsPath);
|
|
return JsonConvert.DeserializeObject<AppSettings>(json);
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
// Unreadable or corrupt settings must not block startup; defaults apply.
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static void SaveSettings(AppSettings settings)
|
|
{
|
|
try
|
|
{
|
|
var json = JsonConvert.SerializeObject(settings, Formatting.Indented);
|
|
File.WriteAllText(SettingsPath, json);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
// A read-only install directory must not break the app; the choice is lost, not fatal.
|
|
}
|
|
}
|
|
}
|
|
} |