diff --git a/DS4Windows/DS4Forms/LanguagePackComboBox.Designer.cs b/DS4Windows/DS4Forms/LanguagePackComboBox.Designer.cs new file mode 100644 index 0000000..de400a5 --- /dev/null +++ b/DS4Windows/DS4Forms/LanguagePackComboBox.Designer.cs @@ -0,0 +1,79 @@ +namespace DS4Windows.DS4Forms +{ + partial class LanguagePackComboBox + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Код, автоматически созданный конструктором компонентов + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.cbCulture = new System.Windows.Forms.ComboBox(); + this.label1 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // cbCulture + // + this.cbCulture.Anchor = System.Windows.Forms.AnchorStyles.Right; + this.cbCulture.DisplayMember = "Value"; + this.cbCulture.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cbCulture.FormattingEnabled = true; + this.cbCulture.Location = new System.Drawing.Point(112, 3); + this.cbCulture.Name = "cbCulture"; + this.cbCulture.Size = new System.Drawing.Size(145, 21); + this.cbCulture.TabIndex = 61; + this.cbCulture.ValueMember = "Key"; + // + // label1 + // + this.label1.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(3, 6); + 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); + // + // LanguagePackComboBox + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.cbCulture); + this.Controls.Add(this.label1); + this.Name = "LanguagePackComboBox"; + this.Size = new System.Drawing.Size(260, 27); + this.SizeChanged += new System.EventHandler(this.LanguagePackComboBox_SizeChanged); + this.Resize += new System.EventHandler(this.LanguagePackComboBox_SizeChanged); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.ComboBox cbCulture; + private System.Windows.Forms.Label label1; + } +} diff --git a/DS4Windows/DS4Forms/LanguagePackComboBox.cs b/DS4Windows/DS4Forms/LanguagePackComboBox.cs new file mode 100644 index 0000000..efb75f7 --- /dev/null +++ b/DS4Windows/DS4Forms/LanguagePackComboBox.cs @@ -0,0 +1,92 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Threading; +using System.Windows.Forms; + +namespace DS4Windows.DS4Forms +{ + public partial class LanguagePackComboBox : UserControl + { + [Category("Action")] + [Description("Fires when the combo box selected index is changed.")] + public event EventHandler SelectedIndexChanged; + + [Category("Action")] + [Description("Fires when the combo box selected value is changed.")] + public event EventHandler SelectedValueChanged; + + [Category("Data")] + [Description("Text used for invariant culture name in the combo box.")] + [Localizable(true)] + public string InvariantCultureText { get; set; } + + [Category("Data")] + [Description("Text for label before the combo box.")] + [Localizable(true)] + public string LabelText { + get { return label1.Text; } + set { label1.Text = value; } + } + + public int SelectedIndex + { + get { return cbCulture.SelectedIndex; } + set { cbCulture.SelectedIndex = value; } + } + + public string SelectedText + { + get { return cbCulture.SelectedText; } + set { cbCulture.SelectedText = value; } + } + + public object SelectedValue + { + get { return cbCulture.SelectedValue; } + set { cbCulture.SelectedValue = value; } + } + + public LanguagePackComboBox() + { + InitializeComponent(); + + // Find the location where application installed. + string exeLocation = Path.GetDirectoryName(Uri.UnescapeDataString(new UriBuilder(Assembly.GetExecutingAssembly().CodeBase).Path)); + + // Get all culture for which satellite folder found with culture code. + Dictionary cultures = CultureInfo.GetCultures(CultureTypes.AllCultures) + .Where(c => Directory.Exists(Path.Combine(exeLocation, c.Name))) + .ToDictionary(c => c.Name, c => c.Equals(CultureInfo.InvariantCulture) ? this.InvariantCultureText : c.NativeName); + + cbCulture.DataSource = new BindingSource(cultures, null); + 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); + } + + private void LanguagePackComboBox_SizeChanged(object sender, EventArgs e) + { + cbCulture.Left = label1.Margin.Left + label1.Width + label1.Margin.Right; + cbCulture.Width = this.Width - cbCulture.Left - cbCulture.Margin.Right - cbCulture.Margin.Left; + } + + private void CbCulture_SelectedIndexChanged(object sender, EventArgs e) + { + + this.SelectedIndexChanged?.Invoke(this, e); + + } + + private void CbCulture_SelectedValueChanged(object sender, EventArgs e) + { + this.SelectedValueChanged?.Invoke(this, e); + } + } +} diff --git a/DS4Windows/DS4Forms/LanguagePackComboBox.resx b/DS4Windows/DS4Forms/LanguagePackComboBox.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/DS4Windows/DS4Forms/LanguagePackComboBox.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/DS4Windows/DS4Windows.csproj b/DS4Windows/DS4Windows.csproj index 0798107..ac6d445 100644 --- a/DS4Windows/DS4Windows.csproj +++ b/DS4Windows/DS4Windows.csproj @@ -164,6 +164,12 @@ X360Device.cs + + UserControl + + + LanguagePackComboBox.cs + @@ -594,6 +600,9 @@ KBM360.cs + + LanguagePackComboBox.cs + Options.cs