Skip to content

Commit 853e9d4

Browse files
Merge pull request #3405 from tom-englert/toggle-smooth-scrolling
Fix #3393: Option to turn off smooth scrolling
2 parents 79ddc44 + 8eadd90 commit 853e9d4

File tree

7 files changed

+43
-4
lines changed

7 files changed

+43
-4
lines changed

ILSpy/App.xaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:styles="urn:TomsToolbox.Wpf.Styles"
55
xmlns:toms="urn:TomsToolbox"
6-
xmlns:themes="clr-namespace:ICSharpCode.ILSpy.Themes">
6+
xmlns:themes="clr-namespace:ICSharpCode.ILSpy.Themes"
7+
xmlns:composition="urn:TomsToolbox.Composition"
8+
xmlns:util="clr-namespace:ICSharpCode.ILSpy.Util">
79
<Application.Resources>
810
<Style x:Key="DialogWindow" TargetType="{x:Type Window}">
911
<Setter Property="ShowInTaskbar" Value="False" />
@@ -24,7 +26,13 @@
2426
</Style>
2527

2628
<Style TargetType="ScrollViewer">
27-
<Setter Property="toms:AdvancedScrollWheelBehavior.Attach" Value="WithAnimation" />
29+
<Setter Property="toms:StyleBindings.Behaviors">
30+
<Setter.Value>
31+
<toms:BehaviorCollection>
32+
<toms:AdvancedScrollWheelBehavior UseScrollingAnimation="{Binding Path=(util:SettingsService.DisplaySettings).EnableSmoothScrolling, Source={composition:Import util:SettingsService}}"/>
33+
</toms:BehaviorCollection>
34+
</Setter.Value>
35+
</Setter>
2836
</Style>
2937

3038
</Application.Resources>

ILSpy/App.xaml.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ public App()
6969
var cmdArgs = Environment.GetCommandLineArgs().Skip(1);
7070
CommandLineArguments = CommandLineArguments.Create(cmdArgs);
7171

72+
// This is only a temporary, read only handle to the settings service to access the AllowMultipleInstances setting before DI is initialized.
73+
// At runtime, you must use the service via DI!
7274
var settingsService = new SettingsService();
7375

7476
bool forceSingleInstance = (CommandLineArguments.SingleInstance ?? true)

ILSpy/Controls/ZoomScrollViewer.xaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
22
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
33
xmlns:Controls="clr-namespace:ICSharpCode.ILSpy.Controls"
4-
xmlns:toms="urn:TomsToolbox">
4+
xmlns:toms="urn:TomsToolbox"
5+
xmlns:composition="urn:TomsToolbox.Composition"
6+
xmlns:util="clr-namespace:ICSharpCode.ILSpy.Util">
57

68
<Style TargetType="{x:Type Controls:ZoomScrollViewer}">
7-
<Setter Property="toms:AdvancedScrollWheelBehavior.Attach" Value="WithAnimation" />
9+
<Setter Property="toms:StyleBindings.Behaviors">
10+
<Setter.Value>
11+
<toms:BehaviorCollection>
12+
<toms:AdvancedScrollWheelBehavior UseScrollingAnimation="{Binding Path=(util:SettingsService.DisplaySettings).EnableSmoothScrolling, Source={composition:Import util:SettingsService}}"/>
13+
</toms:BehaviorCollection>
14+
</Setter.Value>
15+
</Setter>
816
<Setter Property="Template">
917
<Setter.Value>
1018
<ControlTemplate TargetType="{x:Type Controls:ZoomScrollViewer}">

ILSpy/Options/DisplaySettings.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@ public bool ShowRawOffsetsAndBytesBeforeInstruction {
148148
set => SetProperty(ref showRawOffsetsAndBytesBeforeInstruction, value);
149149
}
150150

151+
private bool enableSmoothScrolling;
152+
public bool EnableSmoothScrolling {
153+
get => enableSmoothScrolling;
154+
set => SetProperty(ref enableSmoothScrolling, value);
155+
}
156+
151157
public XName SectionName => "DisplaySettings";
152158

153159
public void LoadFromXml(XElement section)
@@ -172,6 +178,7 @@ public void LoadFromXml(XElement section)
172178
UseNestedNamespaceNodes = (bool?)section.Attribute("UseNestedNamespaceNodes") ?? false;
173179
ShowRawOffsetsAndBytesBeforeInstruction = (bool?)section.Attribute("ShowRawOffsetsAndBytesBeforeInstruction") ?? false;
174180
StyleWindowTitleBar = (bool?)section.Attribute("StyleWindowTitleBar") ?? false;
181+
EnableSmoothScrolling = (bool?)section.Attribute("EnableSmoothScrolling") ?? true;
175182
}
176183

177184
public XElement SaveToXml()
@@ -198,6 +205,7 @@ public XElement SaveToXml()
198205
section.SetAttributeValue("UseNestedNamespaceNodes", UseNestedNamespaceNodes);
199206
section.SetAttributeValue("ShowRawOffsetsAndBytesBeforeInstruction", ShowRawOffsetsAndBytesBeforeInstruction);
200207
section.SetAttributeValue("StyleWindowTitleBar", StyleWindowTitleBar);
208+
section.SetAttributeValue("EnableSmoothScrolling", EnableSmoothScrolling);
201209

202210
return section;
203211
}

ILSpy/Options/DisplaySettingsPanel.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
<StackPanel Margin="3">
7979
<CheckBox IsChecked="{Binding Settings.SortResults}" Content="{x:Static properties:Resources.SortResultsFitness}"></CheckBox>
8080
<CheckBox IsChecked="{Binding Settings.StyleWindowTitleBar}" Content="{x:Static properties:Resources.StyleTheWindowTitleBar}"></CheckBox>
81+
<CheckBox IsChecked="{Binding Settings.EnableSmoothScrolling}" Content="{x:Static properties:Resources.EnableSmoothScrolling}"></CheckBox>
8182
</StackPanel>
8283
</GroupBox>
8384
</StackPanel>

ILSpy/Properties/Resources.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ILSpy/Properties/Resources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,9 @@ Are you sure you want to continue?</value>
591591
<data name="EnableFoldingBlocksBraces" xml:space="preserve">
592592
<value>Enable folding on all blocks in braces</value>
593593
</data>
594+
<data name="EnableSmoothScrolling" xml:space="preserve">
595+
<value>Enable smooth scrolling</value>
596+
</data>
594597
<data name="EnableWordWrap" xml:space="preserve">
595598
<value>Enable word wrap</value>
596599
</data>

0 commit comments

Comments
 (0)