CellKeyEventArgs.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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 CellKeyDown and CellKeyUp
  39. /// events of a Table
  40. /// </summary>
  41. public delegate void CellKeyEventHandler(object sender, CellKeyEventArgs e);
  42. #endregion
  43. #region CellKeyEventArgs
  44. /// <summary>
  45. /// Provides data for the CellKeyDown and CellKeyUp events of a Table
  46. /// </summary>
  47. public class CellKeyEventArgs : KeyEventArgs
  48. {
  49. #region Class Data
  50. /// <summary>
  51. /// The Cell that Raised the event
  52. /// </summary>
  53. private Cell cell;
  54. /// <summary>
  55. /// The Table the Cell belongs to
  56. /// </summary>
  57. private Table table;
  58. /// <summary>
  59. /// The Row index of the Cell
  60. /// </summary>
  61. private int row;
  62. /// <summary>
  63. /// The Column index of the Cell
  64. /// </summary>
  65. private int column;
  66. /// <summary>
  67. /// The Cells bounding rectangle
  68. /// </summary>
  69. private Rectangle cellRect;
  70. #endregion
  71. #region Constructor
  72. /// <summary>
  73. /// Initializes a new instance of the CellKeyEventArgs class with
  74. /// the specified source Cell, table, row index, column index, cell
  75. /// bounds and KeyEventArgs
  76. /// </summary>
  77. /// <param name="cell">The Cell that Raised the event</param>
  78. /// <param name="table">The Table the Cell belongs to</param>
  79. /// <param name="row">The Row index of the Cell</param>
  80. /// <param name="column">The Column index of the Cell</param>
  81. /// <param name="cellRect">The Cell's bounding rectangle</param>
  82. /// <param name="kea"></param>
  83. public CellKeyEventArgs(Cell cell, Table table, int row, int column, Rectangle cellRect, KeyEventArgs kea) : base(kea.KeyData)
  84. {
  85. this.cell = cell;
  86. this.table = table;
  87. this.row = row;
  88. this.column = column;
  89. this.cellRect = cellRect;
  90. }
  91. /// <summary>
  92. /// Initializes a new instance of the CellKeyEventArgs class with
  93. /// the specified source Cell, table, row index, column index and
  94. /// cell bounds
  95. /// </summary>
  96. /// <param name="cell">The Cell that Raised the event</param>
  97. /// <param name="table">The Table the Cell belongs to</param>
  98. /// <param name="cellPos"></param>
  99. /// <param name="cellRect">The Cell's bounding rectangle</param>
  100. /// <param name="kea"></param>
  101. public CellKeyEventArgs(Cell cell, Table table, CellPos cellPos, Rectangle cellRect, KeyEventArgs kea) : base(kea.KeyData)
  102. {
  103. this.cell = cell;
  104. this.table = table;
  105. this.row = cellPos.Row;
  106. this.column = cellPos.Column;
  107. this.cellRect = cellRect;
  108. }
  109. #endregion
  110. #region Properties
  111. /// <summary>
  112. /// Gets the Cell that Raised the event
  113. /// </summary>
  114. public Cell Cell
  115. {
  116. get
  117. {
  118. return this.cell;
  119. }
  120. }
  121. /// <summary>
  122. /// Gets the Table the Cell belongs to
  123. /// </summary>
  124. public Table Table
  125. {
  126. get
  127. {
  128. return this.table;
  129. }
  130. }
  131. /// <summary>
  132. /// Gets the Row index of the Cell
  133. /// </summary>
  134. public int Row
  135. {
  136. get
  137. {
  138. return this.row;
  139. }
  140. }
  141. /// <summary>
  142. /// Gets the Column index of the Cell
  143. /// </summary>
  144. public int Column
  145. {
  146. get
  147. {
  148. return this.column;
  149. }
  150. }
  151. /// <summary>
  152. /// Gets the Cells bounding rectangle
  153. /// </summary>
  154. public Rectangle CellRect
  155. {
  156. get
  157. {
  158. return this.cellRect;
  159. }
  160. }
  161. /// <summary>
  162. /// Gets the position of the Cell
  163. /// </summary>
  164. public CellPos CellPos
  165. {
  166. get
  167. {
  168. return new CellPos(this.Row, this.Column);
  169. }
  170. }
  171. #endregion
  172. }
  173. #endregion
  174. }