Skip to content

Portable Tool for an Ideal Windows Setup

-getting rid of MediaPlayer and uploading temporary files to disk

Greedeks7129d538245c
diff --git a/.Source/GTweak/GTweak.csproj b/.Source/GTweak/GTweak.csproj
index e79314d1..76646d2d 100644
--- a/.Source/GTweak/GTweak.csproj
+++ b/.Source/GTweak/GTweak.csproj
@@ -256,6 +256,11 @@
<DependentUpon>Card.xaml</DependentUpon>
</Compile>
<Compile Include="Core\Model\DataSystemModel.cs" />
+ <Compile Include="Properties\Resources.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DesignTime>True</DesignTime>
+ <DependentUpon>Resources.resx</DependentUpon>
+ </Compile>
<Compile Include="Utilities\BlockRunTweaker.cs" />
<Compile Include="Utilities\DisablingWinKeys.cs" />
<Compile Include="Utilities\Helpers\TaskSchedulerManager.cs" />
@@ -493,11 +498,6 @@
</Page>
</ItemGroup>
<ItemGroup>
- <Compile Include="Properties\Resources.Designer.cs">
- <AutoGen>True</AutoGen>
- <DesignTime>True</DesignTime>
- <DependentUpon>Resources.resx</DependentUpon>
- </Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
@@ -509,9 +509,7 @@
</EmbeddedResource>
<None Include="packages.config" />
<None Include="Resources\Blank.gz" />
- <None Include="Resources\GTweak.gz" />
<None Include="Resources\hosts.gz" />
- <None Include="Resources\Sound.gz" />
<None Include="Resources\Ultimate Performance.pow.gz" />
<Resource Include="Assets\Font\Jura-Medium.ttf" />
<None Include="app.manifest" />
@@ -554,6 +552,7 @@
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>AssemblyInfo.cs</LastGenOutput>
</Content>
+ <None Include="Resources\Sound.wav" />
</ItemGroup>
<ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
diff --git a/.Source/GTweak/Properties/AssemblyInfo.cs b/.Source/GTweak/Properties/AssemblyInfo.cs
index a6714707..28f73776 100644
--- a/.Source/GTweak/Properties/AssemblyInfo.cs
+++ b/.Source/GTweak/Properties/AssemblyInfo.cs
@@ -7,9 +7,9 @@ using System.Windows;
[assembly: AssemblyProduct("GTweak")]
[assembly: AssemblyCopyright("Copyright � Greedeks 2024")]
[assembly: AssemblyTrademark("Greedeks")]
-[assembly: AssemblyInformationalVersion("Build: 5.0.3")]
-[assembly: AssemblyVersion("5.0.35.603")]
-[assembly: AssemblyFileVersion("5.0.35.603")]
+[assembly: AssemblyInformationalVersion("Build: 5.0.4")]
+[assembly: AssemblyVersion("5.0.38.18")]
+[assembly: AssemblyFileVersion("5.0.38.18")]
[assembly: ComVisible(false)]
diff --git a/.Source/GTweak/Properties/AssemblyInfo.tt b/.Source/GTweak/Properties/AssemblyInfo.tt
index abd70ba5..f5870508 100644
--- a/.Source/GTweak/Properties/AssemblyInfo.tt
+++ b/.Source/GTweak/Properties/AssemblyInfo.tt
@@ -9,7 +9,7 @@ using System.Windows;
[assembly: AssemblyProduct("GTweak")]
[assembly: AssemblyCopyright("Copyright � Greedeks 2024")]
[assembly: AssemblyTrademark("Greedeks")]
-[assembly: AssemblyInformationalVersion("Build: 5.0.3")]
+[assembly: AssemblyInformationalVersion("Build: 5.0.4")]
[assembly: AssemblyVersion("5.<#= GenerateVersion() #>")]
[assembly: AssemblyFileVersion("5.<#= GenerateVersion() #>")]
diff --git a/.Source/GTweak/Properties/Resources.Designer.cs b/.Source/GTweak/Properties/Resources.Designer.cs
index eded4c78..24e6ef02 100644
--- a/.Source/GTweak/Properties/Resources.Designer.cs
+++ b/.Source/GTweak/Properties/Resources.Designer.cs
@@ -70,16 +70,6 @@ namespace GTweak.Properties {
}
}
- /// <summary>
- /// Поиск локализованного ресурса типа System.Byte[].
- /// </summary>
- internal static byte[] GTweak {
- get {
- object obj = ResourceManager.GetObject("GTweak", resourceCulture);
- return ((byte[])(obj));
- }
- }
-
/// <summary>
/// Поиск локализованного ресурса типа System.Byte[].
/// </summary>
@@ -91,12 +81,11 @@ namespace GTweak.Properties {
}
/// <summary>
- /// Поиск локализованного ресурса типа System.Byte[].
+ /// Поиск локализованного ресурса типа System.IO.UnmanagedMemoryStream, аналогичного System.IO.MemoryStream.
/// </summary>
- internal static byte[] Sound {
+ internal static System.IO.UnmanagedMemoryStream Sound {
get {
- object obj = ResourceManager.GetObject("Sound", resourceCulture);
- return ((byte[])(obj));
+ return ResourceManager.GetStream("Sound", resourceCulture);
}
}
diff --git a/.Source/GTweak/Properties/Resources.resx b/.Source/GTweak/Properties/Resources.resx
index 5fb9c483..0631b3f5 100644
--- a/.Source/GTweak/Properties/Resources.resx
+++ b/.Source/GTweak/Properties/Resources.resx
@@ -121,14 +121,11 @@
<data name="Blank" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Blank.gz;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
- <data name="GTweak" type="System.Resources.ResXFileRef, System.Windows.Forms">
- <value>..\Resources\GTweak.gz;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
- </data>
<data name="hosts" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\hosts.gz;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="Sound" type="System.Resources.ResXFileRef, System.Windows.Forms">
- <value>..\Resources\Sound.gz;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ <value>..\Resources\Sound.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="Ultimate_Performance_pow" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Ultimate Performance.pow.gz;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
diff --git a/.Source/GTweak/Resources/GTweak.gz b/.Source/GTweak/Resources/GTweak.gz
deleted file mode 100644
index b0ff156f..00000000
Binary files a/.Source/GTweak/Resources/GTweak.gz and /dev/null differ
diff --git a/.Source/GTweak/Resources/Sound.gz b/.Source/GTweak/Resources/Sound.gz
deleted file mode 100644
index 58e25ae3..00000000
Binary files a/.Source/GTweak/Resources/Sound.gz and /dev/null differ
diff --git a/.Source/GTweak/Resources/Sound.wav b/.Source/GTweak/Resources/Sound.wav
new file mode 100644
index 00000000..44eda6f7
Binary files /dev/null and b/.Source/GTweak/Resources/Sound.wav differ
diff --git a/.Source/GTweak/Utilities/Settings.cs b/.Source/GTweak/Utilities/Settings.cs
index 3e2325f8..46020c0b 100644
--- a/.Source/GTweak/Utilities/Settings.cs
+++ b/.Source/GTweak/Utilities/Settings.cs
@@ -17,17 +17,24 @@ namespace GTweak.Utilities
{
internal static string Config = string.Empty;
internal static string FileLocation => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"GTweak");
- internal static string Sound => Path.Combine(FileLocation + @"\resource\notify.mp3");
- internal static string Icon => Path.Combine(FileLocation + @"\resource\GTweak.ico");
internal static string SystemDisk => Path.GetPathRoot(Environment.GetFolderPath(Environment.SpecialFolder.System));
internal static string Hosts => Path.Combine(Environment.SystemDirectory, @"drivers\etc\hosts");
}
internal sealed class Settings
{
+ internal sealed class WinmmMethods
+ {
+ [DllImport("winmm.dll")]
+ public static extern int waveOutGetVolume(IntPtr hwo, out uint dwVolume);
+
+ [DllImport("winmm.dll")]
+ public static extern int waveOutSetVolume(IntPtr hwo, uint dwVolume);
+ }
+
+ private const uint volumeFirstStart = 50;
private static bool _isViewNotification = true;
private static bool _isPlayingSound = true;
- private static byte _volumeNotification = 50;
private static bool _isTopMost = false;
private static bool _isСheckingUpdate = true;
private static string _language = App.GettingSystemLanguage;
@@ -41,47 +48,37 @@ namespace GTweak.Utilities
internal static bool IsViewNotification { get => _isViewNotification; set => _isViewNotification = value; }
internal static bool IsPlayingSound { get => _isPlayingSound; set => _isPlayingSound = value; }
- internal static byte VolumeNotification { get => _volumeNotification; set => _volumeNotification = value; }
internal static bool IsTopMost { get => _isTopMost; set => _isTopMost = value; }
internal static bool IsСheckingUpdate { get => _isСheckingUpdate; set => _isСheckingUpdate = 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; }
- internal void CheckingTempFiles()
- {
- if (!File.Exists(UsePath.Icon))
- new UnarchiveManager(UsePath.Icon, Properties.Resources.GTweak);
-
- if (!File.Exists(UsePath.Sound))
- new UnarchiveManager(UsePath.Sound, Properties.Resources.Sound);
- }
-
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("Volume", null) == null || registryKey.GetValue("TopMost", 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("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("Volume", VolumeNotification, RegistryValueKind.String);
registryKey?.SetValue("TopMost", IsTopMost, RegistryValueKind.String);
registryKey?.SetValue("Update", IsСheckingUpdate, 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, ((uint)(double)((ushort.MaxValue / 100) * volumeFirstStart) & 0x0000ffff) | ((uint)(double)((ushort.MaxValue / 100) * volumeFirstStart) << 16));
}
else
{
IsViewNotification = bool.Parse(registryKey?.GetValue("Notification").ToString() ?? "True");
IsPlayingSound = bool.Parse(registryKey?.GetValue("Sound").ToString() ?? "True");
- VolumeNotification = byte.Parse(registryKey?.GetValue("Volume").ToString() ?? "50");
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");
Language = registryKey?.GetValue("Language").ToString() ?? App.GettingSystemLanguage;
Theme = registryKey?.GetValue("Theme").ToString() ?? "Dark";
+
}
registryKey?.Close();
}
@@ -99,9 +96,6 @@ namespace GTweak.Utilities
case "Sound":
IsPlayingSound = bool.Parse(registryKey?.GetValue("Sound").ToString() ?? "True");
break;
- case "Volume":
- VolumeNotification = byte.Parse(registryKey?.GetValue("Volume").ToString() ?? "50");
- break;
case "TopMost":
IsTopMost = bool.Parse(registryKey?.GetValue("TopMost").ToString() ?? "False");
break;
diff --git a/.Source/GTweak/Utilities/ViewNotification.cs b/.Source/GTweak/Utilities/ViewNotification.cs
index f36da26f..0a8c356f 100644
--- a/.Source/GTweak/Utilities/ViewNotification.cs
+++ b/.Source/GTweak/Utilities/ViewNotification.cs
@@ -1,5 +1,4 @@
using GTweak.Windows;
-using System.Threading;
using System.Threading.Tasks;
using System.Windows;
@@ -9,15 +8,10 @@ namespace GTweak.Utilities
{
private static bool isAlreadyLaunch = false;
- internal async void Show(string action, string tittle = "", string content = "")
+ internal void Show(string action, string tittle = "", string content = "")
{
if (Settings.IsViewNotification)
{
- Thread _thread = new Thread(() => new Settings().CheckingTempFiles()) { IsBackground = true };
- _thread.Start();
-
- await Task.Delay(200);
-
Application.Current.Dispatcher.Invoke(delegate
{
Parallel.Invoke(async delegate
@@ -40,7 +34,7 @@ namespace GTweak.Utilities
TextNotice = content,
ActionNotice = action,
};
- await Task.Delay(100);
+ await Task.Delay(200);
notificationWindow.Show();
notificationWindow.Closed += delegate { isAlreadyLaunch = false; };
});
diff --git a/.Source/GTweak/Windows/LoadingWindow.xaml.cs b/.Source/GTweak/Windows/LoadingWindow.xaml.cs
index 9c787c2d..03405885 100644
--- a/.Source/GTweak/Windows/LoadingWindow.xaml.cs
+++ b/.Source/GTweak/Windows/LoadingWindow.xaml.cs
@@ -49,7 +49,6 @@ namespace GTweak.Windows
Parallel.Invoke(
delegate { Settings.PID = TrustedInstaller.StartTrustedInstallerService(); },
new Settings().СheckingParameters,
- new Settings().CheckingTempFiles,
new WindowsLicense().LicenseStatus,
new SystemData.СomputerСonfiguration().GetConfiguration,
new SearchUpdates().StartСhecking,
diff --git a/.Source/GTweak/Windows/MainWindow.xaml.cs b/.Source/GTweak/Windows/MainWindow.xaml.cs
index 8d2722e9..3e2c4677 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.Security.Policy;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
@@ -24,7 +23,8 @@ namespace GTweak
BtnUpdate.StateNA = Settings.IsСheckingUpdate;
BtnTopMost.StateNA = Topmost = Settings.IsTopMost;
BtnSoundNtn.IsChecked = Settings.IsPlayingSound;
- SliderVolume.Value = Settings.VolumeNotification;
+ Settings.WinmmMethods.waveOutGetVolume(IntPtr.Zero, out uint CurrentVolume);
+ SliderVolume.Value = (ushort)(CurrentVolume & 0x0000ffff) / (ushort.MaxValue / 100);
LanguageSelectionMenu.SelectedIndex = Settings.Language == "en" ? 0 : 1;
ThemeSelectionMenu.SelectedIndex = Settings.Theme switch
{
@@ -152,7 +152,7 @@ namespace GTweak
private void SliderVolume_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
SliderVolume.Value = SliderVolume.Value == 0 ? 1 : SliderVolume.Value;
- Parallel.Invoke(() => { Settings.ChangingParameters(SliderVolume.Value, "Volume"); });
+ Settings.WinmmMethods.waveOutSetVolume(IntPtr.Zero, ((uint)(double)((ushort.MaxValue / 100) * SliderVolume.Value) & 0x0000ffff) | ((uint)(double)((ushort.MaxValue / 100) * SliderVolume.Value) << 16));
}
private void BtnSoundNtn_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
diff --git a/.Source/GTweak/Windows/NotificationWindow.xaml.cs b/.Source/GTweak/Windows/NotificationWindow.xaml.cs
index 7a17414d..f7dc5cb2 100644
--- a/.Source/GTweak/Windows/NotificationWindow.xaml.cs
+++ b/.Source/GTweak/Windows/NotificationWindow.xaml.cs
@@ -2,10 +2,10 @@
using System;
using System.ComponentModel;
using System.Diagnostics;
+using System.Media;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
-using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Threading;
@@ -15,7 +15,6 @@ namespace GTweak.Windows
{
private readonly DispatcherTimer timer;
private TimeSpan time = TimeSpan.FromSeconds(3);
- private readonly MediaPlayer _mediaPlayer = new MediaPlayer();
private string clickAction = string.Empty;
internal string TitleNotice { set => TitleSet.Text = value; get => TitleSet.Text; }
@@ -26,8 +25,6 @@ namespace GTweak.Windows
{
InitializeComponent();
- ImageBody.Source ??= (ImageSource)new ImageSourceConverter().ConvertFromString(UsePath.Icon);
-
timer = new DispatcherTimer(new TimeSpan(0, 0, 1), DispatcherPriority.Normal, delegate
{
if (time == TimeSpan.Zero) { timer.Stop(); this.Close(); }
@@ -63,9 +60,8 @@ namespace GTweak.Windows
{
if (Settings.IsPlayingSound)
{
- _mediaPlayer.Open(new Uri(UsePath.Sound));
- _mediaPlayer.Volume = Settings.VolumeNotification / 100.0f;
- _mediaPlayer.Play();
+ using SoundPlayer notificationSound = new SoundPlayer(Properties.Resources.Sound);
+ notificationSound.Play();
}
switch (ActionNotice)