Skip to content

Portable Tool for an Ideal Windows Setup

-volume correction in different locations of the utility & re

Greedeks59d63087f5ab
diff --git a/.Source/GTweak/Utilities/Control/SettingsRepository.cs b/.Source/GTweak/Utilities/Control/SettingsRepository.cs
index 9b8b449a..fbe4af63 100644
--- a/.Source/GTweak/Utilities/Control/SettingsRepository.cs
+++ b/.Source/GTweak/Utilities/Control/SettingsRepository.cs
@@ -23,19 +23,14 @@ namespace GTweak.Utilities.Control
internal sealed class SettingsRepository
{
- internal sealed class WinmmMethods
- {
- [DllImport("winmm.dll")]
- internal static extern int waveOutGetVolume(IntPtr hwo, out uint dwVolume);
-
- [DllImport("winmm.dll")]
- internal static extern int waveOutSetVolume(IntPtr hwo, uint dwVolume);
- }
+ [DllImport("winmm.dll")]
+ internal static extern int waveOutSetVolume(IntPtr hwo, uint dwVolume);
private static bool _isViewNotification = true;
private static bool _isPlayingSound = true;
private static bool _isTopMost = false;
private static bool _isСheckingUpdate = true;
+ private static byte _volume = 50;
private static string _language = App.GettingSystemLanguage;
private static string _theme = "Dark";
internal static bool _isHiddenIpAddress = false;
@@ -49,6 +44,7 @@ namespace GTweak.Utilities.Control
internal static bool IsPlayingSound { get => _isPlayingSound; set => _isPlayingSound = value; }
internal static bool IsTopMost { get => _isTopMost; set => _isTopMost = value; }
internal static bool IsСheckingUpdate { get => _isСheckingUpdate; set => _isСheckingUpdate = value; }
+ internal static byte Volume { get => _volume; set => _volume = value; }
internal static string Language { get => _language; set => _language = value; }
internal static string Theme { get => _theme; set => _theme = value; }
internal static bool IsHiddenIpAddress { get => _isHiddenIpAddress; set => _isHiddenIpAddress = value; }
@@ -56,17 +52,18 @@ namespace GTweak.Utilities.Control
internal void СheckingParameters()
{
RegistryKey registryKey = Registry.CurrentUser.CreateSubKey(@"Software\GTweak");
- if (registryKey == null || registryKey.GetValue("Notification", null) == null || registryKey.GetValue("Sound", null) == null || registryKey.GetValue("TopMost", null) == null ||
- registryKey.GetValue("Update", null) == null || registryKey.GetValue("Language", null) == null || registryKey.GetValue("HiddenIP", null) == null || registryKey.GetValue("Theme", null) == null)
+ if (registryKey == null || registryKey.GetValue("Notification", null) == null || registryKey.GetValue("Sound", null) == null || registryKey.GetValue("TopMost", null) == null || registryKey.GetValue("Update", null) == null
+ || registryKey.GetValue("Volume", null) == null || registryKey.GetValue("Language", null) == null || registryKey.GetValue("HiddenIP", null) == null || registryKey.GetValue("Theme", null) == null)
{
registryKey?.SetValue("Notification", IsViewNotification, RegistryValueKind.String);
registryKey?.SetValue("Sound", IsPlayingSound, RegistryValueKind.String);
registryKey?.SetValue("TopMost", IsTopMost, RegistryValueKind.String);
registryKey?.SetValue("Update", IsСheckingUpdate, RegistryValueKind.String);
+ registryKey?.SetValue("Volume", Volume, RegistryValueKind.String);
registryKey?.SetValue("HiddenIP", IsHiddenIpAddress, RegistryValueKind.String);
registryKey?.SetValue("Theme", Theme, RegistryValueKind.String);
registryKey?.SetValue("Language", App.GettingSystemLanguage, RegistryValueKind.String);
- WinmmMethods.waveOutSetVolume(IntPtr.Zero, 0x80008000);
+ waveOutSetVolume(IntPtr.Zero, 0x80008000);
}
else
{
@@ -75,6 +72,7 @@ namespace GTweak.Utilities.Control
IsTopMost = bool.Parse(registryKey?.GetValue("TopMost").ToString() ?? "False");
IsСheckingUpdate = bool.Parse(registryKey?.GetValue("Update").ToString() ?? "True");
IsHiddenIpAddress = bool.Parse(registryKey?.GetValue("HiddenIP").ToString() ?? "False");
+ Volume = byte.Parse(registryKey?.GetValue("Volume").ToString() ?? "50");
Language = registryKey?.GetValue("Language").ToString() ?? App.GettingSystemLanguage;
Theme = registryKey?.GetValue("Theme").ToString() ?? "Dark";
}
@@ -97,6 +95,9 @@ namespace GTweak.Utilities.Control
case "TopMost":
IsTopMost = bool.Parse(registryKey?.GetValue("TopMost").ToString() ?? "False");
break;
+ case "Volume":
+ Volume = byte.Parse(registryKey?.GetValue("Volume").ToString() ?? "50");
+ break;
case "Update":
IsСheckingUpdate = bool.Parse(registryKey?.GetValue("Update").ToString() ?? "True");
break;
diff --git a/.Source/GTweak/Utilities/Helpers/RegistryHelp.cs b/.Source/GTweak/Utilities/Helpers/RegistryHelp.cs
index 483b3c0d..2bfbd9a6 100644
--- a/.Source/GTweak/Utilities/Helpers/RegistryHelp.cs
+++ b/.Source/GTweak/Utilities/Helpers/RegistryHelp.cs
@@ -111,7 +111,7 @@ namespace GTweak.Utilities.Helpers
return string.Concat((byte[])Registry.GetValue(subkey, valueName, null) ?? Array.Empty<byte>()) != expectedValue;
}
- internal static T GetValue<T>(string subKey, string valueName, T defaultValue)
+ internal static T GetValue<T>(in string subKey, in string valueName, in T defaultValue)
{
try
{
diff --git a/.Source/GTweak/Utilities/Tweaks/ConfidentialityTweaks.cs b/.Source/GTweak/Utilities/Tweaks/ConfidentialityTweaks.cs
index 29f5d5c0..1fc50e13 100644
--- a/.Source/GTweak/Utilities/Tweaks/ConfidentialityTweaks.cs
+++ b/.Source/GTweak/Utilities/Tweaks/ConfidentialityTweaks.cs
@@ -105,8 +105,7 @@ namespace GTweak.Utilities.Tweaks
@"0.0.0.0 telemetry.microsoft.com",
@"0.0.0.0 bn3sch020010635.wns.windows.com",
@"0.0.0.0 api.cortana.ai"
- }).Where(hostsrules => hosts.Contains(hostsrules)).Count();
- streamReader.Close();
+ }).Where(rule => hosts.Contains(rule)).Count();
}
return numberHostsRules == 0;
}
diff --git a/.Source/GTweak/Windows/MainWindow.xaml.cs b/.Source/GTweak/Windows/MainWindow.xaml.cs
index 6ce73e26..4d28e65f 100644
--- a/.Source/GTweak/Windows/MainWindow.xaml.cs
+++ b/.Source/GTweak/Windows/MainWindow.xaml.cs
@@ -23,8 +23,7 @@ namespace GTweak
BtnUpdate.StateNA = SettingsRepository.IsСheckingUpdate;
BtnTopMost.StateNA = Topmost = SettingsRepository.IsTopMost;
BtnSoundNtn.IsChecked = SettingsRepository.IsPlayingSound;
- SettingsRepository.WinmmMethods.waveOutGetVolume(IntPtr.Zero, out uint currentVolume);
- SliderVolume.Value = (ushort)(currentVolume & 0x0000ffff) / (ushort.MaxValue / 100);
+ SliderVolume.Value = SettingsRepository.Volume;
LanguageSelectionMenu.SelectedIndex = SettingsRepository.Language == "en" ? 0 : 1;
ThemeSelectionMenu.SelectedIndex = SettingsRepository.Theme switch
{
@@ -156,10 +155,10 @@ namespace GTweak
private void SliderVolume_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
SliderVolume.Value = SliderVolume.Value == 0 ? 1 : SliderVolume.Value;
- SettingsRepository.WinmmMethods.waveOutSetVolume(IntPtr.Zero, ((uint)(double)((ushort.MaxValue / 100) * SliderVolume.Value) & 0x0000ffff) | ((uint)(double)((ushort.MaxValue / 100) * SliderVolume.Value) << 16));
+ SettingsRepository.ChangingParameters(SliderVolume.Value, "Volume");
+ SettingsRepository.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)
{
switch (LanguageSelectionMenu.SelectedIndex)