PaintHeaderEventArgs.cs 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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 PaintHeader events of a Table
  39. /// </summary>
  40. public delegate void PaintHeaderEventHandler(object sender, PaintHeaderEventArgs e);
  41. #endregion
  42. #region PaintHeaderEventArgs
  43. /// <summary>
  44. /// Provides data for the PaintHeader event
  45. /// </summary>
  46. public class PaintHeaderEventArgs : PaintEventArgs
  47. {
  48. #region Class Data
  49. /// <summary>
  50. /// The Column to be painted
  51. /// </summary>
  52. private Column column;
  53. /// <summary>
  54. /// The Table the Column's ColumnModel belongs to
  55. /// </summary>
  56. private Table table;
  57. /// <summary>
  58. /// The index of the Column in the Table's ColumnModel
  59. /// </summary>
  60. private int columnIndex;
  61. /// <summary>
  62. /// The style of the Column header
  63. /// </summary>
  64. private ColumnHeaderStyle headerStyle;
  65. /// <summary>
  66. /// The rectangle in which to paint
  67. /// </summary>
  68. private Rectangle headerRect;
  69. /// <summary>
  70. /// Indicates whether the user has done the paining for us
  71. /// </summary>
  72. private bool handled;
  73. #endregion
  74. #region Constructor
  75. /// <summary>
  76. /// Initializes a new instance of the PaintHeaderEventArgs class with
  77. /// the specified graphics and clipping rectangle
  78. /// </summary>
  79. /// <param name="g">The Graphics used to paint the Column header</param>
  80. /// <param name="headerRect">The Rectangle that represents the rectangle
  81. /// in which to paint</param>
  82. public PaintHeaderEventArgs(Graphics g, Rectangle headerRect) : this(g, null, null, -1, ColumnHeaderStyle.None, headerRect)
  83. {
  84. }
  85. /// <summary>
  86. /// Initializes a new instance of the PaintHeaderEventArgs class with
  87. /// the specified graphics, column, table, column index, header style
  88. /// and clipping rectangle
  89. /// </summary>
  90. /// <param name="g">The Graphics used to paint the Column header</param>
  91. /// <param name="column">The Column to be painted</param>
  92. /// <param name="table">The Table the Column's ColumnModel belongs to</param>
  93. /// <param name="columnIndex">The index of the Column in the Table's ColumnModel</param>
  94. /// <param name="headerStyle">The style of the Column's header</param>
  95. /// <param name="headerRect">The Rectangle that represents the rectangle
  96. /// in which to paint</param>
  97. public PaintHeaderEventArgs(Graphics g, Column column, Table table, int columnIndex, ColumnHeaderStyle headerStyle, Rectangle headerRect) : base(g, headerRect)
  98. {
  99. this.column = column;
  100. this.table = table;
  101. this.columnIndex = columnIndex;
  102. this.column = column;
  103. this.headerStyle = headerStyle;
  104. this.headerRect = headerRect;
  105. this.handled = false;
  106. }
  107. #endregion
  108. #region Properties
  109. /// <summary>
  110. /// Gets the Column to be painted
  111. /// </summary>
  112. public Column Column
  113. {
  114. get
  115. {
  116. return this.column;
  117. }
  118. }
  119. /// <summary>
  120. ///
  121. /// </summary>
  122. /// <param name="column"></param>
  123. internal void SetColumn(Column column)
  124. {
  125. this.column = column;
  126. }
  127. /// <summary>
  128. /// Gets the Table the Column's ColumnModel belongs to
  129. /// </summary>
  130. public Table Table
  131. {
  132. get
  133. {
  134. return this.table;
  135. }
  136. }
  137. /// <summary>
  138. ///
  139. /// </summary>
  140. /// <param name="table"></param>
  141. internal void SetTable(Table table)
  142. {
  143. this.table = table;
  144. }
  145. /// <summary>
  146. /// Gets the index of the Column in the Table's ColumnModel
  147. /// </summary>
  148. public int ColumnIndex
  149. {
  150. get
  151. {
  152. return this.columnIndex;
  153. }
  154. }
  155. /// <summary>
  156. ///
  157. /// </summary>
  158. /// <param name="columnIndex"></param>
  159. internal void SetColumnIndex(int columnIndex)
  160. {
  161. this.columnIndex = columnIndex;
  162. }
  163. /// <summary>
  164. /// Gets the style of the Column's header
  165. /// </summary>
  166. public ColumnHeaderStyle HeaderStyle
  167. {
  168. get
  169. {
  170. return this.headerStyle;
  171. }
  172. }
  173. /// <summary>
  174. ///
  175. /// </summary>
  176. /// <param name="headerStyle"></param>
  177. internal void SetHeaderStyle(ColumnHeaderStyle headerStyle)
  178. {
  179. this.headerStyle = headerStyle;
  180. }
  181. /// <summary>
  182. /// Gets the column header's bounding rectangle
  183. /// </summary>
  184. public Rectangle HeaderRect
  185. {
  186. get
  187. {
  188. return this.headerRect;
  189. }
  190. }
  191. /// <summary>
  192. ///
  193. /// </summary>
  194. /// <param name="headerRect"></param>
  195. internal void SetHeaderRect(Rectangle headerRect)
  196. {
  197. this.headerRect = headerRect;
  198. }
  199. /// <summary>
  200. /// Gets or sets a value indicating whether the BeforePaintHeader
  201. /// event was handled
  202. /// </summary>
  203. public bool Handled
  204. {
  205. get
  206. {
  207. return this.handled;
  208. }
  209. set
  210. {
  211. this.handled = value;
  212. }
  213. }
  214. #endregion
  215. }
  216. #endregion
  217. }