times on Rentacoder because of various reasons... too difficult, wants
more $, needs complete rewrite, and coder never got bit acceptance.
The snippet below is a working example of a VB6 program. How would one
do the below in VB.Net?
Thanks for any help.
Expand|Select|Wrap|Line Numbers
- Option Explicit
- Private nPicMidX As Single
- Private nPicMidY As Single
- Private nPicWidth As Single
- Private nPicHeight As Single
- Private clickX As Single
- Private clickY As Single
- Private Sub Form_Load()
- With picImage(0)
- nPicMidX = .Width / 2
- nPicMidY = .Height / 2
- nPicWidth = .Width
- nPicHeight = .Height
- End With 'picImage(0)
- End Sub
- Private Sub Form_MouseDown(Button As Integer, _
- Shift As Integer, _
- X As Single, _
- Y As Single)
- Dim SelectedImg As Integer
- FindImage X, Y
- moveImage SelectedImg, 0, 0
- End Sub
- Private Sub moveImage(ImageIndex As Integer, _
- ByVal DX As Single, _
- ByVal DY As Single)
- Dim newTop As Single
- Dim newLeft As Single
- With picImage(ImageIndex)
- newTop = .Top + DY
- newLeft = .Left + DX
- .Top = newTop
- .Left = newLeft
- End With 'picImage(ImageIndex)
- moveImageLinks ImageIndex, newLeft + nPicMidX, newTop + nPicMidY
- End Sub
- Private Sub moveImageLinks(ByVal ImageIndex As Integer, _
- ByVal newx As Single, _
- ByVal newy As Single)
- If ImageIndex = 0 Then
- lineLink(0).X1 = newx
- lineLink(0).Y1 = newy
- Else
- lineLink(0).X2 = newx
- lineLink(0).Y2 = newy
- End If
- End Sub
- Private Sub picImage_MouseDown(Index As Integer, _
- Button As Integer, _
- Shift As Integer, _
- X As Single, _
- Y As Single)
- clickX = X
- clickY = Y
- End Sub
- Private Sub picImage_MouseMove(Index As Integer, _
- Button As Integer, _
- Shift As Integer, _
- X As Single, _
- Y As Single)
- If Button = 1 Then
- moveImage Index, X - clickX, Y - clickY
- End If
- End Sub
- Private Function FindImage(ByVal X As Single, _
- ByVal Y As Single) As Integer
- Dim myImg As Variant
- For Each myImg In picImage
- If myImg.Left < X Then
- If ((myImg.Left + myImg.Width) > X) Then
- If myImg.Top < Y Then
- If ((myImg.Top + myImg.Height) > Y) Then
- FindImage = myImg.Index
- Exit Function
- End If
- End If
- End If
- End If
- Next myImg
- FindImage = 0
- End Function