From 1a9e7c0b7b1f83dbcc56b7b52530d898cb2b0301 Mon Sep 17 00:00:00 2001 From: Damien LEROY Date: Tue, 16 Jan 2024 16:01:11 +0100 Subject: [PATCH] Adding Languages into settings to modify multiple countries + design --- PowerAccent.Core/PowerAccent.cs | 5 +++ PowerAccent.Core/Services/SettingsService.cs | 31 ++++++++++++++++ PowerAccent.UI/MainWindow.xaml.cs | 1 + .../SettingsPage/CountriesPage.xaml | 8 ++--- .../SettingsPage/CountriesPage.xaml.cs | 36 +++++++++++++++++-- 5 files changed, 74 insertions(+), 7 deletions(-) diff --git a/PowerAccent.Core/PowerAccent.cs b/PowerAccent.Core/PowerAccent.cs index 7fd696f..ce34356 100644 --- a/PowerAccent.Core/PowerAccent.cs +++ b/PowerAccent.Core/PowerAccent.cs @@ -88,6 +88,11 @@ public void ReloadSettings() _settingService.Reload(); } + public void CheckVersion() + { + _settingService.UpdateSettingsVersion(); + } + public void Dispose() { _keyboardListener.Dispose(); diff --git a/PowerAccent.Core/Services/SettingsService.cs b/PowerAccent.Core/Services/SettingsService.cs index 0f52e77..0eacafb 100644 --- a/PowerAccent.Core/Services/SettingsService.cs +++ b/PowerAccent.Core/Services/SettingsService.cs @@ -13,6 +13,14 @@ public Language SelectedLanguage set { this["SelectedLanguage"] = value; Save(); } } + [UserScopedSetting] + [DefaultSettingValue("ALL")] + public Language[] SelectedLanguages + { + get { return (Language[])this["SelectedLanguages"]; } + set { this["SelectedLanguages"] = value; Save(); } + } + [UserScopedSetting] [DefaultSettingValue("Top")] public Position Position @@ -61,6 +69,14 @@ public bool InsertSpaceAfterSelection set { this["InsertSpaceAfterSelection"] = value; Save(); } } + [UserScopedSetting] + [DefaultSettingValue("0")] + public int SettingsVersion + { + get { return (int)this["SettingsVersion"]; } + set { this["SettingsVersion"] = value; Save(); } + } + #region LetterKey public void SetLetterKey(LetterKey letter, char[] value) @@ -103,6 +119,21 @@ private void AddingProperty(string key) } } + // Check and update properties from previous version + public void UpdateSettingsVersion() + { + if (this.SettingsVersion == 1) + return; + + if (this.SettingsVersion == 0) + { + SelectedLanguages = new[] { SelectedLanguage }; + } + + SettingsVersion = 1; + this.Save(); + } + #endregion } diff --git a/PowerAccent.UI/MainWindow.xaml.cs b/PowerAccent.UI/MainWindow.xaml.cs index bf68b76..fcf256b 100644 --- a/PowerAccent.UI/MainWindow.xaml.cs +++ b/PowerAccent.UI/MainWindow.xaml.cs @@ -27,6 +27,7 @@ protected override void OnSourceInitialized(EventArgs e) _powerAccent.OnChangeDisplay += PowerAccent_OnChangeDisplay; _powerAccent.OnSelectCharacter += PowerAccent_OnSelectionCharacter; this.Visibility = Visibility.Hidden; + _powerAccent.CheckVersion(); } private void PowerAccent_OnSelectionCharacter(int index) diff --git a/PowerAccent.UI/SettingsPage/CountriesPage.xaml b/PowerAccent.UI/SettingsPage/CountriesPage.xaml index 50b846d..ef723a7 100644 --- a/PowerAccent.UI/SettingsPage/CountriesPage.xaml +++ b/PowerAccent.UI/SettingsPage/CountriesPage.xaml @@ -16,7 +16,7 @@ -