Added example for point button and fixed a function for creating an angled corner
This commit is contained in:
parent
15dcfcab2d
commit
a97a0d2cec
|
|
@ -32,6 +32,7 @@ Partial Class GUI
|
|||
Me.Label1 = New System.Windows.Forms.Label()
|
||||
Me.Label2 = New System.Windows.Forms.Label()
|
||||
Me.ExportSWButton = New System.Windows.Forms.Button()
|
||||
Me.AngleButton = New System.Windows.Forms.Button()
|
||||
Me.SuspendLayout()
|
||||
'
|
||||
'DrawingPanel
|
||||
|
|
@ -111,11 +112,21 @@ Partial Class GUI
|
|||
Me.ExportSWButton.Text = "Export"
|
||||
Me.ExportSWButton.UseVisualStyleBackColor = False
|
||||
'
|
||||
'AngleButton
|
||||
'
|
||||
Me.AngleButton.Location = New System.Drawing.Point(54, 153)
|
||||
Me.AngleButton.Name = "AngleButton"
|
||||
Me.AngleButton.Size = New System.Drawing.Size(122, 75)
|
||||
Me.AngleButton.TabIndex = 7
|
||||
Me.AngleButton.Text = "Add Angle"
|
||||
Me.AngleButton.UseVisualStyleBackColor = True
|
||||
'
|
||||
'GUI
|
||||
'
|
||||
Me.AutoScaleDimensions = New System.Drawing.SizeF(8.0!, 16.0!)
|
||||
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
|
||||
Me.ClientSize = New System.Drawing.Size(1199, 614)
|
||||
Me.Controls.Add(Me.AngleButton)
|
||||
Me.Controls.Add(Me.ExportSWButton)
|
||||
Me.Controls.Add(Me.Label2)
|
||||
Me.Controls.Add(Me.Label1)
|
||||
|
|
@ -140,4 +151,5 @@ Partial Class GUI
|
|||
Friend WithEvents Label1 As Label
|
||||
Friend WithEvents Label2 As Label
|
||||
Friend WithEvents ExportSWButton As Button
|
||||
Friend WithEvents AngleButton As Button
|
||||
End Class
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ Public Class GUI
|
|||
Dim points As New Dictionary(Of String, Decimal())
|
||||
Dim pointsOrder As New List(Of String)
|
||||
|
||||
'Dim PointButtons As New Dictionary(Of String, Button)
|
||||
|
||||
' --- Start method when GUI loads ---
|
||||
Sub GUI_load() Handles MyBase.Load
|
||||
|
|
@ -28,6 +29,31 @@ Public Class GUI
|
|||
Set_ContainerPointsY()
|
||||
|
||||
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
|
||||
|
||||
' --- Retrive parameters for the drawing box ---
|
||||
|
|
@ -145,7 +171,7 @@ Public Class GUI
|
|||
Set_ContainerPointsY()
|
||||
End If
|
||||
|
||||
'Redraw rectangle
|
||||
'Redraw grating
|
||||
Me.Refresh()
|
||||
|
||||
'SW X-values
|
||||
|
|
@ -161,6 +187,34 @@ Public Class GUI
|
|||
pCon4(3) = (-gratingMaxH / 2) / 1000
|
||||
End Sub
|
||||
|
||||
' --- When angle button is pressed ---
|
||||
Private Sub AngleButton_Click(sender As Object, e As EventArgs) Handles AngleButton.Click
|
||||
'Determine which point is being pressed
|
||||
Dim pointPressed As String
|
||||
pointPressed = "p1" ' Fix this
|
||||
Dim index As Integer = pointsOrder.IndexOf(pointPressed)
|
||||
|
||||
'Retrive that points coords
|
||||
Dim tempX, tempY As Integer
|
||||
tempX = points(pointPressed)(0)
|
||||
tempY = points(pointPressed)(1)
|
||||
|
||||
'Insert two new points
|
||||
points.Add("pT1", {tempX, tempY + 80, 0, 0})
|
||||
pointsOrder.Insert(index + 1, "pT1")
|
||||
points.Add("pT2", {tempX + 50, tempY, 0, 0})
|
||||
pointsOrder.Insert(index + 2, "pT2")
|
||||
|
||||
pointsOrder.RemoveAt(index)
|
||||
|
||||
'Fix those points coords
|
||||
|
||||
'Add those points in pointsOrder and remove orignal point
|
||||
|
||||
'Redraw grating
|
||||
Me.Refresh()
|
||||
End Sub
|
||||
|
||||
' --- When export to SW button is pressed ---
|
||||
Private Sub ExportSWButton_Click(sender As Object, e As EventArgs) Handles ExportSWButton.Click
|
||||
Dim pointTable As New DataTable
|
||||
|
|
|
|||
Loading…
Reference in New Issue