Angle works for all original points and the point buttons are handled correctly
This commit is contained in:
parent
a97a0d2cec
commit
b656e36461
100
Wardrobe/GUI.vb
100
Wardrobe/GUI.vb
|
|
@ -16,7 +16,7 @@ Public Class GUI
|
||||||
Dim points As New Dictionary(Of String, Decimal())
|
Dim points As New Dictionary(Of String, Decimal())
|
||||||
Dim pointsOrder As New List(Of String)
|
Dim pointsOrder As New List(Of String)
|
||||||
|
|
||||||
'Dim PointButtons As New Dictionary(Of String, Button)
|
Dim PointButtons As New List(Of Button)
|
||||||
|
|
||||||
' --- Start method when GUI loads ---
|
' --- Start method when GUI loads ---
|
||||||
Sub GUI_load() Handles MyBase.Load
|
Sub GUI_load() Handles MyBase.Load
|
||||||
|
|
@ -29,31 +29,6 @@ Public Class GUI
|
||||||
Set_ContainerPointsY()
|
Set_ContainerPointsY()
|
||||||
|
|
||||||
Create_StartPoints()
|
Create_StartPoints()
|
||||||
|
|
||||||
Temp_Create_PointButton()
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
' --- TEMP ---
|
|
||||||
Private Sub Temp_Create_PointButton()
|
|
||||||
Dim PointButton As New Button
|
|
||||||
PointButton.Top = 15
|
|
||||||
PointButton.Left = 15
|
|
||||||
PointButton.Width = 30
|
|
||||||
PointButton.Height = 30
|
|
||||||
PointButton.Name = "PointButton"
|
|
||||||
PointButton.Text = ""
|
|
||||||
|
|
||||||
PointButton.BackColor = Color.Transparent
|
|
||||||
PointButton.FlatStyle = FlatStyle.Flat
|
|
||||||
PointButton.FlatAppearance.BorderSize = 0
|
|
||||||
PointButton.FlatAppearance.MouseOverBackColor = Color.Red
|
|
||||||
PointButton.FlatAppearance.MouseDownBackColor = Color.DarkRed
|
|
||||||
|
|
||||||
Dim gp As New Drawing.Drawing2D.GraphicsPath
|
|
||||||
gp.AddEllipse(New Rectangle(New Point(0, 0), New Size(30, 30)))
|
|
||||||
PointButton.Region = New Region(gp)
|
|
||||||
|
|
||||||
containerPanel.Controls.Add(PointButton)
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
' --- Retrive parameters for the drawing box ---
|
' --- Retrive parameters for the drawing box ---
|
||||||
|
|
@ -189,9 +164,38 @@ Public Class GUI
|
||||||
|
|
||||||
' --- When angle button is pressed ---
|
' --- When angle button is pressed ---
|
||||||
Private Sub AngleButton_Click(sender As Object, e As EventArgs) Handles AngleButton.Click
|
Private Sub AngleButton_Click(sender As Object, e As EventArgs) Handles AngleButton.Click
|
||||||
|
' Create Buttons for all clickable points
|
||||||
|
For i = 0 To pointsOrder.Count - 1
|
||||||
|
PointButtons.Add(New Button)
|
||||||
|
|
||||||
|
PointButtons(i).Width = 30
|
||||||
|
PointButtons(i).Height = 30
|
||||||
|
|
||||||
|
PointButtons(i).Left = points(pointsOrder(i))(0) - PointButtons(i).Width / 2
|
||||||
|
PointButtons(i).Top = points(pointsOrder(i))(1) - PointButtons(i).Height / 2
|
||||||
|
|
||||||
|
PointButtons(i).Name = pointsOrder(i) & "_Button"
|
||||||
|
PointButtons(i).Text = ""
|
||||||
|
|
||||||
|
PointButtons(i).BackColor = Color.FromArgb(50, Color.Red)
|
||||||
|
PointButtons(i).FlatStyle = FlatStyle.Flat
|
||||||
|
PointButtons(i).FlatAppearance.BorderSize = 0
|
||||||
|
PointButtons(i).FlatAppearance.MouseOverBackColor = Color.Red
|
||||||
|
PointButtons(i).FlatAppearance.MouseDownBackColor = Color.DarkRed
|
||||||
|
|
||||||
|
Dim gp As New Drawing.Drawing2D.GraphicsPath
|
||||||
|
gp.AddEllipse(New Rectangle(New Point(0, 0), New Size(30, 30)))
|
||||||
|
PointButtons(i).Region = New Region(gp)
|
||||||
|
|
||||||
|
containerPanel.Controls.Add(PointButtons(i))
|
||||||
|
|
||||||
|
AddHandler PointButtons(i).Click, AddressOf Me.PointButton_Click
|
||||||
|
Next
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub PointButton_Click(sender As Button, e As EventArgs)
|
||||||
'Determine which point is being pressed
|
'Determine which point is being pressed
|
||||||
Dim pointPressed As String
|
Dim pointPressed As String = sender.Name.Split("_")(0)
|
||||||
pointPressed = "p1" ' Fix this
|
|
||||||
Dim index As Integer = pointsOrder.IndexOf(pointPressed)
|
Dim index As Integer = pointsOrder.IndexOf(pointPressed)
|
||||||
|
|
||||||
'Retrive that points coords
|
'Retrive that points coords
|
||||||
|
|
@ -199,17 +203,41 @@ Public Class GUI
|
||||||
tempX = points(pointPressed)(0)
|
tempX = points(pointPressed)(0)
|
||||||
tempY = points(pointPressed)(1)
|
tempY = points(pointPressed)(1)
|
||||||
|
|
||||||
'Insert two new points
|
Dim d1, d2 As Integer 'Kommer anges som double i SW coord men vi vill ha pixel coord här
|
||||||
points.Add("pT1", {tempX, tempY + 80, 0, 0})
|
d1 = 80
|
||||||
pointsOrder.Insert(index + 1, "pT1")
|
d2 = 50
|
||||||
points.Add("pT2", {tempX + 50, tempY, 0, 0})
|
If tempX < containerMidX Then
|
||||||
pointsOrder.Insert(index + 2, "pT2")
|
If tempY > containerMidY Then
|
||||||
|
'Kvadrant 4
|
||||||
|
points.Add("pA1", {tempX + d1, tempY, 0, 0})
|
||||||
|
points.Add("pA2", {tempX, tempY - d2, 0, 0})
|
||||||
|
Else
|
||||||
|
'Kvadrant 1
|
||||||
|
points.Add("pA1", {tempX, tempY + d2, 0, 0})
|
||||||
|
points.Add("pA2", {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})
|
||||||
|
Else
|
||||||
|
'Kvadrant 2
|
||||||
|
points.Add("pA1", {tempX - d1, tempY, 0, 0})
|
||||||
|
points.Add("pA2", {tempX, tempY + d2, 0, 0})
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
|
'Insert two new points
|
||||||
|
pointsOrder.Insert(index + 1, "pA1")
|
||||||
|
pointsOrder.Insert(index + 2, "pA2")
|
||||||
pointsOrder.RemoveAt(index)
|
pointsOrder.RemoveAt(index)
|
||||||
|
|
||||||
'Fix those points coords
|
'Remove points buttons
|
||||||
|
For i = 0 To PointButtons.Count - 1
|
||||||
'Add those points in pointsOrder and remove orignal point
|
RemoveHandler PointButtons(i).Click, AddressOf Me.PointButton_Click
|
||||||
|
containerPanel.Controls.RemoveByKey(PointButtons(i).Name)
|
||||||
|
Next
|
||||||
|
|
||||||
'Redraw grating
|
'Redraw grating
|
||||||
Me.Refresh()
|
Me.Refresh()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue