public void MouseMoveKeyboardPreview(MouseEventArgs e)
{
if (SelectedProfile == null)
return;
var pos = e.GetPosition((Image) e.OriginalSource);
var keyboard = _deviceManager.ActiveKeyboard;
var x = pos.X/((double) keyboard.PreviewSettings.Width/keyboard.Width);
var y = pos.Y/((double) keyboard.PreviewSettings.Height/keyboard.Height);
var hoverLayer = GetLayers().Where(l => l.MustDraw())
.FirstOrDefault(l => l.Properties.GetRect(1).Contains(x, y));
HandleDragging(e, x, y, hoverLayer);
if (hoverLayer == null)
{
KeyboardPreviewCursor = Cursors.Arrow;
return;
}
// Turn the mouse pointer into a hand if hovering over an active layer
if (hoverLayer == SelectedLayer)
{
var rect = hoverLayer.Properties.GetRect(1);
KeyboardPreviewCursor =
Math.Sqrt(Math.Pow(x - rect.BottomRight.X, 2) + Math.Pow(y - rect.BottomRight.Y, 2)) < 0.6
? Cursors.SizeNWSE
: Cursors.SizeAll;
}
else
KeyboardPreviewCursor = Cursors.Hand;
}