Solved

Help With Code Please

Posted on 2006-11-06
5
265 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

739 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