From 300e842cb2c4995eba38706dad4751f258e5ca01 Mon Sep 17 00:00:00 2001 From: Korney Czukowski Date: Tue, 19 Dec 2017 14:13:43 +0100 Subject: [PATCH] Filter language assemblies by name --- DS4Windows/DS4Forms/LanguagePackComboBox.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/DS4Windows/DS4Forms/LanguagePackComboBox.cs b/DS4Windows/DS4Forms/LanguagePackComboBox.cs index 6cfe670..3ee31dc 100644 --- a/DS4Windows/DS4Forms/LanguagePackComboBox.cs +++ b/DS4Windows/DS4Forms/LanguagePackComboBox.cs @@ -13,6 +13,7 @@ namespace DS4Windows.DS4Forms public partial class LanguagePackComboBox : UserControl { private string _probingPath = ""; + private string _languageAssemblyName = "DS4Windows.resources.dll"; [Category("Action")] [Description("Fires when the combo box selected index is changed.")] @@ -43,6 +44,14 @@ namespace DS4Windows.DS4Forms set { this._probingPath = value; } } + [Category("Data")] + [Description("Filter language assembly file names in order to ont include irrelevant assemblies to the combo box.")] + public string LanguageAssemblyName + { + get { return this._languageAssemblyName; } + set { this._languageAssemblyName = value; } + } + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public int SelectedIndex { @@ -89,7 +98,7 @@ namespace DS4Windows.DS4Forms // Get all culture for which satellite folder found with culture code. Dictionary cultures = CultureInfo.GetCultures(CultureTypes.AllCultures) - .Where(c => this.IsLanguageAssemblyAvailable(lookupPaths, c)) + .Where(c => c.Equals(CultureInfo.InvariantCulture) || this.IsLanguageAssemblyAvailable(lookupPaths, c)) .ToDictionary(c => c.Name, c => c.Equals(CultureInfo.InvariantCulture) ? this.InvariantCultureText : c.NativeName); return new BindingSource(cultures, null); @@ -97,8 +106,8 @@ namespace DS4Windows.DS4Forms private bool IsLanguageAssemblyAvailable(List lookupPaths, CultureInfo culture) { - return lookupPaths.Select(path => Path.Combine(path, culture.Name)) - .Where(path => Directory.Exists(path)) + return lookupPaths.Select(path => Path.Combine(path, culture.Name, this.LanguageAssemblyName)) + .Where(path => File.Exists(path)) .Count() > 0; }