为进度条值选择哪种颜色 [英] which colours to choose for progress bar values

查看:250
本文介绍了为进度条值选择哪种颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows窗体中,
我正在使用组合框(cboProgress)和ProgressBar(prgProgress)
在组合框的selectedindexchanged事件中(该填充了10到100的数字,间隔为10),我想将进度条的值设置为组合框的选定值.并根据组合框中选择的数字用不同的颜色填充进度栏的前色.

问题:
您能否根据组合框中的选定值给出用于填充进度条前景色的颜色的建议?
这是我所拥有的,但是在设置颜色时我需要帮助.
对颜色有什么建议吗?

谢谢

In windows form,
I am using a combobox (cboProgress) and a ProgressBar (prgProgress)
In the selectedindexchanged event of the combobox (which is populated with numbers from 10 to 100 at interval of 10), I would like to set the value of the progressbar to the selected value of the combobox. And fill the forecolor of the progressbar with a different colour according to the selected number in the combobox.

Question:
Can you please give suggestions on the colours to use for filling the forecolor of the progress bar based on the selected value in the combobox?
This is what I have but I need help in setting the colours please.
Any suggestions on the colours please?

Thanks

private void cboProgress_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cboProgress.SelectedIndex > 0)
            {
                switch (int.Parse(cboProgress.Text))
                {
                    case 10:
                        prgProgress.ForeColor = Color.?;
                        break;
                    case 20:
                        prgProgress.ForeColor = Color.?;
                        break;
                    case 30:
                        prgProgress.ForeColor = Color.?;
                        break;
                    case 40:
                        prgProgress.ForeColor = Color.?;
                        break;
                    case 50:
                        prgProgress.ForeColor = Color.?;
                        break;
                    case 60:
                        prgProgress.ForeColor = Color.?;
                        break;
                    case 70:
                        prgProgress.ForeColor = Color.?;
                        break;
                    case 80:
                        prgProgress.ForeColor = Color.?;
                        break;
                    case 90:
                        prgProgress.ForeColor = Color.?;
                        break;
                    case 100:
                        prgProgress.ForeColor = Color.DarkGreen;
                        break;
                }
                prgProgress.Value = int.Parse(cboProgress.Text);
            }
        }

推荐答案

如果您想更改颜色,则可以将它们从红色(0)平滑更改为绿色(100)

因此,随着它变得更绿色,它变得更加完整.

由于红色是0xff0000,绿色是0x00ff00,因此您可以很容易地计算出给定完成百分比的每个值

那就是R分量= 255 *(100-percentComplete)/100
G分量= 255 * percentComplete/100

这样做的好处是您可以在任何情况下使用它,而不仅是您所描述的情况
If you want to change the colors then I would change them smoothly from red (0) through to green (100)

So as it gets greener, it''s more complete.

As red is 0xff0000 and green is 0x00ff00 you could quite easily calculated the values of each given the percentage of completion

That is the R component = 255 *(100 - percentComplete) / 100
The G component = 255 * percentComplete / 100

Doing it that way has the advantage that you can use it with any situation not just the one you describe


使用绿色来显示进度


这篇关于为进度条值选择哪种颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