Skip to content

Portable Tool for an Ideal Windows Setup

-acceleration of reading during import, correction of saving slider settings

Greedeks4fcb03862bcf
diff --git a/.Source/GTweak/Utilities/Settings.cs b/.Source/GTweak/Utilities/Settings.cs
index e34fdfdf..f85b4cd2 100644
--- a/.Source/GTweak/Utilities/Settings.cs
+++ b/.Source/GTweak/Utilities/Settings.cs
@@ -157,7 +157,7 @@ namespace GTweak.Utilities
{
Filter = "(*.INI)|*.INI"
};
- Nullable<bool> isResult = openFileDialog.ShowDialog();
+ bool? isResult = openFileDialog.ShowDialog();
if (isResult == true)
{
diff --git a/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs b/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs
index f1ccbeff..790de3d1 100644
--- a/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs
+++ b/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs
@@ -320,9 +320,6 @@ namespace GTweak.Utilities.Tweaks
private static extern bool SystemParametersInfo(uint _uiAction, uint _uiParam, uint _pvParam, uint _fWinIni);
internal static void UseSystemSliders(string tweak, uint value)
{
- СonfigSettings.configSystem.Remove(tweak);
- СonfigSettings.configSystem.Add(tweak, Convert.ToString(value));
-
switch (tweak)
{
case "Slider1":
diff --git "a/.Source/GTweak/Utilities/\320\241onfigSettings.cs" "b/.Source/GTweak/Utilities/\320\241onfigSettings.cs"
index f3cf26fa..cebbc723 100644
--- "a/.Source/GTweak/Utilities/\320\241onfigSettings.cs"
+++ "b/.Source/GTweak/Utilities/\320\241onfigSettings.cs"
@@ -7,16 +7,18 @@ namespace GTweak.Utilities
{
internal sealed class СonfigSettings
{
- internal static Dictionary<string, string> configConfidentiality = new Dictionary<string, string>();
- internal static Dictionary<string, string> configInterface = new Dictionary<string, string>();
- internal static Dictionary<string, string> configServices = new Dictionary<string, string>();
- internal static Dictionary<string, string> configSystem = new Dictionary<string, string>();
- private readonly string pathToConfig;
-
[DllImport("kernel32")]
- static extern long WritePrivateProfileString(string section, string key, string value, string filePath);
+ private static extern long WritePrivateProfileString(string section, string key, string value, string filePath);
[DllImport("kernel32")]
- static extern int GetPrivateProfileString(string section, string key, string _default, StringBuilder retVal, int size, string filePath);
+ private static extern int GetPrivateProfileString(string section, string key, string _default, StringBuilder retVal, int size, string filePath);
+ [DllImport("kernel32.dll")]
+ private static extern int GetPrivateProfileSection(string section, StringBuilder retVal, int size, string filePath);
+
+ private readonly string pathToConfig;
+ internal static Dictionary<string, string> configConfidentiality = new Dictionary<string, string>(),
+ configInterface = new Dictionary<string, string>(),
+ configServices = new Dictionary<string, string>(),
+ configSystem = new Dictionary<string, string>();
internal СonfigSettings(string iniPath) => pathToConfig = new FileInfo(iniPath).FullName.ToString();
@@ -27,6 +29,13 @@ namespace GTweak.Utilities
return retValue.ToString();
}
+ internal bool IsThereSection(string section)
+ {
+ StringBuilder retValue = new StringBuilder(255);
+ GetPrivateProfileSection(section, retValue, 255, pathToConfig);
+ return !string.IsNullOrEmpty(retValue.ToString());
+ }
+
internal void WriteConfig(string section, string key, string value) => WritePrivateProfileString(section, key, value, pathToConfig);
}
}
diff --git a/.Source/GTweak/View/SystemView.xaml b/.Source/GTweak/View/SystemView.xaml
index 9cd936c9..9838c134 100644
--- a/.Source/GTweak/View/SystemView.xaml
+++ b/.Source/GTweak/View/SystemView.xaml
@@ -25,17 +25,17 @@
<StackPanel Orientation="Vertical" VerticalAlignment="Top" Width="Auto" Height="Auto">
<StackPanel x:Name="TextSlider1" Orientation="Horizontal" Height="45" VerticalAlignment="Top" Margin="20,0,0,0" MouseEnter="TweakSlider_MouseEnter" MouseLeave="Tweak_MouseLeave">
<TextBlock Style="{StaticResource Text}" Foreground="#ffffff" Margin="0,2,0,0" Text="{DynamicResource slider1_system}"/>
- <Slider x:Name="Slider1" Style="{StaticResource Horizontal_Slider}" IsSnapToTickEnabled="True" Minimum="0" Maximum="20" Margin="7,13,0,0" Width="150" ValueChanged="Sliders_ValueChanged"/>
+ <Slider x:Name="Slider1" Style="{StaticResource Horizontal_Slider}" IsSnapToTickEnabled="True" Minimum="0" Maximum="20" Margin="7,13,0,0" Width="150" ValueChanged="Sliders_ValueChanged" PreviewMouseLeftButtonUp="Sliders_PreviewMouseUp"/>
</StackPanel>
<StackPanel x:Name="TextSlider2" Orientation="Horizontal" Height="45" VerticalAlignment="Top" Margin="20,4,0,0" MouseEnter="TweakSlider_MouseEnter" MouseLeave="Tweak_MouseLeave">
<TextBlock Style="{StaticResource Text}" Foreground="#ffffff" Margin="0,2,0,0" Text="{DynamicResource slider2_system}"/>
- <Slider x:Name="Slider2" Style="{StaticResource Horizontal_Slider}" IsSnapToTickEnabled="True" Minimum="0" Maximum="3" Margin="7,13,0,0" Width="150" ValueChanged="Sliders_ValueChanged"/>
+ <Slider x:Name="Slider2" Style="{StaticResource Horizontal_Slider}" IsSnapToTickEnabled="True" Minimum="0" Maximum="3" Margin="7,13,0,0" Width="150" ValueChanged="Sliders_ValueChanged" PreviewMouseLeftButtonUp="Sliders_PreviewMouseUp"/>
</StackPanel>
<StackPanel x:Name="TextSlider3" Orientation="Horizontal" Height="45" VerticalAlignment="Top" Margin="20,4,0,0" MouseEnter="TweakSlider_MouseEnter" MouseLeave="Tweak_MouseLeave">
<TextBlock Style="{StaticResource Text}" Foreground="#ffffff" Margin="0,2,0,0" Text="{DynamicResource slider3_system}"/>
- <Slider x:Name="Slider3" Style="{StaticResource Horizontal_Slider}" IsSnapToTickEnabled="True" Minimum="0" Maximum="31" Margin="7,13,0,0" Width="170" ValueChanged="Sliders_ValueChanged"/>
+ <Slider x:Name="Slider3" Style="{StaticResource Horizontal_Slider}" IsSnapToTickEnabled="True" Minimum="0" Maximum="31" Margin="7,13,0,0" Width="170" ValueChanged="Sliders_ValueChanged" PreviewMouseLeftButtonUp="Sliders_PreviewMouseUp"/>
</StackPanel>
<TextBox x:Name="TestKeybSettings" Margin="-100,5,0,0" Tag="{DynamicResource text_system}" Width="400" MaxLength="50" Cursor="IBeam"/>
diff --git a/.Source/GTweak/View/SystemView.xaml.cs b/.Source/GTweak/View/SystemView.xaml.cs
index 9872be66..f50eedcd 100644
--- a/.Source/GTweak/View/SystemView.xaml.cs
+++ b/.Source/GTweak/View/SystemView.xaml.cs
@@ -49,6 +49,13 @@ namespace GTweak.View
WorkWithText.TypeWriteAnimation((string)FindResource("defaultDescription"), TextDescription, TimeSpan.FromMilliseconds(250));
}
+ private void Sliders_PreviewMouseUp(object sender, MouseButtonEventArgs e)
+ {
+ Slider slider = (Slider)sender;
+ СonfigSettings.configSystem.Remove(slider.Name);
+ СonfigSettings.configSystem.Add(slider.Name, Convert.ToString(slider.Value));
+ }
+
private void Sliders_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
Slider slider = (Slider)sender;
diff --git a/.Source/GTweak/Windows/ImportWindow.xaml.cs b/.Source/GTweak/Windows/ImportWindow.xaml.cs
index 1cf6bb61..e9aafa4e 100644
--- a/.Source/GTweak/Windows/ImportWindow.xaml.cs
+++ b/.Source/GTweak/Windows/ImportWindow.xaml.cs
@@ -50,7 +50,7 @@ namespace GTweak.Windows
_token.ThrowIfCancellationRequested();
СonfigSettings configSettings = new СonfigSettings(Settings.PathConfig);
- if (i == 2)
+ if (i == 2 && configSettings.IsThereSection("Confidentiality Tweaks"))
{
for (byte number = 1; number <= 18; number++)
{
@@ -70,7 +70,7 @@ namespace GTweak.Windows
}
}
- if (i == 30)
+ if (i == 30 && configSettings.IsThereSection("Interface Tweaks"))
{
for (byte number = 1; number <= 28; number++)
{
@@ -102,7 +102,7 @@ namespace GTweak.Windows
}
}
- if (i == 50)
+ if (i == 50 && configSettings.IsThereSection("Services Tweaks"))
{
for (byte number = 1; number <= 28; number++)
{
@@ -116,7 +116,7 @@ namespace GTweak.Windows
}
}
- if (i == 80)
+ if (i == 80 && configSettings.IsThereSection("System Tweaks"))
{
for (byte number = 1; number <= 3; number++)
{