Added buttons for side square recesses

This commit is contained in:
Anton 2021-02-11 15:09:25 +01:00
parent 49e294e498
commit 2f2435e66a
4 changed files with 280 additions and 77 deletions

151
Wardrobe/GUI.Designer.vb generated
View File

@ -49,6 +49,7 @@ Partial Class GUI
Me.Label_Material = New System.Windows.Forms.Label()
Me.CheckBox_WholeMeshWidths = New System.Windows.Forms.CheckBox()
Me.TextBox_Length = New System.Windows.Forms.TextBox()
Me.Button_SquareSide = New System.Windows.Forms.Button()
Me.DrawingPanel.SuspendLayout()
Me.SuspendLayout()
'
@ -57,27 +58,29 @@ Partial Class GUI
Me.DrawingPanel.BackColor = System.Drawing.SystemColors.Window
Me.DrawingPanel.Controls.Add(Me.Label10)
Me.DrawingPanel.Controls.Add(Me.Label8)
Me.DrawingPanel.Location = New System.Drawing.Point(240, 145)
Me.DrawingPanel.Margin = New System.Windows.Forms.Padding(2)
Me.DrawingPanel.Location = New System.Drawing.Point(320, 178)
Me.DrawingPanel.Margin = New System.Windows.Forms.Padding(3, 2, 3, 2)
Me.DrawingPanel.Name = "DrawingPanel"
Me.DrawingPanel.Size = New System.Drawing.Size(1130, 560)
Me.DrawingPanel.Size = New System.Drawing.Size(1507, 689)
Me.DrawingPanel.TabIndex = 0
'
'Label10
'
Me.Label10.AutoSize = True
Me.Label10.Location = New System.Drawing.Point(13, 482)
Me.Label10.Location = New System.Drawing.Point(17, 593)
Me.Label10.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)
Me.Label10.Name = "Label10"
Me.Label10.Size = New System.Drawing.Size(18, 13)
Me.Label10.Size = New System.Drawing.Size(21, 17)
Me.Label10.TabIndex = 1
Me.Label10.Text = "W"
'
'Label8
'
Me.Label8.AutoSize = True
Me.Label8.Location = New System.Drawing.Point(66, 533)
Me.Label8.Location = New System.Drawing.Point(88, 656)
Me.Label8.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)
Me.Label8.Name = "Label8"
Me.Label8.Size = New System.Drawing.Size(13, 13)
Me.Label8.Size = New System.Drawing.Size(16, 17)
Me.Label8.TabIndex = 0
Me.Label8.Text = "L"
'
@ -91,9 +94,10 @@ Partial Class GUI
'
Me.Label1.AutoSize = True
Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.Location = New System.Drawing.Point(45, 400)
Me.Label1.Location = New System.Drawing.Point(60, 492)
Me.Label1.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(44, 17)
Me.Label1.Size = New System.Drawing.Size(52, 20)
Me.Label1.TabIndex = 4
Me.Label1.Text = "Width"
'
@ -101,39 +105,40 @@ Partial Class GUI
'
Me.Label2.AutoSize = True
Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label2.Location = New System.Drawing.Point(34, 460)
Me.Label2.Location = New System.Drawing.Point(45, 566)
Me.Label2.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(52, 17)
Me.Label2.Size = New System.Drawing.Size(60, 20)
Me.Label2.TabIndex = 5
Me.Label2.Text = "Length"
'
'ExportSWButton
'
Me.ExportSWButton.BackColor = System.Drawing.SystemColors.ActiveCaption
Me.ExportSWButton.Location = New System.Drawing.Point(1281, 717)
Me.ExportSWButton.Margin = New System.Windows.Forms.Padding(2)
Me.ExportSWButton.Location = New System.Drawing.Point(1708, 882)
Me.ExportSWButton.Margin = New System.Windows.Forms.Padding(3, 2, 3, 2)
Me.ExportSWButton.Name = "ExportSWButton"
Me.ExportSWButton.Size = New System.Drawing.Size(92, 33)
Me.ExportSWButton.Size = New System.Drawing.Size(123, 41)
Me.ExportSWButton.TabIndex = 6
Me.ExportSWButton.Text = "Export"
Me.ExportSWButton.UseVisualStyleBackColor = False
'
'AngleButton
'
Me.AngleButton.Location = New System.Drawing.Point(529, 55)
Me.AngleButton.Margin = New System.Windows.Forms.Padding(2)
Me.AngleButton.Location = New System.Drawing.Point(705, 68)
Me.AngleButton.Margin = New System.Windows.Forms.Padding(3, 2, 3, 2)
Me.AngleButton.Name = "AngleButton"
Me.AngleButton.Size = New System.Drawing.Size(92, 28)
Me.AngleButton.Size = New System.Drawing.Size(123, 34)
Me.AngleButton.TabIndex = 7
Me.AngleButton.Text = "Add Angle"
Me.AngleButton.UseVisualStyleBackColor = True
'
'SettingsButton
'
Me.SettingsButton.Location = New System.Drawing.Point(11, 709)
Me.SettingsButton.Margin = New System.Windows.Forms.Padding(2)
Me.SettingsButton.Location = New System.Drawing.Point(15, 873)
Me.SettingsButton.Margin = New System.Windows.Forms.Padding(3, 2, 3, 2)
Me.SettingsButton.Name = "SettingsButton"
Me.SettingsButton.Size = New System.Drawing.Size(60, 41)
Me.SettingsButton.Size = New System.Drawing.Size(80, 50)
Me.SettingsButton.TabIndex = 12
Me.SettingsButton.Text = "Settings"
Me.SettingsButton.UseVisualStyleBackColor = True
@ -143,10 +148,10 @@ Partial Class GUI
Me.ComboBox_TypeChooser.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
Me.ComboBox_TypeChooser.FormattingEnabled = True
Me.ComboBox_TypeChooser.Items.AddRange(New Object() {"Pressure Welded", "Type A"})
Me.ComboBox_TypeChooser.Location = New System.Drawing.Point(91, 46)
Me.ComboBox_TypeChooser.Margin = New System.Windows.Forms.Padding(2)
Me.ComboBox_TypeChooser.Location = New System.Drawing.Point(121, 57)
Me.ComboBox_TypeChooser.Margin = New System.Windows.Forms.Padding(3, 2, 3, 2)
Me.ComboBox_TypeChooser.Name = "ComboBox_TypeChooser"
Me.ComboBox_TypeChooser.Size = New System.Drawing.Size(141, 21)
Me.ComboBox_TypeChooser.Size = New System.Drawing.Size(187, 24)
Me.ComboBox_TypeChooser.TabIndex = 13
Me.ComboBox_TypeChooser.Tag = ""
'
@ -156,10 +161,10 @@ Partial Class GUI
Me.ComboBox_MeshSize.Enabled = False
Me.ComboBox_MeshSize.FormattingEnabled = True
Me.ComboBox_MeshSize.Items.AddRange(New Object() {"12x100 (B9)", "25x50 (F4)", "34x37 (H3)"})
Me.ComboBox_MeshSize.Location = New System.Drawing.Point(91, 196)
Me.ComboBox_MeshSize.Margin = New System.Windows.Forms.Padding(2)
Me.ComboBox_MeshSize.Location = New System.Drawing.Point(121, 241)
Me.ComboBox_MeshSize.Margin = New System.Windows.Forms.Padding(3, 2, 3, 2)
Me.ComboBox_MeshSize.Name = "ComboBox_MeshSize"
Me.ComboBox_MeshSize.Size = New System.Drawing.Size(141, 21)
Me.ComboBox_MeshSize.Size = New System.Drawing.Size(187, 24)
Me.ComboBox_MeshSize.TabIndex = 14
'
'ComboBox_Thickness
@ -168,10 +173,10 @@ Partial Class GUI
Me.ComboBox_Thickness.Enabled = False
Me.ComboBox_Thickness.FormattingEnabled = True
Me.ComboBox_Thickness.Items.AddRange(New Object() {"2", "3", "4"})
Me.ComboBox_Thickness.Location = New System.Drawing.Point(91, 305)
Me.ComboBox_Thickness.Margin = New System.Windows.Forms.Padding(2)
Me.ComboBox_Thickness.Location = New System.Drawing.Point(121, 375)
Me.ComboBox_Thickness.Margin = New System.Windows.Forms.Padding(3, 2, 3, 2)
Me.ComboBox_Thickness.Name = "ComboBox_Thickness"
Me.ComboBox_Thickness.Size = New System.Drawing.Size(141, 21)
Me.ComboBox_Thickness.Size = New System.Drawing.Size(187, 24)
Me.ComboBox_Thickness.TabIndex = 15
'
'ComboBox_Height
@ -180,19 +185,20 @@ Partial Class GUI
Me.ComboBox_Height.Enabled = False
Me.ComboBox_Height.FormattingEnabled = True
Me.ComboBox_Height.Items.AddRange(New Object() {"20", "25", "30"})
Me.ComboBox_Height.Location = New System.Drawing.Point(91, 264)
Me.ComboBox_Height.Margin = New System.Windows.Forms.Padding(2)
Me.ComboBox_Height.Location = New System.Drawing.Point(121, 325)
Me.ComboBox_Height.Margin = New System.Windows.Forms.Padding(3, 2, 3, 2)
Me.ComboBox_Height.Name = "ComboBox_Height"
Me.ComboBox_Height.Size = New System.Drawing.Size(141, 21)
Me.ComboBox_Height.Size = New System.Drawing.Size(187, 24)
Me.ComboBox_Height.TabIndex = 16
'
'Label3
'
Me.Label3.AutoSize = True
Me.Label3.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label3.Location = New System.Drawing.Point(46, 45)
Me.Label3.Location = New System.Drawing.Point(61, 55)
Me.Label3.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(40, 17)
Me.Label3.Size = New System.Drawing.Size(45, 20)
Me.Label3.TabIndex = 17
Me.Label3.Text = "Type"
'
@ -200,9 +206,10 @@ Partial Class GUI
'
Me.Label4.AutoSize = True
Me.Label4.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label4.Location = New System.Drawing.Point(13, 197)
Me.Label4.Location = New System.Drawing.Point(17, 242)
Me.Label4.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(73, 17)
Me.Label4.Size = New System.Drawing.Size(88, 20)
Me.Label4.TabIndex = 18
Me.Label4.Text = "Mesh Size"
'
@ -210,9 +217,10 @@ Partial Class GUI
'
Me.Label5.AutoSize = True
Me.Label5.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label5.Location = New System.Drawing.Point(14, 306)
Me.Label5.Location = New System.Drawing.Point(19, 377)
Me.Label5.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(72, 17)
Me.Label5.Size = New System.Drawing.Size(85, 20)
Me.Label5.TabIndex = 19
Me.Label5.Text = "Thickness"
'
@ -220,9 +228,10 @@ Partial Class GUI
'
Me.Label6.AutoSize = True
Me.Label6.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label6.Location = New System.Drawing.Point(37, 264)
Me.Label6.Location = New System.Drawing.Point(49, 325)
Me.Label6.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(49, 17)
Me.Label6.Size = New System.Drawing.Size(58, 20)
Me.Label6.TabIndex = 20
Me.Label6.Text = "Height"
'
@ -230,9 +239,10 @@ Partial Class GUI
'
Me.Label7.AutoSize = True
Me.Label7.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label7.Location = New System.Drawing.Point(394, 31)
Me.Label7.Location = New System.Drawing.Point(525, 38)
Me.Label7.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)
Me.Label7.Name = "Label7"
Me.Label7.Size = New System.Drawing.Size(78, 17)
Me.Label7.Size = New System.Drawing.Size(91, 20)
Me.Label7.TabIndex = 21
Me.Label7.Text = "Functions"
'
@ -242,28 +252,30 @@ Partial Class GUI
Me.ComboBox_Width.Enabled = False
Me.ComboBox_Width.FormattingEnabled = True
Me.ComboBox_Width.Items.AddRange(New Object() {"500", "700", "722", "1000"})
Me.ComboBox_Width.Location = New System.Drawing.Point(94, 400)
Me.ComboBox_Width.Margin = New System.Windows.Forms.Padding(2)
Me.ComboBox_Width.Location = New System.Drawing.Point(125, 492)
Me.ComboBox_Width.Margin = New System.Windows.Forms.Padding(3, 2, 3, 2)
Me.ComboBox_Width.Name = "ComboBox_Width"
Me.ComboBox_Width.Size = New System.Drawing.Size(141, 21)
Me.ComboBox_Width.Size = New System.Drawing.Size(187, 24)
Me.ComboBox_Width.TabIndex = 23
'
'Button_Square
'
Me.Button_Square.Location = New System.Drawing.Point(716, 55)
Me.Button_Square.Location = New System.Drawing.Point(955, 68)
Me.Button_Square.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4)
Me.Button_Square.Name = "Button_Square"
Me.Button_Square.Size = New System.Drawing.Size(92, 28)
Me.Button_Square.Size = New System.Drawing.Size(123, 34)
Me.Button_Square.TabIndex = 25
Me.Button_Square.Text = "Add Square Corner"
Me.Button_Square.Text = "Add Square C"
Me.Button_Square.UseVisualStyleBackColor = True
'
'Label9
'
Me.Label9.AutoSize = True
Me.Label9.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label9.Location = New System.Drawing.Point(13, 12)
Me.Label9.Location = New System.Drawing.Point(17, 15)
Me.Label9.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)
Me.Label9.Name = "Label9"
Me.Label9.Size = New System.Drawing.Size(146, 17)
Me.Label9.Size = New System.Drawing.Size(168, 20)
Me.Label9.TabIndex = 26
Me.Label9.Text = "Floor gratings data"
'
@ -273,19 +285,20 @@ Partial Class GUI
Me.ComboBox_Material.Enabled = False
Me.ComboBox_Material.FormattingEnabled = True
Me.ComboBox_Material.Items.AddRange(New Object() {"12x100 (B9)", "25x50 (F4)", "34x37 (H3)"})
Me.ComboBox_Material.Location = New System.Drawing.Point(91, 88)
Me.ComboBox_Material.Margin = New System.Windows.Forms.Padding(2)
Me.ComboBox_Material.Location = New System.Drawing.Point(121, 108)
Me.ComboBox_Material.Margin = New System.Windows.Forms.Padding(3, 2, 3, 2)
Me.ComboBox_Material.Name = "ComboBox_Material"
Me.ComboBox_Material.Size = New System.Drawing.Size(141, 21)
Me.ComboBox_Material.Size = New System.Drawing.Size(187, 24)
Me.ComboBox_Material.TabIndex = 27
'
'Label_Material
'
Me.Label_Material.AutoSize = True
Me.Label_Material.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label_Material.Location = New System.Drawing.Point(28, 88)
Me.Label_Material.Location = New System.Drawing.Point(37, 108)
Me.Label_Material.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)
Me.Label_Material.Name = "Label_Material"
Me.Label_Material.Size = New System.Drawing.Size(58, 17)
Me.Label_Material.Size = New System.Drawing.Size(69, 20)
Me.Label_Material.TabIndex = 28
Me.Label_Material.Text = "Material"
'
@ -293,10 +306,10 @@ Partial Class GUI
'
Me.CheckBox_WholeMeshWidths.AutoSize = True
Me.CheckBox_WholeMeshWidths.Enabled = False
Me.CheckBox_WholeMeshWidths.Location = New System.Drawing.Point(94, 368)
Me.CheckBox_WholeMeshWidths.Margin = New System.Windows.Forms.Padding(2)
Me.CheckBox_WholeMeshWidths.Location = New System.Drawing.Point(125, 453)
Me.CheckBox_WholeMeshWidths.Margin = New System.Windows.Forms.Padding(3, 2, 3, 2)
Me.CheckBox_WholeMeshWidths.Name = "CheckBox_WholeMeshWidths"
Me.CheckBox_WholeMeshWidths.Size = New System.Drawing.Size(121, 18)
Me.CheckBox_WholeMeshWidths.Size = New System.Drawing.Size(143, 21)
Me.CheckBox_WholeMeshWidths.TabIndex = 29
Me.CheckBox_WholeMeshWidths.Text = "Whole mesh widths"
Me.CheckBox_WholeMeshWidths.UseCompatibleTextRendering = True
@ -305,17 +318,27 @@ Partial Class GUI
'TextBox_Length
'
Me.TextBox_Length.Enabled = False
Me.TextBox_Length.Location = New System.Drawing.Point(94, 460)
Me.TextBox_Length.Margin = New System.Windows.Forms.Padding(2)
Me.TextBox_Length.Location = New System.Drawing.Point(125, 566)
Me.TextBox_Length.Margin = New System.Windows.Forms.Padding(3, 2, 3, 2)
Me.TextBox_Length.Name = "TextBox_Length"
Me.TextBox_Length.Size = New System.Drawing.Size(141, 20)
Me.TextBox_Length.Size = New System.Drawing.Size(187, 22)
Me.TextBox_Length.TabIndex = 30
'
'Button_SquareSide
'
Me.Button_SquareSide.Location = New System.Drawing.Point(1224, 68)
Me.Button_SquareSide.Name = "Button_SquareSide"
Me.Button_SquareSide.Size = New System.Drawing.Size(121, 35)
Me.Button_SquareSide.TabIndex = 31
Me.Button_SquareSide.Text = "Square Side"
Me.Button_SquareSide.UseVisualStyleBackColor = True
'
'GUI
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleDimensions = New System.Drawing.SizeF(8.0!, 16.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(1155, 687)
Me.ClientSize = New System.Drawing.Size(1540, 846)
Me.Controls.Add(Me.Button_SquareSide)
Me.Controls.Add(Me.TextBox_Length)
Me.Controls.Add(Me.AngleButton)
Me.Controls.Add(Me.Button_Square)
@ -340,6 +363,7 @@ Partial Class GUI
Me.Controls.Add(Me.DrawingPanel)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4)
Me.MaximizeBox = False
Me.Name = "GUI"
Me.Text = "Floor Gratings"
@ -375,4 +399,5 @@ Partial Class GUI
Friend WithEvents TextBox_Length As TextBox
Friend WithEvents Label10 As Label
Friend WithEvents Label8 As Label
Friend WithEvents Button_SquareSide As Button
End Class

