第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在C#.NET 3.5中更改Progressbar的顏色?

如何在C#.NET 3.5中更改Progressbar的顏色?

慕工程0101907 2019-11-27 13:07:27
我想在進(jìn)度欄上做兩件事。將綠色更改為紅色。卸下磚塊,使其成為一種顏色。我不知道如何完成有關(guān)這兩件事的任何信息,我們將不勝感激!謝謝。
查看完整描述

3 回答

?
慕碼人8056858

TA貢獻(xiàn)1803條經(jīng)驗(yàn) 獲得超6個贊

這是最受接受的代碼的無閃爍版本,您可以找到該問題的答案。所有這些都?xì)w功于這些致命答案的發(fā)布者。感謝Dusty,Chris,Matt和Josh!


就像其中一個評論中“ Fueled”的請求一樣,我還需要一個表現(xiàn)得更...專業(yè)的版本。此代碼與以前的代碼一樣保留樣式,但是添加了屏幕外圖像渲染和圖形緩沖(并正確處理了圖形對象)。


結(jié)果:一切正常,沒有閃爍。:)


public class NewProgressBar : ProgressBar

{

    public NewProgressBar()

    {

        this.SetStyle(ControlStyles.UserPaint, true);

    }


    protected override void OnPaintBackground(PaintEventArgs pevent)

    {

        // None... Helps control the flicker.

    }


    protected override void OnPaint(PaintEventArgs e)

    {

        const int inset = 2; // A single inset value to control teh sizing of the inner rect.


        using (Image offscreenImage = new Bitmap(this.Width, this.Height))

        {

            using (Graphics offscreen = Graphics.FromImage(offscreenImage))

            {

                Rectangle rect = new Rectangle(0, 0, this.Width, this.Height);


                if (ProgressBarRenderer.IsSupported)

                    ProgressBarRenderer.DrawHorizontalBar(offscreen, rect);


                rect.Inflate(new Size(-inset, -inset)); // Deflate inner rect.

                rect.Width = (int)(rect.Width * ((double)this.Value / this.Maximum));

                if (rect.Width == 0) rect.Width = 1; // Can't draw rec with width of 0.


                LinearGradientBrush brush = new LinearGradientBrush(rect, this.BackColor, this.ForeColor, LinearGradientMode.Vertical);

                offscreen.FillRectangle(brush, inset, inset, rect.Width, rect.Height);


                e.Graphics.DrawImage(offscreenImage, 0, 0);

                offscreenImage.Dispose();

            }

        }

    }

}


查看完整回答
反對 回復(fù) 2019-11-27
  • 3 回答
  • 0 關(guān)注
  • 1216 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號