mirror of
https://github.com/muskit/MercuryConverter.git
synced 2026-06-02 20:24:26 -07:00
settings clean up
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
namespace MercuryConverter;
|
namespace MercuryConverter;
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Logging;
|
using Avalonia.Logging;
|
||||||
|
|
||||||
@@ -15,8 +14,6 @@ class Program
|
|||||||
[STAThread]
|
[STAThread]
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
new Settings();
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
BuildAvaloniaApp()
|
BuildAvaloniaApp()
|
||||||
|
|||||||
+23
-28
@@ -14,41 +14,38 @@ public enum Theme
|
|||||||
|
|
||||||
public partial class Settings : ObservableObject
|
public partial class Settings : ObservableObject
|
||||||
{
|
{
|
||||||
public static Settings? I;
|
public readonly static Settings I = new();
|
||||||
|
|
||||||
private string iniPath;
|
private string iniPath;
|
||||||
|
|
||||||
public string AppDataPath =>
|
public string AppDataPath =>
|
||||||
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "muskit", "MercuryConverter");
|
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "muskit", "MercuryConverter");
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty] private string dataPath = "";
|
||||||
private string dataPath = "";
|
[ObservableProperty] private string exportPath = "";
|
||||||
[ObservableProperty]
|
|
||||||
private string exportPath = "";
|
|
||||||
[ObservableProperty]
|
|
||||||
private string concurrentExports = (Environment.ProcessorCount/2).ToString();
|
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty] private string concurrentExports = (Environment.ProcessorCount/2).ToString();
|
||||||
private Theme theme = Theme.System;
|
|
||||||
|
[ObservableProperty] private Theme theme = Theme.System;
|
||||||
|
|
||||||
protected override void OnPropertyChanged(PropertyChangedEventArgs e)
|
protected override void OnPropertyChanged(PropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
Console.Write($"Setting {e.PropertyName} changed to ");
|
// Console.Write($"Setting {e.PropertyName} changed to ");
|
||||||
switch (e.PropertyName)
|
// switch (e.PropertyName)
|
||||||
{
|
// {
|
||||||
case nameof(DataPath):
|
// case nameof(DataPath):
|
||||||
Console.WriteLine(DataPath);
|
// Console.WriteLine(DataPath);
|
||||||
break;
|
// break;
|
||||||
case nameof(ExportPath):
|
// case nameof(ExportPath):
|
||||||
Console.WriteLine(ExportPath);
|
// Console.WriteLine(ExportPath);
|
||||||
break;
|
// break;
|
||||||
case nameof(ConcurrentExports):
|
// case nameof(ConcurrentExports):
|
||||||
Console.WriteLine(ConcurrentExports);
|
// Console.WriteLine(ConcurrentExports);
|
||||||
break;
|
// break;
|
||||||
default:
|
// default:
|
||||||
Console.WriteLine("unknown variable");
|
// Console.WriteLine("unknown variable");
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
SaveToIni();
|
SaveToIni();
|
||||||
|
|
||||||
base.OnPropertyChanged(e);
|
base.OnPropertyChanged(e);
|
||||||
@@ -56,8 +53,6 @@ public partial class Settings : ObservableObject
|
|||||||
|
|
||||||
public Settings()
|
public Settings()
|
||||||
{
|
{
|
||||||
I = this;
|
|
||||||
|
|
||||||
Console.WriteLine($"Settings path: {AppDataPath}");
|
Console.WriteLine($"Settings path: {AppDataPath}");
|
||||||
iniPath = Path.Combine(AppDataPath, "settings.ini");
|
iniPath = Path.Combine(AppDataPath, "settings.ini");
|
||||||
|
|
||||||
@@ -69,7 +64,7 @@ public partial class Settings : ObservableObject
|
|||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Couldn't read {iniPath}!\n{e.Message}");
|
Console.WriteLine($"Couldn't read {iniPath}!\n{e.Message}");
|
||||||
Console.WriteLine("Attempting to create new settings file.");
|
Console.WriteLine("Creating new settings file.");
|
||||||
SaveToIni();
|
SaveToIni();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user