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 public class ToolStripProgressBar : ToolStripControlHost
36 #region Public Constructors
37 public ToolStripProgressBar () : base (new ProgressBar ())
41 public ToolStripProgressBar (string name) : this ()
43 this.Control.Name = name;
47 #region Public Properties
49 get { return this.ProgressBar.Maximum; }
50 set { this.ProgressBar.Maximum = value; }
54 get { return this.ProgressBar.Minimum; }
55 set { this.ProgressBar.Minimum = value; }
58 public ProgressBar ProgressBar {
59 get { return (ProgressBar)base.Control; }
63 get { return this.ProgressBar.Step; }
64 set { this.ProgressBar.Step = value; }
67 public ProgressBarStyle Style {
68 get { return this.ProgressBar.Style; }
69 set { this.ProgressBar.Style = value; }
72 public override string Text {
73 get { return base.Text; }
74 set { base.Text = value; }
79 get { return this.ProgressBar.Value; }
80 set { this.ProgressBar.Value = value; }
84 #region Protected Properties
85 protected internal override Padding DefaultMargin { get { return new Padding (1, 2, 1, 1); } }
86 protected override Size DefaultSize { get { return new Size (100, 15); } }
89 #region Public Methods
90 public void Increment (int value)
92 this.ProgressBar.Increment (value);
95 public void PerformStep ()
97 this.ProgressBar.PerformStep ();
101 #region Protected Methods
102 protected override void OnSubscribeControlEvents (Control control)
104 base.OnSubscribeControlEvents (control);
107 protected override void OnUnsubscribeControlEvents (Control control)
109 base.OnUnsubscribeControlEvents (control);
113 #region Public Events
115 [EditorBrowsable (EditorBrowsableState.Never)]
116 public event KeyEventHandler KeyDown;
118 [EditorBrowsable (EditorBrowsableState.Never)]
119 public event KeyPressEventHandler KeyPress;
121 [EditorBrowsable (EditorBrowsableState.Never)]
122 public event KeyEventHandler KeyUp;
124 [EditorBrowsable (EditorBrowsableState.Never)]
125 public event EventHandler LocationChanged;
127 [EditorBrowsable (EditorBrowsableState.Never)]
128 public event EventHandler OwnerChanged;
130 [EditorBrowsable (EditorBrowsableState.Never)]
131 public event EventHandler TextChanged;
133 [EditorBrowsable (EditorBrowsableState.Never)]
134 public event EventHandler Validated;
136 [EditorBrowsable (EditorBrowsableState.Never)]
137 public event CancelEventHandler Validating;