Progress bar и многое другое - C#

Узнай цену своей работы

Формулировка задачи:

Люди, смотрите, есть progress bar допустим ну и типа того. Допустим я хочу свой prgress bar ? что мне делать ? Допустим я нарисовал на фотошопе сам свой Progress Bar и хочу его использовать и что мне делать ? + допустим я нарисовал свой ComboBox , либо TextBox - как его использовать ? Чтоб он имел те же функции что и обычный системный CobmoBox , либо там ProgressBar но имел красивую оболочку ?

Решение задачи: «Progress bar и многое другое»

textual
Листинг программы
class MyProgressBar : Control
{
    int  value;
    int  maxValue;
    bool drawValueInfo;
 
    public MyProgressBar ( )
    {
        this.DoubleBuffered = true;
 
        this.maxValue = 100;
        this.value = 20;
    }
 
    protected override void OnPaint ( PaintEventArgs e )
    {
        float temp    = (float)this.value / (float)this.maxValue;
        int   percent = (int)(temp * 100f);
        int   part    = (int)(temp * this.Width);
 
        var g = e.Graphics;
 
        g.FillRectangle( Brushes.Orange, 0, 0, part, this.Height - 1 );
        g.DrawRectangle( Pens.Black, 0, 0, this.Width - 1, this.Height - 1 );
 
        if ( this.drawValueInfo )
            TextRenderer.DrawText(
                g, percent + "%", this.Font,
                new Rectangle(
                    0, 0,
                    this.Width - 1,
                    this.Height - 1
                    ),
                Color.Black,
                TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter |
                    TextFormatFlags.ExternalLeading
                    );
    }
 
    [Browsable( true )]
    public int Maximum
    {
        get { return this.maxValue; }
        set
        {
            if ( value < 0 )
                throw new ArgumentOutOfRangeException();
 
            if ( this.maxValue == value )
                return;
            if ( this.value > value )
                this.value = value;
 
            this.maxValue = value;
            this.Invalidate();
        }
    }
 
    [Browsable( true )]
    public int Value
    {
        get { return this.value; }
        set
        {
            if ( value < 0 || value > this.maxValue )
                throw new ArgumentOutOfRangeException();
 
            if ( this.value == value )
                return;
 
            this.value = value;
            this.Invalidate();
        }
    }
 
    [Browsable( true )]
    public bool DrawValueInfo
    {
        get { return this.drawValueInfo; }
        set
        {
            if ( this.drawValueInfo == value )
                return;
 
            this.drawValueInfo = value;
            this.Invalidate();
        }
    }
}

ИИ поможет Вам:


  • решить любую задачу по программированию
  • объяснить код
  • расставить комментарии в коде
  • и т.д
Попробуйте бесплатно

Оцени полезность:

11   голосов , оценка 4 из 5