ScrollView Example Timer?

School Boy Error

Member
Licensed User
Longtime User
Hi,

I've been using the scroll view code from the tutorial source code and I don't understand the timer or deltascroll parts. Can anyone help?
 

klaus

Expert
Licensed User
Longtime User
Sorry for answering somewhat late, but I was quite busy the last days.

In the ScrollViewExample program you can scroll the table horizontally either with
- the Seekbar skbScroll, this one is by default hidden.
- a 'dynamic' scrolling using the Panel pnlScroll.

In the pnlScroll_Touch routine, with:
- ACTION_DOWN we memorize the current 'finger' position MoveX0 = X and MoveX1 = X and the current Left property of the ScrollView MoveLeft0 = -scvPersons.Left
- ACTION_MOVE we calculate the new Left property of the ScrollView with Left = MoveLeft0 + (MoveX0 - X),
check the left and right limits and move the ScrollView and the Header Panel,
then we calculate the position difference between the current position and the previous one DeltaX = X - MoveX1 and we memorize the current 'finger' position MoveX1 = X.
- ACTION_UP we calculate the time between ACTION_DOWN and ACTION_UP Time0 = (DateTime.Now - Time0),
then calculate a kind of 'scrolling speed' DeltaScroll = (X - MoveX0) / Time0 * 80
and if DeltaX and DeltaScroll are higher the the given values we enable the timer.

In the Timer1_Tick routine we continue to move the ScrollView and the Header Panel by the pseudo 'scrolling speed' DeltaScroll and decrease DeltaScroll at each Tick DeltaScroll = DeltaScroll / 1.2.
We stop the Timer when the absolut value of DeltaScroll is less than 5dip If Abs(DeltaScroll) < 5dip Then.

The higher the 'speed' the further we move the ScrollView and the Header Panel.

I hope that the explanation is clear enough.

Best regards.
 
Upvote 0
Top