Touch event in Windows Mobile



















Presenting the "Bug terminator". Just a sample program to simulate the touch event
on Windows Mobile 5.0.

The bugs will move around the screen and you can prick it or move it around or flick it!

I also created one using Android and wow it's much simpler using the touchevent function. :)

Here's a portion of the codes.

Mouse Down
=========
Private Sub PictureBox_MouseDown( _
ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs)
'---record the initial x,y where the user taps---
Dim pic As PictureBox = CType(sender, PictureBox)

Dim pic3 As New PictureBox
pic3.Image = New Bitmap(path & "splat.jpg")
pic3.Width = 37
pic3.Height = 39
pic3.Left = pic.Left
pic3.Top = pic.Top
Panel1.Controls.Add(pic3)
_prevX = e.X
_prevY = e.Y

_prevTop = pic.Top
_prevLeft = pic.Left


Mouse Up
=======
ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs)
Dim i As Integer
Dim pic As PictureBox = CType(sender, PictureBox)

'---calculates the distance moved---

If picmove = 10 Then
For i = 1 To 50
If i > 0 And i <> 19 And i <> 39 And i < picmove =" 20" i =" 1"> 0 And i <> 19 And i <> 39 And i < move ="=" deltax =" (e.X" deltay =" (e.Y" picturebox =" CType(sender," text =" pic.Tag" x= " + pic.Left.ToString + " y=" "> 50 Then
picmove = 20 'left
End If
If (pic.Left - _prevLeft) < -50 Then picmove = 10 'right End If If (pic.Left - _prevLeft) <> -5 Then
picmove = 40 'right
End If

'If (pic.Top - _prevTop) > 0 Then
'picmove = 20 'left
'Else
'picmove = 10 'right
'End If

Timer event
=========

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If pic2.Top > 390 Then
changeNav = 1
End If
If pic2.Top < changenav =" 2" changenav =" 2" 2 =" 0"> 390 Then
changeNav2 = 1
End If
If pic.Top < changenav2 =" 2" changenav2 =" 2" 2 =" 0"> 390 Then
changeNav3 = 1
End If
If pic3.Top < 20 Then
changeNav3 = 2
End If


If changeNav3 = 2 Then
pic3.Top += 7
If pic3.Top Mod 2 = 0 Then
pic3.Left += 3
Else
pic3.Left -= 3
End If
Else
pic3.Top -= 7
End If
'pictures.Add(pic2)
End Sub

コメント

人気の投稿