ProgressBarColumn.cs 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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.ComponentModel;
  32. using System.Drawing;
  33. using XPTable.Editors;
  34. using XPTable.Events;
  35. using XPTable.Models.Design;
  36. using XPTable.Renderers;
  37. using XPTable.Sorting;
  38. namespace XPTable.Models
  39. {
  40. /// <summary>
  41. /// Represents a Column whose Cells are displayed as a ProgressBar
  42. /// </summary>
  43. [DesignTimeVisible(false),
  44. ToolboxItem(false)]
  45. public class ProgressBarColumn : Column
  46. {
  47. #region Class Data
  48. /// <summary>
  49. /// Specifies whether the ProgressBar's value as a string
  50. /// should be displayed
  51. /// </summary>
  52. private bool drawPercentageText;
  53. #endregion
  54. #region Constructor
  55. /// <summary>
  56. /// Creates a new ProgressBarColumn with default values
  57. /// </summary>
  58. public ProgressBarColumn() : base()
  59. {
  60. this.Init();
  61. }
  62. /// <summary>
  63. /// Creates a new ProgressBarColumn with the specified header text
  64. /// </summary>
  65. /// <param name="text">The text displayed in the column's header</param>
  66. public ProgressBarColumn(string text) : base(text)
  67. {
  68. this.Init();
  69. }
  70. /// <summary>
  71. /// Creates a new ProgressBarColumn with the specified header text and width
  72. /// </summary>
  73. /// <param name="text">The text displayed in the column's header</param>
  74. /// <param name="width">The column's width</param>
  75. public ProgressBarColumn(string text, int width) : base(text, width)
  76. {
  77. this.Init();
  78. }
  79. /// <summary>
  80. /// Creates a new ProgressBarColumn with the specified header text, width and visibility
  81. /// </summary>
  82. /// <param name="text">The text displayed in the column's header</param>
  83. /// <param name="width">The column's width</param>
  84. /// <param name="visible">Specifies whether the column is visible</param>
  85. public ProgressBarColumn(string text, int width, bool visible) : base(text, width, visible)
  86. {
  87. this.Init();
  88. }
  89. /// <summary>
  90. /// Creates a new ProgressBarColumn with the specified header text and image
  91. /// </summary>
  92. /// <param name="text">The text displayed in the column's header</param>
  93. /// <param name="image">The image displayed on the column's header</param>
  94. public ProgressBarColumn(string text, Image image) : base(text, image)
  95. {
  96. this.Init();
  97. }
  98. /// <summary>
  99. /// Creates a new ProgressBarColumn with the specified header text, image
  100. /// and width
  101. /// </summary>
  102. /// <param name="text">The text displayed in the column's header</param>
  103. /// <param name="image">The image displayed on the column's header</param>
  104. /// <param name="width">The column's width</param>
  105. public ProgressBarColumn(string text, Image image, int width) : base(text, image, width)
  106. {
  107. this.Init();
  108. }
  109. /// <summary>
  110. /// Creates a new ProgressBarColumn with the specified header text, image,
  111. /// width and visibility
  112. /// </summary>
  113. /// <param name="text">The text displayed in the column's header</param>
  114. /// <param name="image">The image displayed on the column's header</param>
  115. /// <param name="width">The column's width</param>
  116. /// <param name="visible">Specifies whether the column is visible</param>
  117. public ProgressBarColumn(string text, Image image, int width, bool visible) : base(text, image, width, visible)
  118. {
  119. this.Init();
  120. }
  121. /// <summary>
  122. /// Initializes the ProgressBarColumn with default values
  123. /// </summary>
  124. private void Init()
  125. {
  126. this.drawPercentageText = true;
  127. this.Editable = false;
  128. }
  129. #endregion
  130. #region Methods
  131. /// <summary>
  132. /// Gets a string that specifies the name of the Column's default CellRenderer
  133. /// </summary>
  134. /// <returns>A string that specifies the name of the Column's default
  135. /// CellRenderer</returns>
  136. public override string GetDefaultRendererName()
  137. {
  138. return "PROGRESSBAR";
  139. }
  140. /// <summary>
  141. /// Gets the Column's default CellRenderer
  142. /// </summary>
  143. /// <returns>The Column's default CellRenderer</returns>
  144. public override ICellRenderer CreateDefaultRenderer()
  145. {
  146. return new ProgressBarCellRenderer();
  147. }
  148. /// <summary>
  149. /// Gets a string that specifies the name of the Column's default CellEditor
  150. /// </summary>
  151. /// <returns>A string that specifies the name of the Column's default
  152. /// CellEditor</returns>
  153. public override string GetDefaultEditorName()
  154. {
  155. return null;
  156. }
  157. /// <summary>
  158. /// Gets the Column's default CellEditor
  159. /// </summary>
  160. /// <returns>The Column's default CellEditor</returns>
  161. public override ICellEditor CreateDefaultEditor()
  162. {
  163. return null;
  164. }
  165. #endregion
  166. #region Properties
  167. /// <summary>
  168. /// Gets or sets whether a Cell's percantage value should be drawn as a string
  169. /// </summary>
  170. [Category("Appearance"),
  171. DefaultValue(true),
  172. Description("Indicates whether a Cell's percantage value is drawn as a string")]
  173. public bool DrawPercentageText
  174. {
  175. get
  176. {
  177. return this.drawPercentageText;
  178. }
  179. set
  180. {
  181. if(this.drawPercentageText != value)
  182. {
  183. this.drawPercentageText = value;
  184. this.OnPropertyChanged(new ColumnEventArgs(this, ColumnEventType.RendererChanged, null));
  185. }
  186. }
  187. }
  188. /// <summary>
  189. /// Gets the Type of the Comparer used to compare the Column's Cells when
  190. /// the Column is sorting
  191. /// </summary>
  192. public override Type DefaultComparerType
  193. {
  194. get
  195. {
  196. return typeof(NumberComparer);
  197. }
  198. }
  199. /// <summary>
  200. /// Gets or sets a value indicating whether the Column's Cells contents
  201. /// are able to be edited
  202. /// </summary>
  203. [Category("Appearance"),
  204. DefaultValue(false),
  205. Description("Controls whether the column's cell contents are able to be changed by the user")]
  206. public new bool Editable
  207. {
  208. get
  209. {
  210. return base.Editable;
  211. }
  212. set
  213. {
  214. base.Editable = value;
  215. }
  216. }
  217. #endregion
  218. }
  219. }