Draw Pie for Scroll Bar
Start a new project. Add a scroll bar hsbDegrees.
Set the properties so that you can select any integer value from 0 to 360.
Add labels lblInfo and lblDegrees as shown.
Add this code to the Scroll event for hsbAngle:
private void hsbAngle_Scroll(object sender, ScrollEventArgs e)
{
// Get the graphics of the form.
Graphics g = this.CreateGraphics();
// Create a Black Brush for background.
SolidBrush myBrushBackground = new SolidBrush(Color.Black);
// Create a Red Brush for foreground.
SolidBrush myBrushForeground = new SolidBrush(Color.Red);
// We want to draw the pie under the scroll bar.
int top = hsbAngle.Location.Y + hsbAngle.Height+10;
// Create a rectangle 200x200 (square) for the circle.
Rectangle myRect = new Rectangle(10, top, 200, 200);
g.FillPie(myBrushBackground, myRect, 0, 360);
g.FillPie(myBrushForeground, myRect, 0, hsbAngle.Value);
lblDegrees.Text = hsbAngle.Value.ToString();
}
To Do: Experiment! Try using 2 scroll bars to select the start and end angle.