Added square corners
This commit is contained in:
parent
37a2511b65
commit
6826acb0d4
|
|
@ -30,8 +30,6 @@ Partial Class GUI
|
||||||
Me.Label2 = New System.Windows.Forms.Label()
|
Me.Label2 = New System.Windows.Forms.Label()
|
||||||
Me.ExportSWButton = New System.Windows.Forms.Button()
|
Me.ExportSWButton = New System.Windows.Forms.Button()
|
||||||
Me.AngleButton = New System.Windows.Forms.Button()
|
Me.AngleButton = New System.Windows.Forms.Button()
|
||||||
Me.LabelAngleX = New System.Windows.Forms.Label()
|
|
||||||
Me.LabelAngleY = New System.Windows.Forms.Label()
|
|
||||||
Me.SettingsButton = New System.Windows.Forms.Button()
|
Me.SettingsButton = New System.Windows.Forms.Button()
|
||||||
Me.ComboBox_TypeChooser = New System.Windows.Forms.ComboBox()
|
Me.ComboBox_TypeChooser = New System.Windows.Forms.ComboBox()
|
||||||
Me.ComboBox_MeshSize = New System.Windows.Forms.ComboBox()
|
Me.ComboBox_MeshSize = New System.Windows.Forms.ComboBox()
|
||||||
|
|
@ -45,6 +43,7 @@ Partial Class GUI
|
||||||
Me.Label8 = New System.Windows.Forms.Label()
|
Me.Label8 = New System.Windows.Forms.Label()
|
||||||
Me.ComboBox_Width = New System.Windows.Forms.ComboBox()
|
Me.ComboBox_Width = New System.Windows.Forms.ComboBox()
|
||||||
Me.ComboBox_Length = New System.Windows.Forms.ComboBox()
|
Me.ComboBox_Length = New System.Windows.Forms.ComboBox()
|
||||||
|
Me.Button_Square = New System.Windows.Forms.Button()
|
||||||
Me.SuspendLayout()
|
Me.SuspendLayout()
|
||||||
'
|
'
|
||||||
'DrawingPanel
|
'DrawingPanel
|
||||||
|
|
@ -95,7 +94,7 @@ Partial Class GUI
|
||||||
'
|
'
|
||||||
'AngleButton
|
'AngleButton
|
||||||
'
|
'
|
||||||
Me.AngleButton.Location = New System.Drawing.Point(11, 147)
|
Me.AngleButton.Location = New System.Drawing.Point(11, 158)
|
||||||
Me.AngleButton.Margin = New System.Windows.Forms.Padding(2)
|
Me.AngleButton.Margin = New System.Windows.Forms.Padding(2)
|
||||||
Me.AngleButton.Name = "AngleButton"
|
Me.AngleButton.Name = "AngleButton"
|
||||||
Me.AngleButton.Size = New System.Drawing.Size(92, 28)
|
Me.AngleButton.Size = New System.Drawing.Size(92, 28)
|
||||||
|
|
@ -103,28 +102,6 @@ Partial Class GUI
|
||||||
Me.AngleButton.Text = "Add Angle"
|
Me.AngleButton.Text = "Add Angle"
|
||||||
Me.AngleButton.UseVisualStyleBackColor = True
|
Me.AngleButton.UseVisualStyleBackColor = True
|
||||||
'
|
'
|
||||||
'LabelAngleX
|
|
||||||
'
|
|
||||||
Me.LabelAngleX.AutoSize = True
|
|
||||||
Me.LabelAngleX.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
|
|
||||||
Me.LabelAngleX.Location = New System.Drawing.Point(12, 192)
|
|
||||||
Me.LabelAngleX.Margin = New System.Windows.Forms.Padding(2, 0, 2, 0)
|
|
||||||
Me.LabelAngleX.Name = "LabelAngleX"
|
|
||||||
Me.LabelAngleX.Size = New System.Drawing.Size(17, 17)
|
|
||||||
Me.LabelAngleX.TabIndex = 10
|
|
||||||
Me.LabelAngleX.Text = "X"
|
|
||||||
'
|
|
||||||
'LabelAngleY
|
|
||||||
'
|
|
||||||
Me.LabelAngleY.AutoSize = True
|
|
||||||
Me.LabelAngleY.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
|
|
||||||
Me.LabelAngleY.Location = New System.Drawing.Point(121, 192)
|
|
||||||
Me.LabelAngleY.Margin = New System.Windows.Forms.Padding(2, 0, 2, 0)
|
|
||||||
Me.LabelAngleY.Name = "LabelAngleY"
|
|
||||||
Me.LabelAngleY.Size = New System.Drawing.Size(17, 17)
|
|
||||||
Me.LabelAngleY.TabIndex = 11
|
|
||||||
Me.LabelAngleY.Text = "Y"
|
|
||||||
'
|
|
||||||
'SettingsButton
|
'SettingsButton
|
||||||
'
|
'
|
||||||
Me.SettingsButton.Location = New System.Drawing.Point(11, 635)
|
Me.SettingsButton.Location = New System.Drawing.Point(11, 635)
|
||||||
|
|
@ -270,11 +247,21 @@ Partial Class GUI
|
||||||
Me.ComboBox_Length.TabIndex = 24
|
Me.ComboBox_Length.TabIndex = 24
|
||||||
Me.ComboBox_Length.Text = "1000"
|
Me.ComboBox_Length.Text = "1000"
|
||||||
'
|
'
|
||||||
|
'Button_Square
|
||||||
|
'
|
||||||
|
Me.Button_Square.Location = New System.Drawing.Point(13, 234)
|
||||||
|
Me.Button_Square.Name = "Button_Square"
|
||||||
|
Me.Button_Square.Size = New System.Drawing.Size(75, 23)
|
||||||
|
Me.Button_Square.TabIndex = 25
|
||||||
|
Me.Button_Square.Text = "Add Square Corner"
|
||||||
|
Me.Button_Square.UseVisualStyleBackColor = True
|
||||||
|
'
|
||||||
'GUI
|
'GUI
|
||||||
'
|
'
|
||||||
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
|
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
|
||||||
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
|
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
|
||||||
Me.ClientSize = New System.Drawing.Size(1155, 687)
|
Me.ClientSize = New System.Drawing.Size(1155, 687)
|
||||||
|
Me.Controls.Add(Me.Button_Square)
|
||||||
Me.Controls.Add(Me.ComboBox_Length)
|
Me.Controls.Add(Me.ComboBox_Length)
|
||||||
Me.Controls.Add(Me.ComboBox_Width)
|
Me.Controls.Add(Me.ComboBox_Width)
|
||||||
Me.Controls.Add(Me.ComboBox_MeshSize)
|
Me.Controls.Add(Me.ComboBox_MeshSize)
|
||||||
|
|
@ -289,8 +276,6 @@ Partial Class GUI
|
||||||
Me.Controls.Add(Me.ExportSWButton)
|
Me.Controls.Add(Me.ExportSWButton)
|
||||||
Me.Controls.Add(Me.ComboBox_Height)
|
Me.Controls.Add(Me.ComboBox_Height)
|
||||||
Me.Controls.Add(Me.ComboBox_Thickness)
|
Me.Controls.Add(Me.ComboBox_Thickness)
|
||||||
Me.Controls.Add(Me.LabelAngleY)
|
|
||||||
Me.Controls.Add(Me.LabelAngleX)
|
|
||||||
Me.Controls.Add(Me.AngleButton)
|
Me.Controls.Add(Me.AngleButton)
|
||||||
Me.Controls.Add(Me.Label2)
|
Me.Controls.Add(Me.Label2)
|
||||||
Me.Controls.Add(Me.Label1)
|
Me.Controls.Add(Me.Label1)
|
||||||
|
|
@ -311,8 +296,6 @@ Partial Class GUI
|
||||||
Friend WithEvents Label2 As Label
|
Friend WithEvents Label2 As Label
|
||||||
Friend WithEvents ExportSWButton As Button
|
Friend WithEvents ExportSWButton As Button
|
||||||
Friend WithEvents AngleButton As Button
|
Friend WithEvents AngleButton As Button
|
||||||
Friend WithEvents LabelAngleX As Label
|
|
||||||
Friend WithEvents LabelAngleY As Label
|
|
||||||
Friend WithEvents SettingsButton As Button
|
Friend WithEvents SettingsButton As Button
|
||||||
Friend WithEvents ComboBox_TypeChooser As ComboBox
|
Friend WithEvents ComboBox_TypeChooser As ComboBox
|
||||||
Friend WithEvents ComboBox_MeshSize As ComboBox
|
Friend WithEvents ComboBox_MeshSize As ComboBox
|
||||||
|
|
@ -326,4 +309,5 @@ Partial Class GUI
|
||||||
Friend WithEvents Label8 As Label
|
Friend WithEvents Label8 As Label
|
||||||
Friend WithEvents ComboBox_Width As ComboBox
|
Friend WithEvents ComboBox_Width As ComboBox
|
||||||
Friend WithEvents ComboBox_Length As ComboBox
|
Friend WithEvents ComboBox_Length As ComboBox
|
||||||
|
Friend WithEvents Button_Square As Button
|
||||||
End Class
|
End Class
|
||||||
|
|
|
||||||
140
Wardrobe/GUI.vb
140
Wardrobe/GUI.vb
|
|
@ -228,15 +228,136 @@ 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
|
||||||
' Add TextBoxes with Labels
|
Dim buttonX As Integer = Me.Controls("AngleButton").Location.X
|
||||||
Create_TextBox("X_TextBox", "", 32, 189, 60)
|
Dim buttonY As Integer = Me.Controls("AngleButton").Location.Y
|
||||||
|
Create_TextBox("X_TextBox", "", buttonX + 20, buttonY + 40, 60)
|
||||||
AddHandler Me.Controls("X_TextBox").TextChanged, AddressOf AngleText_Changed
|
AddHandler Me.Controls("X_TextBox").TextChanged, AddressOf AngleText_Changed
|
||||||
Create_TextBox("Y_TextBox", "", 140, 189, 60)
|
Create_Label("X_Label", "X", buttonX, buttonY + 43)
|
||||||
|
Create_TextBox("Y_TextBox", "", buttonX + 130, buttonY + 40, 60)
|
||||||
AddHandler Me.Controls("Y_TextBox").TextChanged, AddressOf AngleText_Changed
|
AddHandler Me.Controls("Y_TextBox").TextChanged, AddressOf AngleText_Changed
|
||||||
|
Create_Label("Y_Label", "Y", buttonX + 110, buttonY + 43)
|
||||||
|
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Private Sub Button_Square_Click(sender As Object, e As EventArgs) Handles Button_Square.Click
|
||||||
|
Dim buttonX As Integer = Me.Controls("Button_Square").Location.X
|
||||||
|
Dim buttonY As Integer = Me.Controls("Button_Square").Location.Y
|
||||||
|
Create_TextBox("X_TextBox", "", buttonX + 20, buttonY + 40, 60)
|
||||||
|
AddHandler Me.Controls("X_TextBox").TextChanged, AddressOf SquareText_Changed
|
||||||
|
Create_Label("X_Label", "X", buttonX, buttonY + 43)
|
||||||
|
Create_TextBox("Y_TextBox", "", buttonX + 130, buttonY + 40, 60)
|
||||||
|
AddHandler Me.Controls("Y_TextBox").TextChanged, AddressOf SquareText_Changed
|
||||||
|
Create_Label("Y_Label", "Y", buttonX + 110, buttonY + 43)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub SquareText_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).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 PointButton_Click2
|
||||||
|
Next
|
||||||
|
|
||||||
|
angleCounter = angleCounter + 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
' --- When a point button for angle recess is pressed ---
|
||||||
|
Private Sub PointButton_Click2(sender As Button, e As EventArgs)
|
||||||
|
'Determine which point is being pressed
|
||||||
|
Dim pointPressed As String = sender.Name.Split("_")(0)
|
||||||
|
Dim index As Integer = pointsOrder.IndexOf(pointPressed)
|
||||||
|
|
||||||
|
'Retrive that points coords
|
||||||
|
Dim pXP As Decimal = points(pointPressed)(0)
|
||||||
|
Dim pYP As Decimal = points(pointPressed)(1)
|
||||||
|
Dim pXSW As Decimal = points(pointPressed)(2)
|
||||||
|
Dim pYSW As Decimal = points(pointPressed)(3)
|
||||||
|
|
||||||
|
Dim d1P As Decimal = Me.Controls("X_TextBox").Text / scaleDiff
|
||||||
|
Dim d2P As Decimal = Me.Controls("Y_TextBox").Text / scaleDiff
|
||||||
|
Dim d1SW As Decimal = Me.Controls("X_TextBox").Text / 1000
|
||||||
|
Dim d2SW As Decimal = Me.Controls("Y_TextBox").Text / 1000
|
||||||
|
|
||||||
|
If pXP < containerMidX Then
|
||||||
|
If pYP > containerMidY Then
|
||||||
|
'Kvadrant 4
|
||||||
|
points.Add("pS" & angleCounter * 3 - 2, {pXP + d1P, pYP, pXSW + d1SW, pYSW})
|
||||||
|
points.Add("pS" & angleCounter * 3 - 1, {pXP + d1P, pYP - d2P, pXSW + d1SW, pYSW + d2SW})
|
||||||
|
points.Add("pS" & angleCounter * 3, {pXP, pYP - d2P, pXSW, pYSW + d2SW})
|
||||||
|
Else
|
||||||
|
'Kvadrant 1
|
||||||
|
points.Add("pS" & angleCounter * 3 - 2, {pXP, pYP + d2P, pXSW, pYSW - d2SW})
|
||||||
|
points.Add("pS" & angleCounter * 3 - 1, {pXP + d1P, pYP + d2P, pXSW + d1SW, pYSW - d2SW})
|
||||||
|
points.Add("pS" & angleCounter * 3, {pXP + d1P, pYP, pXSW + d1SW, pYSW})
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
If pYP > containerMidY Then
|
||||||
|
'Kvadrant 3
|
||||||
|
points.Add("pS" & angleCounter * 3 - 2, {pXP, pYP - d2P, pXSW, pYSW + d2SW})
|
||||||
|
points.Add("pS" & angleCounter * 3 - 1, {pXP - d1P, pYP - d2P, pXSW - d1SW, pYSW + d2SW})
|
||||||
|
points.Add("pS" & angleCounter * 3, {pXP - d1P, pYP, pXSW - d1SW, pYSW})
|
||||||
|
Else
|
||||||
|
'Kvadrant 2
|
||||||
|
points.Add("pS" & angleCounter * 3 - 2, {pXP - d1P, pYP, pXSW - d1SW, pYSW})
|
||||||
|
points.Add("pS" & angleCounter * 3 - 1, {pXP - d1P, pYP + d2P, pXSW - d1SW, pYSW - d2SW})
|
||||||
|
points.Add("pS" & angleCounter * 3, {pXP, pYP + d2P, pXSW, pYSW - d2SW})
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
|
'Insert two new points
|
||||||
|
pointsOrder.Insert(index + 1, "pS" & angleCounter * 3 - 2)
|
||||||
|
pointsOrder.Insert(index + 2, "pS" & angleCounter * 3 - 1)
|
||||||
|
pointsOrder.Insert(index + 3, "pS" & angleCounter * 3)
|
||||||
|
pointsOrder.RemoveAt(index)
|
||||||
|
|
||||||
|
For i = 0 To PointButtons.Count - 1
|
||||||
|
RemoveHandler PointButtons(0).Click, AddressOf PointButton_Click2
|
||||||
|
containerPanel.Controls.RemoveByKey(PointButtons(0).Name)
|
||||||
|
PointButtons.RemoveAt(0)
|
||||||
|
Next
|
||||||
|
|
||||||
|
'Redraw grating
|
||||||
|
Me.Refresh()
|
||||||
|
|
||||||
|
RemoveHandler Me.Controls("X_TextBox").TextChanged, AddressOf SquareText_Changed
|
||||||
|
Me.Controls.RemoveByKey("X_TextBox")
|
||||||
|
|
||||||
|
RemoveHandler Me.Controls("Y_TextBox").TextChanged, AddressOf SquareText_Changed
|
||||||
|
Me.Controls.RemoveByKey("Y_TextBox")
|
||||||
|
|
||||||
|
Me.Controls.RemoveByKey("X_Label")
|
||||||
|
Me.Controls.RemoveByKey("Y_Label")
|
||||||
|
End Sub
|
||||||
|
|
||||||
Private Sub Create_TextBox(TextBoxName As String, TextBoxText As String, TextBoxLeft As Integer, TextBoxTop As Integer, TextBoxWidth As Integer)
|
Private Sub Create_TextBox(TextBoxName As String, TextBoxText As String, TextBoxLeft As Integer, TextBoxTop As Integer, TextBoxWidth As Integer)
|
||||||
Dim textBoxTemp As New TextBox
|
Dim textBoxTemp As New TextBox
|
||||||
textBoxTemp.Name = TextBoxName
|
textBoxTemp.Name = TextBoxName
|
||||||
|
|
@ -248,6 +369,16 @@ Public Class GUI
|
||||||
Me.Controls.Add(textBoxTemp)
|
Me.Controls.Add(textBoxTemp)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Private Sub Create_Label(LabelName As String, LabelText As String, LabelLeft As Integer, LabelTop As Integer)
|
||||||
|
Dim LabelTemp As New Label
|
||||||
|
LabelTemp.Name = LabelName
|
||||||
|
LabelTemp.Text = LabelText
|
||||||
|
LabelTemp.Left = LabelLeft
|
||||||
|
LabelTemp.Top = LabelTop
|
||||||
|
LabelTemp.Font = New Font("Microsoft Sans Serif", 10)
|
||||||
|
Me.Controls.Add(LabelTemp)
|
||||||
|
End Sub
|
||||||
|
|
||||||
Private Sub AngleText_Changed(sender As TextBox, e As EventArgs)
|
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 Not Me.Controls("X_TextBox").Text = "" And Not Me.Controls("Y_TextBox").Text = "" Then
|
||||||
If containerPanel.Controls.Count = 0 Then
|
If containerPanel.Controls.Count = 0 Then
|
||||||
|
|
@ -345,6 +476,9 @@ Public Class GUI
|
||||||
|
|
||||||
RemoveHandler Me.Controls("Y_TextBox").TextChanged, AddressOf AngleText_Changed
|
RemoveHandler Me.Controls("Y_TextBox").TextChanged, AddressOf AngleText_Changed
|
||||||
Me.Controls.RemoveByKey("Y_TextBox")
|
Me.Controls.RemoveByKey("Y_TextBox")
|
||||||
|
|
||||||
|
Me.Controls.RemoveByKey("X_Label")
|
||||||
|
Me.Controls.RemoveByKey("Y_Label")
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
' --- When export to SW button is pressed ---
|
' --- When export to SW button is pressed ---
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue