Portable Tool for an Ideal Windows Setup
C# activatorbloatware-removalcsharpdebloatdebloaterdisable-servicesmonitoring-systemportableprivacy-toolsregistry-tweakssystem-tuningsystem-utilitytelemetrytweakerwindows-10windows-11windows-debloatwindows-defenderwindows-optimizationwindows-tweaks
fix null reference when registry value is missing (#102) & add label for colorpicker
Greedeks5f1f647418ab
diff --git a/.Source/GTweak/Assets/UserControls/ColorPicker.xaml b/.Source/GTweak/Assets/UserControls/ColorPicker.xamlindex 9a4e6fff..fc2b4ac6 100644--- a/.Source/GTweak/Assets/UserControls/ColorPicker.xaml+++ b/.Source/GTweak/Assets/UserControls/ColorPicker.xaml@@ -154,11 +154,18 @@</Canvas></Grid>- <TextBox x:Name="HexBox" Height="30" Margin="0,10,0,0" MaxLength="7" Width="{Binding ElementName=BtnDefault, Path=ActualWidth}" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" HorizontalAlignment="Center" FontWeight="SemiBold" KeyDown="HexBox_KeyDown" LostFocus="HexBox_LostFocus" TextChanged="HexBox_TextChanged">- <TextBox.Background>- <SolidColorBrush Color="{Binding SelectedColor, RelativeSource={RelativeSource AncestorType=local:ColorPicker}}"/>- </TextBox.Background>- </TextBox>+ <Grid Width="{Binding ElementName=BtnDefault, Path=ActualWidth}" Margin="0,5">+ <Grid.ColumnDefinitions>+ <ColumnDefinition Width="Auto" />+ <ColumnDefinition Width="*" />+ </Grid.ColumnDefinitions>++ <Border Grid.Column="0" BorderThickness="1" BorderBrush="{StaticResource Brush_Separator}" CornerRadius="6" Margin="0,0,5,0" Background="Transparent" VerticalAlignment="Stretch" Padding="10,0">+ <TextBlock Text="HEX" Style="{StaticResource Description}" FontSize="14px" FontWeight="SemiBold" VerticalAlignment="Center" HorizontalAlignment="Center" Padding="0,5"/>+ </Border>++ <TextBox x:Name="HexBox" Grid.Column="1" MinWidth="0" Width="Auto" HorizontalAlignment="Stretch" VerticalContentAlignment="Center" BorderThickness="0" Background="Transparent" FontWeight="SemiBold" MaxLength="7" TextChanged="HexBox_TextChanged" KeyDown="HexBox_KeyDown" LostFocus="HexBox_LostFocus"/>+ </Grid><Button x:Name="BtnDefault" Content="{DynamicResource btn_default}" Style="{StaticResource ButtonContent_Inverted}" Margin="0,10,0,0" HorizontalAlignment="Stretch" Click="BtnDefault_Click"/>diff --git a/.Source/GTweak/Utilities/Helpers/RegistryHelp.cs b/.Source/GTweak/Utilities/Helpers/RegistryHelp.csindex 366c81c9..566164e1 100644--- a/.Source/GTweak/Utilities/Helpers/RegistryHelp.cs+++ b/.Source/GTweak/Utilities/Helpers/RegistryHelp.cs@@ -127,7 +127,27 @@ namespace GTweak.Utilities.Helpersinternal static T GetValue<T>(string subKey, string valueName, T defaultValue){- try { return (T)Convert.ChangeType(Registry.GetValue(subKey, valueName, defaultValue), typeof(T)); }+ try+ {+ object value = Registry.GetValue(subKey, valueName, null);++ switch (value)+ {+ case null:+ return defaultValue;+ case T t:+ return t;+ }++ Type targetType = typeof(T);++ if (targetType.IsEnum)+ {+ return (T)Enum.Parse(targetType, value.ToString());+ }++ return (T)Convert.ChangeType(value, targetType);+ }catch { return defaultValue; }}