context: using System;
  using System.Collections.Generic;
  using System.Diagnostics;
  using System.IO;
  using System.Runtime.InteropServices;
  using System.Text.RegularExpressions;
  using Core.Models;
  using Microsoft.Win32;
  
  namespace Core
  {
      public static class AppSettings
      {
          public static string AUTHOR = "AkiVer";
          public static string APP_NAME = "CSGO Demos Manager";
          public static string APP_WEBSITE = "https://csgo-demos-manager.com";
          public static Version APP_VERSION = new Version("2.13.15");
          private const string MATCH_LIST_FILENAME = "matches.dat";
          public const string PROCESS_NAME = "CSGODemosManager";
          public const string CSGO_PROCESS_NAME = "csgo";
          public const string BOT_PROCESS_NAME = "CSGOSuspectsBot";
          public const string RESOURCES_URI = "pack://application:,,,/csgodm.resources;component/";
  
          public const string CORE_URI = "pack://application:,,,/csgodm.core;component/";
  
          // Dummy file name created from the installer to clear data cache at the 1st start of the app
          public const string DUMMY_CACHE_FILENAME = "cache";
  
          // Round end reason strings for serialization
          public const string CT_WIN = "Counter-Terrorists win";
          public const string T_WIN = "Terrorists win";
          public const string BOMB_EXPLODED = "Bomb exploded";
          public const string BOMB_DEFUSED = "Bomb defused";
          public const string CT_SURRENDER = "CT surrender";
          public const string T_SURRENDER = "T surrender";
          public const string TARGET_SAVED = "Time over";
  
          // Round type strings for serialization
          public const string ECO = "Eco";
          public const string SEMI_ECO = "Semi-Eco";
          public const string NORMAL = "Normal";
          public const string PISTOL_ROUND = "Pistol round";
          public const string FORCE_BUY = "Force buy";
  
          // Unknown string for serialization
          public const string UNKNOWN = "Unknown";
  
          public static Regex STEAM_COMMUNITY_URL_REGEX =
              new Regex("(?:https?:\\/\\/)?steamcommunity\\.com\\/(?:profiles|id)\\/(?<steamID>[a-zA-Z0-9]+)");
  
          public const string STEAM_COMMUNITY_URL = "https://steamcommunity.com/profiles/{0}";
  
          public static List<Language> LANGUAGES = new List<Language>()
          {
              new Language
              {
                  Key = "ar-EG",
                  Name = "Arabic",
                  IsEnabled = false,
              },
              new Language
              {
                  Key = "pt-BR",
                  Name = "Brazilian",
                  IsEnabled = true,
              },
              new Language
              {
                  Key = "zh-Hans",
                  Name = "Chinese (Simplified)",
                  IsEnabled = true,
              },
              new Language
              {
                  Key = "zh-Hant",
                  Name = "Chinese (Traditional)",
                  IsEnabled = false,
              },
              new Language
              {
                  Key = "hr-Hr",
                  Name = "Crotian",
                  IsEnabled = false,
              },
              new Language
              {
                  Key = "da-DK",
                  Name = "Danish",
                  IsEnabled = true,
              },
              new Language
              {
                  Key = "nl-BE",
                  Name = "Dutch",
                  IsEnabled = false,
              },
              new Language
              {
                  Key = "en-US",
                  Name = "English",
                  IsEnabled = true,
              },
              new Language
              {
                  Key = "fr-FR",
                  Name = "French",
                  IsEnabled = true,
              },
              new Language
              {
                  Key = "de-DE",
                  Name = "German",
                  IsEnabled = true,
              },
              new Language
              {
                  Key = "hu-HU",
                  Name = "Hungarian",
                  IsEnabled = true,
              },
              new Language
              {
                  Key = "it-IT",
                  Name = "Italian",
                  IsEnabled = false,
              },
              new Language
              {
                  Key = "ja-JP",
                  Name = "Japanese",
                  IsEnabled = false,
              },
              new Language
              {
                  Key = "pl-PL",
                  Name = "Polish",
                  IsEnabled = true,
              },
              new Language
              {
                  Key = "pt-PT",
                  Name = "Portuguese",
                  IsEnabled = false,
              },
              new Language
              {
                  Key = "ru-RU",
                  Name = "Russian",
                  IsEnabled = false,
              },
              new Language
              {
                  Key = "sr-Cyrl",
                  Name = "Serbian",
                  IsEnabled = false,
              },
              new Language
              {
                  Key = "es-ES",
                  Name = "Spanish",
                  IsEnabled = true,
              },
              new Language
              {
                  Key = "tr",
                  Name = "Turkish",
                  IsEnabled = true,
              },
          };
  
          /// <summary>
          /// Return the Steam exe path from the registry
          /// </summary>
          /// <returns></returns>
          public static string SteamExePath()
          {
              return (string)Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Valve\Steam", "SteamExe", null);
          }
  
          /// <summary>
          /// Return the Steam path
          /// </summary>
          /// <returns></returns>
          public static string SteamPath()
          {
              return (string)Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Valve\Steam", "SteamPath", null);
          }
  
          /// <summary>
          /// Return the CSGO path (csgo folder)
          /// </summary>
          /// <returns></returns>
          public static string GetCsgoPath()
          {
              string steamPath = (string)Registry.GetValue("HKEY_CURRENT_USER\\Software\\Valve\\Steam", "SteamPath", "");
  
              if (steamPath == null)
              {
                  return null;
              }
  
              steamPath = steamPath.Replace("/", "\\");
  
              string pathsFile = Path.Combine(steamPath, "steamapps", "libraryfolders.vdf");
  
              if (!File.Exists(pathsFile))
              {
                  return null;
              }
  
              List<string> libraries = new List<string>
              {
                  Path.Combine(steamPath),
              };
  
              var pathVDF = File.ReadAllLines(pathsFile);
  
              // This is not a full vdf-parser, but it seems to work pretty much, since the vdf-grammar
              // is pretty easy. Hopefully it never breaks. It should be replaced with a full vdf-parser
              Regex pathRegex = new Regex(@"\""(([^\""]*):\\([^\""]*))\""");
              foreach (var line in pathVDF)
              {
                  if (pathRegex.IsMatch(line))
                  {
  
gt:                     string match = pathRegex.Matches(line)[0].Groups[1].Value;