Esempio n. 1
0
        public static void RunAsync(
			string localeName,
			string programPath,
			IEnumerable<string> arguments,
			string workingDirectory)
        {
            var localeInfoService = new LocaleInfoService();

            if (string.IsNullOrWhiteSpace(workingDirectory))
                workingDirectory = Path.GetDirectoryName(programPath);

            if (string.IsNullOrWhiteSpace(localeName))
                throw new ArgumentException("No locale selected");

            if (!localeInfoService.HasLocale(localeName))
                throw new ArgumentException(String.Format("Locale \"{0}\" isn't available", localeName));

            if (!File.Exists(programPath))
                throw new FileNotFoundException(String.Format("\"{0}\" not found", programPath));

            uint localeId = localeInfoService.LocaleNameToLocaleId(localeName).Value;
            Environment.SetEnvironmentVariable("__COMPAT_LAYER", "#ApplicationLocale");
            Environment.SetEnvironmentVariable("AppLocaleID", String.Format("{0:x4}", localeId));
            Environment.SetEnvironmentVariable("LANG", localeName);
            var start = new ProcessStartInfo
            {
                Arguments = string.Join(" ", arguments.Select(arg => "\"" + arg + "\"")),
                FileName = programPath,
                WorkingDirectory = workingDirectory,
            };

            Process.Start(start);
        }
Esempio n. 2
0
        public MainWindow()
        {
            InitializeComponent();
            MainWindowData = new MainWindowData();

            ILocaleInfoService localeInfoService = new LocaleInfoService();
            MainWindowData.AvailableLocales = localeInfoService.GetAvailableLocaleNames()
                .Select(localeInfo => new EncapsulatedLocaleInfo(localeInfoService.GetLocaleInfo(localeInfo)))
                .OrderBy(localeInfo => localeInfo.ToString())
                .ToList(); //necessary for getting "SelectedLocale" binding to work

            LoadConfig();

            if (MainWindowData.SelectedLocale == null)
                MainWindowData.SelectedLocale = MainWindowData.AvailableLocales
                    .FirstOrDefault(locale => locale.ToString().IndexOf("Japan", StringComparison.InvariantCultureIgnoreCase) >= 0);
        }