@@ -569,6 +569,7 @@ public VS2005DockPaneStrip(DockPane pane) : base(pane)
569
569
m_selectMenu . Font = PluginCore . PluginBase . Settings . DefaultFont ;
570
570
m_selectMenu . ImageScalingSize = ScaleHelper . Scale ( new Size ( 16 , 16 ) ) ;
571
571
m_selectMenu . Renderer = new DockPanelStripRenderer ( false ) ;
572
+ m_selectMenu . MouseWheel += ContextMenu_MouseWheel ;
572
573
573
574
ResumeLayout ( ) ;
574
575
}
@@ -1441,6 +1442,51 @@ private void WindowList_Click(object sender, EventArgs e)
1441
1442
SelectMenu . Show ( ButtonWindowList , x , y ) ;
1442
1443
}
1443
1444
1445
+ private static readonly Action < ToolStrip , int > ScrollInternal
1446
+ = ( Action < ToolStrip , int > ) Delegate . CreateDelegate ( typeof ( Action < ToolStrip , int > ) ,
1447
+ typeof ( ToolStrip ) . GetMethod ( "ScrollInternal" ,
1448
+ System . Reflection . BindingFlags . NonPublic
1449
+ | System . Reflection . BindingFlags . Instance ) ) ;
1450
+
1451
+ private static readonly Action < ToolStripDropDownMenu > UpdateScrollButtonStatus
1452
+ = ( Action < ToolStripDropDownMenu > ) Delegate . CreateDelegate ( typeof ( Action < ToolStripDropDownMenu > ) ,
1453
+ typeof ( ToolStripDropDownMenu ) . GetMethod ( "UpdateScrollButtonStatus" ,
1454
+ System . Reflection . BindingFlags . NonPublic
1455
+ | System . Reflection . BindingFlags . Instance ) ) ;
1456
+
1457
+ private void ContextMenu_MouseWheel ( object sender , MouseEventArgs e )
1458
+ {
1459
+ /* Default size, can it be changed? if so we can get it with:
1460
+ ((ToolStripItem)typeof(ToolStripDropDownMenu).GetProperty ("DownScrollButton",
1461
+ System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance ).GetValue(ts, null)).
1462
+ GetPreferredSize(Size.Empty).Height
1463
+ */
1464
+ const int scrollButtonHeight = 9 ;
1465
+
1466
+ var ts = ( ContextMenuStrip ) sender ;
1467
+ int delta = e . Delta ;
1468
+ if ( ts . Items . Count == 0 )
1469
+ return ;
1470
+ var firstItem = ts . Items [ 0 ] ;
1471
+ var lastItem = ts . Items [ ts . Items . Count - 1 ] ;
1472
+ if ( lastItem . Bounds . Bottom < ts . Height && firstItem . Bounds . Top > 0 )
1473
+ return ;
1474
+ delta = delta / - 4 ;
1475
+ if ( delta < 0 && firstItem . Bounds . Top - delta > scrollButtonHeight )
1476
+ {
1477
+ delta = firstItem . Bounds . Top - scrollButtonHeight ;
1478
+ }
1479
+ else if ( delta > 0 && delta > lastItem . Bounds . Bottom - ts . Height + scrollButtonHeight * 2 )
1480
+ {
1481
+ delta = lastItem . Bounds . Bottom - ts . Height + scrollButtonHeight * 2 ;
1482
+ }
1483
+ if ( delta != 0 )
1484
+ {
1485
+ ScrollInternal ( ts , delta ) ;
1486
+ UpdateScrollButtonStatus ( ts ) ;
1487
+ }
1488
+ }
1489
+
1444
1490
private void ContextMenuItem_Up ( object sender , MouseEventArgs e )
1445
1491
{
1446
1492
ToolStripMenuItem item = sender as ToolStripMenuItem ;
0 commit comments