Skip to content

Commit 6ff9bbf

Browse files
committed
Add mouse wheel scrolling
1 parent 3b37a89 commit 6ff9bbf

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

DXMainClient/DXGUI/Multiplayer/QuickMatch/QuickMatchMapList.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ namespace DTAClient.DXGUI.Multiplayer.QuickMatch
1111
{
1212
public class QuickMatchMapList : INItializableWindow
1313
{
14+
private const int ScrollRate = 6;
1415
public const int ItemHeight = 22;
1516
public event EventHandler<QmMapSelectedEventArgs> MapSelected;
1617

@@ -30,6 +31,27 @@ public override void Initialize()
3031
scrollBar.ClientRectangle = new Rectangle(Width - scrollBar.ScrollWidth - 1, 1, scrollBar.ScrollWidth, Height - 2);
3132
scrollBar.Scrolled += ScrollBarScrolled;
3233
AddChild(scrollBar);
34+
35+
MouseScrolled += OnMouseScrolled;
36+
}
37+
38+
private void OnMouseScrolled(object sender, EventArgs e)
39+
{
40+
int scrollWheelValue = Cursor.ScrollWheelValue;
41+
int viewTop = scrollBar.ViewTop - (scrollWheelValue * ScrollRate);
42+
int maxViewTop = scrollBar.Length - scrollBar.DisplayedPixelCount;
43+
44+
if (viewTop < 0)
45+
viewTop = 0;
46+
else if (viewTop > maxViewTop)
47+
viewTop = maxViewTop;
48+
49+
if (viewTop == scrollBar.ViewTop)
50+
return;
51+
52+
scrollBar.ViewTop = viewTop;
53+
RefreshScrollbar();
54+
RefreshItemLocations();
3355
}
3456

3557
public void AddItem(QuickMatchMapItem item)

0 commit comments

Comments
 (0)