vwalla
asked on
Increment Text on Drawing Circles (List of)
I am developing a target software and I need to keep track of shots on the picturebox using drawstring and a number by the circle. My issue is that every circle I draw, all the numbers on the previous circle update to the same (i.e. 4 circles all have "4", draw another and they all update to "5", etc.).
Every time I click (add a shot) I want to increment the number (1,2,3,etc.)
I have attached an image and my code:
Here is my code:
Bullet Class
Shot Count Class
mPictureBox Paint:
Every time I click (add a shot) I want to increment the number (1,2,3,etc.)
I have attached an image and my code:
Here is my code:
Bullet Class
Public Class Bullet
Sub New(ByVal g As Graphics, ByRef center As Point, ByVal radius As Integer, ByVal ShotNo As Integer,
ByRef x As Integer, ByVal y As Integer, ByVal txt As String, _font As String)
' Select a pen object and make it red
Dim inPn As New Pen(My.Settings.Shot_Color_InnerCircle)
Dim osPn As New Pen(My.Settings.Shot_Color_OuterCircle)
Dim pnCtr As New Pen(My.Settings.Shot_Color_CenterMark)
Dim pnDist As New Pen(My.Settings.Shot_Color_RadiusLine)
Dim lineDash As Single() = {3, 3}
Dim osDash As Single() = {1, 1}
pnDist.DashPattern = lineDash
osPn.DashPattern = osDash
' Create a bounding rectangle and make its center the center of our point
' Then make its width 2 * the radius
' Then draw our ellipse
Dim hole As New Rectangle(center.X - radius, center.Y - radius, radius * 2, radius * 2)
Dim perHol As New Rectangle(center.X - radius - 2, center.Y - radius - 2, radius * 2 + 4, radius * 2 + 4)
_shotX = center.X
_shotY = center.Y
g.DrawEllipse(inPn, hole)
g.DrawEllipse(osPn, perHol)
g.DrawLine(pnCtr, New Point(_shotX, _shotY + 1), New Point(_shotX, _shotY - 1)) 'draw vert line
g.DrawLine(pnCtr, New Point(_shotX + 1, _shotY), New Point(_shotX - 1, _shotY)) 'draw horiz line
g.DrawLine(pnDist, _poaX, _poaY, _shotX, _shotY)
Dim newFont = New Font(_font, 8)
Dim textSize As Size = g.MeasureString(txt, newFont).ToSize
g.FillRectangle(Brushes.White, New Rectangle(New Point(x, y), textSize))
g.DrawString(txt, newFont, Brushes.Black, x, y)
End Sub
End Class
Shot Count Class
Public Class ShotCount
Sub New(ByVal g As Graphics, ByRef center As Point, ByVal radius As Integer, _font As String, txt As String)
Dim newFont = New Font(_font, 8)
Dim wBrush As New SolidBrush(Color.White)
Dim bBrush As New SolidBrush(Color.Black)
Dim textSize As Size = g.MeasureString(txt, newFont).ToSize
g.FillRectangle(wBrush, New Rectangle(New Point(center.X, center.Y), textSize))
g.DrawString(txt, newFont, bBrush, center.X, center.Y)
End Sub
End Class
mPictureBox Paint:
'SHOT FLAG
For Each b As Point In shotList
Dim _Bullet As New Bullet(e.Graphics, b, cboCaliber.EditValue / pLineDist() / 2, n)
Next
'SHOT number
For Each s As Point In ShotCount
Dim _shot As New ShotCount(e.Graphics, s, cboCaliber.EditValue / pLineDist() / 2, "Consolas", _s)
Next
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER