Click here to Skip to main content
15,748,098 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am creating a form on which there is a circle on the form and inside this circle i want to add different shapes(user defined) and then fill those shapes with different colors.

Some times the shapes are all circles and some times there are not specified shapes

How can i do this?
Sergey Alexandrovich Kryukov 15-Jul-14 3:46am    
Do you mean System.Windows.Forms? What's wrong with just reading original MSDN documentation where everything is clearly explained? What have you tried so far? What is your difficulty?
Yellow_Flash 15-Jul-14 5:08am    
I have read the MSDN documents that was helpful but what i want to draw is not explain in words i want to show you a sample of that but could not find any way to upload a picture?

Share this answer
Yellow_Flash 15-Jul-14 5:11am    
All these links are helpful but not what i want to create!
Sergey Alexandrovich Kryukov 15-Jul-14 11:26am    
But this is exactly the problem I pointed out. You never properly explained what you wanted to create.
Yellow_Flash 16-Jul-14 4:05am    
Is there a way to upload a picture here ?
Because what I am trying to create is not explainable thorough words!
Sergey Alexandrovich Kryukov 16-Jul-14 9:34am    
No. And there is no a need for that. You can always formulate what do you need in principle. Who want to look at your picture? It will be your implementation detail. Well, no, sometimes a picture would help, but shapes... What's the difference how they look? I already answered your question, anyway. What is unclear? You are always welcome to ask some follow-up questions. Are you going to accept the answer formally (green "Accept" button)?
Yellow_Flash wrote:
Here is one of the drawing I wanted to create
But every time circle size and color should be changed but in this it is a same drawing every time

And if i want to add some other shapes in the circle then i don't have any idea to do so?
What you need is animation. You can use some data model of your graphics and the rendering procedure from data to rendering using the functions you show, called from overridden OnPaint or a handler of the event Paint of some control where you render it. Then you should have some thread doing animation on the data model. This thread should notify the UI thread using Control.Invoke, and invoked method should cause refresh of the graphics in each change using one or more of the Control.Invalidate methods. Please see my past answers:

How to speed up my application?[^],
What kind of playful method is Paint? (DataGridViewImageCell.Paint(...))[^],
capture the drawing on a panel[^],
Drawing Lines between mdi child forms[^].

You can use this technique in all cases when you graphics changes; not only for animation, but for any changing behavior: interactive, animated, combination of those, changing with time by any other events.

Share this answer
Here is one of the drawing I wanted to create
But every time circle size and color should be changed but in this it is a same drawing every time

And if i want to add some other shapes in the circle then i don't have any idea to do so?

Private Sub DrawCircle()
Dim g As Graphics
g = Panel1.CreateGraphics
Dim yellowPen As New Pen(Color.Yellow, 20)
Dim bluePen As New Pen(Color.Blue, 30)
Dim greenPen As New Pen(Color.Green, 20)
Dim skybluePen As New Pen(Color.AliceBlue, 20)
Dim voiletPen As New Pen(Color.Violet, 15)
Dim blackPen As New Pen(Color.Black, 2)

' Draw ellipses
g.DrawEllipse(yellowPen, 260, 180, 10, 10)

g.DrawEllipse(greenPen, 240, 160, 50, 50)

g.DrawEllipse(bluePen, 220, 140, 90, 90)

g.DrawEllipse(greenPen, 200, 120, 130, 130)

g.DrawEllipse(skybluePen, 180, 100, 170, 170)

g.DrawEllipse(blackPen, 180, 100, 170, 170)

g.DrawEllipse(voiletPen, 170, 90, 190, 190)

End Sub

 Private Sub Panel1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
End Sub
Share this answer
Yellow_Flash 16-Jul-14 3:11am    
@Sergey Alexandrovich Kryukov
This is what i have tried
Sergey Alexandrovich Kryukov 16-Jul-14 9:36am    
You should add a comment, not a solution, and add the code to the question using "Improve question". Such posts are considered as abuse, because this is not an answer. I'll answer you.
Yellow_Flash 18-Jul-14 0:46am    
Sorry I am new here and don't know how to properly add my solution here but thanks for the help i ill keep it mind next time

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900