settings clean up

This commit is contained in:
Alex
2025-09-01 01:45:53 -07:00
parent 7929d43c1c
commit e41a5eaea9
2 changed files with 23 additions and 31 deletions
-3
View File
@@ -1,7 +1,6 @@
namespace MercuryConverter;
using System;
using Avalonia;
using Avalonia.Logging;
@@ -15,8 +14,6 @@ class Program
[STAThread]
public static void Main(string[] args)
{
new Settings();
try
{
BuildAvaloniaApp()
+23 -28
View File
@@ -14,41 +14,38 @@ public enum Theme
public partial class Settings : ObservableObject
{
public static Settings? I;
public readonly static Settings I = new();
private string iniPath;
public string AppDataPath =>
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "muskit", "MercuryConverter");
[ObservableProperty]
private string dataPath = "";
[ObservableProperty]
private string exportPath = "";
[ObservableProperty]
private string concurrentExports = (Environment.ProcessorCount/2).ToString();
[ObservableProperty] private string dataPath = "";
[ObservableProperty] private string exportPath = "";
[ObservableProperty]
private Theme theme = Theme.System;
[ObservableProperty] private string concurrentExports = (Environment.ProcessorCount/2).ToString();
[ObservableProperty] private Theme theme = Theme.System;
protected override void OnPropertyChanged(PropertyChangedEventArgs e)
{
Console.Write($"Setting {e.PropertyName} changed to ");
switch (e.PropertyName)
{
case nameof(DataPath):
Console.WriteLine(DataPath);
break;
case nameof(ExportPath):
Console.WriteLine(ExportPath);
break;
case nameof(ConcurrentExports):
Console.WriteLine(ConcurrentExports);
break;
default:
Console.WriteLine("unknown variable");
break;
}
// Console.Write($"Setting {e.PropertyName} changed to ");
// switch (e.PropertyName)
// {
// case nameof(DataPath):
// Console.WriteLine(DataPath);
// break;
// case nameof(ExportPath):
// Console.WriteLine(ExportPath);
// break;
// case nameof(ConcurrentExports):
// Console.WriteLine(ConcurrentExports);
// break;
// default:
// Console.WriteLine("unknown variable");
// break;
// }
SaveToIni();
base.OnPropertyChanged(e);
@@ -56,8 +53,6 @@ public partial class Settings : ObservableObject
public Settings()
{
I = this;
Console.WriteLine($"Settings path: {AppDataPath}");
iniPath = Path.Combine(AppDataPath, "settings.ini");
@@ -69,7 +64,7 @@ public partial class Settings : ObservableObject
catch (Exception e)
{
Console.WriteLine($"Couldn't read {iniPath}!\n{e.Message}");
Console.WriteLine("Attempting to create new settings file.");
Console.WriteLine("Creating new settings file.");
SaveToIni();
}
}