View File

@ -2,8 +2,8 @@
Imports Excel = Microsoft.Office.Interop.Excel
Public Class GUI
'Public Shared filepath As String = "C:\Users\Anton\Documents\Exjobb"
Public Shared filepath As String = "C:\Users\xperd\Documents"
Public Shared filepath As String = "C:\Users\Anton\Documents\Exjobb"
'Public Shared filepath As String = "C:\Users\xperd\Documents"
Dim excelApp As Excel.Application = New Excel.Application
Dim excelWB As Excel.Workbook
@ -171,11 +171,16 @@ Public Class GUI
GUI_Functions.AngleButton(sender, e)
End Sub
' --- When square button is pressed ---
' --- When square corner button is pressed ---
Private Sub Button_Square_Click(sender As Object, e As EventArgs) Handles Button_Square.Click
GUI_Functions.SquareButtton(sender, e)
End Sub
' --- When square side button is pressed ---
Private Sub Button_SquareSide_Click(sender As Object, e As EventArgs) Handles Button_SquareSide.Click
GUI_Functions.SquareSideButtton(sender, e)
End Sub
' ---------------------------------- Settings ----------------------------------
' --- Settings button clicked ---
Private Sub SettingsButton_Click(sender As Object, e As EventArgs) Handles SettingsButton.Click
@ -189,4 +194,5 @@ Public Class GUI
SW_Drawing_Gratings.CreateDrawing()
End Sub
End Class

