Nabend zusammen,
steh mal wieder vor einem Problem
Ich soll ein Dreieck zeichnen, das mit dem Mauszeiger an der Ecke B beliebig bewegt werden kann... so bis dahin kein Problem.
Mein Problem liegt im Darstellen der Seitenbezeichnungen. Bei der Seite "b" ging das recht leicht, Seite "c" sieht auch akzeptabel aus, jedoch etwas zu weit von der Seite entfernt aber die Seite "a" macht mir extrem zu schaffen. Ich kann diese zwar einigermaßen in Positionen bringen doch sie "klebt" nicht direkt an der Seite, wie es die anderen Bezeichnungen machen.
Vielleicht wisst Ihr ja weiter... vielen Dank schon mal im Voraus.
Gute Nacht:old
Hier mal der Code und Screenshots:
Public Class Form1
Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click
Invalidate()
End Sub
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
'Deklarationen der Variablen
Dim g As Graphics = CreateGraphics()
Dim p As Pen = New Pen(backcolor, 0.5)
Dim br As New SolidBrush(Color.Black)
Dim fn As New Font("Arial", 10)
Dim ptMitte As New PointF(CSng(ClientSize.Width / 2), CSng(ClientSize.Height / 2))
Static ptMaus As New PointF
Dim rectA As New RectangleF(0.5 * (ptMitte.X + ptMaus.Y + ptMaus.X), ptMaus.Y, 60, 60)
Dim rectB As New RectangleF(0.5 * (ptMitte.X + ptMaus.X), ptMitte.Y, 120, 120)
Dim rectC As New RectangleF(0.5 * (ptMitte.X + ptMaus.X), ptMaus.Y, 120, 120)
'Löschendes Zeichnen
g.DrawLine(p, ptMitte, ptMaus) 'Strecke AB
g.DrawLine(p, ptMitte, New PointF(ptMaus.X, ptMitte.Y)) 'Strecke AC
g.DrawLine(p, ptMaus, New PointF(ptMaus.X, ptMitte.X)) 'Strecke BC
g.DrawString("a", fn, br, rectA)
g.DrawString("b", fn, br, rectB)
g.DrawString("c", fn, br, rectC)
'g.DrawRectangle(p, 0, 0, ClientSize.Width, ClientSize.Height)
g.FillRectangle(New SolidBrush(BackColor), 0, 0, ClientSize.Width, ClientSize.Height)
'Zeichnen
g.drawstring("a", fn, br, rectA)
g.DrawString("b", fn, br, rectB)
g.DrawString("c", fn, br, rectC)
p.Color = Color.Black
ptMaus.X = CSng(e.X)
ptMaus.Y = CSng(e.Y)
g.DrawLine(p, ptMitte, ptMaus) 'Strecke AB
g.DrawString("c", fn, br, rectC)
p.Color = Color.Black
g.DrawLine(p, ptMaus, New PointF(ptMaus.X, ptMitte.Y)) 'Strecke AC
g.DrawString("b", fn, br, rectB)
p.Color = Color.Black
g.DrawLine(p, ptMitte, New PointF(ptMaus.X, ptMitte.Y)) 'Srecke BC
g.drawString("a", fn, br, rectA)
End Sub
End Class