CellMouseEventArgs.cs 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. //#########################################################################################
  2. //★★★★★★★ http://www.cnpopsoft.com [华普软件] ★★★★★★★
  3. //★★★★★★★ 华普软件 - VB & C#.NET 专业论文与源码荟萃! ★★★★★★★
  4. //#########################################################################################
  5. /*
  6. * Copyright ?2005, Mathew Hall
  7. * All rights reserved.
  8. *
  9. * Redistribution and use in source and binary forms, with or without modification,
  10. * are permitted provided that the following conditions are met:
  11. *
  12. * - Redistributions of source code must retain the above copyright notice,
  13. * this list of conditions and the following disclaimer.
  14. *
  15. * - Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  20. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  22. * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  23. * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  24. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  25. * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  26. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  27. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
  28. * OF SUCH DAMAGE.
  29. */
  30. using System;
  31. using System.Drawing;
  32. using System.Windows.Forms;
  33. using XPTable.Models;
  34. namespace XPTable.Events
  35. {
  36. #region Delegates
  37. /// <summary>
  38. /// Represents the method that will handle the CellMouseEnter, CellMouseLeave,
  39. /// CellMouseDown, CellMouseUp, CellMouseMove and CellMouseHover events of a Table
  40. /// </summary>
  41. public delegate void CellMouseEventHandler(object sender, CellMouseEventArgs e);
  42. #endregion
  43. #region CellMouseEventArgs
  44. /// <summary>
  45. /// Provides data for the CellMouseEnter, CellMouseLeave, CellMouseDown,
  46. /// CellMouseUp and CellMouseMove events of a Table
  47. /// </summary>
  48. public class CellMouseEventArgs : MouseEventArgs
  49. {
  50. #region Class Data
  51. /// <summary>
  52. /// The Cell that raised the event
  53. /// </summary>
  54. private Cell cell;
  55. /// <summary>
  56. /// The Table the Cell belongs to
  57. /// </summary>
  58. private Table table;
  59. /// <summary>
  60. /// The Row index of the Cell
  61. /// </summary>
  62. private int row;
  63. /// <summary>
  64. /// The Column index of the Cell
  65. /// </summary>
  66. private int column;
  67. /// <summary>
  68. /// The Cells bounding rectangle
  69. /// </summary>
  70. private Rectangle cellRect;
  71. #endregion
  72. #region Constructor
  73. /// <summary>
  74. /// Initializes a new instance of the CellMouseEventArgs class with
  75. /// the specified source Cell, table, row index, column index and
  76. /// cell bounds
  77. /// </summary>
  78. /// <param name="cell">The Cell that Raised the event</param>
  79. /// <param name="table">The Table the Cell belongs to</param>
  80. /// <param name="cellPos"></param>
  81. /// <param name="cellRect">The Cell's bounding rectangle</param>
  82. public CellMouseEventArgs(Cell cell, Table table, CellPos cellPos, Rectangle cellRect) : base(MouseButtons.None, 0, -1, -1, 0)
  83. {
  84. this.cell = cell;
  85. this.table = table;
  86. this.row = cellPos.Row;
  87. this.column = cellPos.Column;
  88. this.cellRect = cellRect;
  89. }
  90. /// <summary>
  91. /// Initializes a new instance of the CellMouseEventArgs class with
  92. /// the specified source Cell, table, row index, column index and
  93. /// cell bounds
  94. /// </summary>
  95. /// <param name="cell">The Cell that Raised the event</param>
  96. /// <param name="table">The Table the Cell belongs to</param>
  97. /// <param name="row">The Row index of the Cell</param>
  98. /// <param name="column">The Column index of the Cell</param>
  99. /// <param name="cellRect">The Cell's bounding rectangle</param>
  100. public CellMouseEventArgs(Cell cell, Table table, int row, int column, Rectangle cellRect) : base(MouseButtons.None, 0, -1, -1, 0)
  101. {
  102. this.cell = cell;
  103. this.table = table;
  104. this.row = row;
  105. this.column = column;
  106. this.cellRect = cellRect;
  107. }
  108. /// <summary>
  109. /// Initializes a new instance of the CellMouseEventArgs class with
  110. /// the specified source Cell, table, row index, column index, cell
  111. /// bounds and MouseEventArgs
  112. /// </summary>
  113. /// <param name="cell">The Cell that Raised the event</param>
  114. /// <param name="table">The Table the Cell belongs to</param>
  115. /// <param name="row">The Row index of the Cell</param>
  116. /// <param name="column">The Column index of the Cell</param>
  117. /// <param name="cellRect">The Cell's bounding rectangle</param>
  118. /// <param name="mea">The MouseEventArgs that contains data about the
  119. /// mouse event</param>
  120. public CellMouseEventArgs(Cell cell, Table table, int row, int column, Rectangle cellRect, MouseEventArgs mea) : base(mea.Button, mea.Clicks, mea.X, mea.Y, mea.Delta)
  121. {
  122. this.cell = cell;
  123. this.table = table;
  124. this.row = row;
  125. this.column = column;
  126. this.cellRect = cellRect;
  127. }
  128. /// <summary>
  129. /// Initializes a new instance of the CellMouseEventArgs class with
  130. /// the specified source Cell, table, row index, column index and
  131. /// cell bounds
  132. /// </summary>
  133. /// <param name="cell">The Cell that Raised the event</param>
  134. /// <param name="table">The Table the Cell belongs to</param>
  135. /// <param name="cellPos"></param>
  136. /// <param name="cellRect">The Cell's bounding rectangle</param>
  137. /// <param name="mea"></param>
  138. public CellMouseEventArgs(Cell cell, Table table, CellPos cellPos, Rectangle cellRect, MouseEventArgs mea) : base(mea.Button, mea.Clicks, mea.X, mea.Y, mea.Delta)
  139. {
  140. this.cell = cell;
  141. this.table = table;
  142. this.row = cellPos.Row;
  143. this.column = cellPos.Column;
  144. this.cellRect = cellRect;
  145. }
  146. #endregion
  147. #region Properties
  148. /// <summary>
  149. /// Gets the Cell that Raised the event
  150. /// </summary>
  151. public Cell Cell
  152. {
  153. get
  154. {
  155. return this.cell;
  156. }
  157. }
  158. /// <summary>
  159. /// Gets the Table the Cell belongs to
  160. /// </summary>
  161. public Table Table
  162. {
  163. get
  164. {
  165. return this.table;
  166. }
  167. }
  168. /// <summary>
  169. /// Gets the Row index of the Cell
  170. /// </summary>
  171. public int Row
  172. {
  173. get
  174. {
  175. return this.row;
  176. }
  177. }
  178. /// <summary>
  179. /// Gets the Column index of the Cell
  180. /// </summary>
  181. public int Column
  182. {
  183. get
  184. {
  185. return this.column;
  186. }
  187. }
  188. /// <summary>
  189. /// Gets the Cells bounding rectangle
  190. /// </summary>
  191. public Rectangle CellRect
  192. {
  193. get
  194. {
  195. return this.cellRect;
  196. }
  197. }
  198. /// <summary>
  199. /// Gets the position of the Cell
  200. /// </summary>
  201. public CellPos CellPos
  202. {
  203. get
  204. {
  205. return new CellPos(this.Row, this.Column);
  206. }
  207. }
  208. #endregion
  209. }
  210. #endregion
  211. }