static void Main(string[] args) { Application.EnableVisualStyles(); bool appsettingserror = false; foreach (string s in new string[] { "sox_path", "madplay_path", "vgmstream_path", "lame_path", "faad_path" }) { string v = ConfigurationManager.AppSettings[s]; if (string.IsNullOrEmpty(v)) { appsettingserror = true; Console.Error.WriteLine("The configuration setting " + s + " is missing."); } else if (!File.Exists(ConfigurationManager.AppSettings[s])) { appsettingserror = true; Console.Error.WriteLine("Could not find " + s + ": " + v); } } if (appsettingserror) { MessageBox.Show("One or more programs could not be found; the program may not run properly. See the console for details."); } string ini = null; List <string> initialInputFiles = new List <string>(); bool auto = false; foreach (string arg in args) { if (arg == "--auto") { auto = true; } else if (Path.GetExtension(arg).ToLowerInvariant() == ".ini") { if (ini != null) { throw new Exception("You cannot specify more than one .ini file."); } ini = arg; } else { initialInputFiles.Add(arg); } } OptionsForm f = new OptionsForm(); if (File.Exists(ini ?? "LoopingAudioConverter.ini")) { f.LoadOptions(ini ?? "LoopingAudioConverter.ini"); } f.AddInputFiles(initialInputFiles); if (auto) { Run(f.GetOptions(), showEndDialog: false); } else { Application.Run(f); Task.WaitAll(f.RunningTasks.ToArray()); } }
static void Main(string[] args) { Application.EnableVisualStyles(); List <string> errors = new List <string>(0); foreach (string s in new string[] { "sox_path", "vgmstream_path", "lame_path", "faad_path" }) { string v = ConfigurationManager.AppSettings[s]; if (string.IsNullOrEmpty(v)) { errors.Add("The configuration setting " + s + " is missing"); } else if (!File.Exists(ConfigurationManager.AppSettings[s])) { errors.Add($"Could not find {s} ({v})"); } } if (errors.Any()) { MessageBox.Show("One or more programs could not be found; the program may not run properly:" + Environment.NewLine + string.Join(Environment.NewLine, errors)); } string ini = null; List <string> initialInputFiles = new List <string>(); bool auto = false; foreach (string arg in args) { if (arg == "--auto") { auto = true; } else if (Path.GetExtension(arg).ToLowerInvariant() == ".xml") { if (ini != null) { throw new Exception("You cannot specify more than one .xml file."); } ini = arg; } else { initialInputFiles.Add(arg); } } OptionsForm f = new OptionsForm(); if (File.Exists(ini ?? "LoopingAudioConverter.xml")) { f.LoadOptions(ini ?? "LoopingAudioConverter.xml"); } f.AddInputFiles(initialInputFiles); if (auto) { RunAsync(f.GetOptions(), showEndDialog: false).GetAwaiter().GetResult(); } else { Application.Run(f); Task.WaitAll(f.RunningTasks.ToArray()); } }