Solved

Help With Code Please

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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

728 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