|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
namespace MathProcessor
{
public class MouseWheelGesture : MouseGesture
{
public WheelDirection Direction { get; set; }
public static MouseWheelGesture CtrlDown
{
get
{
return new MouseWheelGesture(ModifierKeys.Control) { Direction = WheelDirection.Down };
}
}
public static MouseWheelGesture CtrlUp
{
get
{
return new MouseWheelGesture(ModifierKeys.Control) { Direction = WheelDirection.Up };
}
}
public MouseWheelGesture()
: base(MouseAction.WheelClick)
{
}
public MouseWheelGesture(ModifierKeys modifiers)
: base(MouseAction.WheelClick, modifiers)
{
}
public override bool Matches(object targetElement, InputEventArgs inputEventArgs)
{
if (!base.Matches(targetElement, inputEventArgs)) return false;
if (!(inputEventArgs is MouseWheelEventArgs)) return false;
var args = (MouseWheelEventArgs)inputEventArgs;
switch (Direction)
{
case WheelDirection.None:
return args.Delta == 0;
case WheelDirection.Up:
return args.Delta > 0;
case WheelDirection.Down:
return args.Delta < 0;
default:
return false;
}
}
public enum WheelDirection
{
None,
Up,
Down,
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I am a full-stack developer. My skills include JavaScript, C#/.Net, MS Azure cloud etc. I love to work on complex programming tasks requiring deep analysis, planning and use of efficient algorithms and data structures.