ToolStripProgressBar.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. //
  2. // ToolStripProgressBar.cs
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining
  5. // a copy of this software and associated documentation files (the
  6. // "Software"), to deal in the Software without restriction, including
  7. // without limitation the rights to use, copy, modify, merge, publish,
  8. // distribute, sublicense, and/or sell copies of the Software, and to
  9. // permit persons to whom the Software is furnished to do so, subject to
  10. // the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be
  13. // included in all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  16. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  18. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  19. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  20. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  21. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. //
  23. // Copyright (c) 2006 Jonathan Pobst
  24. //
  25. // Authors:
  26. // Jonathan Pobst ([email protected])
  27. //
  28. #if NET_2_0
  29. using System.Drawing;
  30. using System.ComponentModel;
  31. namespace System.Windows.Forms
  32. {
  33. [DefaultProperty ("Value")]
  34. public class ToolStripProgressBar : ToolStripControlHost
  35. {
  36. #region Public Constructors
  37. public ToolStripProgressBar () : base (new ProgressBar ())
  38. {
  39. }
  40. public ToolStripProgressBar (string name) : this ()
  41. {
  42. this.Control.Name = name;
  43. }
  44. #endregion
  45. #region Public Properties
  46. [DefaultValue (100)]
  47. public int Maximum {
  48. get { return this.ProgressBar.Maximum; }
  49. set { this.ProgressBar.Maximum = value; }
  50. }
  51. [DefaultValue (0)]
  52. public int Minimum {
  53. get { return this.ProgressBar.Minimum; }
  54. set { this.ProgressBar.Minimum = value; }
  55. }
  56. [Browsable (false)]
  57. public ProgressBar ProgressBar {
  58. get { return (ProgressBar)base.Control; }
  59. }
  60. [DefaultValue (10)]
  61. public int Step {
  62. get { return this.ProgressBar.Step; }
  63. set { this.ProgressBar.Step = value; }
  64. }
  65. [DefaultValue (ProgressBarStyle.Blocks)]
  66. public ProgressBarStyle Style {
  67. get { return this.ProgressBar.Style; }
  68. set { this.ProgressBar.Style = value; }
  69. }
  70. [Browsable (false)]
  71. [EditorBrowsable (EditorBrowsableState.Never)]
  72. public override string Text {
  73. get { return base.Text; }
  74. set { base.Text = value; }
  75. }
  76. [Bindable (true)]
  77. [DefaultValue (0)]
  78. public int Value {
  79. get { return this.ProgressBar.Value; }
  80. set { this.ProgressBar.Value = value; }
  81. }
  82. #endregion
  83. #region Protected Properties
  84. protected internal override Padding DefaultMargin { get { return new Padding (1, 2, 1, 1); } }
  85. protected override Size DefaultSize { get { return new Size (100, 15); } }
  86. #endregion
  87. #region Public Methods
  88. public void Increment (int value)
  89. {
  90. this.ProgressBar.Increment (value);
  91. }
  92. public void PerformStep ()
  93. {
  94. this.ProgressBar.PerformStep ();
  95. }
  96. #endregion
  97. #region Protected Methods
  98. protected override void OnSubscribeControlEvents (Control control)
  99. {
  100. base.OnSubscribeControlEvents (control);
  101. }
  102. protected override void OnUnsubscribeControlEvents (Control control)
  103. {
  104. base.OnUnsubscribeControlEvents (control);
  105. }
  106. #endregion
  107. #region Public Events
  108. [Browsable (false)]
  109. [EditorBrowsable (EditorBrowsableState.Never)]
  110. public new event KeyEventHandler KeyDown;
  111. [Browsable (false)]
  112. [EditorBrowsable (EditorBrowsableState.Never)]
  113. public new event KeyPressEventHandler KeyPress;
  114. [Browsable (false)]
  115. [EditorBrowsable (EditorBrowsableState.Never)]
  116. public new event KeyEventHandler KeyUp;
  117. [Browsable (false)]
  118. [EditorBrowsable (EditorBrowsableState.Never)]
  119. public new event EventHandler LocationChanged;
  120. [Browsable (false)]
  121. [EditorBrowsable (EditorBrowsableState.Never)]
  122. public new event EventHandler OwnerChanged;
  123. [Browsable (false)]
  124. [EditorBrowsable (EditorBrowsableState.Never)]
  125. public new event EventHandler TextChanged;
  126. [Browsable (false)]
  127. [EditorBrowsable (EditorBrowsableState.Never)]
  128. public new event EventHandler Validated;
  129. [Browsable (false)]
  130. [EditorBrowsable (EditorBrowsableState.Never)]
  131. public new event CancelEventHandler Validating;
  132. #endregion
  133. }
  134. }
  135. #endif