Skip to content

Portable Tool for an Ideal Windows Setup

fix anim reboot & re getting parameter values

Greedeksff66f879c846
diff --git a/.Source/GTweak/App.xaml.cs b/.Source/GTweak/App.xaml.cs
index 38f4d34e..c66884b7 100644
--- a/.Source/GTweak/App.xaml.cs
+++ b/.Source/GTweak/App.xaml.cs
@@ -1,11 +1,9 @@
-using GTweak.Utilities.Controls;
+using GTweak.Utilities.Configuration;
+using GTweak.Utilities.Controls;
using GTweak.Utilities.Helpers;
using GTweak.Windows;
using System;
-using System.Globalization;
using System.Linq;
-using System.Runtime.CompilerServices;
-using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Threading;
@@ -17,9 +15,7 @@ namespace GTweak
internal static event EventHandler ThemeChanged;
internal static event EventHandler ImportTweaksUpdate;
- internal static string GettingSystemLanguage => Regex.Replace(CultureInfo.CurrentCulture.ToString(), @"-.+$", "", RegexOptions.Multiline);
internal static void UpdateImport() => ImportTweaksUpdate?.Invoke(default, EventArgs.Empty);
- private void LogError(Exception ex, [CallerMemberName] string memberName = "") => ErrorLogging.LogWritingFile(ex, memberName);
public App()
{
@@ -37,9 +33,7 @@ namespace GTweak
return;
}
- Language = RegistryHelp.GetValue(@"HKEY_CURRENT_USER\Software\GTweak", "Language", "en");
- Theme = RegistryHelp.GetValue(@"HKEY_CURRENT_USER\Software\GTweak", "Theme", "Dark");
-
+ SettingsRepository.СheckingParameters();
BlockRunTweaker.CheckingApplicationCopies();
await BlockRunTweaker.CheckingSystemRequirements();
@@ -48,7 +42,7 @@ namespace GTweak
private void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
- LogError(e.Exception);
+ ErrorLogging.LogWritingFile(e.Exception);
e.Handled = true;
Environment.Exit(0);
}
@@ -56,7 +50,7 @@ namespace GTweak
private void OnUnhandledException(object sender, UnhandledExceptionEventArgs e)
{
if (e.ExceptionObject is Exception ex)
- LogError(ex);
+ ErrorLogging.LogWritingFile(ex);
Environment.Exit(0);
}
@@ -64,7 +58,7 @@ namespace GTweak
{
set
{
- value ??= GettingSystemLanguage;
+ value ??= SystemDiagnostics.SystemDefaultLanguage;
ResourceDictionary dictionary = new ResourceDictionary
{
diff --git a/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs b/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs
index 6e2ea58f..93d20494 100644
--- a/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs
+++ b/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs
@@ -71,6 +71,8 @@ namespace GTweak.Utilities.Configuration
internal static ConnectionStatus CurrentConnection = ConnectionStatus.Lose;
+ internal static string SystemDefaultLanguage => Regex.Replace(CultureInfo.CurrentUICulture.ToString(), @"-.+$", "", RegexOptions.Multiline);
+
internal static bool IsNeedUpdate { get; private set; } = false;
internal static string DownloadVersion { get; private set; } = string.Empty;
@@ -414,25 +416,25 @@ namespace GTweak.Utilities.Configuration
{
try
{
- string dns = CultureInfo.InstalledUICulture.Name switch
+ string dns = SystemDefaultLanguage switch
{
- string name when name.StartsWith("fa") => "aparat.com",
- string name when name.StartsWith("zh") => "baidu.com",
- string name when name.StartsWith("ru") => "yandex.ru",
- string name when name.StartsWith("kk") => "yandex.kz",
- string name when name.StartsWith("ko") => "naver.com",
- string name when name.StartsWith("cs") => "seznam.cz",
- string name when name.StartsWith("tm") => "turkmenportal.com",
- string name when name.StartsWith("vn") => "coccoc.com",
- string name when name.StartsWith("cu") => "ecured.cu",
- string name when name.StartsWith("kp") => "naenara.com.kp",
- string name when name.StartsWith("sy") => "duckduckgo.com",
- string name when name.StartsWith("jp") => "yahoo.co.jp",
- string name when name.StartsWith("de") => "t-online.de",
- string name when name.StartsWith("fr") => "orange.fr",
- string name when name.StartsWith("es") => "terra.es",
- string name when name.StartsWith("it") => "libero.it",
- string name when name.StartsWith("tr") || name.StartsWith("in") || name.StartsWith("ar") => "bing.com",
+ "fa" => "aparat.com",
+ "zh" => "baidu.com",
+ "ru" => "yandex.ru",
+ "kk" => "yandex.kz",
+ "ko" => "naver.com",
+ "cs" => "seznam.cz",
+ "tm" => "turkmenportal.com",
+ "vn" => "coccoc.com",
+ "cu" => "ecured.cu",
+ "kp" => "naenara.com.kp",
+ "sy" => "duckduckgo.com",
+ "jp" => "yahoo.co.jp",
+ "de" => "t-online.de",
+ "fr" => "orange.fr",
+ "es" => "terra.es",
+ "it" => "libero.it",
+ string lang when new[] { "tr", "in", "ar" }.Contains(lang) => "bing.com",
_ => "google.com"
};
diff --git a/.Source/GTweak/Utilities/Controls/SettingsRepository.cs b/.Source/GTweak/Utilities/Controls/SettingsRepository.cs
index 0bb29b3f..45ac5b20 100644
--- a/.Source/GTweak/Utilities/Controls/SettingsRepository.cs
+++ b/.Source/GTweak/Utilities/Controls/SettingsRepository.cs
@@ -1,4 +1,5 @@
-using GTweak.Utilities.Helpers;
+using GTweak.Utilities.Configuration;
+using GTweak.Utilities.Helpers;
using GTweak.Utilities.Helpers.Managers;
using GTweak.Windows;
using Microsoft.Win32;
@@ -45,7 +46,7 @@ namespace GTweak.Utilities.Controls
["EnableIpBlur"] = true,
["EnableSound"] = true,
["VolumeLevel"] = 50,
- ["Language"] = App.GettingSystemLanguage,
+ ["Language"] = SystemDiagnostics.SystemDefaultLanguage,
["Theme"] = "Dark"
};
@@ -75,31 +76,20 @@ namespace GTweak.Utilities.Controls
internal static void СheckingParameters()
{
- bool isRegistryEmpty = false;
-
- foreach (string key in _defaultSettings.Keys)
- {
- if (RegistryHelp.ValueExists(StoragePaths.RegistryLocation, key))
- {
- isRegistryEmpty = true;
- break;
- }
- }
-
- if (isRegistryEmpty)
+ foreach (var kv in _defaultSettings)
{
- foreach (var subkey in _defaultSettings)
- ChangingParameters(subkey.Key, subkey.Value);
- }
- else
- {
- foreach (var kv in _defaultSettings)
+ if (RegistryHelp.ValueExists(StoragePaths.RegistryLocation, kv.Key))
+ ChangingParameters(kv.Key, kv.Value);
+ else
{
_cachedSettings[kv.Key] = kv.Value is bool defaultBool ? RegistryHelp.GetValue(StoragePaths.RegistryLocation, kv.Key, defaultBool ? 1 : 0) is int asBool ? asBool != 0 : defaultBool :
- kv.Value is int defaultInt ? RegistryHelp.GetValue(StoragePaths.RegistryLocation, kv.Key, defaultInt) :
- kv.Value is string defaultString ? RegistryHelp.GetValue(StoragePaths.RegistryLocation, kv.Key, defaultString) : kv.Value;
+ kv.Value is int defaultInt ? RegistryHelp.GetValue(StoragePaths.RegistryLocation, kv.Key, defaultInt) :
+ kv.Value is string defaultString ? RegistryHelp.GetValue(StoragePaths.RegistryLocation, kv.Key, defaultString) : kv.Value;
}
}
+
+ App.Language = (string)_cachedSettings["Language"];
+ App.Theme = (string)_cachedSettings["Theme"];
}
internal static void SaveFileConfig()
diff --git a/.Source/GTweak/View/DataSystemView.xaml.cs b/.Source/GTweak/View/DataSystemView.xaml.cs
index 0a1d8653..22f41987 100644
--- a/.Source/GTweak/View/DataSystemView.xaml.cs
+++ b/.Source/GTweak/View/DataSystemView.xaml.cs
@@ -47,7 +47,7 @@ namespace GTweak.View
new SystemDiagnostics().UpdatingDevicesData();
new MonitoringSystem().GetTotalProcessorUsageAsync();
});
- Application.Current.Dispatcher.Invoke(AnimationProgressBars);
+ AnimationProgressBars();
}
else if ((int)_time.TotalSeconds % 5 == 0)
{
@@ -81,18 +81,17 @@ namespace GTweak.View
{
From = CPULoad.Value,
To = MonitoringSystem.GetProcessorUsage,
- EasingFunction = new PowerEase(),
+ EasingFunction = new QuadraticEase(),
Duration = TimeSpan.FromSeconds(0.2)
};
Timeline.SetDesiredFrameRate(doubleAnim, 240);
CPULoad.BeginAnimation(ProgressBar.ValueProperty, doubleAnim);
-
doubleAnim = new DoubleAnimation()
{
From = RAMLoad.Value,
To = new MonitoringSystem().GetMemoryUsage,
- EasingFunction = new PowerEase(),
+ EasingFunction = new QuadraticEase(),
Duration = TimeSpan.FromSeconds(0.2)
};
Timeline.SetDesiredFrameRate(doubleAnim, 240);
diff --git a/.Source/GTweak/Windows/LoadingWindow.xaml.cs b/.Source/GTweak/Windows/LoadingWindow.xaml.cs
index 1eb4476a..50af86be 100644
--- a/.Source/GTweak/Windows/LoadingWindow.xaml.cs
+++ b/.Source/GTweak/Windows/LoadingWindow.xaml.cs
@@ -49,7 +49,6 @@ namespace GTweak.Windows
Parallel.Invoke(
() => ExecuteWithLogging(TrustedInstaller.StartTrustedInstallerService, nameof(TrustedInstaller.StartTrustedInstallerService)),
- () => ExecuteWithLogging(SettingsRepository.СheckingParameters, nameof(SettingsRepository.СheckingParameters)),
() => ExecuteWithLogging(WindowsLicense.LicenseStatus, nameof(WindowsLicense.LicenseStatus)),
() => ExecuteWithLogging(new SystemDiagnostics().GetHardwareData, nameof(SystemDiagnostics.GetHardwareData)),
() => ExecuteWithLogging(new SystemDiagnostics().ValidateVersionUpdates, nameof(SystemDiagnostics.ValidateVersionUpdates)),
diff --git a/.Source/GTweak/Windows/MainWindow.xaml.cs b/.Source/GTweak/Windows/MainWindow.xaml.cs
index 91cc5852..ae2fd930 100644
--- a/.Source/GTweak/Windows/MainWindow.xaml.cs
+++ b/.Source/GTweak/Windows/MainWindow.xaml.cs
@@ -111,7 +111,6 @@ namespace GTweak
BeginAnimation(OpacityProperty, FadeAnimation.FadeIn(1, 0.3,
async () =>
{
-
if (SystemDiagnostics.IsNeedUpdate && SettingsRepository.IsUpdateCheckRequired)
{
await Task.Delay(500);
diff --git a/.Source/GTweak/Windows/RebootWindow.xaml.cs b/.Source/GTweak/Windows/RebootWindow.xaml.cs
index 7f14ced4..3272a80a 100644
--- a/.Source/GTweak/Windows/RebootWindow.xaml.cs
+++ b/.Source/GTweak/Windows/RebootWindow.xaml.cs
@@ -12,6 +12,6 @@ namespace GTweak.Windows
InitializeComponent();
}
- private void Window_Loaded(object sender, RoutedEventArgs e) => RestartProgress.BeginAnimation(ProgressBar.ValueProperty, FadeAnimation.FadeIn(1, 1.5, () => { SettingsRepository.SelfReboot(); }));
+ private void Window_Loaded(object sender, RoutedEventArgs e) => RestartProgress.BeginAnimation(ProgressBar.ValueProperty, FadeAnimation.FadeIn(100, 1.5, () => { SettingsRepository.SelfReboot(); }));
}
}