RowEventArgs.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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 XPTable.Models;
  32. namespace XPTable.Events
  33. {
  34. #region Delegates
  35. /// <summary>
  36. /// Represents the methods that will handle the PropertyChanged, CellAdded and
  37. /// CellRemoved events of a Row
  38. /// </summary>
  39. public delegate void RowEventHandler(object sender, RowEventArgs e);
  40. #endregion
  41. #region RowEventArgs
  42. /// <summary>
  43. /// Provides data for a Row's PropertyChanged, CellAdded
  44. /// and CellRemoved events
  45. /// </summary>
  46. public class RowEventArgs : EventArgs
  47. {
  48. #region Class Data
  49. /// <summary>
  50. /// The Row that Raised the event
  51. /// </summary>
  52. private Row source;
  53. /// <summary>
  54. /// The index of the Row
  55. /// </summary>
  56. private int rowIndex;
  57. /// <summary>
  58. /// The affected Cell
  59. /// </summary>
  60. private Cell cell;
  61. /// <summary>
  62. /// The start index of the affected Cell(s)
  63. /// </summary>
  64. private int cellToIndex;
  65. /// <summary>
  66. /// The end index of the affected Cell(s)
  67. /// </summary>
  68. private int cellFromIndex;
  69. /// <summary>
  70. /// The type of event
  71. /// </summary>
  72. private RowEventType eventType;
  73. #endregion
  74. #region Constructor
  75. /// <summary>
  76. /// Initializes a new instance of the RowEventArgs class with
  77. /// the specified Row source, row index, start index, end index
  78. /// and affected Cell
  79. /// </summary>
  80. /// <param name="source">The Row that originated the event</param>
  81. /// <param name="eventType">The type of event</param>
  82. public RowEventArgs(Row source, RowEventType eventType) : this(source, -1, null, -1, -1, eventType)
  83. {
  84. }
  85. /// <summary>
  86. /// Initializes a new instance of the RowEventArgs class with
  87. /// the specified Row source, row index, start index, end index
  88. /// and affected Cell
  89. /// </summary>
  90. /// <param name="source">The Row that originated the event</param>
  91. /// <param name="cell">The affected Cell</param>
  92. /// <param name="cellFromIndex">The start index of the affected Cell(s)</param>
  93. /// <param name="cellToIndex">The end index of the affected Cell(s)</param>
  94. public RowEventArgs(Row source, Cell cell, int cellFromIndex, int cellToIndex) : this(source, -1, cell, cellFromIndex, cellToIndex, RowEventType.Unknown)
  95. {
  96. }
  97. /// <summary>
  98. /// Initializes a new instance of the RowEventArgs class with
  99. /// the specified Row source, row index, start index, end index
  100. /// and affected Cell
  101. /// </summary>
  102. /// <param name="source">The Row that originated the event</param>
  103. /// <param name="rowIndex">The index of the Row</param>
  104. /// <param name="cell">The affected Cell</param>
  105. /// <param name="cellFromIndex">The start index of the affected Cell(s)</param>
  106. /// <param name="cellToIndex">The end index of the affected Cell(s)</param>
  107. /// <param name="eventType">The type of event</param>
  108. public RowEventArgs(Row source, int rowIndex, Cell cell, int cellFromIndex, int cellToIndex, RowEventType eventType) : base()
  109. {
  110. this.source = source;
  111. this.rowIndex = rowIndex;
  112. this.cell = cell;
  113. this.cellFromIndex = cellFromIndex;
  114. this.cellToIndex = cellToIndex;
  115. this.eventType = eventType;
  116. }
  117. #endregion
  118. #region Properties
  119. /// <summary>
  120. /// Gets the Row that Raised the event
  121. /// </summary>
  122. public Row Row
  123. {
  124. get
  125. {
  126. return this.source;
  127. }
  128. }
  129. /// <summary>
  130. /// Gets the index of the Row
  131. /// </summary>
  132. public int Index
  133. {
  134. get
  135. {
  136. return this.rowIndex;
  137. }
  138. }
  139. /// <summary>
  140. ///
  141. /// </summary>
  142. /// <param name="rowIndex"></param>
  143. internal void SetRowIndex(int rowIndex)
  144. {
  145. this.rowIndex = rowIndex;
  146. }
  147. /// <summary>
  148. /// Gets the affected Cell
  149. /// </summary>
  150. public Cell Cell
  151. {
  152. get
  153. {
  154. return this.cell;
  155. }
  156. }
  157. /// <summary>
  158. /// Gets the start index of the affected Cell(s)
  159. /// </summary>
  160. public int CellFromIndex
  161. {
  162. get
  163. {
  164. return this.cellFromIndex;
  165. }
  166. }
  167. /// <summary>
  168. /// Gets the end index of the affected Cell(s)
  169. /// </summary>
  170. public int CellToIndex
  171. {
  172. get
  173. {
  174. return this.cellToIndex;
  175. }
  176. }
  177. /// <summary>
  178. /// Gets the type of event
  179. /// </summary>
  180. public RowEventType EventType
  181. {
  182. get
  183. {
  184. return this.eventType;
  185. }
  186. }
  187. #endregion
  188. }
  189. #endregion
  190. }