public static bool ShowSelection() { LanguageWindow win = new LanguageWindow(); ComboBox cb = win.comboBox; cb.ItemsSource = Localization.Translations.Select(t => t.Name); string culture = "en"; CultureInfo info = CultureInfo.CurrentCulture; if (info != null) { for (int i = 0; i < 3; i++) // just to be safe, I don't know enough about cultureinfos { CultureInfo parent = info.Parent; if (parent == null || string.IsNullOrWhiteSpace(parent.Name)) { break; } info = parent; } culture = info.Name; } cb.SelectedIndex = Localization.GetLangByCulture(culture); win.UpdateTexts(); return(win.ShowDialog() == true); }
public MainWindow() { try { // choose language if (!LanguageWindow.ShowSelection()) { Close(); return; } // init main window InitializeComponent(); // set title this.Title = string.Format("{0} {1}", Localization.Get("Name"), Version.PatcherVersion); // check if we can already find the steam path const string key = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 40970"; RegistryKey myKey = Registry.LocalMachine.OpenSubKey(key, false); if (myKey != null && myKey.GetValue("InstallLocation") is string path && !string.IsNullOrWhiteSpace(path)) { pTextBoxPath.Text = path; } // fill setup options list FillTreeView(Version.Changes); // set translated ui elements pathBox.Text = Localization.Get("ui_searchpath"); pButtonCancel.Content = Localization.Get("ui_cancel"); pButtonContinue.Content = Localization.Get("ui_continue"); pButtonSearch.Content = Localization.Get("ui_search"); pButtonUninstall.Content = Localization.Get("ui_uninstall"); TextReferencer.SetText(linkLabel, "ui_welcometext"); var asm = System.Reflection.Assembly.GetExecutingAssembly(); using (Stream stream = asm.GetManifestResourceStream("UnofficialCrusaderPatch.license.txt")) using (StreamReader sr = new StreamReader(stream)) linkLabel.Inlines.Add("\n\n\n\n\n\n" + sr.ReadToEnd()); } catch (Exception e) { Debug.Error(e.ToString()); } }
public static bool ShowSelection() { LanguageWindow win = new LanguageWindow(); win.comboBox.ItemsSource = Languages; CultureInfo info = CultureInfo.CurrentCulture; int index = 1; if (info != null) { for (int i = 0; i < 3; i++) // just to be safe, I don't know enough about cultureinfos { CultureInfo parent = info.Parent; if (parent == null || string.IsNullOrWhiteSpace(parent.Name)) { break; } info = parent; } switch (info.Name) { case "de": index = 0; break; //case "en": //default: // selected = 1; // break; } } Localization.LanguageIndex = index; win.comboBox.SelectedIndex = index; win.UpdateTexts(); return(win.ShowDialog() == true); }