From 45ca80a494e0c9d2f202443b73092b2abef597fc Mon Sep 17 00:00:00 2001 From: Korney Czukowski Date: Thu, 8 Feb 2018 21:44:28 +0100 Subject: [PATCH 1/4] Postpone language packs list population until control Load event --- .../DS4Forms/LanguagePackComboBox.Designer.cs | 1 + DS4Windows/DS4Forms/LanguagePackComboBox.cs | 29 ++++++++++--------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/DS4Windows/DS4Forms/LanguagePackComboBox.Designer.cs b/DS4Windows/DS4Forms/LanguagePackComboBox.Designer.cs index 1ed1ff2..84e31df 100644 --- a/DS4Windows/DS4Forms/LanguagePackComboBox.Designer.cs +++ b/DS4Windows/DS4Forms/LanguagePackComboBox.Designer.cs @@ -55,6 +55,7 @@ this.Controls.Add(this.cbCulture); this.Controls.Add(this.label1); this.Name = "LanguagePackComboBox"; + this.Load += new System.EventHandler(this.LanguagePackComboBox_Load); this.SizeChanged += new System.EventHandler(this.LanguagePackComboBox_SizeChanged); this.Resize += new System.EventHandler(this.LanguagePackComboBox_SizeChanged); this.ResumeLayout(false); diff --git a/DS4Windows/DS4Forms/LanguagePackComboBox.cs b/DS4Windows/DS4Forms/LanguagePackComboBox.cs index b626f60..ae0ced5 100644 --- a/DS4Windows/DS4Forms/LanguagePackComboBox.cs +++ b/DS4Windows/DS4Forms/LanguagePackComboBox.cs @@ -78,19 +78,6 @@ namespace DS4Windows.DS4Forms { InitializeComponent(); cbCulture.Enabled = false; - - Task.Run(() => { - // Find available language assemblies and bind the list to the combo box. - cbCulture.DataSource = CreateLanguageAssembliesBindingSource(); - cbCulture.SelectedValue = Thread.CurrentThread.CurrentUICulture.Name; - - // This must be set here instead of Designer or event would fire at initial selected value setting above. - cbCulture.SelectedIndexChanged += new EventHandler(CbCulture_SelectedIndexChanged); - cbCulture.SelectedValueChanged += new EventHandler(CbCulture_SelectedValueChanged); - - cbCulture.Enabled = true; - LanguageListInitialized.SetResult(true); - }); } private BindingSource CreateLanguageAssembliesBindingSource() @@ -143,5 +130,21 @@ namespace DS4Windows.DS4Forms { SelectedValueChanged?.Invoke(this, e); } + + private void LanguagePackComboBox_Load(object sender, EventArgs e) + { + Invoke(new Action(() => { + // Find available language assemblies and bind the list to the combo box. + cbCulture.DataSource = CreateLanguageAssembliesBindingSource(); + cbCulture.SelectedValue = Thread.CurrentThread.CurrentUICulture.Name; + + // This must be set here instead of Designer or event would fire at initial selected value setting above. + cbCulture.SelectedIndexChanged += new EventHandler(CbCulture_SelectedIndexChanged); + cbCulture.SelectedValueChanged += new EventHandler(CbCulture_SelectedValueChanged); + + cbCulture.Enabled = true; + LanguageListInitialized.SetResult(true); + })); + } } } From 256711f696b1feded53590f20045d2c5f8313e3d Mon Sep 17 00:00:00 2001 From: Korney Czukowski Date: Sun, 11 Feb 2018 20:44:56 +0100 Subject: [PATCH 2/4] Revert "Postpone language packs list population until control Load event" This reverts commit 45ca80a494e0c9d2f202443b73092b2abef597fc. --- .../DS4Forms/LanguagePackComboBox.Designer.cs | 1 - DS4Windows/DS4Forms/LanguagePackComboBox.cs | 29 +++++++++---------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/DS4Windows/DS4Forms/LanguagePackComboBox.Designer.cs b/DS4Windows/DS4Forms/LanguagePackComboBox.Designer.cs index 84e31df..1ed1ff2 100644 --- a/DS4Windows/DS4Forms/LanguagePackComboBox.Designer.cs +++ b/DS4Windows/DS4Forms/LanguagePackComboBox.Designer.cs @@ -55,7 +55,6 @@ this.Controls.Add(this.cbCulture); this.Controls.Add(this.label1); this.Name = "LanguagePackComboBox"; - this.Load += new System.EventHandler(this.LanguagePackComboBox_Load); this.SizeChanged += new System.EventHandler(this.LanguagePackComboBox_SizeChanged); this.Resize += new System.EventHandler(this.LanguagePackComboBox_SizeChanged); this.ResumeLayout(false); diff --git a/DS4Windows/DS4Forms/LanguagePackComboBox.cs b/DS4Windows/DS4Forms/LanguagePackComboBox.cs index ae0ced5..b626f60 100644 --- a/DS4Windows/DS4Forms/LanguagePackComboBox.cs +++ b/DS4Windows/DS4Forms/LanguagePackComboBox.cs @@ -78,6 +78,19 @@ namespace DS4Windows.DS4Forms { InitializeComponent(); cbCulture.Enabled = false; + + Task.Run(() => { + // Find available language assemblies and bind the list to the combo box. + cbCulture.DataSource = CreateLanguageAssembliesBindingSource(); + cbCulture.SelectedValue = Thread.CurrentThread.CurrentUICulture.Name; + + // This must be set here instead of Designer or event would fire at initial selected value setting above. + cbCulture.SelectedIndexChanged += new EventHandler(CbCulture_SelectedIndexChanged); + cbCulture.SelectedValueChanged += new EventHandler(CbCulture_SelectedValueChanged); + + cbCulture.Enabled = true; + LanguageListInitialized.SetResult(true); + }); } private BindingSource CreateLanguageAssembliesBindingSource() @@ -130,21 +143,5 @@ namespace DS4Windows.DS4Forms { SelectedValueChanged?.Invoke(this, e); } - - private void LanguagePackComboBox_Load(object sender, EventArgs e) - { - Invoke(new Action(() => { - // Find available language assemblies and bind the list to the combo box. - cbCulture.DataSource = CreateLanguageAssembliesBindingSource(); - cbCulture.SelectedValue = Thread.CurrentThread.CurrentUICulture.Name; - - // This must be set here instead of Designer or event would fire at initial selected value setting above. - cbCulture.SelectedIndexChanged += new EventHandler(CbCulture_SelectedIndexChanged); - cbCulture.SelectedValueChanged += new EventHandler(CbCulture_SelectedValueChanged); - - cbCulture.Enabled = true; - LanguageListInitialized.SetResult(true); - })); - } } } From bafdc470e39ecfe4a208bdd4e3f15a7ff7ffa93d Mon Sep 17 00:00:00 2001 From: Korney Czukowski Date: Sun, 11 Feb 2018 20:53:10 +0100 Subject: [PATCH 3/4] Remove control properties that were used before they had a chance of being set --- DS4Windows/DS4Forms/LanguagePackComboBox.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/DS4Windows/DS4Forms/LanguagePackComboBox.cs b/DS4Windows/DS4Forms/LanguagePackComboBox.cs index b626f60..8af630f 100644 --- a/DS4Windows/DS4Forms/LanguagePackComboBox.cs +++ b/DS4Windows/DS4Forms/LanguagePackComboBox.cs @@ -16,6 +16,12 @@ namespace DS4Windows.DS4Forms private string InvariantCultureTextValue = "No (English UI)"; private TaskCompletionSource LanguageListInitialized = new TaskCompletionSource(); + // If probing path has been changed in App.config, add the same string here. + public string ProbingPath = "Lang"; + + // Filter language assembly file names in order to ont include irrelevant assemblies to the combo box. + public string LanguageAssemblyName { get; set; } = "DS4Windows.resources.dll"; + [Category("Action")] [Description("Fires when the combo box selected index is changed.")] public event EventHandler SelectedIndexChanged; @@ -45,14 +51,6 @@ namespace DS4Windows.DS4Forms set { label1.Text = value; } } - [Category("Data")] - [Description("If probing path has been changed in App.config, add the same string here.")] - public string ProbingPath { get; set; } = "Lang"; - - [Category("Data")] - [Description("Filter language assembly file names in order to ont include irrelevant assemblies to the combo box.")] - public string LanguageAssemblyName { get; set; } = "DS4Windows.resources.dll"; - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public int SelectedIndex { From 3ced545d9e1932e45e07da46124008caa6a76bf0 Mon Sep 17 00:00:00 2001 From: Korney Czukowski Date: Sun, 11 Feb 2018 20:58:55 +0100 Subject: [PATCH 4/4] Forgot to remove implicit get/set --- DS4Windows/DS4Forms/LanguagePackComboBox.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DS4Windows/DS4Forms/LanguagePackComboBox.cs b/DS4Windows/DS4Forms/LanguagePackComboBox.cs index 8af630f..c7ce483 100644 --- a/DS4Windows/DS4Forms/LanguagePackComboBox.cs +++ b/DS4Windows/DS4Forms/LanguagePackComboBox.cs @@ -20,7 +20,7 @@ namespace DS4Windows.DS4Forms public string ProbingPath = "Lang"; // Filter language assembly file names in order to ont include irrelevant assemblies to the combo box. - public string LanguageAssemblyName { get; set; } = "DS4Windows.resources.dll"; + public string LanguageAssemblyName = "DS4Windows.resources.dll"; [Category("Action")] [Description("Fires when the combo box selected index is changed.")]