View File

@ -158,8 +158,8 @@
' --- Draw all the lines for the container and grating ---
Public Shared Sub DrawingPanel_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs)
' Draw outer grating (red)
Dim penCon As Pen = New Pen(Color.DarkRed, 2)
penCon.DashPattern = {4, 8}
Dim penCon As Pen = New Pen(Color.Red, 2)
penCon.DashPattern = {4, 6}
e.Graphics.DrawLine(penCon, CInt(pCon1(0)), CInt(pCon1(1)), CInt(pCon2(0)), CInt(pCon2(1)))
e.Graphics.DrawLine(penCon, CInt(pCon2(0)), CInt(pCon2(1)), CInt(pCon3(0)), CInt(pCon3(1)))
e.Graphics.DrawLine(penCon, CInt(pCon3(0)), CInt(pCon3(1)), CInt(pCon4(0)), CInt(pCon4(1)))

View File

@ -1,6 +1,7 @@
Public Class GUI_Functions
Private Shared angleFunctionActive As Boolean = False
Private Shared squareFunctionActive As Boolean = False
Private Shared squareSideFunctionActive As Boolean = False
Private Shared pointCounter As Integer
@ -11,16 +12,19 @@
Public Shared Sub AngleButton(sender As Object, e As EventArgs)
GUI.Controls("AngleButton").Enabled = False
GUI.Controls("Button_Square").Enabled = False
GUI.Controls("Button_SquareSide").Enabled = False
Dim buttonX As Integer = GUI.Controls("AngleButton").Location.X
Dim buttonY As Integer = GUI.Controls("AngleButton").Location.Y
GUI.Create_TextBox("X_TextBox", "", buttonX + 20, buttonY + 40, 60)
AddHandler GUI.Controls("X_TextBox").TextChanged, AddressOf FunctionText_Changed
AddHandler GUI.Controls("X_TextBox").TextChanged, AddressOf FunctionTextCorner_Changed
AddHandler GUI.Controls("X_TextBox").KeyPress, AddressOf FunctionText_KeyPress
GUI.Create_LabelGUI("X_Label", "1", buttonX, buttonY + 43)
GUI.Create_TextBox("Y_TextBox", "", buttonX + 130, buttonY + 40, 60)
AddHandler GUI.Controls("Y_TextBox").TextChanged, AddressOf FunctionText_Changed
AddHandler GUI.Controls("Y_TextBox").TextChanged, AddressOf FunctionTextCorner_Changed
AddHandler GUI.Controls("Y_TextBox").KeyPress, AddressOf FunctionText_KeyPress
GUI.Create_LabelGUI("Y_Label", "2", buttonX + 110, buttonY + 43)
angleFunctionActive = True
@ -29,16 +33,19 @@
Public Shared Sub SquareButtton(sender As Object, e As EventArgs)
GUI.Controls("AngleButton").Enabled = False
GUI.Controls("Button_Square").Enabled = False
GUI.Controls("Button_SquareSide").Enabled = False
Dim buttonX As Integer = GUI.Controls("Button_Square").Location.X
Dim buttonY As Integer = GUI.Controls("Button_Square").Location.Y
GUI.Create_TextBox("X_TextBox", "", buttonX + 20, buttonY + 40, 60)
AddHandler GUI.Controls("X_TextBox").TextChanged, AddressOf FunctionText_Changed
AddHandler GUI.Controls("X_TextBox").TextChanged, AddressOf FunctionTextCorner_Changed
AddHandler GUI.Controls("X_TextBox").KeyPress, AddressOf FunctionText_KeyPress
GUI.Create_LabelGUI("X_Label", "1", buttonX, buttonY + 43)
GUI.Create_TextBox("Y_TextBox", "", buttonX + 130, buttonY + 40, 60)
AddHandler GUI.Controls("Y_TextBox").TextChanged, AddressOf FunctionText_Changed
AddHandler GUI.Controls("Y_TextBox").TextChanged, AddressOf FunctionTextCorner_Changed
AddHandler GUI.Controls("Y_TextBox").KeyPress, AddressOf FunctionText_KeyPress
GUI.Create_LabelGUI("Y_Label", "2", buttonX + 110, buttonY + 43)
' Add option for corner or side
@ -46,10 +53,49 @@
squareFunctionActive = True
End Sub
Private Shared Sub FunctionText_Changed(sender As TextBox, e As EventArgs)
If Not GUI.Controls("X_TextBox").Text = "" And Not GUI.Controls("Y_TextBox").Text = "" Then
Public Shared Sub SquareSideButtton(sender As Object, e As EventArgs)
GUI.Controls("AngleButton").Enabled = False
GUI.Controls("Button_Square").Enabled = False
GUI.Controls("Button_SquareSide").Enabled = False
Dim buttonX As Integer = GUI.Controls("Button_SquareSide").Location.X
Dim buttonY As Integer = GUI.Controls("Button_SquareSide").Location.Y
GUI.Create_TextBox("X_TextBox", "", buttonX + 20, buttonY + 40, 60)
AddHandler GUI.Controls("X_TextBox").TextChanged, AddressOf FunctionTextSide_Changed
AddHandler GUI.Controls("X_TextBox").KeyPress, AddressOf FunctionText_KeyPress
GUI.Create_LabelGUI("X_Label", "L", buttonX, buttonY + 43)
GUI.Create_TextBox("Y_TextBox", "", buttonX + 130, buttonY + 40, 60)
AddHandler GUI.Controls("Y_TextBox").TextChanged, AddressOf FunctionTextSide_Changed
AddHandler GUI.Controls("Y_TextBox").KeyPress, AddressOf FunctionText_KeyPress
GUI.Create_LabelGUI("Y_Label", "W", buttonX + 110, buttonY + 43)
GUI.Create_TextBox("Off_TextBox", "", buttonX + 250, buttonY + 40, 60)
AddHandler GUI.Controls("Off_TextBox").TextChanged, AddressOf FunctionTextSide_Changed
AddHandler GUI.Controls("Off_TextBox").KeyPress, AddressOf FunctionText_KeyPress
GUI.Create_LabelGUI("Off_Label", "Offset", buttonX + 210, buttonY + 43)
' Add option for corner or side
squareSideFunctionActive = True
End Sub
Private Shared Sub FunctionText_KeyPress(sender As Object, e As KeyPressEventArgs)
GUI_Gratings_Data.Check_IfNumber(e)
End Sub
Private Shared Sub FunctionTextCorner_Changed(sender As TextBox, e As EventArgs)
Dim value1, value2 As Integer
Try
value1 = CInt(GUI.Controls("X_TextBox").Text)
value2 = CInt(GUI.Controls("Y_TextBox").Text)
Catch ex As Exception
value1 = 0
value2 = 0
End Try
If value1 > 0 AndAlso value2 > 0 Then
If GUI.DrawingPanel.Controls.Count = 2 Then
' Create Buttons for all clickable points
For i = 0 To GUI_Drawing_Panel.pointsOrder.Count - 1
If pointsFunc(GUI_Drawing_Panel.pointsOrder(i)) Then
Dim pointButton As New Button
@ -79,9 +125,133 @@
Next
pointCounter = pointCounter + 1
End If
ElseIf GUI.DrawingPanel.Controls.Count > 2 Then
For i = 0 To GUI_Drawing_Panel.pointsOrder.Count - 1
If pointsFunc(GUI_Drawing_Panel.pointsOrder(i)) Then
RemoveHandler GUI.DrawingPanel.Controls(GUI_Drawing_Panel.pointsOrder(i) & "_Button").Click,
AddressOf PointButton_Click
GUI.DrawingPanel.Controls.RemoveByKey(GUI_Drawing_Panel.pointsOrder(i) & "_Button")
End If
Next
pointCounter = pointCounter - 1
End If
End Sub
Private Shared Sub FunctionTextSide_Changed(sender As TextBox, e As EventArgs)
Dim value1, value2, value3 As Integer
Try
value1 = CInt(GUI.Controls("X_TextBox").Text)
value2 = CInt(GUI.Controls("Y_TextBox").Text)
value3 = CInt(GUI.Controls("Off_TextBox").Text)
Catch ex As Exception
value1 = 0
value2 = 0
value3 = 0
End Try
If value1 > 0 AndAlso value2 > 0 AndAlso value3 > 0 Then
If GUI.DrawingPanel.Controls.Count = 2 Then
For i = 1 To 4 ' Kommer behöva fungera generiskt
Dim sidePoints As New List(Of String)
If i = 1 Then
For j = 0 To GUI_Drawing_Panel.pointsOrder.Count - 1
If GUI_Drawing_Panel.points(GUI_Drawing_Panel.pointsOrder(j))(1) = GUI_Drawing_Panel.pCon1(1) Then
sidePoints.Add(GUI_Drawing_Panel.pointsOrder(j))
End If
Next
For j = 1 To sidePoints.Count / 2
Create_SideButton(value1 / (GUI_Drawing_Panel.scaleDiff), 30,
GUI_Drawing_Panel.pCon1(0) + value3 / (GUI_Drawing_Panel.scaleDiff),
GUI_Drawing_Panel.pCon1(1) - 30 / 2, "Button_" & i & j)
Next
ElseIf i = 2 Then
For j = 1 To GUI_Drawing_Panel.pointsOrder.Count - 1
If GUI_Drawing_Panel.points(GUI_Drawing_Panel.pointsOrder(j))(0) = GUI_Drawing_Panel.pCon2(0) Then
sidePoints.Add(GUI_Drawing_Panel.pointsOrder(j))
End If
Next
For j = 1 To sidePoints.Count / 2
Create_SideButton(30, value2 / (GUI_Drawing_Panel.scaleDiff),
GUI_Drawing_Panel.pCon2(0) - 30 / 2,
GUI_Drawing_Panel.pCon1(1) + value3 / (GUI_Drawing_Panel.scaleDiff), "Button_" & i & j)
Next
ElseIf i = 3 Then
For j = 2 To GUI_Drawing_Panel.pointsOrder.Count - 1
If GUI_Drawing_Panel.points(GUI_Drawing_Panel.pointsOrder(j))(1) = GUI_Drawing_Panel.pCon3(1) Then
sidePoints.Add(GUI_Drawing_Panel.pointsOrder(j))
End If
Next
For j = 1 To sidePoints.Count / 2
Create_SideButton(value1 / (GUI_Drawing_Panel.scaleDiff), 30,
GUI_Drawing_Panel.pCon1(0) + value3 / (GUI_Drawing_Panel.scaleDiff),
GUI_Drawing_Panel.pCon3(1) - 30 / 2, "Button_" & i & j)
Next
Else
For j = 3 To GUI_Drawing_Panel.pointsOrder.Count - 1
If GUI_Drawing_Panel.points(GUI_Drawing_Panel.pointsOrder(j))(0) = GUI_Drawing_Panel.pCon1(0) Then
sidePoints.Add(GUI_Drawing_Panel.pointsOrder(j))
End If
Next
sidePoints.Add(GUI_Drawing_Panel.pointsOrder(0))
For j = 1 To sidePoints.Count / 2
Create_SideButton(30, value2 / (GUI_Drawing_Panel.scaleDiff),
GUI_Drawing_Panel.pCon1(0) - 30 / 2,
GUI_Drawing_Panel.pCon1(1) + value3 / (GUI_Drawing_Panel.scaleDiff), "Button_" & i & j)
Next
End If
Next
pointCounter = pointCounter + 1
Else
'flytta knapparna/ändra storlek
End If
ElseIf GUI.DrawingPanel.Controls.Count > 2 Then
' FIXA HUR DESSA KNAPPAR TAS BORT
For i = 0 To GUI_Drawing_Panel.pointsOrder.Count - 1
If pointsFunc(GUI_Drawing_Panel.pointsOrder(i)) Then
RemoveHandler GUI.DrawingPanel.Controls(GUI_Drawing_Panel.pointsOrder(i) & "_Button").Click,
AddressOf PointButton_Click
GUI.DrawingPanel.Controls.RemoveByKey(GUI_Drawing_Panel.pointsOrder(i) & "_Button")
End If
Next
pointCounter = pointCounter - 1
End If
End Sub
Private Shared Sub Create_SideButton(bWidth As Integer, bHeight As Integer, bLeft As Integer, bTop As Integer, bName As String)
Dim pointButton As New Button
pointButton.Width = bWidth
pointButton.Height = bHeight
pointButton.Left = bLeft
pointButton.Top = bTop
pointButton.Name = bName
pointButton.Text = ""
pointButton.BackColor = Color.FromArgb(50, Color.Red)
pointButton.FlatStyle = FlatStyle.Flat
pointButton.FlatAppearance.BorderSize = 0
pointButton.FlatAppearance.MouseOverBackColor = Color.Red
pointButton.FlatAppearance.MouseDownBackColor = Color.DarkRed
GUI.DrawingPanel.Controls.Add(pointButton)
AddHandler pointButton.Click, AddressOf PointButton_Click
End Sub
' --- When a function button is pressed ---
Private Shared Sub PointButton_Click(sender As Button, e As EventArgs)
'Determine which point is being pressed
@ -362,10 +532,12 @@
'Redraw grating
GUI.DrawingPanel.Refresh()
RemoveHandler GUI.Controls("X_TextBox").TextChanged, AddressOf FunctionText_Changed
RemoveHandler GUI.Controls("X_TextBox").TextChanged, AddressOf FunctionTextCorner_Changed
RemoveHandler GUI.Controls("X_TextBox").KeyPress, AddressOf FunctionText_KeyPress
GUI.Controls.RemoveByKey("X_TextBox")
RemoveHandler GUI.Controls("Y_TextBox").TextChanged, AddressOf FunctionText_Changed
RemoveHandler GUI.Controls("Y_TextBox").TextChanged, AddressOf FunctionTextCorner_Changed
RemoveHandler GUI.Controls("Y_TextBox").KeyPress, AddressOf FunctionText_KeyPress
GUI.Controls.RemoveByKey("Y_TextBox")
GUI.Controls.RemoveByKey("X_Label")