Skip to content

Portable Tool for an Ideal Windows Setup

fix eSPI chipset detection via driver class & optimize navigation animations

Greedeks07fcf648fee3
diff --git a/.Source/GTweak/Styles/Buttons/RadioButtons.xaml b/.Source/GTweak/Styles/Buttons/RadioButtons.xaml
index 18e3ea1c..48ca5217 100644
--- a/.Source/GTweak/Styles/Buttons/RadioButtons.xaml
+++ b/.Source/GTweak/Styles/Buttons/RadioButtons.xaml
@@ -24,35 +24,20 @@
<TranslateTransform X="3" Y="4" />
</Border.RenderTransform>
</Border>
- <Border x:Name="InnerPanel" Height="48" CornerRadius="12" Background="{TemplateBinding Background}" HorizontalAlignment="Left" VerticalAlignment="Center" Padding="0,0,10,0">
- <Grid Height="48">
- <Rectangle x:Name="ContentShadowMask" Grid.ColumnSpan="2" Fill="{StaticResource Brush_ShadowOverlay}" Opacity="{StaticResource IconNavigation_Opacity}" IsHitTestVisible="False">
- <Rectangle.RenderTransform>
- <TranslateTransform X="3" Y="3" />
- </Rectangle.RenderTransform>
- <Rectangle.OpacityMask>
- <VisualBrush Visual="{Binding ElementName=RealContent}" Stretch="None" AlignmentX="Left" AlignmentY="Center" />
- </Rectangle.OpacityMask>
- </Rectangle>
- <Grid x:Name="RealContent" Background="Transparent">
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="48"/>
- <ColumnDefinition Width="Auto"/>
- </Grid.ColumnDefinitions>
- <ContentPresenter x:Name="IconPresenter" Grid.Column="0" Content="{TemplateBinding Content}" VerticalAlignment="Center" HorizontalAlignment="Center" RenderTransformOrigin="0.5,0.5">
- <ContentPresenter.RenderTransform>
- <ScaleTransform ScaleX="1" ScaleY="1"/>
- </ContentPresenter.RenderTransform>
- </ContentPresenter>
- <Viewbox x:Name="NavTextBox" Grid.Column="1" Stretch="Uniform" StretchDirection="DownOnly" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5,0,15,0" Opacity="0">
- <TextBlock Text="{TemplateBinding Tag}" Foreground="{TemplateBinding Foreground}" FontFamily="{TemplateBinding FontFamily}" TextWrapping="NoWrap"/>
- </Viewbox>
- </Grid>
+ <Border x:Name="InnerPanel" Height="48" CornerRadius="12" Background="{TemplateBinding Background}" HorizontalAlignment="Left" VerticalAlignment="Center" Padding="0,0,10,0">
+ <Grid>
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="48"/>
+ <ColumnDefinition Width="Auto"/>
+ </Grid.ColumnDefinitions>
+ <ContentPresenter x:Name="IconPresenter" Grid.Column="0" Content="{TemplateBinding Content}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
+ <Viewbox x:Name="NavTextBox" Grid.Column="1" Stretch="Uniform" StretchDirection="DownOnly" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5,0,15,0" Opacity="0">
+ <TextBlock Text="{TemplateBinding Tag}" Foreground="{TemplateBinding Foreground}" FontFamily="{TemplateBinding FontFamily}" TextWrapping="NoWrap"/>
+ </Viewbox>
</Grid>
</Border>
</Grid>
</Border>
-
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="InnerPanel" Property="Background" Value="{StaticResource Brush_BtnBG_Navigation}"/>
@@ -61,13 +46,6 @@
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard Timeline.DesiredFrameRate="120">
- <ObjectAnimationUsingKeyFrames Storyboard.TargetName="OuterPanel" Storyboard.TargetProperty="CacheMode">
- <DiscreteObjectKeyFrame KeyTime="0:0:0">
- <DiscreteObjectKeyFrame.Value>
- <BitmapCache RenderAtScale="1"/>
- </DiscreteObjectKeyFrame.Value>
- </DiscreteObjectKeyFrame>
- </ObjectAnimationUsingKeyFrames>
<DoubleAnimation Storyboard.TargetName="OuterPanel" Storyboard.TargetProperty="Width" To="300" Duration="0:0:0.35" FillBehavior="HoldEnd">
<DoubleAnimation.EasingFunction>
<PowerEase Power="3" EasingMode="EaseIn"/>
@@ -78,33 +56,12 @@
<QuadraticEase/>
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
- <DoubleAnimation Storyboard.TargetName="IconPresenter" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)" To="1.1" Duration="0:0:0.2">
- <DoubleAnimation.EasingFunction>
- <CubicEase/>
- </DoubleAnimation.EasingFunction>
- </DoubleAnimation>
- <DoubleAnimation Storyboard.TargetName="IconPresenter" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)" To="1.1" Duration="0:0:0.2">
- <DoubleAnimation.EasingFunction>
- <CubicEase/>
- </DoubleAnimation.EasingFunction>
- </DoubleAnimation>
-
- <ObjectAnimationUsingKeyFrames Storyboard.TargetName="OuterPanel" Storyboard.TargetProperty="CacheMode">
- <DiscreteObjectKeyFrame KeyTime="0:0:0.4" Value="{x:Null}"/>
- </ObjectAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard>
<Storyboard Timeline.DesiredFrameRate="120">
- <ObjectAnimationUsingKeyFrames Storyboard.TargetName="OuterPanel" Storyboard.TargetProperty="CacheMode">
- <DiscreteObjectKeyFrame KeyTime="0:0:0">
- <DiscreteObjectKeyFrame.Value>
- <BitmapCache RenderAtScale="1"/>
- </DiscreteObjectKeyFrame.Value>
- </DiscreteObjectKeyFrame>
- </ObjectAnimationUsingKeyFrames>
<DoubleAnimation Storyboard.TargetName="OuterPanel" Storyboard.TargetProperty="Width" To="50" Duration="0:0:0.25" FillBehavior="HoldEnd">
<DoubleAnimation.EasingFunction>
<QuadraticEase/>
@@ -115,19 +72,6 @@
<QuadraticEase/>
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
- <DoubleAnimation Storyboard.TargetName="IconPresenter" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)" To="1" Duration="0:0:0.2">
- <DoubleAnimation.EasingFunction>
- <CubicEase/>
- </DoubleAnimation.EasingFunction>
- </DoubleAnimation>
- <DoubleAnimation Storyboard.TargetName="IconPresenter" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)" To="1" Duration="0:0:0.2">
- <DoubleAnimation.EasingFunction>
- <CubicEase/>
- </DoubleAnimation.EasingFunction>
- </DoubleAnimation>
- <ObjectAnimationUsingKeyFrames Storyboard.TargetName="OuterPanel" Storyboard.TargetProperty="CacheMode">
- <DiscreteObjectKeyFrame KeyTime="0:0:0.3" Value="{x:Null}"/>
- </ObjectAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</Trigger.ExitActions>
diff --git a/.Source/GTweak/Utilities/Configuration/HardwareProvider.cs b/.Source/GTweak/Utilities/Configuration/HardwareProvider.cs
index 37dabc24..1ea37a63 100644
--- a/.Source/GTweak/Utilities/Configuration/HardwareProvider.cs
+++ b/.Source/GTweak/Utilities/Configuration/HardwareProvider.cs
@@ -235,35 +235,36 @@ namespace GTweak.Utilities.Configuration
Motherboard.Data = Motherboard.Data.TrimEnd('\n', '\r');
bool chipsetFound = false;
- using RegistryKey baseKey = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Enum\PCI");
- if (baseKey != null)
+ List<string> pciDevices = RegistryHelp.GetSubKeyNames<List<string>>(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Enum\PCI");
+
+ foreach (string deviceId in pciDevices)
{
- foreach (string deviceId in baseKey.GetSubKeyNames())
+ if (chipsetFound)
+ {
+ break;
+ }
+
+ List<string> deviceInstances = RegistryHelp.GetSubKeyNames<List<string>>(Registry.LocalMachine, $@"SYSTEM\CurrentControlSet\Enum\PCI\{deviceId}");
+
+ foreach (string instanceId in deviceInstances)
{
- if (!chipsetFound)
+ string driverRef = RegistryHelp.GetValue($@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\PCI\{deviceId}\{instanceId}", "Driver", string.Empty);
+ if (string.IsNullOrEmpty(driverRef))
{
- using RegistryKey deviceKey = baseKey.OpenSubKey(deviceId);
- if (deviceKey != null)
- {
- foreach (string subId in deviceKey.GetSubKeyNames())
- {
- using RegistryKey subKey = deviceKey.OpenSubKey(subId);
- string deviceDesc = subKey?.GetValue("DeviceDesc")?.ToString() ?? string.Empty;
- string friendlyName = subKey?.GetValue("FriendlyName")?.ToString() ?? string.Empty;
- string targetString = deviceDesc.Contains("LPC") ? deviceDesc : (friendlyName.Contains("LPC") ? friendlyName : string.Empty);
+ continue;
+ }
- if (!string.IsNullOrWhiteSpace(targetString))
- {
- string chipset = ParseChipset(targetString) ?? string.Empty;
+ string driverDesc = RegistryHelp.GetValue($@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{driverRef}", "DriverDesc", string.Empty);
- if (!string.IsNullOrEmpty(chipset))
- {
- Motherboard.Chipset = chipset;
- chipsetFound = true;
- break;
- }
- }
- }
+ if (driverDesc.IndexOf("LPC", StringComparison.OrdinalIgnoreCase) >= 0 || driverDesc.IndexOf("eSPI", StringComparison.OrdinalIgnoreCase) >= 0)
+ {
+ string chipset = ParseChipset(driverDesc) ?? string.Empty;
+
+ if (!string.IsNullOrWhiteSpace(chipset))
+ {
+ Motherboard.Chipset = chipset;
+ chipsetFound = true;
+ break;
}
}
}