Portable Tool for an Ideal Windows Setup
C# activatorbloatware-removalcsharpdebloatdebloaterdisable-servicesmonitoring-systemportableprivacy-toolsregistry-tweakssystem-tuningsystem-utilitytelemetrytweakerwindows-10windows-11windows-debloatwindows-defenderwindows-optimizationwindows-tweaks
-the program update window and the start of the process
Greedeks97ac92ae0dc3
diff --git a/.Source/GTweak/GTweak.csproj b/.Source/GTweak/GTweak.csprojindex 098d101f..58e2cb75 100644--- a/.Source/GTweak/GTweak.csproj+++ b/.Source/GTweak/GTweak.csproj@@ -282,6 +282,9 @@<Compile Include="Windows\RebootWindow.xaml.cs"><DependentUpon>RebootWindow.xaml</DependentUpon></Compile>+ <Compile Include="Windows\UpdateWindow.xaml.cs">+ <DependentUpon>UpdateWindow.xaml</DependentUpon>+ </Compile><Compile Include="Windows\WaitingWindow.xaml.cs"><DependentUpon>WaitingWindow.xaml</DependentUpon></Compile>@@ -455,6 +458,10 @@<SubType>Designer</SubType><Generator>MSBuild:Compile</Generator></Page>+ <Page Include="Windows\UpdateWindow.xaml">+ <SubType>Designer</SubType>+ <Generator>MSBuild:Compile</Generator>+ </Page><Page Include="Windows\WaitingWindow.xaml"><SubType>Designer</SubType><Generator>MSBuild:Compile</Generator>diff --git a/.Source/GTweak/Languages/en/Lang.xaml b/.Source/GTweak/Languages/en/Lang.xamlindex 31615f34..81495146 100644--- a/.Source/GTweak/Languages/en/Lang.xaml+++ b/.Source/GTweak/Languages/en/Lang.xaml@@ -58,6 +58,7 @@<v:String x:Key="clear_ram_notification">Short-term memory and temporary files have been cleared</v:String><v:String x:Key="disable_recovery_notification">System recovery is disabled, recovery points are unavailable</v:String><v:String x:Key="warndisable_recovery_notification">You have already disabled the recovery system</v:String>+ <v:String x:Key="warn_update_notification">An error occurred during the program update, please try again later</v:String><!--#endregion--><!--#region Main Window -->@@ -98,6 +99,15 @@<v:String x:Key="title_reboot">Attention GTweak reboot</v:String><!--#endregion-->+ <!--#region Update Window -->+ <v:String x:Key="text_update">A new version of the program is available. Do you want to download and update it?</v:String>+ <v:String x:Key="log_update">Сhangelog</v:String>+ <v:String x:Key="btn_now_update">Update</v:String>+ <v:String x:Key="btn_later_update">Later</v:String>+ <v:String x:Key="download_update">Downloading the update</v:String>+ <v:String x:Key="connection_update">Connecting to the server</v:String>+ <!--#endregion-->+<!--#region Confidentiality Page --><v:String x:Key="tgl1_confidentiality">Advertising identifier and targeted advertising</v:String><v:String x:Key="tgl2_confidentiality">All types of syncing your data</v:String>diff --git a/.Source/GTweak/Languages/ru/Lang.xaml b/.Source/GTweak/Languages/ru/Lang.xamlindex 958fa5f5..a5fc1957 100644--- a/.Source/GTweak/Languages/ru/Lang.xaml+++ b/.Source/GTweak/Languages/ru/Lang.xaml@@ -58,6 +58,7 @@<v:String x:Key="clear_ram_notification">Очистка кратковременной памяти и временных файлов произведена</v:String><v:String x:Key="disable_recovery_notification">Восстановление системы отключено, точки восстановления недоступны</v:String><v:String x:Key="warndisable_recovery_notification">У вас уже отключена система восстановления</v:String>+ <v:String x:Key="warn_update_notification">Во время обновления программы произошла ошибка, повторите попытку позже</v:String><!--#endregion--><!--#region Main Window -->@@ -98,6 +99,15 @@<v:String x:Key="title_reboot">Внимание перезагрузка GTweak</v:String><!--#endregion-->+ <!--#region Update Window -->+ <v:String x:Key="text_update">Вам доступна новая версия программы. Вы хотите загрузить и обновить ее?</v:String>+ <v:String x:Key="log_update">Список изменений</v:String>+ <v:String x:Key="btn_now_update">Обновиться</v:String>+ <v:String x:Key="btn_later_update">Позже</v:String>+ <v:String x:Key="download_update">Скачивания обновления</v:String>+ <v:String x:Key="connection_update">Подключение к серверу</v:String>+ <!--#endregion-->+<!--#region Confidentiality Page --><v:String x:Key="tgl1_confidentiality">Рекламный идентификатор и таргетированная реклама</v:String><v:String x:Key="tgl2_confidentiality">Все типы синхронизация ваших данных</v:String>diff --git a/.Source/GTweak/Utilities/Settings.cs b/.Source/GTweak/Utilities/Settings.csindex e3fba079..d7803402 100644--- a/.Source/GTweak/Utilities/Settings.cs+++ b/.Source/GTweak/Utilities/Settings.cs@@ -48,7 +48,7 @@ namespace GTweak.Utilitiesprivate readonly 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("Volume", 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);diff --git a/.Source/GTweak/Utilities/Tweaks/SystemData.cs b/.Source/GTweak/Utilities/Tweaks/SystemData.csindex 192563fd..bf906f03 100644--- a/.Source/GTweak/Utilities/Tweaks/SystemData.cs+++ b/.Source/GTweak/Utilities/Tweaks/SystemData.cs@@ -306,34 +306,34 @@ namespace GTweak.Utilities.Tweaksinternal sealed class UtilityСonfiguration{+ internal static bool IsNeedUpdate = false;+internal sealed class GitVersionUtility{[JsonProperty("tag_name")]internal string СurrentVersion { get; set; }}- internal static bool IsNeedUpdate()+ internal void CheckingUpdate(){- if (СomputerСonfiguration.IsCheckInternetConnection())- {- if (!(WebRequest.Create("https://api.github.com/repos/greedeks/gtweak/releases/latest") is HttpWebRequest webRequest))- return false;+ if (!Settings.IsСheckingUpdate)+ return;- webRequest.ContentType = "application/json";- webRequest.UserAgent = "Nothing";+ if (!(WebRequest.Create("https://api.github.com/repos/greedeks/gtweak/releases/latest") is HttpWebRequest webRequest))+ return;- using Stream stream = webRequest.GetResponse().GetResponseStream();- using StreamReader sreader = new StreamReader(stream);- string DataAsJson = sreader.ReadToEnd();- GitVersionUtility gitVersionUtility = JsonConvert.DeserializeObject<GitVersionUtility>(DataAsJson);- if ((Assembly.GetEntryAssembly() ?? throw new InvalidOperationException()).GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion.Split(' ').Last().Trim() != gitVersionUtility.СurrentVersion)- return true;- else- return false;- }- else- return false;+ webRequest.ContentType = "application/json";+ webRequest.UserAgent = "Nothing";++ using Stream stream = webRequest.GetResponse().GetResponseStream();+ using StreamReader sreader = new StreamReader(stream);+ string DataAsJson = sreader.ReadToEnd();+ GitVersionUtility gitVersionUtility = JsonConvert.DeserializeObject<GitVersionUtility>(DataAsJson);++ if (!string.IsNullOrEmpty(gitVersionUtility.СurrentVersion) && (Assembly.GetEntryAssembly() ?? throw new InvalidOperationException()).GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion.Split(' ').Last().Trim() != gitVersionUtility.СurrentVersion)+ IsNeedUpdate = true;}+}}}diff --git a/.Source/GTweak/View/ApplicationsView.xaml.cs b/.Source/GTweak/View/ApplicationsView.xaml.csindex cbd0fda1..565b44d5 100644--- a/.Source/GTweak/View/ApplicationsView.xaml.cs+++ b/.Source/GTweak/View/ApplicationsView.xaml.cs@@ -104,7 +104,7 @@ namespace GTweak.View}BackgroundWorker backgroundWorker = new BackgroundWorker();- backgroundWorker.DoWork += (s, _) =>+ backgroundWorker.DoWork += delegate{new ViewNotification().Show("", (string)FindResource("title1_notification"), (string)FindResource("appsdelete_notification"));Parallel.Invoke(UninstallingApps.DeletedAllApps);diff --git a/.Source/GTweak/Windows/LoadingWindow.xaml.cs b/.Source/GTweak/Windows/LoadingWindow.xaml.csindex ce6cda46..085ba5fe 100644--- a/.Source/GTweak/Windows/LoadingWindow.xaml.cs+++ b/.Source/GTweak/Windows/LoadingWindow.xaml.cs@@ -52,6 +52,7 @@ namespace GTweak.Windowsnew Settings().RunAnalysis,new WindowsLicense().LicenseStatus,new SystemData.СomputerСonfiguration().GetСonfigurationComputer,+ new SystemData.UtilityСonfiguration().CheckingUpdate,new UninstallingApps().ViewInstalledApp,new UninstallingApps().CheckingForLocalAccount,new SystemTweaks().ViewNetshState,diff --git a/.Source/GTweak/Windows/MainWindow.xaml.cs b/.Source/GTweak/Windows/MainWindow.xaml.csindex 92d8a4c0..61284d2e 100644--- a/.Source/GTweak/Windows/MainWindow.xaml.cs+++ b/.Source/GTweak/Windows/MainWindow.xaml.cs@@ -125,6 +125,14 @@ namespace GTweakDuration = TimeSpan.FromSeconds(0.3),EasingFunction = new QuadraticEase()};+ doubleAnim.Completed += async delegate+ {+ if (SystemData.UtilityСonfiguration.IsNeedUpdate && Settings.IsСheckingUpdate)+ {+ await Task.Delay(1000);+ new UpdateWindow().ShowDialog();+ }+ };Timeline.SetDesiredFrameRate(doubleAnim, 400);BeginAnimation(OpacityProperty, doubleAnim);new TypewriterAnimation(UtilityTitle.Text, UtilityTitle, TimeSpan.FromSeconds(0.4));diff --git a/.Source/GTweak/Windows/MessageWindow.xaml b/.Source/GTweak/Windows/MessageWindow.xamlindex 5f0ffcc5..51d2942e 100644--- a/.Source/GTweak/Windows/MessageWindow.xaml+++ b/.Source/GTweak/Windows/MessageWindow.xaml@@ -36,7 +36,7 @@</Grid><Grid Grid.Row="1">- <TextBlock Foreground="{StaticResource Color_TetBlock_Inactivity}" Height="auto" Width="330" FontFamily="{StaticResource Jura}" FontSize="15px" TextWrapping="Wrap"+ <TextBlock Foreground="{StaticResource Color_TetBlock_Inactivity}" Height="auto" Width="330" FontFamily="{StaticResource Jura}" FontSize="15px" TextWrapping="Wrap"HorizontalAlignment="Center" TextAlignment="Left" FontStretch="Medium" Margin="5,16,0,0"><Run x:Name="TextRun0" Text="{DynamicResource text0_message}"/><Run x:Name="TextRun1" Text="{DynamicResource text1_message}" Foreground="{StaticResource Color_Accent}"/>diff --git a/.Source/GTweak/Windows/UpdateWindow.xaml b/.Source/GTweak/Windows/UpdateWindow.xamlnew file mode 100644index 00000000..a56920a1--- /dev/null+++ b/.Source/GTweak/Windows/UpdateWindow.xaml@@ -0,0 +1,81 @@+<Window x:Class="GTweak.Windows.UpdateWindow"+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"+ xmlns:local="clr-namespace:GTweak.Windows"+ mc:Ignorable="d"+ Title="GTweak" WindowStyle="None"+ Height="180" Width="350" MinHeight="180" MinWidth="350" MaxHeight="200" MaxWidth="350"+ Background="Transparent" AllowsTransparency="True" WindowStartupLocation="CenterScreen" ResizeMode="CanMinimize"+ IsTabStop="False" Loaded="Window_Loaded" Closing="Window_Closing">+ <Grid>+ <Border Background="{StaticResource Color_Background}" BorderThickness="1" CornerRadius="7" Opacity="0.98">+ <Border.BorderBrush>+ <LinearGradientBrush>+ <GradientStop Color="{StaticResource Color_Border_Gradient_1}" Offset="0"/>+ <GradientStop Color="{StaticResource Color_Border_Gradient_2}" Offset="1"/>+ </LinearGradientBrush>+ </Border.BorderBrush>++ <Grid Margin="0" Background="Transparent">+ <Grid.RowDefinitions>+ <RowDefinition Height="31*"/>+ <RowDefinition Height="141*"/>+ </Grid.RowDefinitions>++ <Grid x:Name="TitleBar" Grid.Row="0" SnapsToDevicePixels="True" UseLayoutRounding="True" MouseDown="TitleBar_MouseDown">+ <Border Background="{StaticResource Color_Background_Dark}" CornerRadius="9,9,0,0">+ <TextBlock FontFamily="{StaticResource Jura}" Text="GTweak" Foreground="{StaticResource Color_Accent}" FontSize="17px" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,5,0,0">+ <TextBlock.Effect>+ <DropShadowEffect BlurRadius="20" ShadowDepth="1" Direction="-90" Color="{StaticResource Color_Shadow}" />+ </TextBlock.Effect>+ </TextBlock>+ </Border>+ </Grid>++ <Grid Grid.Row="1">++ <Grid x:Name="DownloadUpdate" Visibility="Hidden">+ <StackPanel Orientation="Vertical">+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">+ <TextBlock x:Name="TextTittle" Margin="0,25,0,0" Text="{DynamicResource download_update}" Foreground="{StaticResource Color_TetBlock_Inactivity}" FontFamily="{StaticResource Jura}" FontSize="15px" HorizontalAlignment="Center" TextAlignment="Center" FontStretch="Medium"/>+ <TextBlock Foreground="{StaticResource Color_TetBlock_Inactivity}" Height="auto" Width="auto" TextAlignment="Center" Style="{StaticResource Text}" FontSize="15px" Margin="10,25,0,0">+ <Run Text="{Binding ElementName=ProgressDownload, Path=Value, Mode=OneWay,StringFormat=N0}"/><Run Text="%"/>+ </TextBlock>+ </StackPanel>+ <ProgressBar x:Name="ProgressDownload" Value="0" Width="250" Height="10" Margin="0,10,0,0" Style="{StaticResource ProgressBarStyle}"/>+ <TextBlock x:Name="SizeByte" Text="{DynamicResource connection_update}" Foreground="{StaticResource Color_TetBlock_Inactivity}" Height="auto" Width="auto" FontFamily="{StaticResource Jura}" Margin="0,5,0,0" FontSize="14px" TextAlignment="Center" FontStretch="Medium" TextWrapping="Wrap"/>+ </StackPanel>+ </Grid>++ <Grid x:Name="QuestionUpdate" Visibility="Visible">+ <Grid.RowDefinitions>+ <RowDefinition Height="46*"/>+ <RowDefinition Height="27*"/>+ </Grid.RowDefinitions>++ <Grid Grid.Row="0" Margin="0,0,0,8">+ <StackPanel Orientation="Vertical">+ <StackPanel Margin="0,15,0,0" HorizontalAlignment="Center">+ <TextBlock Text="{DynamicResource text_update}" Foreground="{StaticResource Color_Highlighted}" Height="auto" Width="325" FontFamily="{StaticResource Jura}" FontSize="15px" TextAlignment="Center" FontStretch="Medium" TextWrapping="Wrap"/>+ </StackPanel>+ <StackPanel Orientation="Vertical" Margin="0,10,0,0">+ <TextBlock x:Name="ViewChangelog" Text="{DynamicResource log_update}" Foreground="{StaticResource Color_TetBlock_Inactivity}" Height="auto" Width="auto" FontFamily="{StaticResource Jura}" FontSize="12px" HorizontalAlignment="Center" TextAlignment="Center" FontStretch="Medium" TextDecorations="Underline" Cursor="Hand" PreviewMouseDown="ViewChangelog_PreviewMouseDown"/>+ </StackPanel>+ </StackPanel>+ </Grid>++ <Grid Grid.Row="1">+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">+ <Button x:Name="BtnLater" Content="{DynamicResource btn_later_update}" Style="{StaticResource BtnDefault}" HorizontalAlignment="Center" VerticalAlignment="Top" Width="110" Height="30" Cursor="Hand" PreviewMouseDown="BtnLater_PreviewMouseDown"/>+ <Button x:Name="BtnUpdate" Content="{DynamicResource btn_now_update}" Style="{StaticResource BtnDefault}" HorizontalAlignment="Center" VerticalAlignment="Top" Width="110" Height="30" Margin="20,0,0,0" Cursor="Hand" PreviewMouseDown="BtnUpdate_PreviewMouseDown"/>+ </StackPanel>+ </Grid>+ </Grid>++ </Grid>+ </Grid>+ </Border>+ </Grid>+</Window>diff --git a/.Source/GTweak/Windows/UpdateWindow.xaml.cs b/.Source/GTweak/Windows/UpdateWindow.xaml.csnew file mode 100644index 00000000..dbaba0e8--- /dev/null+++ b/.Source/GTweak/Windows/UpdateWindow.xaml.cs@@ -0,0 +1,100 @@+using GTweak.Utilities;+using GTweak.Utilities.Helpers;+using System;+using System.ComponentModel;+using System.Diagnostics;+using System.Net;+using System.Reflection;+using System.Windows;+using System.Windows.Input;+using System.Windows.Media.Animation;++namespace GTweak.Windows+{+ public partial class UpdateWindow : Window+ {+ private static readonly string nameOfUser = AppDomain.CurrentDomain.FriendlyName;+ private static readonly string pathOfUser = Assembly.GetExecutingAssembly().Location;+ public UpdateWindow()+ {+ InitializeComponent();+ }++ private void TitleBar_MouseDown(object sender, MouseButtonEventArgs e)+ {+ if (e.LeftButton == MouseButtonState.Pressed)+ DragMove();+ }++ private void Window_Loaded(object sender, RoutedEventArgs e)+ {+ DoubleAnimation doubleAnim = new DoubleAnimation()+ {+ From = 0,+ To = 1,+ Duration = TimeSpan.FromSeconds(0.3),+ EasingFunction = new QuadraticEase()+ };+ Timeline.SetDesiredFrameRate(doubleAnim, 400);+ BeginAnimation(OpacityProperty, doubleAnim);+ new TypewriterAnimation(ViewChangelog.Text, ViewChangelog, TimeSpan.FromSeconds(0.3));+ }++ private void Window_Closing(object sender, CancelEventArgs e)+ {+ Closing -= Window_Closing;+ e.Cancel = true;+ DoubleAnimation doubleAnim = new DoubleAnimation(0, (Duration)TimeSpan.FromSeconds(0.1));+ doubleAnim.Completed += delegate { this.Close(); };+ Timeline.SetDesiredFrameRate(doubleAnim, 400);+ BeginAnimation(OpacityProperty, doubleAnim);+ }++ private void ViewChangelog_PreviewMouseDown(object sender, MouseButtonEventArgs e)+ {+ if (e.LeftButton == MouseButtonState.Pressed)+ Process.Start("https://github.com/Greedeks/GTweak/releases/latest");+ }++ private void BtnLater_PreviewMouseDown(object sender, MouseButtonEventArgs e)+ {+ if (e.LeftButton == MouseButtonState.Pressed)+ this.Close();+ }++ private void BtnUpdate_PreviewMouseDown(object sender, MouseButtonEventArgs e)+ {+ if (e.LeftButton == MouseButtonState.Pressed)+ {+ QuestionUpdate.Visibility = Visibility.Hidden;+ DownloadUpdate.Visibility = Visibility.Visible;++ try+ {+ using WebClient webClient = new WebClient();+ webClient.DownloadProgressChanged += (s, e) =>+ {+ ProgressDownload.Value = e.ProgressPercentage;+ SizeByte.Text = $"{Math.Round(e.BytesReceived / 1024.0)} KB / {Math.Round(e.TotalBytesToReceive / 1024.0)} KB";+ };+ webClient.DownloadFileCompleted += delegate+ {+ Process.Start(new ProcessStartInfo()+ {+ Arguments = $"/c taskkill /f /im \"{nameOfUser}\" && timeout /t 1 && del \"{pathOfUser}\" && ren nGTweak.exe \"{nameOfUser}\" && \"{pathOfUser}\"",+ WindowStyle = ProcessWindowStyle.Hidden,+ CreateNoWindow = true,+ FileName = "cmd.exe"+ });+ };+ webClient.DownloadFileAsync(new Uri("https://github.com/Greedeks/GTweak/releases/latest/download/GTweak.exe"), "nGTweak.exe");+ }+ catch+ {+ this.Close();+ new ViewNotification().Show("", (string)FindResource("title0_notification"), (string)FindResource("warn_update_notification"));+ }+ }+ }+ }+}