FRMouseEvents.cs 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. using System.Windows.Forms;
  2. using System.Drawing;
  3. namespace FastReport.Utils
  4. {
  5. /// <summary>
  6. /// Specifies the main mode of the designer's workspace.
  7. /// </summary>
  8. public enum WorkspaceMode1
  9. {
  10. /// <summary>
  11. /// Specifies selection mode.
  12. /// </summary>
  13. Select,
  14. /// <summary>
  15. /// Specifies insertion mode.
  16. /// </summary>
  17. Insert,
  18. /// <summary>
  19. /// Specifies drag-drop mode.
  20. /// </summary>
  21. DragDrop
  22. }
  23. /// <summary>
  24. /// Specifies the additional mode of the designer's workspace.
  25. /// </summary>
  26. public enum WorkspaceMode2
  27. {
  28. /// <summary>
  29. /// Specifies default mode.
  30. /// </summary>
  31. None,
  32. /// <summary>
  33. /// Indicates that user moves the selected objects.
  34. /// </summary>
  35. Move,
  36. /// <summary>
  37. /// Indicates that user resizes the selected objects.
  38. /// </summary>
  39. Size,
  40. /// <summary>
  41. /// Indicates that user draw the selection rectangle.
  42. /// </summary>
  43. SelectionRect,
  44. /// <summary>
  45. /// Specifies a custom mode handled by the object.
  46. /// </summary>
  47. Custom
  48. }
  49. /// <summary>
  50. /// Provides a data for mouse events.
  51. /// </summary>
  52. public class FRMouseEventArgs
  53. {
  54. /// <summary>
  55. /// The X mouse coordinate.
  56. /// </summary>
  57. public float x;
  58. /// <summary>
  59. /// The Y mouse coordinate.
  60. /// </summary>
  61. public float y;
  62. /// <summary>
  63. /// Current state of mouse buttons.
  64. /// </summary>
  65. public MouseButtons button;
  66. /// <summary>
  67. /// Current keyboard state.
  68. /// </summary>
  69. public Keys modifierKeys;
  70. /// <summary>
  71. /// Indicates that current object was handled the mouse message.
  72. /// </summary>
  73. public bool handled;
  74. /// <summary>
  75. /// The delta of the mouse movement.
  76. /// </summary>
  77. public PointF delta;
  78. /// <summary>
  79. /// The mouse wheel delta.
  80. /// </summary>
  81. public int wheelDelta;
  82. /// <summary>
  83. /// Current cursor shape.
  84. /// </summary>
  85. public Cursor cursor;
  86. /// <summary>
  87. /// Additional mode of the designer's workspace.
  88. /// </summary>
  89. public WorkspaceMode2 mode;
  90. /// <summary>
  91. /// Current sizing point if <b>Mode</b> is set to <b>Size</b>.
  92. /// </summary>
  93. public SizingPoint sizingPoint;
  94. /// <summary>
  95. /// Current selection rectangle if mode is set to <b>SelectionRect</b>.
  96. /// </summary>
  97. public RectangleF selectionRect;
  98. /// <summary>
  99. /// Active object that handles the mouse event.
  100. /// </summary>
  101. public ComponentBase activeObject;
  102. /// <summary>
  103. /// The source object of drag-drop operation.
  104. /// </summary>
  105. public ComponentBase DragSource
  106. {
  107. get
  108. {
  109. if (dragSources != null && dragSources.Length > 0)
  110. return dragSources[dragSources.Length - 1];
  111. return null;
  112. }
  113. set
  114. {
  115. if (value != null)
  116. dragSources = new ComponentBase[] { value };
  117. else
  118. dragSources = null;
  119. }
  120. }
  121. /// <summary>
  122. /// Multiple sources objects of drag-drop operation.
  123. /// </summary>
  124. public ComponentBase[] dragSources;
  125. /// <summary>
  126. /// The target object of drag-drop operation.
  127. /// </summary>
  128. public ComponentBase dragTarget;
  129. /// <summary>
  130. /// The message to show when drag source is over the object.
  131. /// </summary>
  132. public string dragMessage;
  133. /// <summary>
  134. /// Additional data supplied and handled by report objects.
  135. /// </summary>
  136. public object data;
  137. }
  138. /// <summary>
  139. /// Specifies the sizing point used to resize an object by mouse.
  140. /// </summary>
  141. public enum SizingPoint
  142. {
  143. /// <summary>
  144. /// No sizing point.
  145. /// </summary>
  146. None,
  147. /// <summary>
  148. /// Specifies left-top sizing point.
  149. /// </summary>
  150. LeftTop,
  151. /// <summary>
  152. /// Specifies left-bottom sizing point.
  153. /// </summary>
  154. LeftBottom,
  155. /// <summary>
  156. /// Specifies right-top sizing point.
  157. /// </summary>
  158. RightTop,
  159. /// <summary>
  160. /// Specifies right-bottom sizing point.
  161. /// </summary>
  162. RightBottom,
  163. /// <summary>
  164. /// Specifies top-center sizing point.
  165. /// </summary>
  166. TopCenter,
  167. /// <summary>
  168. /// Specifies bottom-center sizing point.
  169. /// </summary>
  170. BottomCenter,
  171. /// <summary>
  172. /// Specifies left-center sizing point.
  173. /// </summary>
  174. LeftCenter,
  175. /// <summary>
  176. /// Specifies right-center sizing point.
  177. /// </summary>
  178. RightCenter
  179. }
  180. internal static class SizingPointHelper
  181. {
  182. // sizing points and its numbers:
  183. // LeftTop (1) TopCenter (5) RightTop (3)
  184. //
  185. // LeftCenter (7) RightCenter (8)
  186. //
  187. // LeftBottom (2) BottomCenter (6) RightBottom (4)
  188. public static SizingPoint SwapDiagonally(SizingPoint p)
  189. {
  190. int[] swap = new int[] { 0, 4, 3, 2, 1, 5, 6, 7, 8 };
  191. return (SizingPoint)swap[(int)p];
  192. }
  193. public static SizingPoint SwapHorizontally(SizingPoint p)
  194. {
  195. int[] swap = new int[] { 0, 3, 4, 1, 2, 5, 6, 8, 7 };
  196. return (SizingPoint)swap[(int)p];
  197. }
  198. public static SizingPoint SwapVertically(SizingPoint p)
  199. {
  200. int[] swap = new int[] { 0, 2, 1, 4, 3, 6, 5, 7, 8 };
  201. return (SizingPoint)swap[(int)p];
  202. }
  203. public static Cursor ToCursor(SizingPoint p)
  204. {
  205. Cursor[] cursors = new Cursor[] { Cursors.Default, Cursors.SizeNWSE, Cursors.SizeNESW, Cursors.SizeNESW,
  206. Cursors.SizeNWSE, Cursors.SizeNS, Cursors.SizeNS, Cursors.SizeWE, Cursors.SizeWE };
  207. return cursors[(int)p];
  208. }
  209. }
  210. /// <summary>
  211. /// Specifies a selection point used to resize an object.
  212. /// </summary>
  213. public class SelectionPoint
  214. {
  215. /// <summary>
  216. /// The X coordinate of the point.
  217. /// </summary>
  218. public float x;
  219. /// <summary>
  220. /// The Y coordinate of the point.
  221. /// </summary>
  222. public float y;
  223. /// <summary>
  224. /// The size mode.
  225. /// </summary>
  226. public SizingPoint sizingPoint;
  227. /// <summary>
  228. /// Initializes a new instance of the <b>SelectionPoint</b> class with specified location and size mode.
  229. /// </summary>
  230. /// <param name="x">The X coordinate.</param>
  231. /// <param name="y">The Y coordinate.</param>
  232. /// <param name="pt">Size mode.</param>
  233. public SelectionPoint(float x, float y, SizingPoint pt)
  234. {
  235. this.x = x;
  236. this.y = y;
  237. sizingPoint = pt;
  238. }
  239. }
  240. }