Solved

Help With Code Please

Posted on 2006-11-06
5
262 Views
Last Modified: 2010-04-16
Hi,
I  am using the following code to produce a ring on the screen however I would like to change the color of the in four parts

based on 360'   0'-90' Green, 90'-180, yellow 180'-315' red, 315'-0' blue

     private void button1_Click(object sender, System.EventArgs e)
     {
          this.TransparencyKey = Color.WhiteSmoke;
          this.BackColor = Color.WhiteSmoke;
          this.Refresh();
          Graphics g = this.CreateGraphics();
          g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
          g.DrawEllipse(new Pen(Brushes.Yellow, 6f), 5, 5, 700, 700);
     }
0
Comment
Question by:schenkp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 16

Expert Comment

by:muzzy2003
ID: 17880347
Try the FillPie method with a new SolidBrush to fill it. Will post code in a minute.
0
 
LVL 16

Expert Comment

by:muzzy2003
ID: 17880362
g.FillPie(new SolidBrush(Color.Green), 5, 5, 700, 700, 0, 90);
g.FillPie(new SolidBrush(Color.Yellow), 5, 5, 700, 700, 90, 180);
g.FillPie(new SolidBrush(Color.Red), 5, 5, 700, 700, 180, 315); // did you mean 270?
g.FillPie(new SolidBrush(Color.Green), 5, 5, 700, 700, 315, 360);

Then draw the white circle to bound it all.
0
 

Author Comment

by:schenkp
ID: 17880610
I still want to keep the original desing of the code which is the circle, and just repaint the circle with the colors list above....

you the end result would be a colored ring wiht the colors listed above.
0
 
LVL 29

Accepted Solution

by:
Gautham Janardhan earned 400 total points
ID: 17880789
g.DrawArc(new Pen(Brushes.Yellow, 6f),5,5,700,700,0,90);
 g.DrawArc(new Pen(Brushes.Red, 6f),5,5,700,700,90,90);
g.DrawArc(new Pen(Brushes.Violet, 6f),5,5,700,700,180,90);
g.DrawArc(new Pen(Brushes.Gold, 6f),5,5,700,700,270,90);
0
 
LVL 16

Assisted Solution

by:muzzy2003
muzzy2003 earned 100 total points
ID: 17880827
Sorry, misinterpreted your question. gauthampj's code should do it.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question