diff --git a/src/MaaWpfGui/Helper/MouseWheelHelper.cs b/src/MaaWpfGui/Helper/MouseWheelHelper.cs
new file mode 100644
index 0000000000..74c3c2beed
--- /dev/null
+++ b/src/MaaWpfGui/Helper/MouseWheelHelper.cs
@@ -0,0 +1,25 @@
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
+
+namespace MaaWpfGui.Helper
+{
+ public static class MouseWheelHelper
+ {
+ public static void HandlePreviewMouseWheel(object sender, MouseWheelEventArgs e)
+ {
+ if (e.Handled)
+ {
+ return;
+ }
+
+ e.Handled = true;
+ var eventArg = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta)
+ {
+ RoutedEvent = UIElement.MouseWheelEvent,
+ };
+ var parent = ((Control)sender).Parent as UIElement;
+ parent?.RaiseEvent(eventArg);
+ }
+ }
+}
diff --git a/src/MaaWpfGui/Views/UI/AnnouncementView.xaml b/src/MaaWpfGui/Views/UI/AnnouncementView.xaml
index f3cfe1d97d..1ffdf40805 100644
--- a/src/MaaWpfGui/Views/UI/AnnouncementView.xaml
+++ b/src/MaaWpfGui/Views/UI/AnnouncementView.xaml
@@ -4,42 +4,41 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:hc="https://handyorg.github.io/handycontrol"
+ xmlns:helper="clr-namespace:MaaWpfGui.Helper"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mdxam="clr-namespace:MdXaml;assembly=MdXaml"
+ xmlns:s="https://github.com/canton7/Stylet"
xmlns:styles="clr-namespace:MaaWpfGui.Styles"
xmlns:ui="clr-namespace:MaaWpfGui.ViewModels.UI"
- Icon="../../newlogo.ico"
Title="{DynamicResource Announcement}"
Width="600"
Height="500"
d:DataContext="{d:DesignInstance {x:Type ui:AnnouncementViewModel}}"
+ Icon="../../newlogo.ico"
mc:Ignorable="d">
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
diff --git a/src/MaaWpfGui/Views/UI/RecognizerView.xaml b/src/MaaWpfGui/Views/UI/RecognizerView.xaml
index 8606f3d6f2..476bfb7709 100644
--- a/src/MaaWpfGui/Views/UI/RecognizerView.xaml
+++ b/src/MaaWpfGui/Views/UI/RecognizerView.xaml
@@ -6,6 +6,7 @@
xmlns:controls="clr-namespace:MaaWpfGui.Styles.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:hc="https://handyorg.github.io/handycontrol"
+ xmlns:helper="clr-namespace:MaaWpfGui.Helper"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:s="https://github.com/canton7/Stylet"
xmlns:ui="clr-namespace:MaaWpfGui.ViewModels.UI"
@@ -221,6 +222,8 @@
HeadersVisibility="None"
IsReadOnly="True"
ItemsSource="{Binding OperBoxNotHaveList}"
+ PreviewMouseWheel="{s:Action HandlePreviewMouseWheel,
+ Target={x:Type helper:MouseWheelHelper}}"
ScrollViewer.CanContentScroll="True"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
Visibility="{c:Binding 'OperBoxNotHaveList.Count != 0'}">
@@ -229,11 +232,6 @@
-
-
-
@@ -255,6 +253,8 @@
HeadersVisibility="None"
IsReadOnly="True"
ItemsSource="{Binding OperBoxHaveList}"
+ PreviewMouseWheel="{s:Action HandlePreviewMouseWheel,
+ Target={x:Type helper:MouseWheelHelper}}"
ScrollViewer.CanContentScroll="True"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
Visibility="{c:Binding 'OperBoxHaveList.Count != 0'}">
@@ -263,11 +263,6 @@
-
-
-
diff --git a/src/MaaWpfGui/Views/UI/RecognizerView.xaml.cs b/src/MaaWpfGui/Views/UI/RecognizerView.xaml.cs
deleted file mode 100644
index ac587dec95..0000000000
--- a/src/MaaWpfGui/Views/UI/RecognizerView.xaml.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-//
-// MaaWpfGui - A part of the MaaCoreArknights project
-// Copyright (C) 2021 MistEO and Contributors
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Affero General Public License v3.0 only as published by
-// the Free Software Foundation, either version 3 of the License, or
-// any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY
-//
-
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Input;
-
-namespace MaaWpfGui.Views.UI
-{
- public partial class RecognizerView
- {
- public RecognizerView()
- {
- InitializeComponent();
- }
-
- private void DataGrid_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
- {
- if (e.Handled)
- {
- return;
- }
-
- e.Handled = true;
- var eventArg = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta)
- {
- RoutedEvent = MouseWheelEvent,
- };
- var parent = ((Control)sender).Parent as UIElement;
- parent?.RaiseEvent(eventArg);
- }
- }
-}
diff --git a/src/MaaWpfGui/Views/UserControl/TaskQueue/InfrastSettingsUserControl.xaml b/src/MaaWpfGui/Views/UserControl/TaskQueue/InfrastSettingsUserControl.xaml
index 77e7ada992..c3243febe6 100644
--- a/src/MaaWpfGui/Views/UserControl/TaskQueue/InfrastSettingsUserControl.xaml
+++ b/src/MaaWpfGui/Views/UserControl/TaskQueue/InfrastSettingsUserControl.xaml
@@ -108,6 +108,8 @@
dd:DragDrop.IsDragSource="True"
dd:DragDrop.IsDropTarget="True"
ItemsSource="{Binding Path=InfrastItemViewModels}"
+ PreviewMouseWheel="{s:Action HandlePreviewMouseWheel,
+ Target={x:Type helper:MouseWheelHelper}}"
ToolTip="{DynamicResource LabelSequenceTip}">
@@ -118,11 +120,6 @@
-
-
-
diff --git a/src/MaaWpfGui/Views/UserControl/TaskQueue/InfrastSettingsUserControl.xaml.cs b/src/MaaWpfGui/Views/UserControl/TaskQueue/InfrastSettingsUserControl.xaml.cs
index abffb1dba0..c29de5ca9e 100644
--- a/src/MaaWpfGui/Views/UserControl/TaskQueue/InfrastSettingsUserControl.xaml.cs
+++ b/src/MaaWpfGui/Views/UserControl/TaskQueue/InfrastSettingsUserControl.xaml.cs
@@ -29,21 +29,5 @@ namespace MaaWpfGui.Views.UserControl.TaskQueue
{
InitializeComponent();
}
-
- private void ListBox_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
- {
- if (e.Handled)
- {
- return;
- }
-
- e.Handled = true;
- var eventArg = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta)
- {
- RoutedEvent = UIElement.MouseWheelEvent
- };
- var parent = ((Control)sender).Parent as UIElement;
- parent?.RaiseEvent(eventArg);
- }
}
}