Code:
                         / Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / WinForms / Managed / System / WinForms / ProgressBar.cs / 1 / ProgressBar.cs
                        
                        
                            //------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
//  
//----------------------------------------------------------------------------- 
/* 
 */ 
namespace System.Windows.Forms {
    using System.Runtime.Serialization.Formatters; 
    using System.Runtime.Remoting;
    using System.Diagnostics;
    using System.Diagnostics.CodeAnalysis;
    using System; 
    using System.Security.Permissions;
    using System.Drawing; 
    using System.ComponentModel; 
    using System.ComponentModel.Design;
    using System.Windows.Forms; 
    using Microsoft.Win32;
    using System.Runtime.InteropServices;
    using System.Windows.Forms.Layout;
    using System.Globalization; 
    ///  
    ///    
    ///       Represents a Windows progress bar control. 
    ///     
    ///  
    [
    ComVisible(true), 
    ClassInterface(ClassInterfaceType.AutoDispatch),
    DefaultProperty("Value"), 
    DefaultBindingProperty("Value"), 
    SRDescription(SR.DescriptionProgressBar)
    ] 
    public class ProgressBar : Control {
        //# VS7 205: simcooke 
        //REMOVED: AddOnValueChanged, RemoveOnValueChanged, OnValueChanged and all designer plumbing associated with it.
        //         OnValueChanged event no longer exists. 
 
        // these four values define the range of possible values, how to navigate
        // through them, and the current position 
        //
        private int minimum = 0;
        private int maximum = 100;
        private int step = 10; 
        private int value = 0;
 
        //this defines marquee animation speed 
        private int marqueeSpeed = 100;
 
        private Color defaultForeColor = SystemColors.Highlight;
        private ProgressBarStyle style = ProgressBarStyle.Blocks;
 
        private EventHandler onRightToLeftLayoutChanged;
        private bool rightToLeftLayout = false; 
 
        /// 
        ///    
        ///       Initializes a new instance of the  
        ///   
        public ProgressBar() 
        : base() {
            SetStyle(ControlStyles.UserPaint | 
                     ControlStyles.UseTextForAccessibility |
                     ControlStyles.Selectable, false);
            ForeColor = defaultForeColor;
        } 
        /// 
        ///     
        ///       This is called when creating a window. Inheriting classes can ovveride
        ///       this to add extra functionality, but should not forget to first call
        ///       base.getCreateParams() to make sure the control continues to work
        ///       correctly. 
        ///     
        ///   
        protected override CreateParams CreateParams { 
            [SecurityPermission(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.UnmanagedCode)]
            get { 
                CreateParams cp = base.CreateParams;
                cp.ClassName = NativeMethods.WC_PROGRESS;
                if (this.Style == ProgressBarStyle.Continuous) {
                    cp.Style |= NativeMethods.PBS_SMOOTH; 
                }
                else if (this.Style == ProgressBarStyle.Marquee && !DesignMode) { 
                    cp.Style |= NativeMethods.PBS_MARQUEE; 
                }
 
                if (RightToLeft == RightToLeft.Yes && RightToLeftLayout == true) {
                    //We want to turn on mirroring for Form explicitly.
                    cp.ExStyle |= NativeMethods.WS_EX_LAYOUTRTL;
                    //Don't need these styles when mirroring is turned on. 
                    cp.ExStyle &= ~(NativeMethods.WS_EX_RTLREADING | NativeMethods.WS_EX_RIGHT | NativeMethods.WS_EX_LEFTSCROLLBAR);
                } 
                return cp; 
            }
        } 
        ///  
        ///  
        [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] 
        public override bool AllowDrop { 
            get {
                return base.AllowDrop; 
            }
            set {
                base.AllowDrop = value;
            } 
        }
 
