PaintCellEventArgs.cs 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  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 PaintCell events of a Table
  39. /// </summary>
  40. public delegate void PaintCellEventHandler(object sender, PaintCellEventArgs e);
  41. #endregion
  42. #region PaintCellEventArgs
  43. /// <summary>
  44. /// Provides data for the PaintCell event
  45. /// </summary>
  46. public class PaintCellEventArgs : PaintEventArgs
  47. {
  48. #region Class Data
  49. /// <summary>
  50. /// The Cell to be painted
  51. /// </summary>
  52. private Cell cell;
  53. /// <summary>
  54. /// The Table the Cell belongs to
  55. /// </summary>
  56. private Table table;
  57. /// <summary>
  58. /// The Row index of the Cell
  59. /// </summary>
  60. private int row;
  61. /// <summary>
  62. /// The Column index of the Cell
  63. /// </summary>
  64. private int column;
  65. /// <summary>
  66. /// Specifies whether the Cell is selected
  67. /// </summary>
  68. private bool selected;
  69. /// <summary>
  70. /// Specifies whether the Cell has focus
  71. /// </summary>
  72. private bool focused;
  73. /// <summary>
  74. /// Specifies whether the Cell's Column is sorted
  75. /// </summary>
  76. private bool sorted;
  77. /// <summary>
  78. /// Specifies whether the Cell is editable
  79. /// </summary>
  80. private bool editable;
  81. /// <summary>
  82. /// Specifies whether the Cell is enabled
  83. /// </summary>
  84. private bool enabled;
  85. /// <summary>
  86. /// The rectangle in which to paint the Cell
  87. /// </summary>
  88. private Rectangle cellRect;
  89. /// <summary>
  90. /// Indicates whether the user has done the paining for us
  91. /// </summary>
  92. private bool handled;
  93. #endregion
  94. #region Constructor
  95. /// <summary>
  96. /// Initializes a new instance of the PaintCellEventArgs class with
  97. /// the specified graphics and clipping rectangle
  98. /// </summary>
  99. /// <param name="g">The Graphics used to paint the Cell</param>
  100. /// <param name="cellRect">The Rectangle that represents the rectangle
  101. /// in which to paint</param>
  102. public PaintCellEventArgs(Graphics g, Rectangle cellRect) : this(g, null, null, -1, -1, false, false, false, false, true, cellRect)
  103. {
  104. }
  105. /// <summary>
  106. /// Initializes a new instance of the PaintCellEventArgs class with
  107. /// the specified graphics, table, row index, column index, selected value,
  108. /// focused value, mouse value and clipping rectangle
  109. /// </summary>
  110. /// <param name="g">The Graphics used to paint the Cell</param>
  111. /// <param name="cell">The Cell to be painted</param>
  112. /// <param name="table">The Table the Cell belongs to</param>
  113. /// <param name="row">The Row index of the Cell</param>
  114. /// <param name="column">The Column index of the Cell</param>
  115. /// <param name="selected">Specifies whether the Cell is selected</param>
  116. /// <param name="focused">Specifies whether the Cell has focus</param>
  117. /// <param name="sorted">Specifies whether the Cell's Column is sorted</param>
  118. /// <param name="editable">Specifies whether the Cell is able to be edited</param>
  119. /// <param name="enabled">Specifies whether the Cell is enabled</param>
  120. /// <param name="cellRect">The rectangle in which to paint the Cell</param>
  121. public PaintCellEventArgs(Graphics g, Cell cell, Table table, int row, int column, bool selected, bool focused, bool sorted, bool editable, bool enabled, Rectangle cellRect) : base(g, cellRect)
  122. {
  123. this.cell = cell;
  124. this.table = table;
  125. this.row = row;
  126. this.column = column;
  127. this.selected = selected;
  128. this.focused = focused;
  129. this.sorted = sorted;
  130. this.editable = editable;
  131. this.enabled = enabled;
  132. this.cellRect = cellRect;
  133. this.handled = false;
  134. }
  135. #endregion
  136. #region Properties
  137. /// <summary>
  138. /// Gets the Cell to be painted
  139. /// </summary>
  140. public Cell Cell
  141. {
  142. get
  143. {
  144. return this.cell;
  145. }
  146. }
  147. /// <summary>
  148. ///
  149. /// </summary>
  150. /// <param name="cell"></param>
  151. internal void SetCell(Cell cell)
  152. {
  153. this.cell = cell;
  154. }
  155. /// <summary>
  156. /// Gets the Table the Cell belongs to
  157. /// </summary>
  158. public Table Table
  159. {
  160. get
  161. {
  162. return this.table;
  163. }
  164. }
  165. /// <summary>
  166. ///
  167. /// </summary>
  168. /// <param name="table"></param>
  169. internal void SetTable(Table table)
  170. {
  171. this.table = table;
  172. }
  173. /// <summary>
  174. /// Gets the Row index of the Cell
  175. /// </summary>
  176. public int Row
  177. {
  178. get
  179. {
  180. return this.row;
  181. }
  182. }
  183. /// <summary>
  184. ///
  185. /// </summary>
  186. /// <param name="row"></param>
  187. internal void SetRow(int row)
  188. {
  189. this.row = row;
  190. }
  191. /// <summary>
  192. /// Gets the Column index of the Cell
  193. /// </summary>
  194. public int Column
  195. {
  196. get
  197. {
  198. return this.column;
  199. }
  200. }
  201. /// <summary>
  202. ///
  203. /// </summary>
  204. /// <param name="column"></param>
  205. internal void SetColumn(int column)
  206. {
  207. this.column = column;
  208. }
  209. /// <summary>
  210. /// Gets whether the Cell is selected
  211. /// </summary>
  212. public bool Selected
  213. {
  214. get
  215. {
  216. return this.selected;
  217. }
  218. }
  219. /// <summary>
  220. ///
  221. /// </summary>
  222. /// <param name="selected"></param>
  223. internal void SetSelected(bool selected)
  224. {
  225. this.selected = selected;
  226. }
  227. /// <summary>
  228. /// Gets whether the Cell has focus
  229. /// </summary>
  230. public bool Focused
  231. {
  232. get
  233. {
  234. return this.focused;
  235. }
  236. }
  237. /// <summary>
  238. ///
  239. /// </summary>
  240. /// <param name="focused"></param>
  241. internal void SetFocused(bool focused)
  242. {
  243. this.focused = focused;
  244. }
  245. /// <summary>
  246. /// Gets whether the Cell's Column is sorted
  247. /// </summary>
  248. public bool Sorted
  249. {
  250. get
  251. {
  252. return this.sorted;
  253. }
  254. }
  255. /// <summary>
  256. ///
  257. /// </summary>
  258. /// <param name="sorted"></param>
  259. internal void SetSorted(bool sorted)
  260. {
  261. this.sorted = sorted;
  262. }
  263. /// <summary>
  264. /// Gets whether the Cell is able to be edited
  265. /// </summary>
  266. public bool Editable
  267. {
  268. get
  269. {
  270. return this.editable;
  271. }
  272. }
  273. /// <summary>
  274. ///
  275. /// </summary>
  276. /// <param name="editable"></param>
  277. internal void SetEditable(bool editable)
  278. {
  279. this.editable = editable;
  280. }
  281. /// <summary>
  282. /// Gets whether the Cell is enabled
  283. /// </summary>
  284. public bool Enabled
  285. {
  286. get
  287. {
  288. return this.enabled;
  289. }
  290. }
  291. /// <summary>
  292. ///
  293. /// </summary>
  294. /// <param name="enabled"></param>
  295. internal void SetEnabled(bool enabled)
  296. {
  297. this.enabled = enabled;
  298. }
  299. /// <summary>
  300. /// Gets the Cells bounding rectangle
  301. /// </summary>
  302. public Rectangle CellRect
  303. {
  304. get
  305. {
  306. return this.cellRect;
  307. }
  308. }
  309. /// <summary>
  310. ///
  311. /// </summary>
  312. /// <param name="cellRect"></param>
  313. internal void SetCellRect(Rectangle cellRect)
  314. {
  315. this.cellRect = cellRect;
  316. }
  317. /// <summary>
  318. /// Gets the position of the Cell
  319. /// </summary>
  320. public CellPos CellPos
  321. {
  322. get
  323. {
  324. return new CellPos(this.Row, this.Column);
  325. }
  326. }
  327. /// <summary>
  328. /// Gets or sets a value indicating whether the BeforePaintCell
  329. /// event was handled
  330. /// </summary>
  331. public bool Handled
  332. {
  333. get
  334. {
  335. return this.handled;
  336. }
  337. set
  338. {
  339. this.handled = value;
  340. }
  341. }
  342. #endregion
  343. }
  344. #endregion
  345. }