Not sure if I am going about it the right way but i have got it to work by adding a second path for anti clockwise
==================================================
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
initialize1()
initialize2()
End Sub
Private boxes1 As New List(Of PictureBox)
Private path1 As New Drawing2D.GraphicsPath
Dim pts1 As New List(Of Point)
Private Sub initialize1()
'get pictureboxes into a list and their locations into an array
For Each c As Control In Me.Controls
If TypeOf c Is PictureBox Then
boxes1.Add(c)
pts1.Add(c.Location)
End If
Next
'use GraphicsPath to add the location points
'in this case this will result in a nice circle with 2 point between each picturebox
path1.AddClosedCurve(pts1.ToArray)
'there are now 19 points in path.PathPoints array, first equals last (closed figure)
'get the index of the picturebox location point in the path.PathPoints
'and set it in the Tag of the box for later reference
Dim pb As PictureBox
For p As Integer = 0 To boxes1.Count - 1
pb = boxes1(p)
For i As Integer = 1 To path1.PathPoints.Length - 1
If pb.Location = path1.PathPoints(i) Then
pb.Tag = i
End If
Next
Next
End Sub
Private boxes2 As New List(Of PictureBox)
Private path2 As New Drawing2D.GraphicsPath
Dim pts2 As New List(Of Point)
Private Sub initialize2()
'get pictureboxes into a list and their locations into an array
For Each c As Control In Me.Controls
If TypeOf c Is PictureBox Then
boxes2.Add(c)
pts2.Add(c.Location)
End If
Next
pts2.Reverse()
'use GraphicsPath to add the location points
'in this case this will result in a nice circle with 2 point between each picturebox
path2.AddClosedCurve(pts2.ToArray)
'there are now 19 points in path.PathPoints array, first equals last (closed figure)
'get the index of the picturebox location point in the path.PathPoints
'and set it in the Tag of the box for later reference
Dim pb As PictureBox
For p As Integer = 0 To boxes1.Count - 1
pb = boxes2(p)
For i As Integer = 1 To path2.PathPoints.Length - 1
If pb.Location = path2.PathPoints(i) Then
pb.Tag = i
End If
Next
Next
End Sub
' un-comment this to see the path drawn on form:
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
e.Graphics.DrawPath(Pens.Blue, path1)
e.Graphics.DrawPath(Pens.Red, path2)
End Sub
'just to see which box is which, draws the name
Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) _
Handles PictureBox1.Paint, PictureBox6.Paint, PictureBox5.Paint, PictureBox4.Paint, PictureBox3.Paint, PictureBox2.Paint
Dim pb As PictureBox = sender
e.Graphics.DrawString(pb.Name, Me.Font, Brushes.Blue, 0, 0)
End Sub
Private Sub btnRotateclock_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRotateclock.Click
'animation handled by the BackgroundWorker asynchronous in order to not sleep UI thread
If Not BackgroundWorker1.IsBusy Then
BackgroundWorker1.RunWorkerAsync()
End If
End Sub
Private Sub btnRotateanticlock_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRotateanticlock.Click
'animation handled by the BackgroundWorker asynchronous in order to not sleep UI thread
If Not BackgroundWorker2.IsBusy Then
BackgroundWorker2.RunWorkerAsync()
End If
End Sub
Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
'rotate each picturebox three steps in the path.PathPoints array.
'this will move each box to the next main location point
For x As Integer = 0 To 2
BackgroundWorker1.ReportProgress(0) 'report to UI thread
If x < 2 Then Threading.Thread.Sleep(200) 'sleep thread 200 milliseconds between each step
Next
End Sub
Private Sub BackgroundWorker1_ProgressChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles BackgroundWorker1.ProgressChanged
rotate1()
End Sub
Private Sub BackgroundWorker2_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker2.DoWork
'rotate each picturebox three steps in the path.PathPoints array.
'this will move each box to the next main location point
For x As Integer = 0 To 2
BackgroundWorker2.ReportProgress(0) 'report to UI thread
If x < 2 Then Threading.Thread.Sleep(200) 'sleep thread 200 milliseconds between each step
Next
End Sub
Private Sub BackgroundWorker2_ProgressChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles BackgroundWorker2.ProgressChanged
rotate2()
End Sub
Private Sub rotate1()
'rotates each picturebox one step in the path.PathPoints array
Dim i As Integer
For Each pb As PictureBox In boxes1
i = pb.Tag
i -= 1
If i = 0 Then i = path1.PathPoints.Length - 1
pb.Location = Point.Round(path1.PathPoints(i))
pb.Tag = i
pb.Refresh()
Next
End Sub
Private Sub rotate2()
'rotates each picturebox one step in the path.PathPoints array
Dim i As Integer
For Each pb As PictureBox In boxes2
i = pb.Tag
i -= 1
If i = 0 Then i = path2.PathPoints.Length - 1
pb.Location = Point.Round(path2.PathPoints(i))
pb.Tag = i
pb.Refresh()
Next
End Sub
End Class
=============================================================
But of course now the problem is when you rotate clockwise a few times then rotate anticlockwise
the pictureboxs are not in the correct places as they move to the starting point of path2 instead of moving backward from where
path1 has left off
I'm trying to say something like this on btnrotateanticlockwise button
path2.current.pathpoints = path1.current.pathpoints
have not figured this out yet ... not sure if I'm going about it the right way but ill keep playing with it