Es liegt wohl eher an der Art deiner Anzeige. Auch mehr als 100 Linien sollten
nicht flackern. Eventuell die Linienlänge über einen Tooltip anzeigen.
Ein Einfacher Test mit einer PictureBox und einem Tooltip:
Imports System.Drawing.Drawing2D
Imports System.Math
Public Class Form1
Private WithEvents Pb As New PictureBox With {.Dock = DockStyle.Fill, _
.Parent = Me}
Private Tt As New ToolTip
Private ptlist As New List(Of Point)
Private startpoint As Point
Private endpoint As Point
Private Sub Pb_MouseDown(ByVal sender As Object, ByVal e As _
System.Windows.Forms.MouseEventArgs) Handles Pb.MouseDown
startpoint = e.Location
Tt.Active = True
End Sub
Private Sub Pb_MouseMove(ByVal sender As Object, ByVal e As _
System.Windows.Forms.MouseEventArgs) Handles Pb.MouseMove
If e.Button = Windows.Forms.MouseButtons.Left Then
endpoint = e.Location
Tt.Show(CStr(GetDistance(startpoint, endpoint)), Pb, e.X + 10, e.Y _
+ 20, 10000)
Pb.Invalidate()
End If
End Sub
Private Sub Pb_MouseUp(ByVal sender As Object, ByVal e As _
System.Windows.Forms.MouseEventArgs) Handles Pb.MouseUp
If My.Computer.Keyboard.CtrlKeyDown Then
ptlist.Add(startpoint)
ptlist.Add(e.Location)
End If
startpoint = Nothing
Tt.Active = False
Pb.Invalidate()
End Sub
Private Sub Pb_Paint(ByVal sender As Object, ByVal e As _
System.Windows.Forms.PaintEventArgs) Handles Pb.Paint
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias
Using p As New Pen(Color.Red, 3)
For i As Int32 = 0 To ptlist.Count - 1 Step 2
e.Graphics.DrawLine(p, ptlist(i), ptlist(i + 1))
Next
If Not startpoint.IsEmpty Then
p.Color = Color.Blue
e.Graphics.DrawLine(p, startpoint, endpoint)
End If
End Using
End Sub
Function GetDistance(ByVal a As Point, ByVal b As Point) As Integer
Return CInt(Sqrt((Pow((a.X - b.X), 2) + Pow((a.Y - b.Y), 2))))
End Function
End Class MfG GPM 0 |