private void MouseWheel(object sender, MouseEventArgs e) { int amount = e.Delta * SystemInformation.MouseWheelScrollLines / 120; int numberOfPixelsToMove = amount; if (numberOfPixelsToMove == 0) { return; } if (m_dragHandler == null) { return; } DragData dragData = new DragData(); dragData.YPercent = (float)(numberOfPixelsToMove) / (float)m_drawSurface.Height; dragData.Button = MouseButtons.Right; m_dragHandler(dragData); }
void PerformDrag(int x, int y, MouseButtons btn) { if (m_dragHandler == null) { return; } DragData dragData = new DragData(); dragData.X = x; dragData.Y = y; dragData.XDiff = x - m_lastX; dragData.YDiff = y - m_lastY; // This is the increment we moved, scaled to the window size. dragData.XPercent = (float)(dragData.XDiff) / (float)m_drawSurface.Width; dragData.YPercent = (float)(dragData.YDiff) / (float)m_drawSurface.Height; // How much we rotated relative to center. double x1 = m_lastX - m_drawSurface.Width / 2, y1 = m_drawSurface.Height / 2 - m_lastY; double x2 = x - m_drawSurface.Width / 2, y2 = m_drawSurface.Height / 2 - y; double angle1 = Math.Atan2(y1, x1); double angle2 = Math.Atan2(y2, x2); dragData.Rotation = (float)angle2 - (float)angle1; // Our radial change. double r1 = Math.Sqrt(x1 * x1 + y1 * y1); double r2 = Math.Sqrt(x2 * x2 + y2 * y2); dragData.Radial = (float)r2 - (float)r1; dragData.RadialPercent = (float)r2 / (float)r1; dragData.Button = btn; dragData.ShiftDown = this.ShiftDown; dragData.CtrlDown = this.CtrlDown; m_dragHandler(dragData); }