Assuming you might only want to draw the last octant selected slow, then one way that could be done is use an index to indicate which circle should be draw slow, and check for that in your draw circle sub.
vb.net Code:
'.....
Private DrawIt7 As Boolean
Private DrawIt8 As Boolean
Private DrawSlow, ImDrawing As Integer 'Add two values that can be compared to see which circle should be drawn slow
'Modify each button press to set which circle should be drawn slow
'for example, set DrawSlow to 3 in the octantThree_Click event (note sweep angle reset, and timer started as well)
Private Sub octantThree_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles octantThree.Click
If TextBox1.TextLength <> 0 And TextBox2.TextLength <> 0 And TextBox3.TextLength <> 0 Then
Label6.Text = "Center: (" + "-" + Math.Abs(CType(TextBox2.Text, Integer)).ToString + ", " + CType(TextBox1.Text, Integer).ToString + ")"
Label9.Text = "Octant 3"
sweepAngle = 1
Timer1.Start()
DrawSlow = 3
DrawIt3 = True
Invalidate()
Else
MessageBox.Show("Please fill-up the fields first before plotting the circle", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If
End Sub
'Note which circle you are drawing in the paint event by setting the ImDrawing variable, for example DrawIt3 and DrawIt4 cases.
If DrawIt3 Then
ImDrawing = 3
x = CType(TextBox1.Text, Integer)
y = CType(TextBox2.Text, Integer)
r = CType(TextBox3.Text, Integer)
FillCircle(g, -y, x, 3, Brushes.Black)
DrawCircle(g, -y, x, r, Pens.Cyan)
End If
If DrawIt4 Then
ImDrawing = 4
x = CType(TextBox1.Text, Integer)
y = CType(TextBox2.Text, Integer)
r = CType(TextBox3.Text, Integer)
FillCircle(g, -x, y, 3, Brushes.Black)
DrawCircle(g, -x, y, r, Pens.Gold)
End If
'And in your DrawCircle Sub, choose to drawArc or DrawCircle based on whether ImDrawing matches DrawSlow.
Private Sub DrawCircle(ByVal g As Graphics, ByVal x As Single, ByVal y As Single, ByVal r As Single, ByVal p As Pen)
If ImDrawing = DrawSlow Then
g.DrawArc(p, x - r, y - r, r * 2, r * 2, 0, Me.sweepAngle)
Else
g.DrawEllipse(p, x - r, y - r, r * 2, r * 2)
End If
End Sub
p.s. As already mentioned, you don't need that Private g As Graphics declaration at the top, or setting it in the Form_Load event.
If you haven't set it in the IDE properties, I would add
DoubleBuffered = True
in the Form_Load event, to minimize flashing while you're drawing
Code:
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
DoubleBuffered = True
End Sub
p.s. I think I would change your timer code to make it draw the circle somewhat faster.
Code:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Me.sweepAngle += 3
If Me.sweepAngle >= 360 Then
Me.Timer1.Stop()
End If
Me.Refresh()
End Sub
Maybe allow the user to pick a "speed", by changing that 3 to another value (between 1 and 180).
p.p.s. Given the colors you're using, drawing on a black background (swap your black and white pens and brushes), helps the circles stand out (other than the blue). If you want to stay with a white background, then probably choose a number of "dark" colors, not yellow and cyan.
Attachment 131481
The blue is the upper right, which is extremely hard to see on the image in the forum, since they've shrunk the image. The shrunk image makes it hard to see a few of the other circles, but in normal size on your screen, it is just the blue that doesn't stand out.