c#怎样画出像任务管理器那样的线

cgstian 2009-03-02 10:40:55
想画出那样动态变化的线,根据传进来的数据,曲线进行变化
...全文
142 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
月光下的土豆 2009-03-02
  • 打赏
  • 举报
回复
收藏
xuyiazl 2009-03-02
  • 打赏
  • 举报
回复
SmartThreadPool 的开源包里有UsageControl
Dobzhansky 2009-03-02
  • 打赏
  • 举报
回复
xuyiazl:
STP = SmartThreadPool
^_^
Dobzhansky 2009-03-02
  • 打赏
  • 举报
回复
jinjazz 那个不错
另外, SmartThreadPool 那个文件的源码里头也有一个类似的控件
xuyiazl 2009-03-02
  • 打赏
  • 举报
回复
cgstian 2009-03-02
  • 打赏
  • 举报
回复
一楼的大哥我QQ304903797,可以详细讲讲么?
jinjazz 2009-03-02
  • 打赏
  • 举报
回复
代码参考

http://www.codeproject.com/KB/miscctrl/SimplePerfChart.aspx
北京的雾霾天 2009-03-02
  • 打赏
  • 举报
回复
可以参考一下下面的代码:

public Form1()
{
InitializeComponent();
this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw, true);
}
private PerformanceCounter _oPerformanceCounter;
private Queue<float> queue;
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
this._oPerformanceCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total");
this.queue = new Queue<float>();
Timer timer = new Timer();
timer.Interval = 200;
timer.Tick += new EventHandler(timer_Tick);
timer.Start();
}

void timer_Tick(object sender, EventArgs e)
{
float _nVal = _oPerformanceCounter.NextValue();
this.queue.Enqueue(_nVal);
if (this.queue.Count > 50)
{
this.queue.Dequeue();
}
this.Invalidate();
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
if (this.queue.Count > 1)
{
float[] fa = this.queue.ToArray();

for (int i = 1; i < fa.Length; i++)
{
e.Graphics.DrawLine(SystemPens.ControlText, i * 5, this.ClientRectangle.Height - fa[i] * this.ClientRectangle.Height / 100, (i - 1) * 5, this.ClientRectangle.Height - fa[i - 1] * this.ClientRectangle.Height / 100);
}
}
}
protected override void OnFormClosed(FormClosedEventArgs e)
{
base.OnFormClosed(e);
_oPerformanceCounter.Dispose();
}
...

62,267

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