Skip to content

Commit de2f864

Browse files
committed
CM-44177 - Fix violation panel scroll
1 parent 6bf4329 commit de2f864

9 files changed

+56
-5
lines changed

src/extension/Cycode.VisualStudio.Extension.Shared/Components/ViolationCards/Common/Markdown.xaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:mdXaml="clr-namespace:MdXaml;assembly=MdXaml">
5-
<!-- FIXME(MarshalX): scroll gesture does not work -->
65
<mdXaml:MarkdownScrollViewer
76
x:Name="MarkdownScrollViewer"
87
Margin="5,5,5,5"

src/extension/Cycode.VisualStudio.Extension.Shared/Components/ViolationCards/IacViolationCardControl.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:common="clr-namespace:Cycode.VisualStudio.Extension.Shared.Components.ViolationCards.Common"
55
xmlns:t="clr-namespace:Cycode.VisualStudio.Extension.Shared.Components.ViolationCards.Common.TextBoxes">
6-
<ScrollViewer VerticalScrollBarVisibility="Auto">
6+
<ScrollViewer x:Name="Scroll" VerticalScrollBarVisibility="Auto" PreviewMouseWheel="ScrollViewer_MouseWheel" Focusable="False">
77
<Grid x:Name="Grid" VerticalAlignment="Top">
88
<Grid.RowDefinitions>
99
<RowDefinition />

src/extension/Cycode.VisualStudio.Extension.Shared/Components/ViolationCards/IacViolationCardControl.xaml.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.IO;
22
using System.Windows;
3+
using System.Windows.Input;
34
using Cycode.VisualStudio.Extension.Shared.Cli.DTO;
45
using Cycode.VisualStudio.Extension.Shared.Cli.DTO.ScanResult.Iac;
56
using Cycode.VisualStudio.Extension.Shared.Helpers;
@@ -58,4 +59,16 @@ void OnSuccess(AiRemediationResultData remediationResult) {
5859
GridHelper.ShowRow(Grid, _aiRemediationRowIndex);
5960
}
6061
}
62+
63+
private void ScrollViewer_MouseWheel(object sender, MouseWheelEventArgs e) {
64+
// If the mouse is not over the control, we don't want to scroll it
65+
if (!IsMouseOver) return;
66+
67+
// Raise the event on the parent control
68+
Scroll.RaiseEvent(new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta) {
69+
RoutedEvent = MouseWheelEvent
70+
});
71+
72+
e.Handled = true;
73+
}
6174
}

src/extension/Cycode.VisualStudio.Extension.Shared/Components/ViolationCards/SastViolationCardControl.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:common="clr-namespace:Cycode.VisualStudio.Extension.Shared.Components.ViolationCards.Common"
55
xmlns:t="clr-namespace:Cycode.VisualStudio.Extension.Shared.Components.ViolationCards.Common.TextBoxes">
6-
<ScrollViewer VerticalScrollBarVisibility="Auto">
6+
<ScrollViewer x:Name="Scroll" VerticalScrollBarVisibility="Auto" PreviewMouseWheel="ScrollViewer_MouseWheel" Focusable="False">
77
<Grid x:Name="Grid" VerticalAlignment="Top">
88
<Grid.RowDefinitions>
99
<RowDefinition />

src/extension/Cycode.VisualStudio.Extension.Shared/Components/ViolationCards/SastViolationCardControl.xaml.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Collections.Generic;
22
using System.Linq;
33
using System.Windows;
4+
using System.Windows.Input;
45
using Cycode.VisualStudio.Extension.Shared.Cli.DTO;
56
using Cycode.VisualStudio.Extension.Shared.Cli.DTO.ScanResult.Sast;
67
using Cycode.VisualStudio.Extension.Shared.Helpers;
@@ -77,4 +78,16 @@ void OnSuccess(AiRemediationResultData remediationResult) {
7778
GridHelper.ShowRow(Grid, _aiRemediationRowIndex);
7879
}
7980
}
81+
82+
private void ScrollViewer_MouseWheel(object sender, MouseWheelEventArgs e) {
83+
// If the mouse is not over the control, we don't want to scroll it
84+
if (!IsMouseOver) return;
85+
86+
// Raise the event on the parent control
87+
Scroll.RaiseEvent(new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta) {
88+
RoutedEvent = MouseWheelEvent
89+
});
90+
91+
e.Handled = true;
92+
}
8093
}

