Skip to content

Portable Tool for an Ideal Windows Setup

auto-fill languages array from resource dictionary

Greedeks154313230487
diff --git a/.Source/GTweak/App.xaml.cs b/.Source/GTweak/App.xaml.cs
index c9bf3681..7329b18b 100644
--- a/.Source/GTweak/App.xaml.cs
+++ b/.Source/GTweak/App.xaml.cs
@@ -85,12 +85,9 @@ namespace GTweak
{
Source = value switch
{
- "fr" => GetResourceUri("fr"),
- "it" => GetResourceUri("it"),
- "ko" => GetResourceUri("ko"),
+ "be" => GetResourceUri("ru"),
_ when code == "pt" && region == "br" => GetResourceUri("pt-br"),
- _ when new[] { "ru", "be" }.Contains(value) => GetResourceUri("ru"),
- "uk" => GetResourceUri("uk"),
+ _ when SettingsEngine.AvailableLangs?.Contains(value, StringComparer.OrdinalIgnoreCase) == true => GetResourceUri(value),
_ => GetResourceUri("en")
}
};
diff --git a/.Source/GTweak/Core/ViewModel/MainViewModel.cs b/.Source/GTweak/Core/ViewModel/MainViewModel.cs
index 3317c27c..a3f4fbea 100644
--- a/.Source/GTweak/Core/ViewModel/MainViewModel.cs
+++ b/.Source/GTweak/Core/ViewModel/MainViewModel.cs
@@ -6,6 +6,7 @@ using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
+using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
@@ -97,8 +98,11 @@ namespace GTweak.Core.ViewModel
CurrentView = new MoreVM();
- FillLanguages();
- FillThemes();
+ Task.Run(() =>
+ {
+ Application.Current.Dispatcher.Invoke(FillLanguages);
+ Application.Current.Dispatcher.Invoke(FillThemes);
+ });
}
private void FillLanguages()
diff --git a/.Source/GTweak/Utilities/Controls/SettingsEngine.cs b/.Source/GTweak/Utilities/Controls/SettingsEngine.cs
index dfd13c4b..274fd4b5 100644
--- a/.Source/GTweak/Utilities/Controls/SettingsEngine.cs
+++ b/.Source/GTweak/Utilities/Controls/SettingsEngine.cs
@@ -6,10 +6,12 @@ using Microsoft.Win32;
using Ookii.Dialogs.Wpf;
using System;
using System.Collections.Generic;
+using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
+using System.Windows;
namespace GTweak.Utilities.Controls
{
@@ -18,7 +20,7 @@ namespace GTweak.Utilities.Controls
[DllImport("winmm.dll")]
internal static extern int waveOutSetVolume(IntPtr hwo, uint dwVolume);
- internal static readonly string[] AvailableLangs = { "en", "fr", "it", "ko", "pt-br", "ru", "uk" };
+ internal static readonly string[] AvailableLangs = !DesignerProperties.GetIsInDesignMode(new DependencyObject()) ? new ResourceDictionary { Source = new Uri("Languages/LanguageCatalog.xaml", UriKind.Relative) }.Keys.Cast<string>().Select(key => key.Replace("_main", "").Replace("_", "-")).OrderBy(lang => lang, StringComparer.OrdinalIgnoreCase).ToArray() : Array.Empty<string>();
internal static readonly string[] AvailableThemes = { "dark", "light", "cobalt", "amethyst", "cblue", "system" };
internal static string currentRelease = (Assembly.GetEntryAssembly() ?? throw new InvalidOperationException()).GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion.Split(' ').Last().Trim();