        ///  
        ///  
        [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public override Image BackgroundImage {
            get { 
                return base.BackgroundImage;
            } 
            set { 
                base.BackgroundImage = value;
            } 
        }
        /// 
        ///     
        ///       Gets or sets the style of the ProgressBar. This is can be either Blocks or Continuous. 
        ///     
        ///   
        [
        Browsable(true),
        EditorBrowsable(EditorBrowsableState.Always),
        DefaultValue(ProgressBarStyle.Blocks), 
        SRCategory(SR.CatBehavior),
        SRDescription(SR.ProgressBarStyleDescr) 
        ] 
        public ProgressBarStyle Style {
            get { 
                return style;
            }
            set {
                if (style != value) { 
                    //valid values are 0x0 to 0x2
                    if (!ClientUtils.IsEnumValid(value, (int)value, (int)ProgressBarStyle.Blocks, (int)ProgressBarStyle.Marquee)){ 
                        throw new InvalidEnumArgumentException("value", (int)value, typeof(ProgressBarStyle)); 
                    }
                    style = value; 
                    if (IsHandleCreated)
                        RecreateHandle();
                    if (style == ProgressBarStyle.Marquee)
                    { 
                        StartMarquee();
                    } 
                } 
            }
        } 
        /// 
        ///   
        [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public override ImageLayout BackgroundImageLayout {
            get {
                return base.BackgroundImageLayout; 
            }
            set { 
                base.BackgroundImageLayout = value; 
            }
        } 
        /// 
        ///     Deriving classes can override this to configure a default size for their control. 
        ///     This is more efficient than setting the size in the control's constructor.
        ///   
        protected override Size DefaultSize { 
            get {
                return new Size(100, 23); 
            }
        }
        /// 
        ///     This property is overridden and hidden from statement completion 
        ///     on controls that are based on Win32 Native Controls. 
        ///  
        [EditorBrowsable(EditorBrowsableState.Never)] 
        protected override bool DoubleBuffered {
            get {
                return base.DoubleBuffered;
            } 
            set {
                base.DoubleBuffered = value; 
            } 
        }
 
        /// 
        ///    
        ///       Gets or sets the font of text in the  
        ///   
        [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] 
        public override Font Font {
            get { 
                return base.Font;
            }
            set {
                base.Font = value; 
            }
        } 
 
        ///  
        ///    
        ///       Gets or sets the marquee animation speed of the  
        ///   
        [
        DefaultValue(100), 
        SRCategory(SR.CatBehavior), 
        SRDescription(SR.ProgressBarMarqueeAnimationSpeed)]
        public int MarqueeAnimationSpeed { 
            get {
                return marqueeSpeed;
            }
            [SuppressMessage("Microsoft.Usage", "CA2208:InstantiateArgumentExceptionsCorrectly")] 
            set {
                if (value < 0) { 
                    throw new ArgumentOutOfRangeException("MarqueeAnimationSpeed must be non-negative"); 
                }
                marqueeSpeed = value; 
                if (!DesignMode) {
                    StartMarquee();
                }
            } 
        }
 
        /// 
        ///     
        ///       Start the Marquee rolling (or stop it, if the speed = 0)
        ///     
        ///  
        private void StartMarquee() 
        {
            if (IsHandleCreated && style == ProgressBarStyle.Marquee) 
            { 
                if (marqueeSpeed == 0)
                { 
                    SendMessage(NativeMethods.PBM_SETMARQUEE, 0, marqueeSpeed);
                }
                else
                { 
                    SendMessage(NativeMethods.PBM_SETMARQUEE, 1, marqueeSpeed);
                } 
            } 
        }
 
        /// 
        ///    
        ///       Gets or sets the maximum value of the   
        ///   
        [
        DefaultValue(100), 
        SRCategory(SR.CatBehavior),
        RefreshProperties(RefreshProperties.Repaint),
        SRDescription(SR.ProgressBarMaximumDescr)
        ] 
        public int Maximum {
            get { 
                return maximum; 
            }
            set { 
                if (maximum != value) {
                    // Ensure that value is in the Win32 control's acceptable range
                    // Message: '%1' is not a valid value for '%0'. '%0' must be greater than %2.
                    // Should this set a boundary for the top end too? 
                    if (value < 0)
                        throw new ArgumentOutOfRangeException("Maximum", SR.GetString(SR.InvalidLowBoundArgumentEx, "Maximum", value.ToString(CultureInfo.CurrentCulture), (0).ToString(CultureInfo.CurrentCulture))); 
 
                    if (minimum > value) minimum = value;
 
                    maximum = value;
                    if (this.value > maximum) this.value = maximum;
 
                    if (IsHandleCreated) {
                        SendMessage(NativeMethods.PBM_SETRANGE32, minimum, maximum); 
                        UpdatePos() ; 
                    }
                } 
            }
        }
        /// 
        ///     
        ///       Gets or sets the minimum value of the  
        ///   
        [
        DefaultValue(0),
        SRCategory(SR.CatBehavior),
        RefreshProperties(RefreshProperties.Repaint), 
        SRDescription(SR.ProgressBarMinimumDescr)
        ] 
        public int Minimum { 
            get {
                return minimum; 
            }
            set {
                if (minimum != value) {
                    // Ensure that value is in the Win32 control's acceptable range 
                    // Message: '%1' is not a valid value for '%0'. '%0' must be greater than %2.
                    // Should this set a boundary for the top end too? 
                    if (value < 0) 
                        throw new ArgumentOutOfRangeException("Minimum", SR.GetString(SR.InvalidLowBoundArgumentEx, "Minimum", value.ToString(CultureInfo.CurrentCulture), (0).ToString(CultureInfo.CurrentCulture)));
                    if (maximum < value) maximum = value; 
                    minimum = value;
                    if (this.value < minimum) this.value = minimum; 
                    if (IsHandleCreated) { 
                        SendMessage(NativeMethods.PBM_SETRANGE32, minimum, maximum); 
                        UpdatePos() ;
                    } 
                }
            }
        }
 
        protected override void OnBackColorChanged(EventArgs e)
        { 
            base.OnBackColorChanged(e); 
            if (IsHandleCreated)
            { 
                UnsafeNativeMethods.SendMessage(new HandleRef(this, Handle), NativeMethods.PBM_SETBKCOLOR, 0, ColorTranslator.ToWin32(BackColor));
            }
        }
 
        protected override void OnForeColorChanged(EventArgs e)
        { 
            base.OnForeColorChanged(e); 
            if (IsHandleCreated)
            { 
                UnsafeNativeMethods.SendMessage(new HandleRef(this, Handle), NativeMethods.PBM_SETBARCOLOR, 0, ColorTranslator.ToWin32(ForeColor));
            }
        }
 
        ///  
        ///     
        ///    [To be supplied.] 
        ///      
        ///  
        [
        Browsable(false),
        EditorBrowsable(EditorBrowsableState.Never), 
        DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)
        ] 
        public new Padding Padding { 
            get { return base.Padding; }
            set { base.Padding = value;} 
        }
        [
        Browsable(false), 
        EditorBrowsable(EditorBrowsableState.Never)
        ] 
        public new event EventHandler PaddingChanged { 
            add { base.PaddingChanged += value; }
            remove { base.PaddingChanged -= value; } 
        }
        ///  
        ///     This is used for international applications where the language
        ///     is written from RightToLeft. When this property is true, 
        //      and the RightToLeft is true, mirroring will be turned on on the form, and 
        ///     control placement and text will be from right to left.
        ///   
        [
        SRCategory(SR.CatAppearance),
        Localizable(true),
        DefaultValue(false), 
        SRDescription(SR.ControlRightToLeftLayoutDescr)
        ] 
        public virtual bool RightToLeftLayout { 
            get {
 
                return rightToLeftLayout;
            }
            set { 
                if (value != rightToLeftLayout) {
                    rightToLeftLayout = value; 
                    using(new LayoutTransaction(this, this, PropertyNames.RightToLeftLayout)) { 
                        OnRightToLeftLayoutChanged(EventArgs.Empty);
                    } 
                }
            }
        }
 
        ///  
        ///    [To be supplied.] 
        ///   
        [SRCategory(SR.CatPropertyChanged), SRDescription(SR.ControlOnRightToLeftLayoutChangedDescr)]
        public event EventHandler RightToLeftLayoutChanged {
            add {
                onRightToLeftLayoutChanged += value; 
            }
            remove { 
                onRightToLeftLayoutChanged -= value; 
            }
        } 
        /// 
        ///     
        ///       Gets or sets the amount that a call to   
        ///  
        [ 
        DefaultValue(10),
        SRCategory(SR.CatBehavior),
        SRDescription(SR.ProgressBarStepDescr)
        ] 
        public int Step {
            get { 
                return step; 
            }
            set { 
                step = value;
                if (IsHandleCreated) SendMessage(NativeMethods.PBM_SETSTEP, step, 0);
            }
        } 
        /// 
        ///   
        [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
        new public bool TabStop {
            get {
                return base.TabStop; 
            }
            set { 
                base.TabStop = value; 
            }
        } 
        ///  
        ///  
        [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), Bindable(false)] 
        public override string Text {
            get {
                return base.Text;
            } 
            set {
                base.Text = value; 
            } 
        }
 
        /// 
        ///     
        ///       Gets or sets the current position of the  
        ///   
        [
        DefaultValue(0),
        SRCategory(SR.CatBehavior),
        Bindable(true), 
        SRDescription(SR.ProgressBarValueDescr)
        ] 
        public int Value { 
            get {
                return value; 
            }
            set {
                if (this.value != value) {
                    if ((value < minimum) || (value > maximum)) 
                        throw new ArgumentOutOfRangeException("Value", SR.GetString(SR.InvalidBoundArgument, "Value", value.ToString(CultureInfo.CurrentCulture), "'minimum'", "'maximum'"));
                    this.value = value; 
                    UpdatePos() ; 
                }
            } 
        }
        ///  
        ///     ProgressBar Onpaint.
        ///   
        /// 
        ///   
        ///  
        ///     
        ///       Advances the current position of the  
        ///  
        public void Increment(int value) {
            if (this.Style == ProgressBarStyle.Marquee) { 
                throw new InvalidOperationException(SR.GetString(SR.ProgressBarIncrementMarqueeException));
            } 
            this.value += value; 
            // Enforce that value is within the range (minimum, maximum) 
            if (this.value < minimum) {
                this.value = minimum;
            }
            if (this.value > maximum) { 
                this.value = maximum;
            } 
 
            UpdatePos();
        } 
        /// 
        ///    Overridden to set up our properties. 
        ///  
        /// 
        ///    Overridden to remove event handler.
        ///  
        /// 
        ///    [To be supplied.]  
        ///  
        [EditorBrowsable(EditorBrowsableState.Advanced)] 
        protected virtual void OnRightToLeftLayoutChanged(EventArgs e) { 
            if (GetAnyDisposingInHierarchy()) {
                return; 
            }
            if (RightToLeft == RightToLeft.Yes) {
                RecreateHandle(); 
            }
 
            if (onRightToLeftLayoutChanged != null) { 
                 onRightToLeftLayoutChanged(this, e);
            } 
        }
 
        ///  
        ///     
        ///       Advances the current position of the  
        ///  
        public void PerformStep() { 
            if (this.Style == ProgressBarStyle.Marquee) {
                throw new InvalidOperationException(SR.GetString(SR.ProgressBarPerformStepMarqueeException)); 
            } 
            Increment(step);
        } 
        /// 
        ///     Resets the fore color to be based on the parent's fore color. 
        ///  
        [EditorBrowsable(EditorBrowsableState.Never)] 
        public override void ResetForeColor() { 
            ForeColor = defaultForeColor;
        } 
        ///  
        ///     Returns true if the ForeColor should be persisted in code gen.
        ///   
        [EditorBrowsable(EditorBrowsableState.Never)] 
        internal override bool ShouldSerializeForeColor() {
            return ForeColor != defaultForeColor; 
        }
        /// 
        ///    Returns a string representation for this control. 
        ///   
        ///  
        ///     Sends the underlying window a PBM_SETPOS message to update
        ///     the current value of the progressbar. 
        ///  
        /// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
//  
//----------------------------------------------------------------------------- 
/* 
 */ 
namespace System.Windows.Forms {
    using System.Runtime.Serialization.Formatters; 
    using System.Runtime.Remoting;
    using System.Diagnostics;
    using System.Diagnostics.CodeAnalysis;
    using System; 
    using System.Security.Permissions;
    using System.Drawing; 
    using System.ComponentModel; 
    using System.ComponentModel.Design;
    using System.Windows.Forms; 
    using Microsoft.Win32;
    using System.Runtime.InteropServices;
    using System.Windows.Forms.Layout;
    using System.Globalization; 
    ///  
    ///    
    ///       Represents a Windows progress bar control. 
    ///     
    ///  
    [
    ComVisible(true), 
    ClassInterface(ClassInterfaceType.AutoDispatch),
    DefaultProperty("Value"), 
    DefaultBindingProperty("Value"), 
    SRDescription(SR.DescriptionProgressBar)
    ] 
    public class ProgressBar : Control {
        //# VS7 205: simcooke 
        //REMOVED: AddOnValueChanged, RemoveOnValueChanged, OnValueChanged and all designer plumbing associated with it.
        //         OnValueChanged event no longer exists. 
 
        // these four values define the range of possible values, how to navigate
        // through them, and the current position 
        //
        private int minimum = 0;
        private int maximum = 100;
        private int step = 10; 
        private int value = 0;
 
        //this defines marquee animation speed 
        private int marqueeSpeed = 100;
 
        private Color defaultForeColor = SystemColors.Highlight;
        private ProgressBarStyle style = ProgressBarStyle.Blocks;
 
        private EventHandler onRightToLeftLayoutChanged;
        private bool rightToLeftLayout = false; 
 
        /// 
        ///    
        ///       Initializes a new instance of the  
        ///   
        public ProgressBar() 
        : base() {
            SetStyle(ControlStyles.UserPaint | 
                     ControlStyles.UseTextForAccessibility |
                     ControlStyles.Selectable, false);
            ForeColor = defaultForeColor;
        } 
        /// 
        ///     
        ///       This is called when creating a window. Inheriting classes can ovveride
        ///       this to add extra functionality, but should not forget to first call
        ///       base.getCreateParams() to make sure the control continues to work
        ///       correctly. 
        ///     
        ///   
        protected override CreateParams CreateParams { 
            [SecurityPermission(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.UnmanagedCode)]
            get { 
                CreateParams cp = base.CreateParams;
                cp.ClassName = NativeMethods.WC_PROGRESS;
                if (this.Style == ProgressBarStyle.Continuous) {
                    cp.Style |= NativeMethods.PBS_SMOOTH; 
                }
                else if (this.Style == ProgressBarStyle.Marquee && !DesignMode) { 
                    cp.Style |= NativeMethods.PBS_MARQUEE; 
                }
 
                if (RightToLeft == RightToLeft.Yes && RightToLeftLayout == true) {
                    //We want to turn on mirroring for Form explicitly.
                    cp.ExStyle |= NativeMethods.WS_EX_LAYOUTRTL;
                    //Don't need these styles when mirroring is turned on. 
                    cp.ExStyle &= ~(NativeMethods.WS_EX_RTLREADING | NativeMethods.WS_EX_RIGHT | NativeMethods.WS_EX_LEFTSCROLLBAR);
                } 
                return cp; 
            }
        } 
        ///  
        ///  
        [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] 
        public override bool AllowDrop { 
            get {
                return base.AllowDrop; 
            }
            set {
                base.AllowDrop = value;
            } 
        }
 
        ///  
        ///  
        [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public override Image BackgroundImage {
            get { 
                return base.BackgroundImage;
            } 
            set { 
                base.BackgroundImage = value;
            } 
        }
        /// 
        ///     
        ///       Gets or sets the style of the ProgressBar. This is can be either Blocks or Continuous. 
        ///     
        ///   
        [
        Browsable(true),
        EditorBrowsable(EditorBrowsableState.Always),
        DefaultValue(ProgressBarStyle.Blocks), 
        SRCategory(SR.CatBehavior),
        SRDescription(SR.ProgressBarStyleDescr) 
        ] 
        public ProgressBarStyle Style {
            get { 
                return style;
            }
            set {
                if (style != value) { 
                    //valid values are 0x0 to 0x2
                    if (!ClientUtils.IsEnumValid(value, (int)value, (int)ProgressBarStyle.Blocks, (int)ProgressBarStyle.Marquee)){ 
                        throw new InvalidEnumArgumentException("value", (int)value, typeof(ProgressBarStyle)); 
                    }
                    style = value; 
                    if (IsHandleCreated)
                        RecreateHandle();
                    if (style == ProgressBarStyle.Marquee)
                    { 
                        StartMarquee();
                    } 
                } 
            }
        } 
        /// 
        ///   
        [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public override ImageLayout BackgroundImageLayout {
            get {
                return base.BackgroundImageLayout; 
            }
            set { 
                base.BackgroundImageLayout = value; 
            }
        } 
        /// 
        ///     Deriving classes can override this to configure a default size for their control. 
        ///     This is more efficient than setting the size in the control's constructor.
        ///   
        protected override Size DefaultSize { 
            get {
                return new Size(100, 23); 
            }
        }
        /// 
        ///     This property is overridden and hidden from statement completion 
        ///     on controls that are based on Win32 Native Controls. 
        ///  
        [EditorBrowsable(EditorBrowsableState.Never)] 
        protected override bool DoubleBuffered {
            get {
                return base.DoubleBuffered;
            } 
            set {
                base.DoubleBuffered = value; 
            } 
        }
 
        /// 
        ///    
        ///       Gets or sets the font of text in the  
        ///   
        [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] 
        public override Font Font {
            get { 
                return base.Font;
            }
            set {
                base.Font = value; 
            }
        } 
 
        ///  
        ///    
        ///       Gets or sets the marquee animation speed of the  
        ///   
        [
        DefaultValue(100), 
        SRCategory(SR.CatBehavior), 
        SRDescription(SR.ProgressBarMarqueeAnimationSpeed)]
        public int MarqueeAnimationSpeed { 
            get {
                return marqueeSpeed;
            }
            [SuppressMessage("Microsoft.Usage", "CA2208:InstantiateArgumentExceptionsCorrectly")] 
            set {
                if (value < 0) { 
                    throw new ArgumentOutOfRangeException("MarqueeAnimationSpeed must be non-negative"); 
                }
                marqueeSpeed = value; 
                if (!DesignMode) {
                    StartMarquee();
                }
            } 
        }
 
        /// 
        ///     
        ///       Start the Marquee rolling (or stop it, if the speed = 0)
        ///     
        ///  
        private void StartMarquee() 
        {
            if (IsHandleCreated && style == ProgressBarStyle.Marquee) 
            { 
                if (marqueeSpeed == 0)
                { 
                    SendMessage(NativeMethods.PBM_SETMARQUEE, 0, marqueeSpeed);
                }
                else
                { 
                    SendMessage(NativeMethods.PBM_SETMARQUEE, 1, marqueeSpeed);
                } 
            } 
        }
 
        /// 
        ///    
        ///       Gets or sets the maximum value of the   
        ///   
        [
        DefaultValue(100), 
        SRCategory(SR.CatBehavior),
        RefreshProperties(RefreshProperties.Repaint),
        SRDescription(SR.ProgressBarMaximumDescr)
        ] 
        public int Maximum {
            get { 
                return maximum; 
            }
            set { 
                if (maximum != value) {
                    // Ensure that value is in the Win32 control's acceptable range
                    // Message: '%1' is not a valid value for '%0'. '%0' must be greater than %2.
                    // Should this set a boundary for the top end too? 
                    if (value < 0)
                        throw new ArgumentOutOfRangeException("Maximum", SR.GetString(SR.InvalidLowBoundArgumentEx, "Maximum", value.ToString(CultureInfo.CurrentCulture), (0).ToString(CultureInfo.CurrentCulture))); 
 
                    if (minimum > value) minimum = value;
 
                    maximum = value;
                    if (this.value > maximum) this.value = maximum;
 
                    if (IsHandleCreated) {
                        SendMessage(NativeMethods.PBM_SETRANGE32, minimum, maximum); 
                        UpdatePos() ; 
                    }
                } 
            }
        }
        /// 
        ///     
        ///       Gets or sets the minimum value of the  
        ///   
        [
        DefaultValue(0),
        SRCategory(SR.CatBehavior),
        RefreshProperties(RefreshProperties.Repaint), 
        SRDescription(SR.ProgressBarMinimumDescr)
        ] 
        public int Minimum { 
            get {
                return minimum; 
            }
            set {
                if (minimum != value) {
                    // Ensure that value is in the Win32 control's acceptable range 
                    // Message: '%1' is not a valid value for '%0'. '%0' must be greater than %2.
                    // Should this set a boundary for the top end too? 
                    if (value < 0) 
                        throw new ArgumentOutOfRangeException("Minimum", SR.GetString(SR.InvalidLowBoundArgumentEx, "Minimum", value.ToString(CultureInfo.CurrentCulture), (0).ToString(CultureInfo.CurrentCulture)));
                    if (maximum < value) maximum = value; 
                    minimum = value;
                    if (this.value < minimum) this.value = minimum; 
                    if (IsHandleCreated) { 
                        SendMessage(NativeMethods.PBM_SETRANGE32, minimum, maximum); 
                        UpdatePos() ;
                    } 
                }
            }
        }
 
        protected override void OnBackColorChanged(EventArgs e)
        { 
            base.OnBackColorChanged(e); 
            if (IsHandleCreated)
            { 
                UnsafeNativeMethods.SendMessage(new HandleRef(this, Handle), NativeMethods.PBM_SETBKCOLOR, 0, ColorTranslator.ToWin32(BackColor));
            }
        }
 
        protected override void OnForeColorChanged(EventArgs e)
        { 
            base.OnForeColorChanged(e); 
            if (IsHandleCreated)
            { 
                UnsafeNativeMethods.SendMessage(new HandleRef(this, Handle), NativeMethods.PBM_SETBARCOLOR, 0, ColorTranslator.ToWin32(ForeColor));
            }
        }
 
        ///  
        ///     
        ///    [To be supplied.] 
        ///      
        ///  
        [
        Browsable(false),
        EditorBrowsable(EditorBrowsableState.Never), 
        DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)
        ] 
        public new Padding Padding { 
            get { return base.Padding; }
            set { base.Padding = value;} 
        }
        [
        Browsable(false), 
        EditorBrowsable(EditorBrowsableState.Never)
        ] 
        public new event EventHandler PaddingChanged { 
            add { base.PaddingChanged += value; }
            remove { base.PaddingChanged -= value; } 
        }
        ///  
        ///     This is used for international applications where the language
        ///     is written from RightToLeft. When this property is true, 
        //      and the RightToLeft is true, mirroring will be turned on on the form, and 
        ///     control placement and text will be from right to left.
        ///   
        [
        SRCategory(SR.CatAppearance),
        Localizable(true),
        DefaultValue(false), 
        SRDescription(SR.ControlRightToLeftLayoutDescr)
        ] 
        public virtual bool RightToLeftLayout { 
            get {
 
                return rightToLeftLayout;
            }
            set { 
                if (value != rightToLeftLayout) {
                    rightToLeftLayout = value; 
                    using(new LayoutTransaction(this, this, PropertyNames.RightToLeftLayout)) { 
                        OnRightToLeftLayoutChanged(EventArgs.Empty);
                    } 
                }
            }
        }
 
        ///  
        ///    [To be supplied.] 
        ///   
        [SRCategory(SR.CatPropertyChanged), SRDescription(SR.ControlOnRightToLeftLayoutChangedDescr)]
        public event EventHandler RightToLeftLayoutChanged {
            add {
                onRightToLeftLayoutChanged += value; 
            }
            remove { 
                onRightToLeftLayoutChanged -= value; 
            }
        } 
        /// 
        ///     
        ///       Gets or sets the amount that a call to   
        ///  
        [ 
        DefaultValue(10),
        SRCategory(SR.CatBehavior),
        SRDescription(SR.ProgressBarStepDescr)
        ] 
        public int Step {
            get { 
                return step; 
            }
            set { 
                step = value;
                if (IsHandleCreated) SendMessage(NativeMethods.PBM_SETSTEP, step, 0);
            }
        } 
        /// 
        ///   
        [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
        new public bool TabStop {
            get {
                return base.TabStop; 
            }
            set { 
                base.TabStop = value; 
            }
        } 
        ///  
        ///  
        [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), Bindable(false)] 
        public override string Text {
            get {
                return base.Text;
            } 
            set {
                base.Text = value; 
            } 
        }
 
        /// 
        ///     
        ///       Gets or sets the current position of the  
        ///   
        [
        DefaultValue(0),
        SRCategory(SR.CatBehavior),
        Bindable(true), 
        SRDescription(SR.ProgressBarValueDescr)
        ] 
        public int Value { 
            get {
                return value; 
            }
            set {
                if (this.value != value) {
                    if ((value < minimum) || (value > maximum)) 
                        throw new ArgumentOutOfRangeException("Value", SR.GetString(SR.InvalidBoundArgument, "Value", value.ToString(CultureInfo.CurrentCulture), "'minimum'", "'maximum'"));
                    this.value = value; 
                    UpdatePos() ; 
                }
            } 
        }
        ///  
        ///     ProgressBar Onpaint.
        ///   
        /// 
        ///   
        ///  
        ///     
        ///       Advances the current position of the  
        ///  
        public void Increment(int value) {
            if (this.Style == ProgressBarStyle.Marquee) { 
                throw new InvalidOperationException(SR.GetString(SR.ProgressBarIncrementMarqueeException));
            } 
            this.value += value; 
            // Enforce that value is within the range (minimum, maximum) 
            if (this.value < minimum) {
                this.value = minimum;
            }
            if (this.value > maximum) { 
                this.value = maximum;
            } 
 
            UpdatePos();
        } 
        /// 
        ///    Overridden to set up our properties. 
        ///  
        /// 
        ///    Overridden to remove event handler.
        ///  
        /// 
        ///    [To be supplied.]  
        ///  
        [EditorBrowsable(EditorBrowsableState.Advanced)] 
        protected virtual void OnRightToLeftLayoutChanged(EventArgs e) { 
            if (GetAnyDisposingInHierarchy()) {
                return; 
            }
            if (RightToLeft == RightToLeft.Yes) {
                RecreateHandle(); 
            }
 
            if (onRightToLeftLayoutChanged != null) { 
                 onRightToLeftLayoutChanged(this, e);
            } 
        }
 
        ///  
        ///     
        ///       Advances the current position of the  
        ///  
        public void PerformStep() { 
            if (this.Style == ProgressBarStyle.Marquee) {
                throw new InvalidOperationException(SR.GetString(SR.ProgressBarPerformStepMarqueeException)); 
            } 
            Increment(step);
        } 
        /// 
        ///     Resets the fore color to be based on the parent's fore color. 
        ///  
        [EditorBrowsable(EditorBrowsableState.Never)] 
        public override void ResetForeColor() { 
            ForeColor = defaultForeColor;
        } 
        ///  
        ///     Returns true if the ForeColor should be persisted in code gen.
        ///   
        [EditorBrowsable(EditorBrowsableState.Never)] 
        internal override bool ShouldSerializeForeColor() {
            return ForeColor != defaultForeColor; 
        }
        /// 
        ///    Returns a string representation for this control. 
        ///   
        ///  
        ///     Sends the underlying window a PBM_SETPOS message to update
        ///     the current value of the progressbar. 
        ///  
        /// 
                        
                        
                        
                    Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- XmlQualifiedNameTest.cs
- SslStreamSecurityElement.cs
- ProxyWebPartManager.cs
- assertwrapper.cs
- NameValuePermission.cs
- SQLDateTimeStorage.cs
- EncoderFallback.cs
- ChildTable.cs
- DataGridRow.cs
- DBDataPermission.cs
- InstalledFontCollection.cs
- SafeCryptContextHandle.cs
- ProxyWebPart.cs
- StorageEndPropertyMapping.cs
- DataGridHyperlinkColumn.cs
- Propagator.Evaluator.cs
- ModuleElement.cs
- AuthenticatingEventArgs.cs
- EntityDesignerBuildProvider.cs
- RsaKeyIdentifierClause.cs
- WebScriptServiceHostFactory.cs
- BindValidator.cs
- XmlElement.cs
- HtmlGenericControl.cs
- serverconfig.cs
- RequiredFieldValidator.cs
- xmlglyphRunInfo.cs
- PingReply.cs
- GlyphCache.cs
- ParameterModifier.cs
- RbTree.cs
- CompilationRelaxations.cs
- DecoderNLS.cs
- SendParametersContent.cs
- Html32TextWriter.cs
- DataComponentGenerator.cs
- NameValueCollection.cs
- RunWorkerCompletedEventArgs.cs
- autovalidator.cs
- BorderGapMaskConverter.cs
- ConnectionsZone.cs
- SafeFileHandle.cs
- CodeGenerationManager.cs
- X509ChainElement.cs
- PrintEvent.cs
- SqlVersion.cs
- Emitter.cs
- MenuItemCollection.cs
- HijriCalendar.cs
- FirstMatchCodeGroup.cs
- SimpleMailWebEventProvider.cs
- DataGridViewImageColumn.cs
- BitVector32.cs
- SqlConnectionPoolProviderInfo.cs
- CodeTypeReference.cs
- mansign.cs
- SqlRecordBuffer.cs
- DataGridViewCellValidatingEventArgs.cs
- ExpressionDumper.cs
- SqlFileStream.cs
- Floater.cs
- ScriptManager.cs
- HttpRequestWrapper.cs
- EdmToObjectNamespaceMap.cs
- ToolStripSystemRenderer.cs
- Screen.cs
- VirtualPathExtension.cs
- AllMembershipCondition.cs
- LinqDataSourceUpdateEventArgs.cs
- HttpListenerContext.cs
- WSHttpBindingCollectionElement.cs
- EventLogPermission.cs
- CodeAttributeDeclaration.cs
- _HeaderInfoTable.cs
- AmbiguousMatchException.cs
- AdjustableArrowCap.cs
- XmlElementCollection.cs
- LZCodec.cs
- TableCellAutomationPeer.cs
- ManipulationDeltaEventArgs.cs
- EventHandlersStore.cs
- SafeNativeMemoryHandle.cs
- TabItemWrapperAutomationPeer.cs
- RepeatEnumerable.cs
- QueryCacheEntry.cs
- AssemblyAssociatedContentFileAttribute.cs
- ThaiBuddhistCalendar.cs
- ChtmlCommandAdapter.cs
- ClientOptions.cs
- Pkcs7Recipient.cs
- ListChangedEventArgs.cs
- Int64AnimationBase.cs
- MapPathBasedVirtualPathProvider.cs
- TimelineGroup.cs
- FastEncoderWindow.cs
- ETagAttribute.cs
- ModifiableIteratorCollection.cs
- CustomCategoryAttribute.cs
- PartManifestEntry.cs
- Random.cs