繁体中文
设为首页
加入收藏
当前位置:.Net技术首页 >> Asp.Net开发 >> ProgressStatusBar源代码(转自C#)

ProgressStatusBar源代码(转自C#)

2007-04-15 08:00:00  作者:  来源:互联网  浏览次数:0  文字大小:【】【】【
简介:摘自:http://discuss.develop.com/ 測試過,挺好的! public class ProgressStatusBar : System.Windows.Forms.StatusBar { public ProgressStatusBar() { this.SizingGrip = false; this.ShowPanels = true; } pr...

摘自: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; }

}

}

责任编辑:admin
相关文章