Пример #1
0
        /// <summary>
        /// Creates a localized string from a .INI file.
        /// </summary>
        /// <param name="ini">The .ini file to load from.</param>
        /// <param name="section">The section in which the string is stored.</param>
        /// <param name="key">The key to load from. Languages others than <see cref="Toolbox.DEFAULT_LANGUAGE"/> are loaded from keys with the name of the language appended (e.g. "mystring.lituanian")</param>
        public LocalizedString(INIFile ini, string section, string key)
        {
            Strings = new Dictionary <string, string> {
                { Toolbox.DEFAULT_LANGUAGE, ini.GetValue <string>(section, key) }
            };

            foreach (string k in ini.GetKeysInSection(section))
            {
                if (!k.StartsWith(key + "."))
                {
                    continue;
                }
                string language = k.Substring(k.Length + 1).ToLowerInvariant();
                if (Strings.ContainsKey(language))
                {
                    continue;
                }
                Strings.Add(language, ini.GetValue <string>(section, k));
            }
        }
        private static void Main(string[] args)
        {
            Console.Title = "BriefingRoom output console";
            DebugLog.Instance.CreateLogFileWriter();

            using (INIFile ini = new INIFile($"{BRPaths.DATABASE}Common.ini"))
                TARGETED_DCS_WORLD_VERSION = ini.GetValue("Versions", "DCSVersion", "2.5");

            if (args.Length > 0)                // Command-line arguments are present, use the command-line tool
            {
                Database.Instance.Initialize(); // Called here in command-line mode, when in GUI mode function is called by the SplashScreen
                if (DebugLog.Instance.ErrorCount > 0)
                {
                    return;                                   // Errors found, abort! abort!
                }
                try
                {
                    using (CommandLineTool clt = new CommandLineTool())
                        clt.DoCommandLine(args);
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"ERROR: {ex.Message}");
                }

#if DEBUG
                Console.WriteLine();
                Console.WriteLine("Press any key to close this window");
                Console.ReadKey();
#endif
            }
            else // No command-line, use the GUI tool
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                // Display the splash screen while the database is being loaded
                using (SplashScreenForm splashScreen = new SplashScreenForm())
                {
                    splashScreen.ShowDialog();
                    if (splashScreen.AbortStartup)
                    {
                        return;
                    }
                }

                Application.Run(new MainForm());
            }

            DebugLog.Instance.CloseLogFileWriter();
        }