Portable Tool for an Ideal Windows Setup
C# activatorbloatware-removalcsharpdebloatdebloaterdisable-servicesmonitoring-systemportableprivacy-toolsregistry-tweakssystem-tuningsystem-utilitytelemetrytweakerwindows-10windows-11windows-debloatwindows-defenderwindows-optimizationwindows-tweaks
upd. prevent execution in design mode
Greedeks5245c2800199
diff --git a/.Source/GTweak/Core/ViewModel/MainViewModel.cs b/.Source/GTweak/Core/ViewModel/MainViewModel.csindex a3f4fbea..38439dfc 100644--- a/.Source/GTweak/Core/ViewModel/MainViewModel.cs+++ b/.Source/GTweak/Core/ViewModel/MainViewModel.cs@@ -6,10 +6,10 @@ 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;+using System.Windows.Threading;namespace GTweak.Core.ViewModel{@@ -86,7 +86,7 @@ namespace GTweak.Core.ViewModelpublic MainViewModel(){App.TweaksImported += delegate { CurrentView = new MoreVM(); };- App.LanguageChanged += delegate { FillThemes(); };+ App.LanguageChanged += delegate { Application.Current.Dispatcher.Invoke(FillThemes); };ConfidentialityCommand = new RelayCommand(Confidentiality);InterfaceCommand = new RelayCommand(Interface);@@ -98,28 +98,25 @@ namespace GTweak.Core.ViewModelCurrentView = new MoreVM();- Task.Run(() =>+ if (!DesignerProperties.GetIsInDesignMode(new DependencyObject())){- Application.Current.Dispatcher.Invoke(FillLanguages);- Application.Current.Dispatcher.Invoke(FillThemes);- });+ Application.Current.Dispatcher.BeginInvoke(new Action(() =>+ {+ FillLanguages();+ FillThemes();+ }), DispatcherPriority.ApplicationIdle);+ }}private void FillLanguages(){Languages.Clear();- ResourceDictionary dictionary = Application.Current.Resources.MergedDictionaries.FirstOrDefault(d => d.Source != null && d.Source.OriginalString.Contains("LanguageCatalog.xaml")) ?? Application.Current.Resources;+ ResourceDictionary dictionary = new ResourceDictionary { Source = new Uri($"Languages/LanguageCatalog.xaml", UriKind.Relative) };foreach (string code in SettingsEngine.AvailableLangs)- {- string key = $"{code.Replace("-", "_")}_main";- string display = dictionary[key] as string ?? code;- Languages.Add(new MainModel.LanguageItem { Code = code, Display = display });- }-- if (!DesignerProperties.GetIsInDesignMode(new DependencyObject()))- SelectedLanguage = SettingsEngine.AvailableLangs.Contains(SettingsEngine.Language) ? SettingsEngine.Language : SettingsEngine.AvailableLangs.FirstOrDefault();+ Languages.Add(new MainModel.LanguageItem { Code = code, Display = dictionary[$"{code.Replace("-", "_")}_main"] as string ?? code });+ SelectedLanguage = SettingsEngine.AvailableLangs.Contains(SettingsEngine.Language) ? SettingsEngine.Language : SettingsEngine.AvailableLangs.FirstOrDefault();}private void FillThemes()@@ -130,11 +127,7 @@ namespace GTweak.Core.ViewModelThemes.Clear();foreach (string code in SettingsEngine.AvailableThemes)- {- string key = $"cmbox_{code}_main";- string display = Application.Current.Resources[key] as string ?? code;- Themes.Add(new MainModel.ThemeItem { Code = code, Display = display });- }+ Themes.Add(new MainModel.ThemeItem { Code = code, Display = Application.Current.Resources[$"cmbox_{code}_main"] as string ?? code });SelectedTheme = SettingsEngine.AvailableThemes.Contains(SettingsEngine.Theme) ? SettingsEngine.Theme : SettingsEngine.AvailableThemes.FirstOrDefault();}diff --git a/.Source/GTweak/Utilities/Controls/SettingsEngine.cs b/.Source/GTweak/Utilities/Controls/SettingsEngine.csindex 274fd4b5..28f2f10b 100644--- a/.Source/GTweak/Utilities/Controls/SettingsEngine.cs+++ b/.Source/GTweak/Utilities/Controls/SettingsEngine.cs@@ -6,7 +6,6 @@ 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;@@ -20,7 +19,7 @@ namespace GTweak.Utilities.Controls[DllImport("winmm.dll")]internal static extern int waveOutSetVolume(IntPtr hwo, uint dwVolume);- 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[] AvailableLangs = 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();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();