Professional Documents
Culture Documents
Em n y, ch vic ko th vo Form l OK
Vy l phn giao din l n ri, by gi ko thm timer ra, mc ch to thi gian chy trong phn th.
Timer th hin y l c.
// Khai bo 1 bin dng cho timer, chy ct thi gian tnh bng ms int tickStart = 0; public Form1() { InitializeComponent(); }
private void Form1_Load(object sender, EventArgs e) { // khi khi ng s c chy GraphPane myPane = zedGraphControl1.GraphPane; // Khai bo sa dng Graph loi GraphPane; // Cc thng tin cho th ca mnh myPane.Title.Text = "y l title trn cng, bn thay i cho ph hp vi chng trnh"; myPane.XAxis.Title.Text = "Thi gian ct X"; myPane.YAxis.Title.Text = "Tiu ct Y"; // nh ngha list v th. cc bn hiu r c ch lm vic y khai bo 2 list im <=> 2 ng th RollingPointPairList list1 = new RollingPointPairList(1200);
// tin cho vic s dng chng ta s xy dng 1 hm draw phc v cho vic v th public void draw(double setpoint1, double setpoint2) // v d ny chng ta c 2 ng { if (zedGraphControl1.GraphPane.CurveList.Count <= 0) return; // Kim tra vic khi to cc ng curve // a v im xut pht LineItem curve1 = zedGraphControl1.GraphPane.CurveList[0] as LineItem; LineItem curve2 = zedGraphControl1.GraphPane.CurveList[1] as LineItem; if (curve1 == null) return; if (curve2 == null) return; // list cha cc im. // Get the PointPairList IPointListEdit list1 = curve1.Points as IPointListEdit; IPointListEdit list2 = curve2.Points as IPointListEdit;
gi hm v chng ta s kch hot cho Timer1 chy, p vo Timer1 ly s kin, sau vit code nh code tham kho bn di.
private void timer1_Tick(object sender, EventArgs e) { draw(5,20); }
10
11
Hnh trn l thi gian chy ( th dch tnh tin), hnh bn di bt u t 0 (dn li)
12