Hello guys!
I have 9 Pictureboxes on my form.
How can I arrange these boxes to look like a circle?
Printable View
Hello guys!
I have 9 Pictureboxes on my form.
How can I arrange these boxes to look like a circle?
Let me explain a bit better..
On my form I have this :
What I want to do is to show the nine pictureboxes on the circle's edge, meaning I want to dock those boxes on the circle's lines.Code:Imports System.Drawing.Drawing2D
Public Class frmPreview
Private bCircle As New Bitmap(1500, 1200)
'Declare The Graphics Object To Draw Onto
Private gCircle As Graphics = Graphics.FromImage(bCircle)
Private Sub frmPreview_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim pCirclePen As New Pen(Color.Black, 3)
Dim sStartX As Integer = picDraw.Left
Dim sStartY As Integer = picDraw.Top
Dim sEndX As Integer = picDraw.Width
Dim sEndY As Integer = picDraw.Height
gCircle.DrawEllipse(pCirclePen, sStartX, sStartY, sEndX - sStartX, sEndY - sStartY)
Me.picDraw.Image = bCircle
End Sub
End Class
Is it clearer now?
The red arrows on this picture, shows how I want the pictureboxes aligned.
I didvided the form into 4 parts :
I thought it would have been easier to calcualte the coords for each picture then.Code:Dim sTopLeftQuarter As Rectangle
sTopLeftQuarter.X = sStartX
sTopLeftQuarter.Y = sStartY
sTopLeftQuarter.Width = sCenterHorz
sTopLeftQuarter.Height = sCenterVert
Dim sTopRightQuarter As Rectangle
sTopRightQuarter.X = sCenterHorz
sTopRightQuarter.Y = sStartY
sTopRightQuarter.Width = sEndX
sTopRightQuarter.Height = sCenterVert
Dim sBottomLeftQuarter As Rectangle
sBottomLeftQuarter.X = sStartX
sBottomLeftQuarter.Y = sCenterVert
sBottomLeftQuarter.Width = sCenterHorz
sBottomLeftQuarter.Height = sEndY
Dim sBottomRightQuarter As Rectangle
sBottomRightQuarter.X = sCenterHorz
sBottomRightQuarter.Y = sCenterVert
sBottomRightQuarter.Width = sEndX
sBottomRightQuarter.Height = sEndY
Can anyone help?
vb Code:
PictureBox1.location = New Point(Xcircle + (Rayon*cos(angle)) - (PictureBox1.Width/2), Ycircle + (Rayon*sin(angle)) + (PictureBox1.Width/2))
thtis will set a pictureBox on the edge at an angle of ) degre. Then move around the circle with the angle and play with the sign in the formula to set the other pictureBoxes
Hello talkro!
Thanx for your wonderful advice!
Could you explain a bit more on what some of those mean?
Or, more clearly, how would I declare & initialise angle ,Rayon, Xcricle and so on.
PS: It said I must spread more reputations around..
OK, I took the long route ( probably wrong ) but, it works for me!
This is what I've done :
It looks perfect on a resolution of 800 x 600.Code:Imports System.Drawing.Drawing2D
Public Class frmPreview
Private bCircle As New Bitmap(700, 700)
'Declare The Graphics Object To Draw Onto
Private gCircle As Graphics = Graphics.FromImage(bCircle)
Private Sub frmPreview_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim pCirclePen As New Pen(Color.Black, 3)
Dim sStartX As Integer = picDraw.Left
Dim sStartY As Integer = picDraw.Top
Dim sEndX As Integer = picDraw.Width
Dim sEndY As Integer = picDraw.Height
Dim sCenterHorz As Integer = (picDraw.Width / 2)
Dim sCenterVert As Integer = (picDraw.Height / 2)
Dim sCenterPicHorz As Integer = (pic1.Width / 2)
Dim sCenterPicVert As Integer = (pic1.Height / 2)
Dim sQuarterHorz As Integer = (picDraw.Width / 4)
Dim sQuarterVert As Integer = (picDraw.Height / 4)
gCircle.DrawEllipse(pCirclePen, sStartX, sStartY, sEndX - sStartX, sEndY - sStartY)
Me.picDraw.Image = bCircle
pic1.Location = New System.Drawing.Point((sQuarterHorz / 2) + 25, sQuarterVert / 2)
pic2.Location = New System.Drawing.Point((sCenterHorz - sCenterPicHorz), 3)
pic3.Location = New System.Drawing.Point(((sQuarterHorz * 4) - 2) - (pic3.Width * 2), sQuarterVert / 2)
pic4.Location = New System.Drawing.Point(3, sCenterVert - sCenterPicVert)
pic5.Location = New System.Drawing.Point(sCenterHorz - sCenterPicHorz, sCenterVert - sCenterPicVert)
pic6.Location = New System.Drawing.Point(((sQuarterHorz * 4) - 2) - pic3.Width, sCenterVert - sCenterPicVert)
pic7.Location = New System.Drawing.Point((sQuarterHorz / 2) + 25, (((sQuarterVert * 4) + 2) - (pic7.Height * 2)))
pic8.Location = New System.Drawing.Point(sCenterHorz - sCenterPicHorz, (((sQuarterVert * 4) + 2) - pic7.Height - 3))
pic9.Location = New System.Drawing.Point(((sQuarterHorz * 4) - 2) - (pic3.Width * 2), (((sQuarterVert * 4) + 2) - (pic9.Height * 2)))
End Sub
End Class
Thanx anyways poeple!