Portable Tool for an Ideal Windows Setup
C# activatorbloatware-removalcsharpdebloatdebloaterdisable-servicesmonitoring-systemportableprivacy-toolsregistry-tweakssystem-tuningsystem-utilitytelemetrytweakerwindows-10windows-11windows-debloatwindows-defenderwindows-optimizationwindows-tweaks
auto filling of the combox
Greedeks36aa3508bbd2
diff --git a/.Source/GTweak/App.xaml b/.Source/GTweak/App.xamlindex 0aee25f9..5210b48a 100644--- a/.Source/GTweak/App.xaml+++ b/.Source/GTweak/App.xaml@@ -7,8 +7,8 @@<Application.Resources><ResourceDictionary><ResourceDictionary.MergedDictionaries>- <ResourceDictionary Source="Languages/LanguageCatalog.xaml" /><ResourceDictionary Source="Languages/en/Localize.xaml" />+ <ResourceDictionary Source="Languages/LanguageCatalog.xaml" /><ResourceDictionary Source="Core/DataTemplate.xaml" /><ResourceDictionary Source="Assets/Font/Font.xaml" /><ResourceDictionary Source="Assets/DrawingImages/Deleted/Applications.xaml" />diff --git a/.Source/GTweak/App.xaml.cs b/.Source/GTweak/App.xaml.csindex 01089da3..c9bf3681 100644--- a/.Source/GTweak/App.xaml.cs+++ b/.Source/GTweak/App.xaml.cs@@ -114,17 +114,17 @@ namespace GTweak{set{- value ??= "Dark";+ value ??= SettingsEngine.AvailableThemes.First();ResourceDictionary dictionary = new ResourceDictionary{Source = value switch{- "Dark" => GetResourceUri("Dark", true),- "Light" => GetResourceUri("Light", true),- "Cobalt" => GetResourceUri("Cobalt", true),- "Dark amethyst" => GetResourceUri("Dark amethyst", true),- "Cold Blue" => GetResourceUri("Cold Blue", true),+ "dark" => GetResourceUri("Dark", true),+ "light" => GetResourceUri("Light", true),+ "cobalt" => GetResourceUri("Cobalt", true),+ "amethyst" => GetResourceUri("Dark amethyst", true),+ "cblue" => GetResourceUri("Cold Blue", true),_ => RegistryHelp.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize", "AppsUseLightTheme", string.Empty) == "0" ? GetResourceUri("Dark", true) : GetResourceUri("Light", true)}};diff --git a/.Source/GTweak/Core/Model/MainModel.cs b/.Source/GTweak/Core/Model/MainModel.csnew file mode 100644index 00000000..07111d35--- /dev/null+++ b/.Source/GTweak/Core/Model/MainModel.cs@@ -0,0 +1,21 @@+namespace GTweak.Core.Model+{+ internal class MainModel+ {+ public object CurrentView { get; set; }+ public string SelectedLanguage { get; set; }+ public string SelectedTheme { get; set; }++ internal class LanguageItem+ {+ public string Code { get; set; }+ public string Display { get; set; }+ }++ internal class ThemeItem+ {+ public string Code { get; set; }+ public string Display { get; set; }+ }+ }+}diff --git a/.Source/GTweak/Core/ViewModel/DataSystemVM.cs b/.Source/GTweak/Core/ViewModel/DataSystemVM.csindex 759e72f0..6c269501 100644--- a/.Source/GTweak/Core/ViewModel/DataSystemVM.cs+++ b/.Source/GTweak/Core/ViewModel/DataSystemVM.cs@@ -9,7 +9,7 @@ namespace GTweak.Core.ViewModel{internal class DataSystemVM : ViewModelBase{- private readonly DataSystemModel _model;+ private readonly DataSystemModel _model = new DataSystemModel();private ObservableCollection<DataSystemModel> _collection;public ObservableCollection<DataSystemModel> DisplayData@@ -61,8 +61,6 @@ namespace GTweak.Core.ViewModelpublic DataSystemVM(){- _model = new DataSystemModel();-DisplayData = new ObservableCollection<DataSystemModel>{CreateModelCollection("OSName", SystemDiagnostics.HardwareData.OS.Name, "unknown_information_systemInformatin"),diff --git a/.Source/GTweak/Core/ViewModel/MainViewModel.cs b/.Source/GTweak/Core/ViewModel/MainViewModel.csindex 61b3a0c0..3317c27c 100644--- a/.Source/GTweak/Core/ViewModel/MainViewModel.cs+++ b/.Source/GTweak/Core/ViewModel/MainViewModel.cs@@ -1,6 +1,12 @@-using GTweak.Utilities.Configuration;+using GTweak.Core.Model;+using GTweak.Utilities.Configuration;+using GTweak.Utilities.Controls;using System;+using System.Collections.ObjectModel;+using System.ComponentModel;+using System.Linq;using System.Reflection;+using System.Windows;using System.Windows.Input;using System.Windows.Media;@@ -8,13 +14,17 @@ namespace GTweak.Core.ViewModel{internal class MainViewModel : ViewModelBase{+ public ObservableCollection<MainModel.LanguageItem> Languages { get; } = new ObservableCollection<MainModel.LanguageItem>();+ public ObservableCollection<MainModel.ThemeItem> Themes { get; } = new ObservableCollection<MainModel.ThemeItem>();++ private readonly MainModel _model = new MainModel();private readonly SystemDiagnostics _systemDiagnostics = new SystemDiagnostics();- private object _currentView;+ private bool _isThemeUpdateInternal = false;public object CurrentView{- get => _currentView;- set { _currentView = value; OnPropertyChanged(); }+ get => _model.CurrentView;+ set { _model.CurrentView = value; OnPropertyChanged(); }}public ImageSource DisplayProfileAvatar => _systemDiagnostics.GetProfileImage();@@ -23,6 +33,39 @@ namespace GTweak.Core.ViewModelpublic string DisplayTweakVersion => (Assembly.GetEntryAssembly() ?? throw new InvalidOperationException()).GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;+ public string SelectedLanguage+ {+ get => _model.SelectedLanguage;+ set+ {+ if (_model.SelectedLanguage != value)+ {+ _model.SelectedLanguage = value;+ OnPropertyChanged();+ SettingsEngine.Language = value;+ App.Language = value;+ }+ }+ }++ public string SelectedTheme+ {+ get => _model.SelectedTheme;+ set+ {+ if (_model.SelectedTheme != value)+ {+ _model.SelectedTheme = value;+ OnPropertyChanged();+ if (!_isThemeUpdateInternal && _model.SelectedTheme != null)+ {+ SettingsEngine.Theme = value;+ App.Theme = value;+ }+ }+ }+ }+public ICommand ConfidentialityCommand { get; set; }public ICommand InterfaceCommand { get; set; }public ICommand PakagesCommand { get; set; }@@ -41,6 +84,9 @@ namespace GTweak.Core.ViewModelpublic MainViewModel(){+ App.TweaksImported += delegate { CurrentView = new MoreVM(); };+ App.LanguageChanged += delegate { FillThemes(); };+ConfidentialityCommand = new RelayCommand(Confidentiality);InterfaceCommand = new RelayCommand(Interface);PakagesCommand = new RelayCommand(Pakages);@@ -51,7 +97,44 @@ namespace GTweak.Core.ViewModelCurrentView = new MoreVM();- App.TweaksImported += delegate { CurrentView = new MoreVM(); };+ FillLanguages();+ FillThemes();+ }++ 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;++ 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();++ }++ private void FillThemes()+ {+ _isThemeUpdateInternal = true;+ try+ {+ Themes.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 });+ }++ SelectedTheme = SettingsEngine.AvailableThemes.Contains(SettingsEngine.Theme) ? SettingsEngine.Theme : SettingsEngine.AvailableThemes.FirstOrDefault();+ }+ finally { _isThemeUpdateInternal = false; }}}}diff --git a/.Source/GTweak/GTweak.csproj b/.Source/GTweak/GTweak.csprojindex 87bdfec9..5d343c34 100644--- a/.Source/GTweak/GTweak.csproj+++ b/.Source/GTweak/GTweak.csproj@@ -248,6 +248,7 @@<Compile Include="Assets\UserControl\ProggressRing.xaml.cs"><DependentUpon>ProggressRing.xaml</DependentUpon></Compile>+ <Compile Include="Core\Model\MainModel.cs" /><Compile Include="Core\ViewModel\DataSystemVM.cs" /><Compile Include="Core\ViewModel\InterfaceVM.cs" /><Compile Include="Assets\UserControl\Card.xaml.cs">diff --git a/.Source/GTweak/Utilities/Controls/SettingsEngine.cs b/.Source/GTweak/Utilities/Controls/SettingsEngine.csindex 446e0cfa..dfd13c4b 100644--- a/.Source/GTweak/Utilities/Controls/SettingsEngine.cs+++ b/.Source/GTweak/Utilities/Controls/SettingsEngine.cs@@ -19,7 +19,7 @@ namespace GTweak.Utilities.Controlsinternal 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[] AvailableThemes = { "Dark", "Light", "Cobalt", "Dark amethyst", "Cold Blue", "System" };+ 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();internal static readonly string currentName = AppDomain.CurrentDomain.FriendlyName;@@ -34,7 +34,7 @@ namespace GTweak.Utilities.Controls["EnableSound"] = true,["VolumeLevel"] = 50,["Language"] = SystemDiagnostics.GetCurrentSystemLang().Code,- ["Theme"] = "Dark"+ ["Theme"] = AvailableThemes.First()};private static readonly Dictionary<string, object> _cachedSettings = new Dictionary<string, object>(_defaultSettings);diff --git a/.Source/GTweak/Windows/MainWindow.xaml b/.Source/GTweak/Windows/MainWindow.xamlindex 6b335d28..13871b50 100644--- a/.Source/GTweak/Windows/MainWindow.xaml+++ b/.Source/GTweak/Windows/MainWindow.xaml@@ -239,27 +239,12 @@<StackPanel Orientation="Horizontal" Height="45" VerticalAlignment="Top" Margin="40,10,0,0"><TextBlock Style="{StaticResource Text_In}" Foreground="{StaticResource Color_Highlighted}" Text="{DynamicResource cmbox_lang_main}"/>- <ComboBox x:Name="LanguageSelectionMenu" Height="25" Width="155" Margin="10,-5,0,0" MaxDropDownHeight="220" ScrollViewer.VerticalScrollBarVisibility="Auto" SelectionChanged="LanguageSelectionMenu_SelectionChanged" >- <TextBlock Text="{DynamicResource en_main}"/>- <TextBlock Text="{DynamicResource fr_main}"/>- <TextBlock Text="{DynamicResource it_main}"/>- <TextBlock Text="{DynamicResource ko_main}"/>- <TextBlock Text="{DynamicResource pt_br_main}"/>- <TextBlock Text="{DynamicResource ru_main}"/>- <TextBlock Text="{DynamicResource uk_main}"/>- </ComboBox>+ <ComboBox Height="25" Width="155" Margin="10,-5,0,0" MaxDropDownHeight="220" ItemsSource="{Binding Languages}" SelectedValue="{Binding SelectedLanguage, Mode=TwoWay}" SelectedValuePath="Code" DisplayMemberPath="Display"/></StackPanel><StackPanel Orientation="Horizontal" Height="45" VerticalAlignment="Top" Margin="40,5,0,0"><TextBlock Style="{StaticResource Text_In}" Foreground="{StaticResource Color_Highlighted}" Text="{DynamicResource cmbox_theme_main}"/>- <ComboBox x:Name="ThemeSelectionMenu" Height="25" Width="155" Margin="10,-5,0,0" SelectionChanged="ThemeSelectionMenu_SelectionChanged">- <TextBlock Text="{DynamicResource cmbox_dark_main}"/>- <TextBlock Text="{DynamicResource cmbox_light_main}"/>- <TextBlock Text="{DynamicResource cmbox_cobalt_main}"/>- <TextBlock Text="{DynamicResource cmbox_amethyst_main}"/>- <TextBlock Text="{DynamicResource cmbox_cblue_main}"/>- <TextBlock Text="{DynamicResource cmbox_system_main}"/>- </ComboBox>+ <ComboBox Height="25" Width="155" Margin="10,-5,0,0" ItemsSource="{Binding Themes}" SelectedValue="{Binding SelectedTheme, Mode=TwoWay}" SelectedValuePath="Code" DisplayMemberPath="Display"/></StackPanel><Border Background="{DynamicResource Color_Accent}" Height="1.2" Width="330" VerticalAlignment="Bottom" Margin="0,10,0,0" CornerRadius="10 10 0 0"/>diff --git a/.Source/GTweak/Windows/MainWindow.xaml.cs b/.Source/GTweak/Windows/MainWindow.xaml.csindex 65487cdd..765c2dae 100644--- a/.Source/GTweak/Windows/MainWindow.xaml.cs+++ b/.Source/GTweak/Windows/MainWindow.xaml.cs@@ -5,7 +5,6 @@ using GTweak.Windows;using System;using System.ComponentModel;using System.Diagnostics;-using System.Linq;using System.Threading.Tasks;using System.Windows;using System.Windows.Controls;@@ -25,19 +24,11 @@ namespace GTweakBtnTopMost.StateNA = Topmost = SettingsEngine.IsTopMost;BtnSoundNtn.IsChecked = SettingsEngine.IsPlayingSound;SliderVolume.Value = SettingsEngine.Volume;- LanguageSelectionMenu.SelectedIndex = GetSelectedIndex(SettingsEngine.Language, "en", SettingsEngine.AvailableLangs);- ThemeSelectionMenu.SelectedIndex = GetSelectedIndex(SettingsEngine.Theme, "Dark", SettingsEngine.AvailableThemes);App.TweaksImported += delegate { BtnMore.IsChecked = true; };App.ThemeChanged += delegate { Close(); new RebootWindow().ShowDialog(); };}- private int GetSelectedIndex(string value, string defaultValue, params string[] listing)- {- int index = Array.IndexOf(listing, value);- return index >= 0 ? index : Array.IndexOf(listing, defaultValue);- }-#region Button Title/Animation Windowprivate void ButtonHelp_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e) => Process.Start(new ProcessStartInfo("https://github.com/Greedeks/GTweak/issues/new/choose") { UseShellExecute = true });@@ -118,20 +109,6 @@ namespace GTweakSettingsEngine.waveOutSetVolume(IntPtr.Zero, ((uint)(double)(ushort.MaxValue / 100 * SliderVolume.Value) & 0x0000ffff) | ((uint)(double)(ushort.MaxValue / 100 * SliderVolume.Value) << 16));}- private void LanguageSelectionMenu_SelectionChanged(object sender, SelectionChangedEventArgs e)- {- string selectedLang = SettingsEngine.AvailableLangs.ElementAtOrDefault(LanguageSelectionMenu.SelectedIndex) ?? SettingsEngine.AvailableLangs.Last();- SettingsEngine.Language = selectedLang;- App.Language = selectedLang;- }-- private void ThemeSelectionMenu_SelectionChanged(object sender, SelectionChangedEventArgs e)- {- string selectedTheme = SettingsEngine.AvailableThemes.ElementAtOrDefault(ThemeSelectionMenu.SelectedIndex) ?? SettingsEngine.AvailableThemes.Last();- SettingsEngine.Theme = selectedTheme;- App.Theme = selectedTheme;- }-private void BtnExport_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e) => SettingsEngine.SaveFileConfig();private void BtnImport_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e) => SettingsEngine.OpenFileConfig();