Portable Tool for an Ideal Windows Setup
C# activatorbloatware-removalcsharpdebloatdebloaterdisable-servicesmonitoring-systemportableprivacy-toolsregistry-tweakssystem-tuningsystem-utilitytelemetrytweakerwindows-10windows-11windows-debloatwindows-defenderwindows-optimizationwindows-tweaks
fix: ComboBox dropdown scroll clipping and add fade effect
Greedeks605fea4bd0e4
diff --git a/.Source/GTweak/Assets/UserControl/Card.xaml.cs b/.Source/GTweak/Assets/UserControl/Card.xaml.csindex 205244ca..3e7041e9 100644--- a/.Source/GTweak/Assets/UserControl/Card.xaml.cs+++ b/.Source/GTweak/Assets/UserControl/Card.xaml.cs@@ -38,7 +38,7 @@ namespace GTweak.Assets.UserControlinternal static readonly DependencyProperty TextProperty =DependencyProperty.Register(nameof(TextBlock), typeof(string), typeof(Card), new PropertyMetadata(string.Empty));- internal static new readonly DependencyProperty ContentProperty =+ internal static readonly DependencyProperty ContentProperty =DependencyProperty.Register(nameof(BtnContent), typeof(string), typeof(Button), new PropertyMetadata(string.Empty, (s, e) => ((Button)s).Content = (string)e.NewValue));private static void OnIconStyleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)diff --git a/.Source/GTweak/Converters/ScrollFadeMaskConverter.cs b/.Source/GTweak/Converters/ScrollFadeMaskConverter.csnew file mode 100644index 00000000..e08f4d91--- /dev/null+++ b/.Source/GTweak/Converters/ScrollFadeMaskConverter.cs@@ -0,0 +1,91 @@+using System;+using System.Globalization;+using System.Windows;+using System.Windows.Data;+using System.Windows.Media;++namespace GTweak.Converters+{+ public class ScrollFadeMaskConverter : IMultiValueConverter+ {+ public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)+ {+ if (values.Length < 3 || values[0] == DependencyProperty.UnsetValue || values[1] == DependencyProperty.UnsetValue || values[2] == DependencyProperty.UnsetValue)+ {+ return Brushes.White;+ }++ double offset = (double)values[0];+ double viewportHeight = (double)values[1];+ double extentHeight = (double)values[2];++ if (viewportHeight <= 0 || extentHeight <= 0)+ {+ return Brushes.White;+ }++ double scrollableHeight = Math.Max(0, extentHeight - viewportHeight);++ if (scrollableHeight <= 0)+ {+ return Brushes.White;+ }++ double fadeHeight = Math.Min(30.0, viewportHeight * 0.5);++ if (fadeHeight < 4)+ {+ return Brushes.White;+ }++ double epsilon = 0.5;++ double visibleStart = offset;+ double visibleEnd = offset + viewportHeight;++ bool showTopFade = visibleStart > epsilon;+ bool showBottomFade = visibleEnd < extentHeight - epsilon;++ double topFadeEnd = fadeHeight / viewportHeight;+ double bottomFadeStart = 1.0 - (fadeHeight / viewportHeight);++ LinearGradientBrush brush = new LinearGradientBrush+ {+ StartPoint = new Point(0, 0),+ EndPoint = new Point(0, 1)+ };++ if (showTopFade)+ {+ brush.GradientStops.Add(new GradientStop(Colors.Transparent, 0.0));+ brush.GradientStops.Add(new GradientStop(Color.FromArgb(0xAA, 0xFF, 0xFF, 0xFF), topFadeEnd * 0.5));+ brush.GradientStops.Add(new GradientStop(Colors.White, topFadeEnd));+ }+ else+ {+ brush.GradientStops.Add(new GradientStop(Colors.White, 0.0));+ brush.GradientStops.Add(new GradientStop(Colors.White, topFadeEnd));+ }++ brush.GradientStops.Add(new GradientStop(Colors.White, bottomFadeStart));++ if (showBottomFade)+ {+ brush.GradientStops.Add(new GradientStop(Colors.White, bottomFadeStart));+ brush.GradientStops.Add(new GradientStop(Color.FromArgb(0xAA, 0xFF, 0xFF, 0xFF), bottomFadeStart + (topFadeEnd * 0.5)));+ brush.GradientStops.Add(new GradientStop(Colors.Transparent, 1.0));+ }+ else+ {+ brush.GradientStops.Add(new GradientStop(Colors.White, 1.0));+ }++ return brush;+ }++ public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)+ {+ throw new NotImplementedException();+ }+ }+}diff --git a/.Source/GTweak/GTweak.csproj b/.Source/GTweak/GTweak.csprojindex 3827ee36..3f21112f 100644--- a/.Source/GTweak/GTweak.csproj+++ b/.Source/GTweak/GTweak.csproj@@ -133,6 +133,7 @@<Compile Include="Core\ViewModel\PakagesViewModel.cs" /><Compile Include="Core\ViewModel\ServicesViewModel.cs" /><Compile Include="Core\ViewModel\SystemViewModel.cs" />+ <Compile Include="Converters\ScrollFadeMaskConverter.cs" /><Compile Include="Utilities\Configuration\DiskTypeIdentifier.cs" /><Compile Include="Utilities\Configuration\HardwareData.cs" /><Compile Include="Utilities\Maintenance\ClearingMemory.cs" />diff --git a/.Source/GTweak/Styles/Inputs/ComboBox.xaml b/.Source/GTweak/Styles/Inputs/ComboBox.xamlindex 48009d64..0a1d3554 100644--- a/.Source/GTweak/Styles/Inputs/ComboBox.xaml+++ b/.Source/GTweak/Styles/Inputs/ComboBox.xaml@@ -1,4 +1,5 @@<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"+ xmlns:conv="clr-namespace:GTweak.Converters"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"><Style x:Key="CustomComboBoxItemStyle" TargetType="ComboBoxItem" BasedOn="{StaticResource {x:Type ComboBoxItem}}">@@ -7,6 +8,12 @@<Setter Property="KeyboardNavigation.TabNavigation" Value="None"/><Setter Property="FocusVisualStyle" Value="{x:Null}"/><Setter Property="Padding" Value="0,4,0,4"/>+ <Setter Property="RenderTransform">+ <Setter.Value>+ <TranslateTransform Y="4"/>+ </Setter.Value>+ </Setter>+ <Setter Property="Opacity" Value="0"/><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="ComboBoxItem">@@ -28,6 +35,22 @@<Trigger Property="IsMouseOver" Value="True"><Setter Property="Foreground" Value="{StaticResource Brush_Accent}"/></Trigger>+ <EventTrigger RoutedEvent="Loaded">+ <BeginStoryboard>+ <Storyboard Timeline.DesiredFrameRate="120">+ <DoubleAnimation Storyboard.TargetProperty="Opacity" From="0" To="1" Duration="0:0:0.15">+ <DoubleAnimation.EasingFunction>+ <QuadraticEase EasingMode="EaseOut"/>+ </DoubleAnimation.EasingFunction>+ </DoubleAnimation>+ <DoubleAnimation Storyboard.TargetProperty="RenderTransform.(TranslateTransform.Y)" From="4" To="0" Duration="0:0:0.15">+ <DoubleAnimation.EasingFunction>+ <CubicEase EasingMode="EaseOut"/>+ </DoubleAnimation.EasingFunction>+ </DoubleAnimation>+ </Storyboard>+ </BeginStoryboard>+ </EventTrigger></ControlTemplate.Triggers></ControlTemplate></Setter.Value>@@ -142,19 +165,33 @@</Border><Popup x:Name="Popup" IsOpen="{TemplateBinding IsDropDownOpen}" Placement="Bottom" VerticalOffset="2" AllowsTransparency="True" Focusable="False"><Border x:Name="PopupBorder"- Width="{Binding ActualWidth, RelativeSource={RelativeSource TemplatedParent}}"- Background="{StaticResource Brush_Background_СomboBox}"- BorderBrush="{TemplateBinding BorderBrush}"- BorderThickness="{TemplateBinding BorderThickness}"- CornerRadius="5"- Opacity="1"- ClipToBounds="True"- RenderTransformOrigin="0,0">+ Width="{Binding ActualWidth, RelativeSource={RelativeSource TemplatedParent}}"+ Background="{StaticResource Brush_Background_СomboBox}"+ BorderBrush="{TemplateBinding BorderBrush}"+ BorderThickness="{TemplateBinding BorderThickness}"+ CornerRadius="5"+ Opacity="0"+ ClipToBounds="True"+ RenderTransformOrigin="0.5,0"><Border.RenderTransform>- <ScaleTransform x:Name="PopupScaleTransform" ScaleY="0" CenterY="0"/>+ <ScaleTransform x:Name="PopupScale" ScaleY="0" /></Border.RenderTransform>- <ScrollViewer MaxHeight="{TemplateBinding MaxDropDownHeight}" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Padding="0" Margin="0">- <ItemsPresenter Margin="1,4,8,4"/>+ <ScrollViewer x:Name="PART_ScrollViewer" MaxHeight="{TemplateBinding MaxDropDownHeight}" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Padding="1,4,8,4">+ <Grid>+ <Border>+ <Border.OpacityMask>+ <MultiBinding>+ <MultiBinding.Converter>+ <conv:ScrollFadeMaskConverter/>+ </MultiBinding.Converter>+ <Binding ElementName="PART_ScrollViewer" Path="VerticalOffset"/>+ <Binding ElementName="PART_ScrollViewer" Path="ViewportHeight"/>+ <Binding ElementName="PART_ScrollViewer" Path="ExtentHeight"/>+ </MultiBinding>+ </Border.OpacityMask>+ <ItemsPresenter/>+ </Border>+ </Grid></ScrollViewer></Border></Popup>@@ -163,12 +200,12 @@<EventTrigger RoutedEvent="ToggleButton.Checked"><BeginStoryboard><Storyboard Timeline.DesiredFrameRate="120">- <DoubleAnimation Storyboard.TargetName="PopupBorder" Storyboard.TargetProperty="Opacity" From="0" To="1" Duration="0:0:0.1">+ <DoubleAnimation Storyboard.TargetName="PopupBorder" Storyboard.TargetProperty="Opacity" From="0" To="1" Duration="0:0:0.15"><DoubleAnimation.EasingFunction>- <QuadraticEase/>+ <QuadraticEase EasingMode="EaseOut"/></DoubleAnimation.EasingFunction></DoubleAnimation>- <DoubleAnimation Storyboard.TargetName="PopupScaleTransform" Storyboard.TargetProperty="ScaleY" From="0" To="1" Duration="0:0:0.2">+ <DoubleAnimation Storyboard.TargetName="PopupScale" Storyboard.TargetProperty="ScaleY" From="0" To="1" Duration="0:0:0.2"><DoubleAnimation.EasingFunction><CubicEase EasingMode="EaseOut"/></DoubleAnimation.EasingFunction>