using System; using System.IO; using System.Windows.Forms; namespace NHSE.WinForms; internal static class Program { /// /// Directory where the executable is located. /// private static readonly string WorkingDirectory = Path.GetDirectoryName(Environment.ProcessPath) ?? ""; /// /// Settings file name. /// private const string ConfigFileName = "settings.json"; /// /// Full path to the settings file. /// private static string PathConfig => Path.Combine(WorkingDirectory, ConfigFileName); /// /// Application settings, loaded at startup. /// public static ApplicationSettings Settings { get; } /// /// Static constructor to load settings as early as possible. /// static Program() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Settings = ApplicationSettings.Load(PathConfig); WinFormsUtil.SetApplicationTheme(Settings.DarkMode); } /// /// The main entry point for the application. /// [STAThread] private static void Main() { var args = Environment.GetCommandLineArgs(); if (args.Contains("-dark")) WinFormsUtil.SetApplicationTheme(SystemColorMode.Dark); Application.Run(new Main()); } public static void SaveSettings() => Settings.Save(PathConfig); }