module tool { author suo
     export class PageComponent { private _tfPage : eui . Label = null ; private _btnPre : tool . Button = null ; private _btnNext : tool . Button = null ; private _btnFinally : tool . Button = null ; private _changePage : Handler = null ; private _curPage : number = 1 ; private _maxPage : number = 1 ; private _showNum : number = - 1 ; private _startIndex : number = - 1 ; private _endIndex : number = - 1 ; param btnPre param btnNext param tfPage param btnFinally public constructor ( btnPre , btnNext = null , tfPage = null , btnFinally = null ) { this . _btnPre = btnPre ; this . _btnNext = btnNext ; this . _btnFinally = btnFinally ; this . _tfPage = tfPage ; if ( this . _btnPre != null ) { this . _btnPre . mouseClickHandler = Handler . create ( this , ( ) => { this . curPage -- ; } ) ; } if ( this . _btnNext != null ) { this . _btnNext . mouseClickHandler = Handler . create ( this , ( ) => { this . curPage ++ ; } ) ; } if ( this . _btnFinally != null ) { this . _btnFinally . mouseClickHandler = Handler . create ( this , ( ) => { this . curPage = this . maxPage ; } ) ; } } /**
         * 设置声音
         */ public setSound ( perBtnSound , nextBtnSound ) { this . _btnPre . setSound ( perBtnSound ) ; this . _btnNext . setSound ( nextBtnSound ) ; } public dispose ( ) { if ( this . _btnPre != null ) { this . _btnPre . dispose ( ) ; this . _btnPre = null ; } if ( this . _btnNext != null ) { this . _btnNext . dispose ( ) ; this . _btnNext = null ; } if ( this . _changePage != null ) { this . _changePage . recover ( ) ; this . _changePage = null ; } if ( this . _btnFinally != null ) { this . _btnFinally . dispose ( ) ; this . _btnFinally = null ; } this . _tfPage = null ; } /**无回调参数*/ public set onChangePage ( changePage ) { this . _changePage = changePage ; } public setData ( dataLength , showNum ) { this . _showNum = showNum ; this . _maxPage = Math . ceil ( dataLength / this . _showNum ) ; } public get maxPage ( ) : number { return this . _maxPage ; } public set maxPage ( value ) { this . _maxPage = value > 0 ? value : 1 ; } public get curPage ( ) : number { return this . _curPage ; } public set curPage ( value ) { if ( value >= 1 && value <= this . _maxPage ) { this . _curPage = value ; this . _startIndex = ( this . _curPage - 1 ) * this . _showNum ; this . _endIndex = this . _curPage * this . _showNum ; if ( this . _changePage != null ) { this . _changePage . run ( ) ; } if ( this . _btnPre != null ) { this . _btnPre . enabled = this . _curPage > 1 ; } if ( this . _btnNext != null ) { this . _btnNext . enabled = this . _curPage < this . _maxPage ; } if ( this . _btnFinally != null ) { this . _btnFinally . enabled = ! ( this . _curPage == this . _maxPage ) ; } } if ( this . _tfPage != null ) { this . _tfPage . text = this . _curPage + "/" + this . _maxPage ; } } /**Array.slice(startIndex, endIndex)*/ public get endIndex ( ) : number { return this . _endIndex ; } /**Array.slice(startIndex, endIndex)*/ public get startIndex ( ) : number { return this . _startIndex ; } } }