Load settings from Global sooner, set culture from settings, add event handler for language picker change

This commit is contained in:
Korney Czukowski 2017-12-12 21:52:13 +01:00
parent f0b645b7e5
commit a794d2c718
2 changed files with 22 additions and 1 deletions

View File

@ -88,6 +88,9 @@ namespace DS4Windows
public DS4Form(string[] args)
{
Global.Load();
Program.SetCulture(UseLang);
InitializeComponent();
ThemeUtil.SetTheme(lvDebug);
@ -181,7 +184,6 @@ namespace DS4Windows
Log.TrayIconLog += ShowNotification;
Directory.CreateDirectory(appdatapath);
Global.Load();
if (!Save()) //if can't write to file
{
if (MessageBox.Show("Cannot write at current location\nCopy Settings to appdata?", "DS4Windows",
@ -2487,6 +2489,13 @@ namespace DS4Windows
}
}
private void languagePackComboBox1_SelectedValueChanged(object sender, EventArgs e)
{
UseLang = ((DS4Forms.LanguagePackComboBox)sender).SelectedValue.ToString();
Save();
MessageBox.Show("DS4Windows must be restarted in order to have an effect.");
}
private void cBFlashWhenLate_CheckedChanged(object sender, EventArgs e)
{
FlashWhenLate = cBFlashWhenLate.Checked;

View File

@ -120,6 +120,18 @@ namespace DS4Windows
threadComEvent.Close();
}
public static void SetCulture(string culture)
{
foreach (Thread t in new Thread[] { Thread.CurrentThread, controlThread })
{
if (t != null && !t.CurrentUICulture.Equals(culture))
{
try { t.CurrentUICulture = CultureInfo.GetCultureInfo(culture); }
catch { /* Skip setting culture that we cannot set */ }
}
}
}
private static void createControlService()
{
controlThread = new Thread(() => { rootHub = new ControlService(); });