shape back color

I have created a User Control using graphic's fill property. It's a circle. It's like a speedometer hence it has many colors and filled using different shapes. I need to have it's empty space to have back color to some thing other than the default color. How to change the back color of the graphic's shape???

Answers


Check out Pens, Brushes and Colors

Graphics g = this.CreateGraphics();
SolidBrush myBrush = new SolidBrush(Color.Red);
g.FillEllipse(myBrush, ClientRectangle);

A more complete example. This will fill the background of the UserControl (based on the size of the user control) to Pink, and create a small circle that is filled with an orange backgroung color.

  protected override void OnPaint(PaintEventArgs e)
  {
     Graphics g = e.Graphics;

     SolidBrush sb = new SolidBrush(Color.Pink);
     g.FillRectangle(sb, e.ClipRectangle);
     sb.Dispose();

     sb = new SolidBrush(Color.Orange);
     g.FillEllipse(sb, 20, 20, 20, 20);
     sb.Dispose();
  }

Is this more what you are looking for?

If you want the background color to be the same as the user control, change this:

SolidBrush sb = new SolidBrush(this.BackColor); //Color.Pink);

Need Your Help

angular.bootstrap and angular ui-router not launching controllers

javascript angularjs cordova angular-ui-router

I'm in the process of switching an existing AngularJS mobile app from Trigger.io to Cordova, as it provides way better/more plugins for what I'm building.

How do I track the route to my destination page from various 301s?

redirect http-status-code-301

Simple question for someone who might know, the most difficult thing in the world for me:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.