首页 > 开发 > 综合 > 正文

ProgressStatusBar源代码(转自C#)

2024-07-21 02:24:20
字体:
来源:转载
供稿:网友


收集最实用的网页特效代码!

摘自:http://discuss.develop.com/
測試過,挺好的!

  public class progressstatusbar : system.windows.forms.statusbar
        {

                public progressstatusbar()
                {
                        this.sizinggrip = false;
                        this.showpanels = true;
                }
            
                protected override void
ondrawitem(statusbardrawitemeventargs e)
                {
                        if
(e.panel.gettype().tostring().endswith("progresspanel"))
                        {
                                progresspanel progresspanel =
(progresspanel) e.panel;

                                if (progresspanel.value >
progresspanel.minimum)
                                {
                                        int newwidth =
(int)(((double)progresspanel.value / (double)progresspanel.maximum) *
(double)progresspanel.width);
                                        rectangle newbounds = e.bounds;
                                        solidbrush paintbrush = new
solidbrush(progresspanel.forecolor);
                                        newbounds.width = newwidth;
    
e.graphics.fillregion(paintbrush, new region(newbounds));
                                        paintbrush.dispose();
                                }
                                else
                                {
                                        base.ondrawitem(e);
                                }
                        }
                        else
                        {
                                base.ondrawitem(e);
                        }
                }

                public void updatevalue(progresspanel progresspanel, int
newvalue)
                {
                        progresspanel.value = newvalue;
                }
        }

        public class progresspanel : system.windows.forms.statusbarpanel
        {
                private int m_minimum = 1;
                private int m_maximum = 100;
                private int m_value = 0;
                private color m_color;

                public progresspanel()
                {
                        this.style = statusbarpanelstyle.ownerdraw;
                        this.forecolor = color.darkblue;
                }

                public int minimum
                {
                        get { return m_minimum; }
                        set     { m_minimum = value; }
                }

                public int maximum
                {
                        get { return m_maximum; }
                        set     { m_maximum = value; }
                }
            
                public int value
                {
                        get { return m_value; }
                        set { m_value = value; }
                }

                public color forecolor
                {
                        get     { return m_color; }
                        set { m_color = value; }
                }
        }



发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表