Skip to content

Commit 9caff53

Browse files
committed
4.90.2
-fixed a bug where all settings were not saved -added a check for an empty settings file -refactoring
1 parent 0af8d43 commit 9caff53

File tree

9 files changed

+60
-42
lines changed

9 files changed

+60
-42
lines changed

.Source/GTweak/Language/lang.ru.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
<v:String x:Key="firewalloff_notification">У вас отключен брандмауэр, включите и примените твик снова</v:String>
5454
<v:String x:Key="clearingcache_notification">Произведена очистка системного кэша файлов</v:String>
5555
<v:String x:Key="import_warning_notification">Данный файл не подходит для импорта</v:String>
56+
<v:String x:Key="import_empty_notification">Этот файл пуст, применение твиков невозможно</v:String>
57+
<v:String x:Key="export_warning_notification">Это не имеет смысла, файл будет пустым. Сначала примените хотя бы один твик</v:String>
5658
<v:String x:Key="clear_ram_notification">Очистка кратковременной памяти и временных файлов произведена</v:String>
5759
<v:String x:Key="disable_recovery_notification">Восстановление системы отключено, точки восстановления недоступны</v:String>
5860
<v:String x:Key="warndisable_recovery_notification">У вас уже отключена система восстановления</v:String>

.Source/GTweak/Language/lang.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
<v:String x:Key="firewalloff_notification">Your firewall is disabled, turn it on and apply the tweak again</v:String>
5454
<v:String x:Key="clearingcache_notification">The system file cache has been cleared</v:String>
5555
<v:String x:Key="import_warning_notification">This file is not suitable for import</v:String>
56+
<v:String x:Key="import_empty_notification">This file is empty, the application of tweaks is not possible</v:String>
57+
<v:String x:Key="export_warning_notification">It doesn't make sense, the file will be empty. First, apply at least one tweak</v:String>
5658
<v:String x:Key="clear_ram_notification">Short-term memory and temporary files have been cleared</v:String>
5759
<v:String x:Key="disable_recovery_notification">System recovery is disabled, recovery points are unavailable</v:String>
5860
<v:String x:Key="warndisable_recovery_notification">You have already disabled the recovery system</v:String>

.Source/GTweak/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
[assembly: AssemblyCopyright("Copyright © 2024 Greedeks")]
1111
[assembly: AssemblyTrademark("Greedeks")]
1212
[assembly: AssemblyCulture("")]
13-
[assembly: AssemblyInformationalVersion("Build: 4.90.1")]
14-
[assembly: AssemblyFileVersion("4.90.1")]
13+
[assembly: AssemblyInformationalVersion("Build: 4.90.2")]
14+
[assembly: AssemblyFileVersion("4.90.2")]
1515

1616
[assembly: ComVisible(false)]
1717

