Results 1 to 6 of 6

Thread: [RESOLVED] [2005] Arrange Pictureboxes in a Circle

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2005
    Posts
    384

    Resolved [RESOLVED] [2005] Arrange Pictureboxes in a Circle

    Hello guys!
    I have 9 Pictureboxes on my form.
    How can I arrange these boxes to look like a circle?

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2005
    Posts
    384

    Re: [2005] Arrange Pictureboxes in a Circle

    Let me explain a bit better..
    On my form I have this :
    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
    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.
    Is it clearer now?

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2005
    Posts
    384

    Re: [2005] Arrange Pictureboxes in a Circle

    The red arrows on this picture, shows how I want the pictureboxes aligned.
    I didvided the form into 4 parts :
    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
    I thought it would have been easier to calcualte the coords for each picture then.

    Can anyone help?
    Attached Images Attached Images  

  4. #4
    Fanatic Member
    Join Date
    Feb 2007
    Location
    Eindhoven
    Posts
    828

    Re: [2005] Arrange Pictureboxes in a Circle

    vb Code:
    1. 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

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2005
    Posts
    384

    Re: [2005] Arrange Pictureboxes in a Circle

    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..

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2005
    Posts
    384

    Re: [2005] Arrange Pictureboxes in a Circle

    OK, I took the long route ( probably wrong ) but, it works for me!
    This is what I've done :
    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
    It looks perfect on a resolution of 800 x 600.

    Thanx anyways poeple!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width