本文整理汇总了C#中MouseEventArgs.SetMovementX方法的典型用法代码示例。如果您正苦于以下问题:C# MouseEventArgs.SetMovementX方法的具体用法?C# MouseEventArgs.SetMovementX怎么用?C# MouseEventArgs.SetMovementX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MouseEventArgs
的用法示例。
在下文中一共展示了MouseEventArgs.SetMovementX方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Mouse_Move
void Mouse_Move(object sender, MouseMoveEventArgs e)
{
lastX = e.X;
lastY = e.Y;
if (TouchTest)
{
foreach (TouchEventHandler h in touchEventHandlers)
{
TouchEventArgs args = new TouchEventArgs();
args.SetX(e.X);
args.SetY(e.Y);
args.SetId(0);
h.OnTouchMove(args);
}
}
else
{
foreach (MouseEventHandler h in mouseEventHandlers)
{
MouseEventArgs args = new MouseEventArgs();
args.SetX(e.X);
args.SetY(e.Y);
args.SetMovementX(e.XDelta);
args.SetMovementY(e.YDelta);
args.SetEmulated(false);
h.OnMouseMove(args);
}
}
}
示例2: UpdateMousePosition
void UpdateMousePosition()
{
current = Mouse.GetState();
if (!window.Focused)
{
return;
}
if (current != previous)
{
// Mouse state has changed
int xdelta = current.X - previous.X;
int ydelta = current.Y - previous.Y;
foreach (MouseEventHandler h in mouseEventHandlers)
{
MouseEventArgs args = new MouseEventArgs();
args.SetX(lastX);
args.SetY(lastY);
args.SetMovementX(xdelta);
args.SetMovementY(ydelta);
args.SetEmulated(true);
h.OnMouseMove(args);
}
}
previous = current;
if (mousePointerLocked)
{
/*
* Windows: OK
* Cursor hides properly
* Cursor is trapped inside window
* Centering works
*
* Linux: Needs workaround
* Cursor hides properly
* Cursor is trapped inside window
* Centering broken
*
* Mac OS X: OK
* Cursor hides properly (although visible when doing Skype screencast)
* Centering works
* Opening "mission control" by gesture does not free cursor
*/
int centerx = window.Bounds.Left + (window.Bounds.Width / 2);
int centery = window.Bounds.Top + (window.Bounds.Height / 2);
// Setting cursor position this way works on Windows and Mac
Mouse.SetPosition(centerx, centery);
}
}
示例3: window_RenderFrame
void window_RenderFrame(object sender, OpenTK.FrameEventArgs e)
{
UpdateMousePositionArgs a = new UpdateMousePositionArgs();
UpdateMousePosition(a);
if (!TouchTest)
{
foreach (MouseEventHandler h in mouseEventHandlers)
{
MouseEventArgs args2 = new MouseEventArgs();
args2.SetX(a.mouseCurrentX);
args2.SetY(a.mouseCurrentY);
args2.SetMovementX((int)a.mouseDeltaX);
args2.SetMovementY((int)a.mouseDeltaY);
h.OnMouseMove(args2);
}
}
foreach (NewFrameHandler h in newFrameHandlers)
{
NewFrameEventArgs args = new NewFrameEventArgs();
args.SetDt((float)e.Time);
h.OnNewFrame(args);
}
window.SwapBuffers();
}