Skip to content

Portable Tool for an Ideal Windows Setup

upd. download progress design in ToolsetCard & minor fixes

Greedeks7e1899dd4480
diff --git a/.Source/GTweak/Assets/UserControls/ToolsetCard.xaml b/.Source/GTweak/Assets/UserControls/ToolsetCard.xaml
index 3fe6465d..3747c008 100644
--- a/.Source/GTweak/Assets/UserControls/ToolsetCard.xaml
+++ b/.Source/GTweak/Assets/UserControls/ToolsetCard.xaml
@@ -155,7 +155,6 @@
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
-
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,-2,0,0" FontSize="13px">
<TextBlock.Style>
<Style TargetType="TextBlock" BasedOn="{StaticResource TextDefault}">
@@ -200,9 +199,44 @@
</Style.Triggers>
</Style>
</Grid.Style>
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="Auto"/>
+ <ColumnDefinition Width="Auto"/>
+ </Grid.ColumnDefinitions>
+
+ <Ellipse Grid.Column="0" Width="6" Height="6" Fill="{StaticResource Brush_Accent}" VerticalAlignment="Center" Margin="0,0,6,0">
+ <Ellipse.CacheMode>
+ <BitmapCache RenderAtScale="2" />
+ </Ellipse.CacheMode>
+ <Ellipse.Effect>
+ <DropShadowEffect BlurRadius="15" ShadowDepth="0" Opacity="1" Color="{StaticResource Color_Shadow}" />
+ </Ellipse.Effect>
+ <Ellipse.Triggers>
+ <EventTrigger RoutedEvent="FrameworkElement.Loaded">
+ <BeginStoryboard>
+ <Storyboard Timeline.DesiredFrameRate="120" RepeatBehavior="Forever">
+ <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity">
+ <DiscreteDoubleKeyFrame KeyTime="0:0:0" Value="1"/>
+ <DiscreteDoubleKeyFrame KeyTime="0:0:0.5" Value="0"/>
+ <DiscreteDoubleKeyFrame KeyTime="0:0:1" Value="1"/>
+ </DoubleAnimationUsingKeyFrames>
+ </Storyboard>
+ </BeginStoryboard>
+ </EventTrigger>
+ </Ellipse.Triggers>
+ </Ellipse>
+
+ <Grid Grid.Column="1" Width="55" VerticalAlignment="Center">
+ <Border CornerRadius="10" Opacity="0.4" Background="{StaticResource Brush_ShadowOverlay}" IsHitTestVisible="False">
+ <Border.RenderTransform>
+ <TranslateTransform X="3" Y="6" />
+ </Border.RenderTransform>
+ </Border>
- <TextBlock Panel.ZIndex="5" Text="{Binding Progress, StringFormat='{}{0:0}%',ElementName=root}" Style="{StaticResource TextDefault}" FontFamily="{StaticResource Play}" Foreground="{StaticResource Brush_Highlighted_Inverted}" FontSize="12px" HorizontalAlignment="Center" VerticalAlignment="Center"/>
- <ProgressBar Value="{Binding Progress,ElementName=root}" Foreground="{StaticResource Brush_Accent}" Minimum="0" Maximum="100" Height="20" MinWidth="150" VerticalAlignment="Center"/>
+ <Border Background="{StaticResource Brush_Accent}" CornerRadius="10" Padding="10,3">
+ <TextBlock Text="{Binding Progress, StringFormat='{}{0:0}%', ElementName=root}" Style="{StaticResource TextDefault}" FontFamily="{StaticResource Play}" Foreground="{StaticResource Brush_Highlighted_Inverted}" FontSize="12px" HorizontalAlignment="Center" VerticalAlignment="Center"/>
+ </Border>
+ </Grid>
</Grid>
</Grid>
diff --git a/.Source/GTweak/Styles/Buttons/Buttons.xaml b/.Source/GTweak/Styles/Buttons/Buttons.xaml
index 26c6a53f..116bb3fd 100644
--- a/.Source/GTweak/Styles/Buttons/Buttons.xaml
+++ b/.Source/GTweak/Styles/Buttons/Buttons.xaml
@@ -148,14 +148,13 @@
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid>
- <Border CornerRadius="7" Opacity="0.5" Background="{StaticResource Brush_ShadowOverlay}" IsHitTestVisible="False" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
+ <Border CornerRadius="7" Opacity="0.4" Background="{StaticResource Brush_ShadowOverlay}" IsHitTestVisible="False" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Border.RenderTransform>
<TranslateTransform X="3" Y="6"/>
</Border.RenderTransform>
</Border>
<Border Background="{TemplateBinding Background}" CornerRadius="7">
- <Border x:Name="RollTarget" Background="Transparent"
- RenderTransformOrigin="0.5,0.5">
+ <Border x:Name="RollTarget" Background="Transparent" RenderTransformOrigin="0.5,0.5">
<Border.RenderTransform>
<TransformGroup>
<ScaleTransform x:Name="PressScale" ScaleX="1" ScaleY="1"/>
diff --git a/.Source/GTweak/Utilities/Controls/SettingsEngine.cs b/.Source/GTweak/Utilities/Controls/SettingsEngine.cs
index 7d03dd7c..53659f7f 100644
--- a/.Source/GTweak/Utilities/Controls/SettingsEngine.cs
+++ b/.Source/GTweak/Utilities/Controls/SettingsEngine.cs
@@ -76,9 +76,12 @@ namespace GTweak.Utilities.Controls
}
else
{
- _cachedSettings[kv.Key] = kv.Value is bool defaultBool ? RegistryHelp.GetValue(PathLocator.Registry.BaseKey, kv.Key, defaultBool ? 1 : 0) is int asBool ? asBool != 0 : defaultBool :
- kv.Value is int defaultInt ? RegistryHelp.GetValue(PathLocator.Registry.BaseKey, kv.Key, defaultInt) :
- kv.Value is string defaultString ? RegistryHelp.GetValue(PathLocator.Registry.BaseKey, kv.Key, defaultString) : kv.Value;
+ _cachedSettings[kv.Key] = kv.Value switch
+ {
+ bool valueBool => RegistryHelp.GetValue(PathLocator.Registry.BaseKey, kv.Key, valueBool ? 1 : 0) is int i ? i != 0 : valueBool,
+ int valueInt => RegistryHelp.GetValue(PathLocator.Registry.BaseKey, kv.Key, valueInt),
+ _ => RegistryHelp.GetValue(PathLocator.Registry.BaseKey, kv.Key, kv.Value?.ToString())
+ };
}
}
@@ -178,12 +181,12 @@ namespace GTweak.Utilities.Controls
RegistryHelp.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\Microsoft\Tracing\GTweak_RASAPI32");
RegistryHelp.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\Microsoft\Tracing\GTweak_RASMANCS");
- CommandExecutor.RunCommand("/c " + CommandExecutor.CleanCommand(string.Join(" & ", new[] { $@"taskkill /f /im ""{CurrentName}""", "choice /c y /n /d y /t 3", $@"del ""{CurrentLocation}""",
+ CommandExecutor.RunCommand("/c " + CommandExecutor.CleanCommand(string.Join(" & ", new[] { $@"taskkill /f /im ""{CurrentName}""", "choice /c y /valueInt /d y /t 3", $@"del ""{CurrentLocation}""",
$@"rd /s /q ""{PathLocator.Folders.Workspace}""", $@"rd /s /q ""{Environment.SystemDirectory}\config\systemprofile\AppData\Local\GTweak""" })));
}
catch (Exception ex) { ErrorLogging.LogDebug(ex); }
}
- internal static void SelfReboot() => CommandExecutor.RunCommand($"/c taskkill /f /im \"{CurrentName}\" & choice /c y /n /d y /t 1 & start \"\" \"{CurrentLocation}\"");
+ internal static void SelfReboot() => CommandExecutor.RunCommand($"/c taskkill /f /im \"{CurrentName}\" & choice /c y /valueInt /d y /t 1 & start \"\" \"{CurrentLocation}\"");
}
}
\ No newline at end of file
diff --git a/.Source/GTweak/Utilities/Maintenance/RegistryExporter.cs b/.Source/GTweak/Utilities/Maintenance/RegistryExporter.cs
index 5e773415..ac5e2913 100644
--- a/.Source/GTweak/Utilities/Maintenance/RegistryExporter.cs
+++ b/.Source/GTweak/Utilities/Maintenance/RegistryExporter.cs
@@ -10,42 +10,27 @@ namespace GTweak.Utilities.Maintenance
{
internal sealed class RegistryExporter
{
- internal string[] RegistryPaths = {
+ internal readonly string[] RegistryPaths =
+ {
@"HKEY_CLASSES_ROOT\*\shellex",
@"HKEY_CLASSES_ROOT\CLSID",
@"HKEY_CLASSES_ROOT\Wow6432Node\CLSID",
- @"HKEY_CLASSES_ROOT\AppID\MicrosoftEdgeUpdate.exe",
- @"HKEY_CURRENT_USER\Software\Microsoft",
+ @"HKEY_CLASSES_ROOT\AppID",
+ @"HKEY_CURRENT_USER\Software",
+ @"HKEY_CURRENT_USER\System",
@"HKEY_CURRENT_USER\Control Panel",
- @"HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion",
- @"HKEY_CURRENT_USER\Software\Microsoft\EdgeUpdate",
- @"HKEY_CURRENT_USER\Software\Microsoft\EdgeWebView",
- @"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run",
@"HKEY_USERS\.DEFAULT\Control Panel",
@"HKEY_USERS\S-1-5-19\Control Panel",
@"HKEY_USERS\S-1-5-20\Control Panel",
- @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PolicyManager\current\device",
- @"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control",
- @"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows",
- @"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Edge",
- @"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services",
- @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion",
- @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer",
- @"HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Edge",
- @"HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Edge",
- @"HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Edge Update",
- @"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\edgeupdate",
- @"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\edgeupdatem",
- @"HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate",
- @"HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\EdgeWebView",
- @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\EdgeWebView",
- @"HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft EdgeWebView",
- @"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MicrosoftEdgeElevationService",
- @"HKEY_LOCAL_MACHINE\SOFTWARE\Classes\MSEdgeHTM",
- @"HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet\Microsoft Edge"
+ @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft",
+ @"HKEY_LOCAL_MACHINE\SOFTWARE\Policies",
+ @"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet",
+ @"HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft",
+ @"HKEY_LOCAL_MACHINE\SOFTWARE\Classes",
+ @"HKEY_LOCAL_MACHINE\SOFTWARE\Clients"
};
- private bool RegistryKeyExists(string fullPath)
+ private static bool RegistryKeyExists(string fullPath)
{
int index = fullPath.IndexOf('\\');
if (index < 0)
@@ -53,8 +38,8 @@ namespace GTweak.Utilities.Maintenance
return false;
}
- string hive = !string.IsNullOrEmpty(fullPath) && index >= 0 && index <= fullPath.Length ? fullPath.Substring(0, index) : string.Empty;
- string subKey = (fullPath != null && index + 1 < fullPath.Length) ? fullPath.Substring(index + 1) : string.Empty;
+ string hive = fullPath.Substring(0, index);
+ string subKey = fullPath.Substring(index + 1);
RegistryKey baseKey = hive switch
{
@@ -73,7 +58,7 @@ namespace GTweak.Utilities.Maintenance
try
{
- using var key = baseKey.OpenSubKey(subKey);
+ using RegistryKey key = baseKey.OpenSubKey(subKey);
return key != null;
}
catch { return false; }
@@ -81,14 +66,13 @@ namespace GTweak.Utilities.Maintenance
internal void Export(string fileName)
{
- string finalRegFile = fileName;
string tempDir = PathLocator.Folders.Workspace;
Directory.CreateDirectory(tempDir);
List<string> tempFiles = new List<string>();
try
{
- foreach (var path in RegistryPaths)
+ foreach (string path in RegistryPaths)
{
if (!RegistryKeyExists(path))
{
@@ -98,22 +82,19 @@ namespace GTweak.Utilities.Maintenance
string tempFile = Path.Combine(tempDir, Path.GetRandomFileName() + ".reg");
tempFiles.Add(tempFile);
- ProcessStartInfo psi = new ProcessStartInfo("reg.exe", $"EXPORT \"{path}\" \"{tempFile}\" /y")
+ using Process proc = Process.Start(new ProcessStartInfo("reg.exe", $"EXPORT \"{path}\" \"{tempFile}\" /y")
{
CreateNoWindow = true,
UseShellExecute = false
- };
- Process proc = Process.Start(psi);
+ });
proc.WaitForExit();
}
- StringBuilder sb = new StringBuilder();
+ using StreamWriter writer = new StreamWriter(fileName, false, Encoding.Unicode);
foreach (string file in tempFiles)
{
- sb.AppendLine(File.ReadAllText(file, Encoding.Unicode));
+ writer.WriteLine(File.ReadAllText(file, Encoding.Unicode));
}
-
- File.WriteAllText(finalRegFile, sb.ToString(), Encoding.Unicode);
}
catch { NotificationManager.Show("warn", "error_reg_exporter_noty").Perform(); }
finally
diff --git a/.Source/GTweak/Utilities/Managers/NotificationManager.cs b/.Source/GTweak/Utilities/Managers/NotificationManager.cs
index 494c93e8..3408d639 100644
--- a/.Source/GTweak/Utilities/Managers/NotificationManager.cs
+++ b/.Source/GTweak/Utilities/Managers/NotificationManager.cs
@@ -2,6 +2,7 @@ using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
+using System.Windows.Threading;
using GTweak.Utilities.Controls;
using GTweak.Windows;
@@ -51,10 +52,11 @@ namespace GTweak.Utilities.Managers
};
private static int _isNotificationOpen;
+
internal static NotificationBuilder Show(string titleKey = "", string textKey = "")
{
- string title = Application.Current.TryFindResource($"title_{titleKey}_noty") as string ?? string.Empty;
- string text = Application.Current.TryFindResource(textKey) as string ?? string.Empty;
+ string title = Application.Current?.TryFindResource($"title_{titleKey}_noty") as string ?? string.Empty;
+ string text = Application.Current?.TryFindResource(textKey) as string ?? string.Empty;
return new NotificationBuilder(title, text);
}
@@ -84,7 +86,14 @@ namespace GTweak.Utilities.Managers
{
if (SettingsEngine.IsViewNotification && Interlocked.CompareExchange(ref _isNotificationOpen, 1, 0) == 0)
{
- await Application.Current.Dispatcher.InvokeAsync(async () =>
+ Dispatcher dispatcher = Application.Current?.Dispatcher;
+ if (dispatcher == null)
+ {
+ Interlocked.Exchange(ref _isNotificationOpen, 0);
+ return;
+ }
+
+ await dispatcher.InvokeAsync(async () =>
{
NotificationWindow window = new NotificationWindow
{
@@ -95,8 +104,8 @@ namespace GTweak.Utilities.Managers
if (string.IsNullOrWhiteSpace(window.NoticeTitle) && string.IsNullOrWhiteSpace(window.NoticeText))
{
- window.NoticeTitle = Application.Current.Resources["title_warn_noty"] as string;
- window.NoticeText = Application.Current.Resources[action == NoticeAction.Logout ? "logout_noty" : "restart_noty"] as string;
+ window.NoticeTitle = (Application.Current?.Resources)?["title_warn_noty"] as string ?? string.Empty;
+ window.NoticeText = (Application.Current?.Resources)?[action == NoticeAction.Logout ? "logout_noty" : "restart_noty"] as string ?? string.Empty;
}
window.Closed += delegate { Interlocked.Exchange(ref _isNotificationOpen, 0); };
@@ -113,5 +122,4 @@ namespace GTweak.Utilities.Managers
}
}
}
-
}
\ No newline at end of file
diff --git a/.Source/GTweak/Windows/NotificationWindow.xaml b/.Source/GTweak/Windows/NotificationWindow.xaml
index 66600d36..c1d73eca 100644
--- a/.Source/GTweak/Windows/NotificationWindow.xaml
+++ b/.Source/GTweak/Windows/NotificationWindow.xaml
@@ -69,7 +69,7 @@
</Grid>
</Grid>
- <ProgressBar x:Name="ProgressTimer" Grid.ColumnSpan="2" Maximum="100" Value="0" Foreground="{StaticResource Brush_Accent}" Height="3" Width="375" HorizontalAlignment="Center" VerticalAlignment="Bottom" Panel.ZIndex="10"/>
+ <ProgressBar x:Name="ProgressTimer" Grid.ColumnSpan="2" Maximum="100" Value="0" Foreground="{StaticResource Brush_Accent}" Height="3" Width="375" HorizontalAlignment="Center" VerticalAlignment="Bottom" Panel.ZIndex="10"/>
</Grid>
</Grid>
</ui:FluentWindow>