You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.1 KiB
36 lines
1.1 KiB
// <file>
|
|
// <copyright see="prj:///doc/copyright.txt"/>
|
|
// <license see="prj:///doc/license.txt"/>
|
|
// <author name="Daniel Grunwald"/>
|
|
// <version>$Revision$</version>
|
|
// </file>
|
|
|
|
using System;
|
|
using System.Windows.Forms;
|
|
|
|
namespace ICSharpCode.TextEditor.Util
|
|
{
|
|
/// <summary>
|
|
/// Accumulates mouse wheel deltas and reports the actual number of lines to scroll.
|
|
/// </summary>
|
|
internal class MouseWheelHandler
|
|
{
|
|
// CODE DUPLICATION: See ICSharpCode.SharpDevelop.Widgets.MouseWheelHandler
|
|
|
|
private const int WHEEL_DELTA = 120;
|
|
|
|
private int mouseWheelDelta;
|
|
|
|
public int GetScrollAmount(MouseEventArgs e)
|
|
{
|
|
// accumulate the delta to support high-resolution mice
|
|
mouseWheelDelta += e.Delta;
|
|
|
|
var linesPerClick = Math.Max(SystemInformation.MouseWheelScrollLines, val2: 1);
|
|
|
|
var scrollDistance = mouseWheelDelta*linesPerClick/WHEEL_DELTA;
|
|
mouseWheelDelta %= Math.Max(val1: 1, WHEEL_DELTA/linesPerClick);
|
|
return scrollDistance;
|
|
}
|
|
}
|
|
}
|