2 // ToolStripProgressBar.cs
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:
12 // The above copyright notice and this permission notice shall be
13 // included in all copies or substantial portions of the Software.
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.
23 // Copyright (c) 2006 Jonathan Pobst
26 // Jonathan Pobst (monkey@jpobst.com)
30 using System.ComponentModel;
32 namespace System.Windows.Forms
34 [DefaultProperty ("Value")]
35 public class ToolStripProgressBar : ToolStripControlHost
37 #region Public Constructors
38 public ToolStripProgressBar () : base (new ProgressBar ())
42 public ToolStripProgressBar (string name) : this ()
44 this.Control.Name = name;
48 #region Public Properties
51 get { return this.ProgressBar.Maximum; }
52 set { this.ProgressBar.Maximum = value; }
57 get { return this.ProgressBar.Minimum; }
58 set { this.ProgressBar.Minimum = value; }
62 public ProgressBar ProgressBar {
63 get { return (ProgressBar)base.Control; }
68 get { return this.ProgressBar.Step; }
69 set { this.ProgressBar.Step = value; }
72 [DefaultValue (ProgressBarStyle.Blocks)]
73 public ProgressBarStyle Style {
74 get { return this.ProgressBar.Style; }
75 set { this.ProgressBar.Style = value; }
79 [EditorBrowsable (EditorBrowsableState.Never)]
80 public override string Text {
81 get { return base.Text; }
82 set { base.Text = value; }
88 get { return this.ProgressBar.Value; }
89 set { this.ProgressBar.Value = value; }
93 #region Protected Properties
94 protected internal override Padding DefaultMargin { get { return new Padding (1, 2, 1, 1); } }
95 protected override Size DefaultSize { get { return new Size (100, 15); } }
98 #region Public Methods
99 public void Increment (int value)
101 this.ProgressBar.Increment (value);
104 public void PerformStep ()
106 this.ProgressBar.PerformStep ();
110 #region Protected Methods
111 protected override void OnSubscribeControlEvents (Control control)
113 base.OnSubscribeControlEvents (control);
116 protected override void OnUnsubscribeControlEvents (Control control)
118 base.OnUnsubscribeControlEvents (control);
122 #region Public Events
124 [EditorBrowsable (EditorBrowsableState.Never)]
125 public event KeyEventHandler KeyDown;
127 [EditorBrowsable (EditorBrowsableState.Never)]
128 public event KeyPressEventHandler KeyPress;
130 [EditorBrowsable (EditorBrowsableState.Never)]
131 public event KeyEventHandler KeyUp;
133 [EditorBrowsable (EditorBrowsableState.Never)]
134 public event EventHandler LocationChanged;
136 [EditorBrowsable (EditorBrowsableState.Never)]
137 public event EventHandler OwnerChanged;
139 [EditorBrowsable (EditorBrowsableState.Never)]
140 public event EventHandler TextChanged;
142 [EditorBrowsable (EditorBrowsableState.Never)]
143 public event EventHandler Validated;
145 [EditorBrowsable (EditorBrowsableState.Never)]
146 public event CancelEventHandler Validating;