Skip to content

Portable Tool for an Ideal Windows Setup

add auto-scrolling for navigation

Greedeksee94004609ba
diff --git a/.Source/GTweak/View/ConfidentialityView.xaml b/.Source/GTweak/View/ConfidentialityView.xaml
index eb749e24..c85beac5 100644
--- a/.Source/GTweak/View/ConfidentialityView.xaml
+++ b/.Source/GTweak/View/ConfidentialityView.xaml
@@ -28,7 +28,6 @@
<Grid Grid.Row="0">
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
-
<uc:FlowPanel VerticalSpacing="20" HorizontalSpacing="5" Margin="10">
<uc:ToggleButton x:Name="TglButton1" Style="{StaticResource ToggleStyle}" StateNA="{Binding [TglButton1].State}" TextResource="{DynamicResource tgl1_conf}" Description="{DynamicResource tgl1_desc_conf}" />
@@ -51,9 +50,8 @@
<uc:ToggleButton x:Name="TglButton18" Style="{StaticResource ToggleStyle}" StateNA="{Binding [TglButton18].State}" TextResource="{DynamicResource tgl18_conf}" Description="{DynamicResource tgl18_desc_conf}" />
<uc:ToggleButton x:Name="TglButton19" Style="{StaticResource ToggleStyle}" StateNA="{Binding [TglButton19].State}" TextResource="{DynamicResource tgl19_conf}" Description="{DynamicResource tgl19_desc_conf}" />
<uc:ToggleButton x:Name="TglButton20" Style="{StaticResource ToggleStyle}" StateNA="{Binding [TglButton20].State}" TextResource="{DynamicResource tgl20_conf}" Description="{DynamicResource tgl20_desc_conf}" />
-
- </uc:FlowPanel>
+ </uc:FlowPanel>
</ScrollViewer>
</Grid>
diff --git a/.Source/GTweak/View/InterfaceView.xaml b/.Source/GTweak/View/InterfaceView.xaml
index a151b64a..4c47d78a 100644
--- a/.Source/GTweak/View/InterfaceView.xaml
+++ b/.Source/GTweak/View/InterfaceView.xaml
@@ -28,7 +28,6 @@
<Grid Grid.Row="0">
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
-
<uc:FlowPanel VerticalSpacing="20" HorizontalSpacing="5" Margin="10">
<StackPanel Orientation="Vertical" Margin="0,-10,0,-10">
@@ -75,7 +74,7 @@
</uc:ExpandableBox>
</StackPanel>
</StackPanel>
-
+
<uc:ToggleButton x:Name="TglButton1" Style="{StaticResource ToggleStyle}" StateNA="{Binding [TglButton1].State}" TextResource="{DynamicResource tgl1_intf}" Description="{DynamicResource tgl1_desc_intf}" />
<uc:ToggleButton x:Name="TglButton2" Style="{StaticResource ToggleStyle}" StateNA="{Binding [TglButton2].State}" TextResource="{DynamicResource tgl2_intf}" Description="{DynamicResource tgl2_desc_intf}" />
<uc:ToggleButton x:Name="TglButton3" Style="{StaticResource ToggleStyle}" StateNA="{Binding [TglButton3].State}" TextResource="{DynamicResource tgl3_intf}" Description="{DynamicResource tgl3_desc_intf}" />
@@ -107,7 +106,6 @@
<uc:ToggleButton x:Name="TglButton29" Style="{StaticResource ToggleStyle}" StateNA="{Binding [TglButton29].State}" TextResource="{DynamicResource tgl29_intf}" Description="{DynamicResource tgl29_desc_intf}" />
</uc:FlowPanel>
-
</ScrollViewer>
</Grid>
diff --git a/.Source/GTweak/View/ServicesView.xaml b/.Source/GTweak/View/ServicesView.xaml
index 60acec68..f789cead 100644
--- a/.Source/GTweak/View/ServicesView.xaml
+++ b/.Source/GTweak/View/ServicesView.xaml
@@ -27,7 +27,6 @@
<Grid Grid.Row="0">
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
-
<uc:FlowPanel VerticalSpacing="20" HorizontalSpacing="5" Margin="10">
<uc:ToggleButton x:Name="TglButton1" Style="{StaticResource ToggleStyle}" StateNA="{Binding [TglButton1].State}" TextResource="{DynamicResource tgl1_svc}" Description="{DynamicResource tgl1_desc_svc}" />
@@ -62,9 +61,8 @@
<uc:ToggleButton x:Name="TglButton30" Style="{StaticResource ToggleStyle}" StateNA="{Binding [TglButton30].State}" TextResource="{DynamicResource tgl30_svc}" Description="{DynamicResource tgl30_desc_svc}" />
<uc:ToggleButton x:Name="TglButton31" Visibility="{Binding EdgeAvailable}" Style="{StaticResource ToggleStyle}" StateNA="{Binding [TglButton31].State}" TextResource="{DynamicResource tgl31_svc}" Description="{DynamicResource tgl31_desc_svc}" />
<uc:ToggleButton x:Name="TglButton32" Style="{StaticResource ToggleStyle}" StateNA="{Binding [TglButton32].State}" TextResource="{DynamicResource tgl32_svc}" Description="{DynamicResource tgl32_desc_svc}" />
-
- </uc:FlowPanel>
+ </uc:FlowPanel>
</ScrollViewer>
</Grid>
diff --git a/.Source/GTweak/View/SystemView.xaml b/.Source/GTweak/View/SystemView.xaml
index 9b759cfe..4f56cba9 100644
--- a/.Source/GTweak/View/SystemView.xaml
+++ b/.Source/GTweak/View/SystemView.xaml
@@ -28,7 +28,6 @@
<Grid Grid.Row="0">
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
-
<uc:FlowPanel VerticalSpacing="20" HorizontalSpacing="5" Margin="10">
<StackPanel Orientation="Vertical" Margin="0,-20,0,0">
@@ -52,7 +51,7 @@
<uc:ToggleButton x:Name="TglButton1" Style="{StaticResource ToggleStyle}" StateNA="{Binding [TglButton1].State}" Margin="0,20,0,0" TextResource="{DynamicResource tgl1_sys}" Description="{DynamicResource tgl1_desc_sys}" />
<uc:ToggleButton x:Name="TglButton2" Style="{StaticResource ToggleStyle}" StateNA="{Binding [TglButton2].State}" Margin="0,20,0,0" TextResource="{DynamicResource tgl2_sys}" Description="{DynamicResource tgl2_desc_sys}" />
</StackPanel>
-
+
<uc:ToggleButton x:Name="TglButton3" Style="{StaticResource ToggleStyle}" StateNA="{Binding [TglButton3].State}" TextResource="{DynamicResource tgl3_sys}" Description="{DynamicResource tgl3_desc_sys}" />
<uc:ToggleButton x:Name="TglButton4" Style="{StaticResource ToggleStyle}" StateNA="{Binding [TglButton4].State}" TextResource="{DynamicResource tgl4_sys}" Description="{DynamicResource tgl4_desc_sys}" />
<uc:ToggleButton x:Name="TglButton5" Style="{StaticResource ToggleStyle}" StateNA="{Binding [TglButton5].State}" TextResource="{DynamicResource tgl5_sys}" Description="{DynamicResource tgl5_desc_sys}" />
@@ -81,7 +80,6 @@
<uc:ToggleButton x:Name="TglButton28" Style="{StaticResource ToggleStyle}" StateNA="{Binding [TglButton28].State}" TextResource="{DynamicResource tgl28_sys}" Description="{DynamicResource tgl28_desc_sys}" />
<uc:ToggleButton x:Name="TglButton29" Style="{StaticResource ToggleStyle}" StateNA="{Binding [TglButton29].State}" TextResource="{DynamicResource tgl29_sys}" Description="{DynamicResource tgl29_desc_sys}" />
</uc:FlowPanel>
-
</ScrollViewer>
</Grid>
diff --git a/.Source/GTweak/Windows/MainWindow.xaml b/.Source/GTweak/Windows/MainWindow.xaml
index 2befaed2..c2b679e5 100644
--- a/.Source/GTweak/Windows/MainWindow.xaml
+++ b/.Source/GTweak/Windows/MainWindow.xaml
@@ -104,7 +104,7 @@
</LinearGradientBrush>
</Border.OpacityMask>
- <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" CanContentScroll="True">
+ <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
<Grid Width="400" Margin="0" VirtualizingStackPanel.IsVirtualizing="True">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
@@ -253,9 +253,9 @@
<Grid Grid.ColumnSpan="2" Panel.ZIndex="100" VerticalAlignment="Top">
<Border Margin="0,15,0,50" MinWidth="70" MaxWidth="320" HorizontalAlignment="Left" ClipToBounds="True">
-
- <ScrollViewer Padding="0,0,15,0" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" CanContentScroll="True" FlowDirection="RightToLeft">
- <StackPanel Orientation="Vertical" FlowDirection="LeftToRight">
+
+ <ScrollViewer x:Name="NavScroll" Padding="0,0,15,0" SizeChanged="NavigationScrollViewer_SizeChanged" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" FlowDirection="RightToLeft">
+ <StackPanel x:Name="NavPanel" Orientation="Vertical" FlowDirection="LeftToRight" RadioButton.Checked="NavigationRtbn_Checked">
<RadioButton Name="BtnUtils" Style="{StaticResource BtnNavigation}" Tag="{DynamicResource rbtn_utils_main}" Command="{Binding NavigateToUtilsCommand}" IsChecked="True" >
<ui:SymbolIcon Symbol="Toolbox20" FontSize="20"/>
@@ -269,7 +269,7 @@
<ui:SymbolIcon Symbol="Color20" FontSize="20"/>
</RadioButton>
- <RadioButton Style="{StaticResource BtnNavigation}" Tag="{DynamicResource rbtn_app_main}" Command="{Binding NavigateToPackagesCommand}">
+ <RadioButton Style="{StaticResource BtnNavigation}" Tag="{DynamicResource rbtn_app_main}" Command="{Binding NavigateToPackagesCommand}" Checked="NavigationRtbn_Checked">
<ui:SymbolIcon Symbol="Apps20" FontSize="20"/>
</RadioButton>
diff --git a/.Source/GTweak/Windows/MainWindow.xaml.cs b/.Source/GTweak/Windows/MainWindow.xaml.cs
index 8add4b2d..b479ac78 100644
--- a/.Source/GTweak/Windows/MainWindow.xaml.cs
+++ b/.Source/GTweak/Windows/MainWindow.xaml.cs
@@ -3,6 +3,7 @@ using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Windows;
+using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Interop;
@@ -23,14 +24,29 @@ namespace GTweak.Windows
[DllImport("user32.dll")]
private static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
+ internal static readonly DependencyProperty CurrentVerticalOffsetProperty =
+ DependencyProperty.RegisterAttached("CurrentVerticalOffset", typeof(double), typeof(MainWindow), new PropertyMetadata(0.0, OnCurrentVerticalOffsetChanged));
+
+ internal static void SetCurrentVerticalOffset(DependencyObject target, double value) => target.SetValue(CurrentVerticalOffsetProperty, value);
+
+ private static void OnCurrentVerticalOffsetChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ if (d is ScrollViewer scrollViewer)
+ {
+ scrollViewer.ScrollToVerticalOffset((double)e.NewValue);
+ }
+ }
+
private const int WM_NCLBUTTONDOWN = 0xA1, HTCAPTION = 0x2;
private bool _settingsOpen = false, _ignoreMouseClick = false;
+ private RadioButton _activeBtnCache;
public MainWindow()
{
InitializeComponent();
App.TweaksImported += delegate { BtnUtils.IsChecked = true; };
}
+
protected override void OnSourceInitialized(EventArgs e)
{
base.OnSourceInitialized(e);
@@ -59,9 +75,9 @@ namespace GTweak.Windows
transform.BeginAnimation(TranslateTransform.XProperty, FactoryAnimation.CreateIn(transform.X, toX, 0.5, useCubicEase: true));
}
- #region TitleBar
private void HandleWindowState() => WindowState = WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized;
+ #region TitleBar
private void TitleBar_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (e?.ChangedButton == MouseButton.Left)
@@ -131,7 +147,7 @@ namespace GTweak.Windows
}
#endregion
- #region SettingsPanel
+ #region Settings Panel
private void BtnNotification_ChangedState(object sender, RoutedEventArgs e) => SettingsEngine.IsViewNotification = !BtnNotification.State;
private void BtnUpdate_ChangedState(object sender, RoutedEventArgs e) => SettingsEngine.IsUpdateCheckRequired = !BtnUpdate.State;
@@ -165,6 +181,61 @@ namespace GTweak.Windows
}
#endregion
+ #region Navigation & Scrolling
+ private void NavigationScrollViewer_SizeChanged(object sender, SizeChangedEventArgs e)
+ {
+ if (sender is ScrollViewer scrollViewer)
+ {
+ if (e.HeightChanged && _activeBtnCache != null && scrollViewer.ScrollableHeight > 0)
+ {
+ Dispatcher.BeginInvoke(new Action(() =>
+ {
+ if (_activeBtnCache.IsLoaded)
+ {
+ _activeBtnCache.BringIntoView();
+ }
+ }), DispatcherPriority.Loaded);
+ }
+ }
+ }
+
+ private void NavigationRtbn_Checked(object sender, RoutedEventArgs e)
+ {
+ if (e.OriginalSource is RadioButton radioButton)
+ {
+ _activeBtnCache = radioButton;
+
+ Dispatcher.BeginInvoke(new Action(() =>
+ {
+ if (radioButton.IsLoaded && radioButton.IsDescendantOf(NavPanel))
+ {
+ double margin = radioButton.ActualHeight;
+
+ Point btnPos = radioButton.TranslatePoint(new Point(0, 0), NavPanel);
+
+ double btnTop = btnPos.Y, btnBottom = btnTop + margin, viewTop = NavScroll.VerticalOffset,
+ viewBottom = viewTop + NavScroll.ViewportHeight, targetOffset = viewTop;
+
+ if (btnTop - margin < viewTop)
+ {
+ targetOffset = btnTop - margin;
+ }
+ else if (btnBottom + margin > viewBottom)
+ {
+ targetOffset = btnBottom + margin - NavScroll.ViewportHeight;
+ }
+
+ if (targetOffset != viewTop)
+ {
+ SetCurrentVerticalOffset(NavScroll, viewTop);
+ NavScroll.BeginAnimation(CurrentVerticalOffsetProperty, FactoryAnimation.CreateIn(viewTop, targetOffset, 0.5, useCubicEase: true));
+ }
+ }
+ }), DispatcherPriority.Loaded);
+ }
+ }
+ #endregion
+
private void BtnUpdate_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
UpdateBanner.BeginAnimation(OpacityProperty, FactoryAnimation.CreateIn(1, 0, 0.3, () => { UpdateBanner.Visibility = Visibility.Collapsed; }));