Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Adding a step size #1

Closed
TheMinefighter opened this issue Jun 28, 2018 · 1 comment · Fixed by #50 or #53
Closed

Feature Request: Adding a step size #1

TheMinefighter opened this issue Jun 28, 2018 · 1 comment · Fixed by #50 or #53

Comments

@TheMinefighter
Copy link

Sometimes a custom Step Size would be really useful, which would change by how much the arrows change the value. Implementation in the OnIncrease and OnDecrease method as follows:

        /// <summary>
        /// Increase the displayed integer value
        /// </summary>
        protected virtual void OnIncrease()
        {
            if (this.Value >= this.MaxValue)
            {
                // Value is not incremented if it is already maxed or above
                this.Value = this.MaxValue;
            }
            else
            { 
                if (this.Value + this.StepSize <= this.MaxValue)
                    this.Value = (int) (this.Value + this.StepSize);
                else
                {
                    if (this.Value <= this.MinValue)
                    {
                        // Value is not incremented if it is already min or below
                        this.Value = this.MinValue;
                    }
                }
            }
        }

        /// <summary>
        /// Decrease the displayed integer value
        /// </summary>
        protected virtual void OnDecrease()
        {
            if (this.Value <= this.MinValue)
            {
                // Value is not decremented if it is already minimum or below
                this.Value = this.MinValue;
            }
            else
            {
                if (this.Value - this.StepSize > this.MinValue)
                    this.Value = (int) (this.Value - this.StepSize);
                else
                {
                    if (this.Value >= this.MaxValue)
                    {
                        // Value is not incremented if it is already maxed or above
                        this.Value = this.MaxValue;
                    }
                }
            }
        }
Dirkster99 added a commit that referenced this issue Jun 28, 2018
@Dirkster99
Copy link
Owner

Dirkster99 commented Jun 28, 2018

Thanks for the good feature description - its implemented with version 1.0.3 of the library and nuget package (it may take some time until you can download the opackage:
Dirkster.NumericUpDownLib 1.0.3

as soon as its available on nuget (usually 30-60 mins).

I close this assuming its resolved but feel free to re-open should you find problems with this.

Install-Package Dirkster.NumericUpDownLib -Version 1.0.3

Dirkster99 added a commit that referenced this issue Oct 20, 2022
Fix #1: FormatString not working with custom texts, Fix #2: Control not scaling correctly with HorizontalAlignment set to "Stretch"
Dirkster99 added a commit that referenced this issue Oct 20, 2022
…ontrol not scaling correctly with HorizontalAlignment set to "Stretch""
Dirkster99 added a commit that referenced this issue Oct 20, 2022
Revert "Fix #1: FormatString not working with custom texts, Fix #2: Control not scaling correctly with HorizontalAlignment set to "Stretch""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment