-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
59 lines (53 loc) · 1.68 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System;
using System.IO;
using System.Text.Json;
using System.Windows.Forms;
namespace FNFCoverManager
{
internal static class Program
{
internal class SongDirectory
{
public string Name { get; set; }
public string Path { get; set; }
}
internal class Config
{
public List<SongDirectory> SongDirs { get; set; }
public List<CoverDirectory> CoverDirs { get; set; }
}
internal class CoverDirectory
{
public string SongName { get; set; }
public string CoverName { get; set; }
public string Path { get; set; }
}
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// Load the JSON config
string configPath = @"fnfcovermanager_config.json";
Config config = LoadConfig(configPath);
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new Form1(config));
}
static Config LoadConfig(string path)
{
try
{
string jsonString = File.ReadAllText(path);
return JsonSerializer.Deserialize<Config>(jsonString);
}
catch (Exception ex)
{
MessageBox.Show($"Failed to load config: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return null;
}
}
}
}