C# 怎么画这图?多谢 = 师傅让我做个图从3000到5000之间取出 200个随机数,每秒20个,然后实时显示,,各位高人们这个怎么做啊? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 有三种方式第一种、使用GDI+的graphic类;第二种、使用WPF的drawingvisual类;第三种、使用托管directx的device类。具体使用方法你可以看这些类的成员。 具体怎么去实现啊?我刚接触C#,不知道从哪儿下手,谁有个什么小例子啥的不?谢谢啊,我邮箱[email protected] http://msdn.microsoft.com/zh-cn/library/ms771684(v=vs.90).aspx int[] arr = new int[20]; private void timer1_Tick(object sender, EventArgs e) { Random rand = new Random(); for (int i = 0; i < 20; i++) { arr[i] = rand.Next(3000, 5000); } this.Invalidate(); } private void DrawItems(int[] arr,Graphics g) { for (int i = 0; i < arr.Length; i++) { g.DrawString(arr[i].ToString(), this.Font, new SolidBrush(Color.Red), 0, 20 * i); } } private void Form1_Paint(object sender, PaintEventArgs e) { DrawItems(arr, e.Graphics); } public partial class Form1 : Form{ Timer timer = new Timer(); Random random = new Random(); List<PointF> points = new List<PointF>(); public Form1() { InitializeComponent(); this.DoubleBuffered = true; timer.Interval = 1000 / 20; timer.Tick += delegate { this.Invalidate(); }; timer.Start(); } protected override void OnPaint(PaintEventArgs e) { const int SampleCount = 200, Min = 3000, Max = 5000; if (points.Count < SampleCount) { this.points.Add(new PointF( this.Width / (SampleCount + 1.0f) * (1 + points.Count), this.Height / (Max - Min + 1.0f) * (random.Next(Min, Max) - Min) )); } if (points.Count > 1) { e.Graphics.DrawLines(Pens.Blue, points.ToArray()); } }} 谢谢大家那我在picturebox里显示那些怎么是一点一点的啊,用鼠标点一下那个窗口就出点,这是为什么呢? 200分吸引火力 关于web service生成wsdl spreadsheet控件中LanguageSettings属性的用法 计算运行时间 [=============]datagridview 如何 达到这个效果 商品跟 商品属性表设计问题,请各位赐教 如何让TabControl中的TabItem不可拖动 这个DataSet应该怎么处理啊,难,马上给分 .net c# 网站发布遇到的问题 请 大神将C#这段代码翻译成Delphi 或者告知是什么意思!!谢谢各位大神了!! vb中退出子程序用exit sub ,c#中有与这个相似的方法吗? 进来看看,帮我一下了! 远程USB视频监控
第一种、使用GDI+的graphic类;
第二种、使用WPF的drawingvisual类;
第三种、使用托管directx的device类。
具体使用方法你可以看这些类的成员。
int[] arr = new int[20]; private void timer1_Tick(object sender, EventArgs e)
{
Random rand = new Random();
for (int i = 0; i < 20; i++)
{
arr[i] = rand.Next(3000, 5000);
}
this.Invalidate(); } private void DrawItems(int[] arr,Graphics g)
{
for (int i = 0; i < arr.Length; i++)
{
g.DrawString(arr[i].ToString(), this.Font, new SolidBrush(Color.Red), 0, 20 * i);
}
} private void Form1_Paint(object sender, PaintEventArgs e)
{
DrawItems(arr, e.Graphics); }
public partial class Form1 : Form
{
Timer timer = new Timer();
Random random = new Random();
List<PointF> points = new List<PointF>(); public Form1()
{
InitializeComponent();
this.DoubleBuffered = true;
timer.Interval = 1000 / 20;
timer.Tick += delegate { this.Invalidate(); };
timer.Start();
} protected override void OnPaint(PaintEventArgs e)
{
const int SampleCount = 200, Min = 3000, Max = 5000;
if (points.Count < SampleCount)
{
this.points.Add(new PointF(
this.Width / (SampleCount + 1.0f) * (1 + points.Count),
this.Height / (Max - Min + 1.0f) * (random.Next(Min, Max) - Min)
));
}
if (points.Count > 1)
{
e.Graphics.DrawLines(Pens.Blue, points.ToArray());
}
}
}
那我在picturebox里显示那些怎么是一点一点的啊,用鼠标点一下那个窗口就出点,这是为什么呢?