Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Main")
 
    cvsGraph.Initialize(pnlGraph)
 
    InitGraph
 
    Timer1.Initialize("Timer1", 1000)
    Timer1.Enabled = True
    DrawRow
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Private Sub InitGraph
    dx = (pnlGraph.Width - 40dip) / 256
    x0 = (pnlGraph.Width - 256 * dx) / 1.8
    x1 = x0 + 256 * dx
    dy = (pnlGraph.Height - 40dip) / 60
    y0 = pnlGraph.Height - (pnlGraph.Height - 60 * dy) / 1.8
    y1 = y0 - 60 * dy
    cvsGraph.DrawLine(x0 - 4dip, y0, x1 + 6dip , y0, Colors.Black, 1dip)
    cvsGraph.DrawLine(x0, y0 + 4dip, x0 , y1 - 6dip, Colors.Black, 1dip)
    rectMoveSource.Initialize(x0, y0 - 59 * dy, x1, y0)
    rectMoveDest.Initialize(x0, y1, x1, y0 - dy)
End Sub
Private Sub DrawRow
    Private col, x, y As Int
    Private rct As Rect
 
    For col = 0 To 255
        x = x0 + col * dx
        y = y0 - dy
        rct.Initialize(x, y, x + dx, y0)
        cvsGraph.DrawRect(rct, Colors.RGB(Rnd(0, 256), Rnd(0, 256), Rnd(0, 256)), True, 1dip)
    Next
    pnlGraph.Invalidate
End Sub
Private Sub MoveRows
    cvsGraph.DrawBitmap(cvsGraph.Bitmap, rectMoveSource, rectMoveDest)
End Sub
Private Sub Timer1_Tick
    MoveRows
    DrawRow
End Sub