import win.ui;
/*DSG{{*/
var winform = win.form(text="aardio form";right=759;bottom=469)
winform.add(
button={cls="button";text="动起来";left=0;top=440;right=119;bottom=470;db=1;dl=1;z=2};
button2={cls="button";text="暂停";left=134;top=440;right=253;bottom=470;db=1;dl=1;z=3};
static={cls="static";left=0;top=0;right=760;bottom=428;db=1;dl=1;dr=1;dt=1;notify=1;transparent=1;z=1}
)
/*}}*/

import cchart;

cchart.CreateChart();
cchart.Attach1(winform.static.hwnd,0);//kTypeXY=0 折线图
cchart.ChooseCurChart1(winform.static.hwnd);
//设置显示网格
cchart.SetGridLine(true,true,true,true,0);
//设置背景色
cchart.SetBkgndColor(0xFFE6C2,0);

var timeid;
var index = 0;

//开定时器
timeid = winform.setInterval(
	300,function(){
		cchart.AddPoint2D(index, math.random(0,50) ,0,0);
		cchart.ReDraw2();
		index++;
	}
);

winform.button.oncommand = function(id,event){
    //开定时器
	winform.changeInterval(timeid,300);
}
winform.button2.oncommand = function(id,event){
    if(timeid){
        //暂停定时器
    	winform.changeInterval(timeid,-1);	
    }
	
}

//防止闪烁
winform.static.onEraseBkgnd  = function(hwnd,message,wParam,lParam){
    return 0;//禁止擦除背景
};


winform.onClose = function(hwnd,message,wParam,lParam){
    cchart.Detach(winform.static.hwnd);
    cchart.DestroyChart();
}



winform.show();
win.loopMessage();
return winform;