Solved

Help With Code Please

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video discusses moving either the default database or any database to a new volume.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

757 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now