mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2024-11-30 04:54:20 +01:00
Make control localizable
This commit is contained in:
parent
acfb9b2629
commit
40b0c94905
17
DS4Windows/DS4Forms/LanguagePackComboBox.Designer.cs
generated
17
DS4Windows/DS4Forms/LanguagePackComboBox.Designer.cs
generated
@ -28,42 +28,33 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LanguagePackComboBox));
|
||||||
this.cbCulture = new System.Windows.Forms.ComboBox();
|
this.cbCulture = new System.Windows.Forms.ComboBox();
|
||||||
this.label1 = new System.Windows.Forms.Label();
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// cbCulture
|
// cbCulture
|
||||||
//
|
//
|
||||||
this.cbCulture.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
resources.ApplyResources(this.cbCulture, "cbCulture");
|
||||||
this.cbCulture.DisplayMember = "Value";
|
this.cbCulture.DisplayMember = "Value";
|
||||||
this.cbCulture.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
this.cbCulture.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
this.cbCulture.FormattingEnabled = true;
|
this.cbCulture.FormattingEnabled = true;
|
||||||
this.cbCulture.Location = new System.Drawing.Point(112, 3);
|
|
||||||
this.cbCulture.Name = "cbCulture";
|
this.cbCulture.Name = "cbCulture";
|
||||||
this.cbCulture.Size = new System.Drawing.Size(145, 21);
|
|
||||||
this.cbCulture.TabIndex = 61;
|
|
||||||
this.cbCulture.ValueMember = "Key";
|
this.cbCulture.ValueMember = "Key";
|
||||||
//
|
//
|
||||||
// label1
|
// label1
|
||||||
//
|
//
|
||||||
this.label1.Anchor = System.Windows.Forms.AnchorStyles.Left;
|
resources.ApplyResources(this.label1, "label1");
|
||||||
this.label1.AutoSize = true;
|
|
||||||
this.label1.Location = new System.Drawing.Point(3, 6);
|
|
||||||
this.label1.Name = "label1";
|
this.label1.Name = "label1";
|
||||||
this.label1.Size = new System.Drawing.Size(100, 13);
|
|
||||||
this.label1.TabIndex = 62;
|
|
||||||
this.label1.Text = "Use language pack";
|
|
||||||
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
|
||||||
this.label1.SizeChanged += new System.EventHandler(this.LanguagePackComboBox_SizeChanged);
|
this.label1.SizeChanged += new System.EventHandler(this.LanguagePackComboBox_SizeChanged);
|
||||||
//
|
//
|
||||||
// LanguagePackComboBox
|
// LanguagePackComboBox
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
resources.ApplyResources(this, "$this");
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.Controls.Add(this.cbCulture);
|
this.Controls.Add(this.cbCulture);
|
||||||
this.Controls.Add(this.label1);
|
this.Controls.Add(this.label1);
|
||||||
this.Name = "LanguagePackComboBox";
|
this.Name = "LanguagePackComboBox";
|
||||||
this.Size = new System.Drawing.Size(260, 27);
|
|
||||||
this.SizeChanged += new System.EventHandler(this.LanguagePackComboBox_SizeChanged);
|
this.SizeChanged += new System.EventHandler(this.LanguagePackComboBox_SizeChanged);
|
||||||
this.Resize += new System.EventHandler(this.LanguagePackComboBox_SizeChanged);
|
this.Resize += new System.EventHandler(this.LanguagePackComboBox_SizeChanged);
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
@ -13,8 +13,10 @@ namespace DS4Windows.DS4Forms
|
|||||||
{
|
{
|
||||||
public partial class LanguagePackComboBox : UserControl
|
public partial class LanguagePackComboBox : UserControl
|
||||||
{
|
{
|
||||||
|
private string _invariantCultureText = "No (English UI)";
|
||||||
private string _probingPath = "";
|
private string _probingPath = "";
|
||||||
private string _languageAssemblyName = "DS4Windows.resources.dll";
|
private string _languageAssemblyName = "DS4Windows.resources.dll";
|
||||||
|
private TaskCompletionSource<bool> _languageListInitialized = new TaskCompletionSource<bool>();
|
||||||
|
|
||||||
[Category("Action")]
|
[Category("Action")]
|
||||||
[Description("Fires when the combo box selected index is changed.")]
|
[Description("Fires when the combo box selected index is changed.")]
|
||||||
@ -27,7 +29,15 @@ namespace DS4Windows.DS4Forms
|
|||||||
[Category("Data")]
|
[Category("Data")]
|
||||||
[Description("Text used for invariant culture name in the combo box.")]
|
[Description("Text used for invariant culture name in the combo box.")]
|
||||||
[Localizable(true)]
|
[Localizable(true)]
|
||||||
public string InvariantCultureText { get; set; }
|
public string InvariantCultureText
|
||||||
|
{
|
||||||
|
get { return _invariantCultureText; }
|
||||||
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("InvariantCultureText_Changed call will complete when ready, no need for a warning", "CS4014:Await.Warning")]
|
||||||
|
set {
|
||||||
|
_invariantCultureText = value;
|
||||||
|
InvariantCultureText_Changed(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Category("Data")]
|
[Category("Data")]
|
||||||
[Description("Text for label before the combo box.")]
|
[Description("Text for label before the combo box.")]
|
||||||
@ -89,6 +99,7 @@ namespace DS4Windows.DS4Forms
|
|||||||
cbCulture.SelectedValueChanged += new EventHandler(CbCulture_SelectedValueChanged);
|
cbCulture.SelectedValueChanged += new EventHandler(CbCulture_SelectedValueChanged);
|
||||||
|
|
||||||
cbCulture.Enabled = true;
|
cbCulture.Enabled = true;
|
||||||
|
_languageListInitialized.SetResult(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,10 +113,12 @@ namespace DS4Windows.DS4Forms
|
|||||||
.ToList();
|
.ToList();
|
||||||
lookupPaths.Insert(0, exeLocation);
|
lookupPaths.Insert(0, exeLocation);
|
||||||
|
|
||||||
// Get all culture for which satellite folder found with culture code.
|
// Get all culture for which satellite folder found with culture code, then insert invariant culture at the beginning.
|
||||||
Dictionary<string, string> cultures = CultureInfo.GetCultures(CultureTypes.AllCultures)
|
List<KeyValuePair<string, string>> cultures = CultureInfo.GetCultures(CultureTypes.AllCultures)
|
||||||
.Where(c => c.Equals(CultureInfo.InvariantCulture) || this.IsLanguageAssemblyAvailable(lookupPaths, c))
|
.Where(c => this.IsLanguageAssemblyAvailable(lookupPaths, c))
|
||||||
.ToDictionary(c => c.Name, c => c.Equals(CultureInfo.InvariantCulture) ? this.InvariantCultureText : c.NativeName);
|
.Select(c => new KeyValuePair<string, string>(c.Name, c.NativeName))
|
||||||
|
.ToList();
|
||||||
|
cultures.Insert(0, new KeyValuePair<string, string>("", this.InvariantCultureText));
|
||||||
|
|
||||||
return new BindingSource(cultures, null);
|
return new BindingSource(cultures, null);
|
||||||
}
|
}
|
||||||
@ -117,6 +130,14 @@ namespace DS4Windows.DS4Forms
|
|||||||
.Count() > 0;
|
.Count() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task InvariantCultureText_Changed(string value)
|
||||||
|
{
|
||||||
|
// Normally the completion flag will be long set by the time this method is called.
|
||||||
|
await _languageListInitialized.Task;
|
||||||
|
BindingSource dataSource = ((BindingSource)cbCulture.DataSource);
|
||||||
|
dataSource[0] = new KeyValuePair<string, string>("", value);
|
||||||
|
}
|
||||||
|
|
||||||
private void LanguagePackComboBox_SizeChanged(object sender, EventArgs e)
|
private void LanguagePackComboBox_SizeChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
cbCulture.Left = label1.Margin.Left + label1.Width + label1.Margin.Right;
|
cbCulture.Left = label1.Margin.Left + label1.Width + label1.Margin.Right;
|
||||||
|
@ -117,4 +117,79 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
|
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||||
|
<data name="cbCulture.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||||
|
<value>Right</value>
|
||||||
|
</data>
|
||||||
|
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||||
|
<data name="cbCulture.Location" type="System.Drawing.Point, System.Drawing">
|
||||||
|
<value>112, 3</value>
|
||||||
|
</data>
|
||||||
|
<data name="cbCulture.Size" type="System.Drawing.Size, System.Drawing">
|
||||||
|
<value>145, 21</value>
|
||||||
|
</data>
|
||||||
|
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||||
|
<data name="cbCulture.TabIndex" type="System.Int32, mscorlib">
|
||||||
|
<value>61</value>
|
||||||
|
</data>
|
||||||
|
<data name=">>cbCulture.Name" xml:space="preserve">
|
||||||
|
<value>cbCulture</value>
|
||||||
|
</data>
|
||||||
|
<data name=">>cbCulture.Type" xml:space="preserve">
|
||||||
|
<value>System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</data>
|
||||||
|
<data name=">>cbCulture.Parent" xml:space="preserve">
|
||||||
|
<value>$this</value>
|
||||||
|
</data>
|
||||||
|
<data name=">>cbCulture.ZOrder" xml:space="preserve">
|
||||||
|
<value>0</value>
|
||||||
|
</data>
|
||||||
|
<data name="label1.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||||
|
<value>Left</value>
|
||||||
|
</data>
|
||||||
|
<data name="label1.AutoSize" type="System.Boolean, mscorlib">
|
||||||
|
<value>True</value>
|
||||||
|
</data>
|
||||||
|
<data name="label1.Location" type="System.Drawing.Point, System.Drawing">
|
||||||
|
<value>3, 6</value>
|
||||||
|
</data>
|
||||||
|
<data name="label1.Size" type="System.Drawing.Size, System.Drawing">
|
||||||
|
<value>100, 13</value>
|
||||||
|
</data>
|
||||||
|
<data name="label1.TabIndex" type="System.Int32, mscorlib">
|
||||||
|
<value>62</value>
|
||||||
|
</data>
|
||||||
|
<data name="label1.Text" xml:space="preserve">
|
||||||
|
<value>Use language pack</value>
|
||||||
|
</data>
|
||||||
|
<data name="label1.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing">
|
||||||
|
<value>MiddleLeft</value>
|
||||||
|
</data>
|
||||||
|
<data name=">>label1.Name" xml:space="preserve">
|
||||||
|
<value>label1</value>
|
||||||
|
</data>
|
||||||
|
<data name=">>label1.Type" xml:space="preserve">
|
||||||
|
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</data>
|
||||||
|
<data name=">>label1.Parent" xml:space="preserve">
|
||||||
|
<value>$this</value>
|
||||||
|
</data>
|
||||||
|
<data name=">>label1.ZOrder" xml:space="preserve">
|
||||||
|
<value>1</value>
|
||||||
|
</data>
|
||||||
|
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
|
||||||
|
<value>6, 13</value>
|
||||||
|
</data>
|
||||||
|
<data name="$this.Size" type="System.Drawing.Size, System.Drawing">
|
||||||
|
<value>260, 27</value>
|
||||||
|
</data>
|
||||||
|
<data name=">>$this.Name" xml:space="preserve">
|
||||||
|
<value>LanguagePackComboBox</value>
|
||||||
|
</data>
|
||||||
|
<data name=">>$this.Type" xml:space="preserve">
|
||||||
|
<value>System.Windows.Forms.UserControl, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
Loading…
Reference in New Issue
Block a user