' Draw pie slices. Note that the DrawPie
' and FillPie methods draw using degrees
' clockwise from horizontal.
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As _
System.Windows.Forms.PaintEventArgs) Handles _
MyBase.Paint
Const GAP As Single = 5
Const W As Single = 100
Dim gr As Graphics = e.Graphics
Dim X As Single
Dim Y As Single
Dim circle_brush As Brush = Brushes.White
Dim slice_brush As Brush = Brushes.Black
' Northeast wedge.
X = 0
Y = 0
gr.DrawEllipse(Pens.White, X, Y, W, W)
gr.FillPie(slice_brush, _
X, Y, W, W, 300, 30)
gr.DrawPie(Pens.Red, _
X, Y, W, W, 300, 30)
' Everything else.
X += W + GAP
gr.DrawEllipse(Pens.White, X, Y, W, W)
gr.FillPie(slice_brush, _
X, Y, W, W, 300, -330)
gr.DrawPie(Pens.Red, _
X, Y, W, W, 300, -330)
' East wedge.
Y += W + GAP
X = 0
gr.DrawEllipse(Pens.White, X, Y, W, W)
gr.FillPie(slice_brush, _
X, Y, W, W, 315, 90)
gr.DrawPie(Pens.Red, _
X, Y, W, W, 315, 90)
' Everything else.
X += W + GAP
gr.DrawEllipse(Pens.White, X, Y, W, W)
gr.FillPie(slice_brush, _
X, Y, W, W, 315, -270)
gr.DrawPie(Pens.Red, _
X, Y, W, W, 315, -270)
' Northwest quadrant.
Y += W + GAP
X = 0
gr.DrawEllipse(Pens.White, X, Y, W, W)
gr.FillPie(slice_brush, _
X, Y, W, W, 315, 45)
gr.DrawPie(Pens.Red, _
X, Y, W, W, 315, 45)
' Everything else.
X += W + GAP
gr.DrawEllipse(Pens.White, X, Y, W, W)
gr.FillPie(slice_brush, _
X, Y, W, W, 315, -315)
gr.DrawPie(Pens.Red, _
X, Y, W, W, 315, -315)
End Sub
|