Files
@ ae8f7007cb0e
Branch filter:
Location: seniordesign-ui/Demo.WindowsForms/BSE.Windows.Forms/ProgressBar/ToolStripProgressBar.cs
ae8f7007cb0e
9.7 KiB
text/x-csharp
Added licensing information
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms.Design;
using System.Drawing;
using System.ComponentModel;
namespace BSE.Windows.Forms
{
/// <summary>
/// Represents a Windows progress bar control contained in a StatusStrip.
/// </summary>
[ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.ToolStrip | ToolStripItemDesignerAvailability.StatusStrip)]
[ToolboxBitmap(typeof(System.Windows.Forms.ProgressBar))]
public class ToolStripProgressBar : ToolStripControlHost
{
#region Events
#endregion
#region Constants
#endregion
#region FieldsPrivate
#endregion
#region Properties
/// <summary>
/// Gets the ProgressBar.
/// </summary>
/// <value>
/// Type: <see cref="BSE.Windows.Forms.ProgressBar"/>
/// A ProgressBar.
/// </value>
public ProgressBar ProgressBar
{
get { return base.Control as ProgressBar; }
}
/// <summary>
/// Gets or sets a value indicating whether items are to be placed from right to left
/// and text is to be written from right to left.
/// </summary>
/// <value>
/// Type: <see cref="System.Windows.Forms.RightToLeft"/>
/// true if items are to be placed from right to left and text is to be written from right to left; otherwise, false.
/// </value>
public override RightToLeft RightToLeft
{
get { return this.ProgressBar.RightToLeft; }
set { this.ProgressBar.RightToLeft = value; }
}
/// <summary>
/// Gets or sets the color used for the background rectangle for this <see cref="ToolStripProgressBar"/>.
/// </summary>
/// <value>
/// Type: <see cref="System.Drawing.Color"/>
/// A Color used for the background rectangle of this ToolStripProgressBar.
/// </value>
[Browsable(true)]
[Category("Appearance")]
[Description("The color used for the background rectangle of this control.")]
public Color BackgroundColor
{
get { return this.ProgressBar.BackgroundColor; }
set { this.ProgressBar.BackgroundColor = value; }
}
/// <summary>
/// Gets or sets the color used for the value rectangle of this control.
/// Gets or sets color used for the value rectangle for this <see cref="ToolStripProgressBar"/>.
/// </summary>
/// <value>
/// Type: <see cref="System.Drawing.Color"/>
/// A Color used for the value rectangle for this ToolStripProgressBar.
/// </value>
[Browsable(true)]
[Category("Appearance")]
[Description("The end color of the gradient used for the value rectangle of this control.")]
public Color ValueColor
{
get { return this.ProgressBar.ValueColor; }
set { this.ProgressBar.ValueColor = value; }
}
/// <summary>
/// Gets or sets the foreground color of the hosted control.
/// </summary>
/// <value>
/// Type: <see cref="System.Drawing.Color"/>
/// A <see cref="Color"/> representing the foreground color of the hosted control.
/// </value>
[Browsable(true)]
[Category("Appearance")]
[Description("The Foreground color used to display text on the progressbar")]
public override Color ForeColor
{
get { return this.ProgressBar.ForeColor; }
set { this.ProgressBar.ForeColor = value; }
}
/// <summary>
/// Gets or sets the font to be used on the hosted control.
/// </summary>
/// <value>
/// Type: <see cref="System.Drawing.Font"/>
/// The Font for the hosted control.
/// </value>
[Category("Appearance")]
[Description("The font used to display text on the progressbar")]
public override Font Font
{
get { return this.ProgressBar.Font; }
set { this.ProgressBar.Font = value; }
}
/// <summary>
/// Gets or sets the upper bound of the range that is defined for this <see cref="ToolStripProgressBar"/>.
/// </summary>
/// <value>
/// Type: <see cref="System.Int32"/>
/// An integer representing the upper bound of the range. The default is 100.
/// </value>
[Category("Behavior")]
[DefaultValue(100)]
[RefreshProperties(RefreshProperties.All)]
[Description("The upper bound of the range this progressbar is working with.")]
public int Maximum
{
get { return this.ProgressBar.Maximum; }
set { this.ProgressBar.Maximum = value; }
}
/// <summary>
/// Gets or sets the lower bound of the range that is defined for this <see cref="ToolStripProgressBar"/>.
/// </summary>
/// <value>
/// Type: <see cref="System.Int32"/>
/// An integer representing the lower bound of the range. The default is 0.
/// </value>
[Category("Behavior")]
[DefaultValue(0)]
[RefreshProperties(RefreshProperties.All)]
[Description("The lower bound of the range this progressbar is working with.")]
public int Minimum
{
get { return this.ProgressBar.Minimum; }
set { this.ProgressBar.Minimum = value; }
}
/// <summary>
/// Gets or sets the current value of the <see cref="ToolStripProgressBar"/>.
/// </summary>
/// <value>
/// Type: <see cref="System.Int32"/>
/// An integer representing the current value.
/// </value>
[Category("Behavior")]
[DefaultValue(0)]
[RefreshProperties(RefreshProperties.All)]
[Description("The current value for the progressbar, in the range specified by the minimum and maximum.")]
public int Value
{
get { return this.ProgressBar.Value; }
set { this.ProgressBar.Value = value; }
}
/// <summary>
/// Gets or sets the text displayed on the <see cref="BSE.Windows.Forms.ToolStripProgressBar"/>.
/// </summary>
/// <value>
/// Type: <see cref="System.String"/>
/// A <see cref="System.String"/> representing the display text.
/// </value>
[Category("Behavior")]
[Description("The text to display on the progressbar")]
public override string Text
{
get { return this.ProgressBar.Text; }
set { this.ProgressBar.Text = value; }
}
/// <summary>
/// Gets the height and width of the ToolStripProgressBar in pixels.
/// </summary>
/// <value>
/// Type: <see cref="System.Drawing.Size"/>
/// A Point value representing the height and width.
/// </value>
protected override Size DefaultSize
{
get { return new Size(100, 15); }
}
/// <summary>
/// Gets the spacing between the <see cref="ToolStripProgressBar"/> and adjacent items.
/// </summary>
protected override Padding DefaultMargin
{
get
{
if ((base.Owner != null) && (base.Owner is StatusStrip))
{
return new Padding(1, 3, 1, 3);
}
return new Padding(1, 1, 1, 2);
}
}
#endregion
#region MethodsPublic
/// <summary>
/// Initializes a new instance of the ToolStripProgressBar class.
/// </summary>
public ToolStripProgressBar()
: base(CreateControlInstance())
{
}
#endregion
#region MethodsProtected
/// <summary>
/// Raises the OwnerChanged event.
/// </summary>
/// <param name="e">An EventArgs that contains the event data.</param>
protected override void OnOwnerChanged(EventArgs e)
{
if (base.Owner != null)
{
base.Owner.RendererChanged += new EventHandler(OwnerRendererChanged);
}
base.OnOwnerChanged(e);
}
#endregion
#region MethodsPrivate
private static Control CreateControlInstance()
{
BSE.Windows.Forms.ProgressBar progressBar = new BSE.Windows.Forms.ProgressBar();
progressBar.Size = new Size(100, 15);
return progressBar;
}
private void OwnerRendererChanged(object sender, EventArgs e)
{
ToolStripRenderer toolsTripRenderer = this.Owner.Renderer;
if (toolsTripRenderer != null)
{
if (toolsTripRenderer is BseRenderer)
{
ToolStripProfessionalRenderer renderer = toolsTripRenderer as ToolStripProfessionalRenderer;
if (renderer != null)
{
this.ProgressBar.BorderColor = renderer.ColorTable.ToolStripBorder;
}
if (this.Owner.GetType() != typeof(StatusStrip))
{
this.Margin = new Padding(1, 1, 1, 3);
}
}
else
{
this.Margin = DefaultMargin;
}
}
}
#endregion
}
}
|