private void _MouseMove(object sender, InputDevice.MouseControlEventArgs e) { if (Focused) { Cursor.Position = new Point(Location.X + Width / 2, Location.Y + Height / 2); } if (Mouses.ContainsKey(e.DeviceData.Info.deviceHandle)) { // convert to absolute mouse cooridnates MouseData Current = Mouses[e.DeviceData.Info.deviceHandle]; Current.PosX += e.DeltaX; Current.PosY += e.DeltaY; if (Current.PosX < 0) { Current.PosX = 0; } if (Current.PosY < 0) { Current.PosY = 0; } if (Current.PosX >= Canvas.Width) { Current.PosX = Canvas.Width - 1; } if (Current.PosY >= Canvas.Height) { Current.PosY = Canvas.Height - 1; } } }
private void _MouseDown(object sender, InputDevice.MouseControlEventArgs e) { if (e.LeftButton) { MouseEventButtonDownLeft(this, Mouses[e.DeviceData.Info.deviceHandle]); } else if (e.RightButton) { MouseEventButtonDownRight(this, Mouses[e.DeviceData.Info.deviceHandle]); } }
private void _MouseWheel(object sender, InputDevice.MouseControlEventArgs e) { if (Mouses.ContainsKey(e.DeviceData.Info.deviceHandle)) { if (e.Wheel > 0) { MouseEventWheelUp(this, Mouses[e.DeviceData.Info.deviceHandle]); } else if (e.Wheel < 0) { MouseEventWheelDown(this, Mouses[e.DeviceData.Info.deviceHandle]); } } }
private void _MouseUp(object sender, InputDevice.MouseControlEventArgs e) { if (!Mouses.ContainsKey(e.DeviceData.Info.deviceHandle)) { MouseData NewMouse = new MouseData(); NewMouse.PosX = Canvas.Width / 2; NewMouse.PosY = Canvas.Height / 2; NewMouse.Data = e.DeviceData; Mouses.Add(e.DeviceData.Info.deviceHandle, NewMouse); } if (Mouses.ContainsKey(e.DeviceData.Info.deviceHandle) && e.LeftButton) { MouseEventButtonUpLeft(this, Mouses[e.DeviceData.Info.deviceHandle]); } else if (e.RightButton) { MouseEventButtonUpRight(this, Mouses[e.DeviceData.Info.deviceHandle]); } }