.Source/GTweak/Utilities/Helpers/BrushAnimation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace GTweak.Utilities.Helpers
88
{
9-
internal class BrushAnimation : AnimationTimeline
9+
internal sealed class BrushAnimation : AnimationTimeline
1010
{
1111
protected override Freezable CreateInstanceCore()
1212
{

.Source/GTweak/Utilities/Helpers/ButtonNavigation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace GTweak.Utilities.Helpers
55
{
6-
internal class ButtonNavigation : RadioButton
6+
internal sealed class ButtonNavigation : RadioButton
77
{
88
static ButtonNavigation() => DefaultStyleKeyProperty.OverrideMetadata(typeof(ButtonNavigation), new FrameworkPropertyMetadata(typeof(ButtonNavigation)));
99
}

.Source/GTweak/Utilities/Helpers/RegistryHelp.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
namespace GTweak.Utilities.Helpers
66
{
7-
internal struct RegistryHelp
7+
internal readonly struct RegistryHelp
88
{
9-
internal static void DeleteFolderTree(in RegistryKey _registrykey, in string _subkey)
9+
internal static void DeleteFolderTree(in RegistryKey _registrykey, in string _subkey)
1010
{
1111
if (_registrykey.OpenSubKey(_subkey) != null)
1212
try { _registrykey.DeleteSubKeyTree(_subkey); } catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }

.Source/GTweak/Utilities/Helpers/WorkWithText.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace GTweak.Utilities.Helpers
77
{
8-
internal struct WorkWithText
8+
internal readonly struct WorkWithText
99
{
1010
internal static void TypeWriteAnimation(string textToAnimate, TextBlock _textBlock, TimeSpan _timeSpan)
1111
{

.Source/GTweak/Utilities/Settings.cs

Lines changed: 45 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
using System.Diagnostics;
77
using System.Globalization;
88
using System.IO;
9+
using System.Linq;
910
using System.Reflection;
1011
using System.Threading.Tasks;
12+
using System.Windows;
1113

1214
namespace GTweak.Utilities
1315
{
14-
internal struct Settings
16+
internal readonly struct Settings
1517
{
1618
internal static string PathConfig = string.Empty;
1719
internal static string PathSound => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)) + @"\GTweak\Sound.mp3";
@@ -101,44 +103,51 @@ internal static void ChangingParameters<T>(T value, string selection)
101103

102104
internal static void SaveFileConfig()
103105
{
104-
SaveFileDialog saveFileDialog = new SaveFileDialog
105-
{
106-
FileName = "Config GTweak",
107-
Filter = "(*.INI)|*.INI",
108-
RestoreDirectory = true
109-
};
110-
111-
Nullable<bool> isResult = saveFileDialog.ShowDialog();
106+
if (СonfigSettings.configConfidentiality.Count == 0 && СonfigSettings.configInterface.Count == 0
107+
&& СonfigSettings.configServices.Count == 0 && СonfigSettings.configSystem.Count == 0)
108+
new ViewNotification().Show("", (string)Application.Current.Resources["title1_notification"], (string)Application.Current.Resources["export_warning_notification"]);
112109

113-
if (isResult == true)
110+
else
114111
{
115-
string path = Path.GetDirectoryName(saveFileDialog.FileName);
116-
string filename = Path.GetFileNameWithoutExtension(saveFileDialog.FileName);
112+
SaveFileDialog saveFileDialog = new SaveFileDialog
113+
{
114+
FileName = "Config GTweak",
115+
Filter = "(*.INI)|*.INI",
116+
RestoreDirectory = true
117+
};
117118

118-
try
119+
Nullable<bool> isResult = saveFileDialog.ShowDialog();
120+
121+
if (isResult == true)
119122
{
120-
PathConfig = path + @"\" + filename + ".ini";
123+
string path = Path.GetDirectoryName(saveFileDialog.FileName);
124+
string filename = Path.GetFileNameWithoutExtension(saveFileDialog.FileName);
125+
126+
try
127+
{
128+
PathConfig = path + @"\" + filename + ".ini";
121129

122-
if (File.Exists(PathConfig))
123-
File.Delete(PathConfig);
130+
if (File.Exists(PathConfig))
131+
File.Delete(PathConfig);
124132

125-
СonfigSettings settingsFileINI = new СonfigSettings(PathConfig);
126-
settingsFileINI.WriteConfig("GTweak", "Author", "Greedeks");
127-
settingsFileINI.WriteConfig("GTweak", "Release", "v4");
133+
СonfigSettings settingsFileINI = new СonfigSettings(PathConfig);
134+
settingsFileINI.WriteConfig("GTweak", "Author", "Greedeks");
135+
settingsFileINI.WriteConfig("GTweak", "Release", "v4");
128136

129-
foreach (KeyValuePair<string, string> addConfidentiality in СonfigSettings.configConfidentiality)
130-
settingsFileINI.WriteConfig("Confidentiality Tweaks", addConfidentiality.Key, addConfidentiality.Value);
137+
foreach (KeyValuePair<string, string> addConfidentiality in СonfigSettings.configConfidentiality)
138+
settingsFileINI.WriteConfig("Confidentiality Tweaks", addConfidentiality.Key, addConfidentiality.Value);
131139

132-
foreach (KeyValuePair<string, string> addInterface in СonfigSettings.configInterface)
133-
settingsFileINI.WriteConfig("Interface Tweaks", addInterface.Key, addInterface.Value);
140+
foreach (KeyValuePair<string, string> addInterface in СonfigSettings.configInterface)
141+
settingsFileINI.WriteConfig("Interface Tweaks", addInterface.Key, addInterface.Value);
134142

135-
foreach (KeyValuePair<string, string> addServices in СonfigSettings.configServices)
136-
settingsFileINI.WriteConfig("Services Tweaks", addServices.Key, addServices.Value);
143+
foreach (KeyValuePair<string, string> addServices in СonfigSettings.configServices)
144+
settingsFileINI.WriteConfig("Services Tweaks", addServices.Key, addServices.Value);
137145

138-
foreach (KeyValuePair<string,string> addSystem in СonfigSettings.configSystem)
139-
settingsFileINI.WriteConfig("System Tweaks", addSystem.Key, addSystem.Value);
146+
foreach (KeyValuePair<string, string> addSystem in СonfigSettings.configSystem)
147+
settingsFileINI.WriteConfig("System Tweaks", addSystem.Key, addSystem.Value);
148+
}
149+
catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }
140150
}
141-
catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }
142151
}
143152
}
144153

@@ -156,9 +165,14 @@ internal static void OpenFileConfig()
156165
СonfigSettings settingsFileINI = new СonfigSettings(PathConfig);
157166

158167
if (settingsFileINI.ReadConfig("GTweak", "Author").Contains("Greedeks") && settingsFileINI.ReadConfig("GTweak", "Release").Contains("v4"))
159-
new ImportWindow().ShowDialog();
168+
{
169+
if (File.ReadLines(PathConfig).Any(line => line.Contains("TglButton")) || File.ReadLines(PathConfig).Any(line => line.Contains("Slider")))
170+
new ImportWindow().ShowDialog();
171+
else
172+
new ViewNotification().Show("", (string)Application.Current.Resources["title1_notification"], (string)Application.Current.Resources["import_empty_notification"]);
173+
}
160174
else
161-
new ViewNotification().Show("", (string)System.Windows.Application.Current.Resources["title1_notification"], (string)System.Windows.Application.Current.Resources["import_warning_notification"]);
175+
new ViewNotification().Show("", (string)Application.Current.Resources["title1_notification"], (string)Application.Current.Resources["import_warning_notification"]);
162176
}
163177
}
164178

@@ -170,7 +184,7 @@ internal static void SelfRemoval()
170184
RegistryHelp.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\Microsoft\Tracing\GTweak_RASAPI32");
171185
RegistryHelp.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\Microsoft\Tracing\GTweak_RASMANCS");
172186

173-
System.Windows.Application.Current.Shutdown();
187+
Application.Current.Shutdown();
174188
Process.Start(new ProcessStartInfo()
175189
{
176190
Arguments = "/C choice /C Y /N /D Y /T 3 & Del \"" + (new FileInfo(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath)).Name + "\" & " +

.Source/GTweak/Utilities/СonfigSettings.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ namespace GTweak.Utilities
77
{
88
internal sealed class СonfigSettings
99
{
10-
internal static Dictionary<string, string> configConfidentiality = new Dictionary<string, string>(18);
11-
internal static Dictionary<string, string> configInterface = new Dictionary<string, string>(28);
12-
internal static Dictionary<string, string> configServices = new Dictionary<string, string>(28);
13-
internal static Dictionary<string, string> configSystem = new Dictionary<string, string>(23);
10+
internal static Dictionary<string, string> configConfidentiality = new Dictionary<string, string>();
11+
internal static Dictionary<string, string> configInterface = new Dictionary<string, string>();
12+
internal static Dictionary<string, string> configServices = new Dictionary<string, string>();
13+
internal static Dictionary<string, string> configSystem = new Dictionary<string, string>();
1414
private readonly string pathToConfig;
1515

1616
[DllImport("kernel32")]

0 commit comments

Comments
 (0)