私はターゲットソフトウェアを開発しています。私は描画紐とサークル番号を使ってピクチャボックス上のショットを追跡する必要があります。私の問題は、前回のサークルのすべての数字が同じサークルに更新される(つまり、4つのサークルすべてが「4」、別のサークルが描画され、「5」に更新されるなど)すべてのサークルを描画することです。描画円上のテキストのインクリメント(リスト)
私がイメージして自分のコードを添付した:
ここでは、コードです:
Public Class TargetAnalysis
Dim n As Integer = 0
Dim zoomPct As Decimal = 1
Dim shotList As New List(Of Point)
Dim scaleList As New List(Of Point)
Dim poaList As New List(Of Point)
Dim ShotCount As New List(Of Point)
Private Sub mPictureBox_MouseClick(sender As Object, e As MouseEventArgs) Handles mPictureBox.MouseClick
If e.Button = MouseButtons.Left Then
If shotFlag = True Then
n += 1
_shotX = e.X
_shotY = e.Y
shotList.Add(New Point(_shotX, _shotY))
ShotCount.Add(New Point(_shotX, _shotY))
shotDist = Math.Sqrt((_shotX - _poaX)^2 + (_shotY - _poaY)^2)
Me.lbDataPoints.Items.Insert(shotList.Count - 1, "SHOT - " &
FormatNumber(shotDist * pLineDist(), 2) & " in.")
Me.txtShotCount.EditValue = shotList.Count
mPictureBox.Refresh()
End If
end if
End Sub
Private Sub mPictureBox_Paint(sender As Object, e As PaintEventArgs) Handles mPictureBox.Paint
'SHOT number
For Each s As Point In ShotCount
Dim calRad As Decimal = cboCaliber.EditValue/pLineDist()/2
Dim _shot As New ShotCount(e.Graphics, New Point(s.X + calRad, s.Y + calRad), cboCaliber.EditValue/pLineDist()/2,
"Consolas", FormatNumber((Math.Sqrt((s.X - _poaX)^2 + (s.Y - _poaY)^2)) *
pLineDist(), 2) & "in")
Next
end sub
このコードは増加しませんが、
を示し、距離を持続しないが、弾丸はクラスでなければなりません。次に、各箇条書きを 'List(Of T)'に格納します。彼らがあなたの位置を更新するように動かすと、それで正しい位置に各弾をペイントします。作業領域を出ると、それらをリストから削除します。 – OneFineDay
各箇条書きはクラス内にありますが、テキスト文字列を独自のクラスにも移動すると言っていますか?ありがとう –
私はTextを処理するためにBulletNoクラスを追加しましたが、今私は以下を呼び出します:For Each t As Integer in _shotNo Dim _shotとして新しいBulletNo(e.Graphics、_shotX、_shotY、n、 "Consolas") 次。これはカウントを表示しますが、他のショットテキスト文字列を削除します。 –