Rev 1404 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1399 | 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 abstract class InteractionMode |
||
| 11 | { |
||
| 1404 | chris | 12 | public const int NO_MODE = -1; |
| 1399 | chris | 13 | public const int SELECT = 0; |
| 14 | public const int RECTANGLE = 1; |
||
| 15 | public const int ELLIPSE = 2; |
||
| 16 | public const int POLYGON = 3; |
||
| 17 | |||
| 18 | protected MainForm mParent = null; |
||
| 19 | |||
| 1404 | chris | 20 | private int mMode = NO_MODE; |
| 21 | |||
| 22 | public int Mode { get { return mMode; } } |
||
| 23 | |||
| 1399 | chris | 24 | public InteractionMode(MainForm parent) |
| 1404 | chris | 25 | : this(parent, NO_MODE) |
| 1399 | chris | 26 | { |
| 1404 | chris | 27 | } |
| 28 | |||
| 29 | public InteractionMode(MainForm parent, int mode) |
||
| 30 | { |
||
| 1399 | chris | 31 | mParent = parent; |
| 1404 | chris | 32 | mMode = mode; |
| 1399 | chris | 33 | } |
| 34 | |||
| 1402 | chris | 35 | // public abstract void MouseDown(MouseEventArgs e); |
| 1420 | chris | 36 | public abstract void MouseMove(MouseEventArgs e, bool isMouseDown = false); |
| 1399 | chris | 37 | public abstract void MouseUp(MouseEventArgs e); |
| 38 | |||
| 1400 | chris | 39 | public abstract void Render(); |
| 40 | |||
| 1399 | chris | 41 | public static InteractionMode CreateMode(MainForm parent, int mode) |
| 42 | { |
||
| 43 | switch(mode) |
||
| 44 | { |
||
| 45 | case SELECT: |
||
| 46 | return new SelectMode(parent); |
||
| 47 | case RECTANGLE: |
||
| 48 | return new RectangleMode(parent); |
||
| 49 | case ELLIPSE: |
||
| 50 | return new EllipseMode(parent); |
||
| 51 | case POLYGON: |
||
| 52 | return new PolygonMode(parent); |
||
| 53 | } |
||
| 54 | |||
| 55 | return null; |
||
| 56 | } |
||
| 57 | } |
||
| 58 | } |