diff --git a/Wardrobe/GUI.vb b/Wardrobe/GUI.vb index 25ca540..d774ef5 100644 --- a/Wardrobe/GUI.vb +++ b/Wardrobe/GUI.vb @@ -229,53 +229,62 @@ Public Class GUI ' --- When angle button is pressed --- Private Sub AngleButton_Click(sender As Object, e As EventArgs) Handles AngleButton.Click ' Add TextBoxes with Labels - Dim XValueBox As New TextBox - XValueBox.Name = "X_TextBox" - XValueBox.Text = "50" - XValueBox.Left = 32 - XValueBox.Top = 189 - XValueBox.Width = 60 - XValueBox.Font = New Font("Microsoft Sans Serif", 10) - Me.Controls.Add(XValueBox) + Create_TextBox("X_TextBox", "", 32, 189, 60) + AddHandler Me.Controls("X_TextBox").TextChanged, AddressOf AngleText_Changed + Create_TextBox("Y_TextBox", "", 140, 189, 60) + AddHandler Me.Controls("Y_TextBox").TextChanged, AddressOf AngleText_Changed - Dim YValueBox As New TextBox - YValueBox.Name = "Y_TextBox" - YValueBox.Text = "50" - YValueBox.Left = 140 - YValueBox.Top = 189 - YValueBox.Width = 60 - YValueBox.Font = New Font("Microsoft Sans Serif", 10) - Me.Controls.Add(YValueBox) - ' Create Buttons for all clickable points - For i = 0 To pointsOrder.Count - 1 - PointButtons.Add(New Button) + End Sub - PointButtons(i).Width = 30 - PointButtons(i).Height = 30 + Private Sub Create_TextBox(TextBoxName As String, TextBoxText As String, TextBoxLeft As Integer, TextBoxTop As Integer, TextBoxWidth As Integer) + Dim textBoxTemp As New TextBox + textBoxTemp.Name = TextBoxName + textBoxTemp.Text = TextBoxText + textBoxTemp.Left = TextBoxLeft + textBoxTemp.Top = TextBoxTop + textBoxTemp.Width = TextBoxWidth + textBoxTemp.Font = New Font("Microsoft Sans Serif", 10) + Me.Controls.Add(textBoxTemp) + End Sub - PointButtons(i).Left = points(pointsOrder(i))(0) - PointButtons(i).Width / 2 - PointButtons(i).Top = points(pointsOrder(i))(1) - PointButtons(i).Height / 2 + Private Sub AngleText_Changed(sender As TextBox, e As EventArgs) + If Not Me.Controls("X_TextBox").Text = "" And Not Me.Controls("Y_TextBox").Text = "" Then + If containerPanel.Controls.Count = 0 Then + ' Create Buttons for all clickable points + For i = 0 To pointsOrder.Count - 1 + PointButtons.Add(New Button) - PointButtons(i).Name = pointsOrder(i) & "_Button" - PointButtons(i).Text = "" + PointButtons(i).Width = 30 + PointButtons(i).Height = 30 - 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 + PointButtons(i).Left = points(pointsOrder(i))(0) - PointButtons(i).Width / 2 + PointButtons(i).Top = points(pointsOrder(i))(1) - PointButtons(i).Height / 2 - 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) + PointButtons(i).Name = pointsOrder(i) & "_Button" + PointButtons(i).Text = "" - containerPanel.Controls.Add(PointButtons(i)) + 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 - AddHandler PointButtons(i).Click, AddressOf PointButton_Click - Next + 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) - angleCounter = angleCounter + 1 + containerPanel.Controls.Add(PointButtons(i)) + + AddHandler PointButtons(i).Click, AddressOf PointButton_Click + Next + + angleCounter = angleCounter + 1 + + + + End If + End If End Sub ' --- When a point button for angle recess is pressed --- @@ -330,6 +339,12 @@ Public Class GUI 'Redraw grating Me.Refresh() + + RemoveHandler Me.Controls("X_TextBox").TextChanged, AddressOf AngleText_Changed + Me.Controls.RemoveByKey("X_TextBox") + + RemoveHandler Me.Controls("Y_TextBox").TextChanged, AddressOf AngleText_Changed + Me.Controls.RemoveByKey("Y_TextBox") End Sub ' --- When export to SW button is pressed ---