程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> 關於C語言 >> ProgressStatusBar源代碼

ProgressStatusBar源代碼

編輯:關於C語言
 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; }
                }
        }


  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved