Go to most recent revision | Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1402 | chris | 1 | using System; |
| 2 | using System.Collections.Generic; |
||
| 3 | using System.Linq; |
||
| 4 | using System.Text; |
||
| 5 | using System.Threading.Tasks; |
||
| 6 | using System.Windows.Forms; |
||
| 7 | |||
| 8 | namespace ShapeEditor.interaction |
||
| 9 | { |
||
| 10 | public class PanInteraction : InteractionMode |
||
| 11 | { |
||
| 12 | private int mLastX = 0; |
||
| 13 | private int mLastY = 0; |
||
| 14 | private bool mRightButtonDown = false; |
||
| 15 | |||
| 16 | public PanInteraction(MainForm parent) |
||
| 17 | : base(parent) |
||
| 18 | { |
||
| 19 | } |
||
| 20 | |||
| 21 | public override void MouseMove(MouseEventArgs e) |
||
| 22 | { |
||
| 23 | if (e.Button == MouseButtons.Right) |
||
| 24 | { |
||
| 25 | if (!mRightButtonDown) |
||
| 26 | { |
||
| 27 | // not pressed before - set |
||
| 28 | mRightButtonDown = true; |
||
| 29 | } |
||
| 30 | else |
||
| 31 | { |
||
| 32 | // dragging |
||
| 33 | int deltaX = e.X - mLastX; |
||
| 34 | int deltaY = e.Y - mLastY; |
||
| 35 | |||
| 36 | mParent.PanBy(deltaX, deltaY); |
||
| 37 | } |
||
| 38 | } |
||
| 39 | |||
| 40 | mLastX = e.X; |
||
| 41 | mLastY = e.Y; |
||
| 42 | } |
||
| 43 | |||
| 44 | public override void MouseUp(MouseEventArgs e) |
||
| 45 | { |
||
| 46 | if (e.Button == MouseButtons.Right) |
||
| 47 | { |
||
| 48 | mRightButtonDown = false; |
||
| 49 | } |
||
| 50 | } |
||
| 51 | |||
| 52 | public override void Render() |
||
| 53 | { |
||
| 54 | } |
||
| 55 | } |
||
| 56 | } |