Add multiple angles!

This commit is contained in:
Anton 2021-01-28 14:49:39 +01:00
parent b656e36461
commit 84e149dff1
1 changed files with 18 additions and 14 deletions

View File

@ -18,6 +18,8 @@ Public Class GUI
Dim PointButtons As New List(Of Button)
Dim angleCounter As Integer
' --- Start method when GUI loads ---
Sub GUI_load() Handles MyBase.Load
containerPanel = DrawingPanel
@ -189,8 +191,10 @@ Public Class GUI
containerPanel.Controls.Add(PointButtons(i))
AddHandler PointButtons(i).Click, AddressOf Me.PointButton_Click
AddHandler PointButtons(i).Click, AddressOf PointButton_Click
Next
angleCounter = angleCounter + 1
End Sub
Private Sub PointButton_Click(sender As Button, e As EventArgs)
@ -209,34 +213,34 @@ Public Class GUI
If tempX < containerMidX Then
If tempY > containerMidY Then
'Kvadrant 4
points.Add("pA1", {tempX + d1, tempY, 0, 0})
points.Add("pA2", {tempX, tempY - d2, 0, 0})
points.Add("pA" & angleCounter * 2 - 1, {tempX + d1, tempY, 0, 0})
points.Add("pA" & angleCounter * 2, {tempX, tempY - d2, 0, 0})
Else
'Kvadrant 1
points.Add("pA1", {tempX, tempY + d2, 0, 0})
points.Add("pA2", {tempX + d1, tempY, 0, 0})
points.Add("pA" & angleCounter * 2 - 1, {tempX, tempY + d2, 0, 0})
points.Add("pA" & angleCounter * 2, {tempX + d1, tempY, 0, 0})
End If
Else
If tempY > containerMidY Then
'Kvadrant 3
points.Add("pA1", {tempX, tempY - d2, 0, 0})
points.Add("pA2", {tempX - d1, tempY, 0, 0})
points.Add("pA" & angleCounter * 2 - 1, {tempX, tempY - d2, 0, 0})
points.Add("pA" & angleCounter * 2, {tempX - d1, tempY, 0, 0})
Else
'Kvadrant 2
points.Add("pA1", {tempX - d1, tempY, 0, 0})
points.Add("pA2", {tempX, tempY + d2, 0, 0})
points.Add("pA" & angleCounter * 2 - 1, {tempX - d1, tempY, 0, 0})
points.Add("pA" & angleCounter * 2, {tempX, tempY + d2, 0, 0})
End If
End If
'Insert two new points
pointsOrder.Insert(index + 1, "pA1")
pointsOrder.Insert(index + 2, "pA2")
pointsOrder.Insert(index + 1, "pA" & angleCounter * 2 - 1)
pointsOrder.Insert(index + 2, "pA" & angleCounter * 2)
pointsOrder.RemoveAt(index)
'Remove points buttons
For i = 0 To PointButtons.Count - 1
RemoveHandler PointButtons(i).Click, AddressOf Me.PointButton_Click
containerPanel.Controls.RemoveByKey(PointButtons(i).Name)
RemoveHandler PointButtons(0).Click, AddressOf PointButton_Click
containerPanel.Controls.RemoveByKey(PointButtons(0).Name)
PointButtons.RemoveAt(0)
Next
'Redraw grating