Advertisement
Advertisement
| 04.16.2008 at 10:15PM PDT, ID: 23329825 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: |
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
Public Class UserControl1
Private Sub UserControl1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not MoveImage Is Nothing Then
X1 = (Me.Width / 2) - (MoveImage.Width / 2)
X2 = (Me.Width / 2) + (MoveImage.Width / 2)
Y1 = (Me.Height / 2) - (MoveImage.Height / 2)
Y2 = (Me.Height / 2) + (MoveImage.Height / 2)
Invalidate()
End If
End Sub
Dim X1, X2, Y1, Y2 As Integer 'For finding out where the Pointer will be relative to the cursor.
Dim IsMouseDown As Boolean 'Is the cursor pressed down.
Private MoveImage As Bitmap
Public Property PointerImage() As Bitmap
Get
Return MoveImage
End Get
Set(ByVal value As Bitmap)
MoveImage = value
End Set
End Property
Private Sub UserControl1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
IsMouseDown = True
End Sub
Private Sub UserControl1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
If IsMouseDown = True Then
If X1 < 300 And X1 > 0 Then
X1 = e.X - MoveImage.Width / 2
Invalidate()
ElseIf X1 > 299 Then
X1 = e.X - MoveImage.Width / 2
Invalidate()
End If
End If
End Sub
Private Sub UserControl1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
IsMouseDown = False
End Sub
Private Sub UserControl1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
If Not MoveImage Is Nothing Then
e.Graphics.DrawImage(MoveImage, New PointF(X1, Y1))
End If
End Sub
End Class
|