src/extension/Cycode.VisualStudio.Extension.Shared/Components/ViolationCards/ScaViolationCardControl.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:common="clr-namespace:Cycode.VisualStudio.Extension.Shared.Components.ViolationCards.Common"
55
xmlns:t="clr-namespace:Cycode.VisualStudio.Extension.Shared.Components.ViolationCards.Common.TextBoxes">
6-
<ScrollViewer VerticalScrollBarVisibility="Auto">
6+
<ScrollViewer x:Name="Scroll" VerticalScrollBarVisibility="Auto" PreviewMouseWheel="ScrollViewer_MouseWheel" Focusable="False">
77
<Grid x:Name="Grid" VerticalAlignment="Top">
88
<Grid.RowDefinitions>
99
<RowDefinition />

src/extension/Cycode.VisualStudio.Extension.Shared/Components/ViolationCards/ScaViolationCardControl.xaml.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Windows;
2+
using System.Windows.Input;
23
using Cycode.VisualStudio.Extension.Shared.Cli.DTO;
34
using Cycode.VisualStudio.Extension.Shared.Cli.DTO.ScanResult.Sca;
45
using Cycode.VisualStudio.Extension.Shared.Helpers;
@@ -86,4 +87,16 @@ await _cycodeService.ApplyDetectionIgnoreAsync(
8687
CliScanType.Sca, CliIgnoreType.Cve, _detection.DetectionDetails.Alert?.CveIdentifier
8788
);
8889
}
90+
91+
private void ScrollViewer_MouseWheel(object sender, MouseWheelEventArgs e) {
92+
// If the mouse is not over the control, we don't want to scroll it
93+
if (!IsMouseOver) return;
94+
95+
// Raise the event on the parent control
96+
Scroll.RaiseEvent(new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta) {
97+
RoutedEvent = MouseWheelEvent
98+
});
99+
100+
e.Handled = true;
101+
}
89102
}

src/extension/Cycode.VisualStudio.Extension.Shared/Components/ViolationCards/SecretViolationCardControl.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:common="clr-namespace:Cycode.VisualStudio.Extension.Shared.Components.ViolationCards.Common"
55
xmlns:t="clr-namespace:Cycode.VisualStudio.Extension.Shared.Components.ViolationCards.Common.TextBoxes">
6-
<ScrollViewer VerticalScrollBarVisibility="Auto">
6+
<ScrollViewer x:Name="Scroll" VerticalScrollBarVisibility="Auto" PreviewMouseWheel="ScrollViewer_MouseWheel" Focusable="False">
77
<Grid x:Name="Grid" VerticalAlignment="Top">
88
<Grid.RowDefinitions>
99
<RowDefinition />

src/extension/Cycode.VisualStudio.Extension.Shared/Components/ViolationCards/SecretViolationCardControl.xaml.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Windows;
2+
using System.Windows.Input;
23
using Cycode.VisualStudio.Extension.Shared.Cli.DTO;
34
using Cycode.VisualStudio.Extension.Shared.Cli.DTO.ScanResult.Secret;
45
using Cycode.VisualStudio.Extension.Shared.Helpers;
@@ -47,4 +48,16 @@ await _cycodeService.ApplyDetectionIgnoreAsync(
4748
CliScanType.Secret, CliIgnoreType.Value, _detection.DetectionDetails.DetectedValue
4849
);
4950
}
51+
52+
private void ScrollViewer_MouseWheel(object sender, MouseWheelEventArgs e) {
53+
// If the mouse is not over the control, we don't want to scroll it
54+
if (!IsMouseOver) return;
55+
56+
// Raise the event on the parent control
57+
Scroll.RaiseEvent(new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta) {
58+
RoutedEvent = MouseWheelEvent
59+
});
60+
61+
e.Handled = true;
62+
}
5063
}

0 commit comments

Comments
 (0)