New file structure done

This commit is contained in:
Anton 2021-02-08 11:46:02 +01:00
parent 5b1ef57515
commit 318f83993f
6 changed files with 488 additions and 481 deletions

129
Wardrobe/GUI.Designer.vb generated
View File

@ -52,10 +52,10 @@ Partial Class GUI
'DrawingPanel
'
Me.DrawingPanel.BackColor = System.Drawing.SystemColors.Window
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
'
'ContextMenuStrip1
@ -68,9 +68,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"
'
@ -78,39 +79,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(586, 55)
Me.AngleButton.Margin = New System.Windows.Forms.Padding(2)
Me.AngleButton.Location = New System.Drawing.Point(781, 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
@ -120,10 +122,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 = ""
'
@ -133,10 +135,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
@ -145,10 +147,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
@ -157,19 +159,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"
'
@ -177,9 +180,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"
'
@ -187,9 +191,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"
'
@ -197,9 +202,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"
'
@ -207,9 +213,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(306, 28)
Me.Label7.Location = New System.Drawing.Point(408, 34)
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"
'
@ -219,10 +226,10 @@ 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
'
'ComboBox_Length
@ -230,17 +237,18 @@ Partial Class GUI
Me.ComboBox_Length.Enabled = False
Me.ComboBox_Length.FormattingEnabled = True
Me.ComboBox_Length.Items.AddRange(New Object() {"300", "600", "900", "1000", "3000"})
Me.ComboBox_Length.Location = New System.Drawing.Point(94, 460)
Me.ComboBox_Length.Margin = New System.Windows.Forms.Padding(2)
Me.ComboBox_Length.Location = New System.Drawing.Point(125, 566)
Me.ComboBox_Length.Margin = New System.Windows.Forms.Padding(3, 2, 3, 2)
Me.ComboBox_Length.Name = "ComboBox_Length"
Me.ComboBox_Length.Size = New System.Drawing.Size(141, 21)
Me.ComboBox_Length.Size = New System.Drawing.Size(187, 24)
Me.ComboBox_Length.TabIndex = 24
'
'Button_Square
'
Me.Button_Square.Location = New System.Drawing.Point(728, 55)
Me.Button_Square.Location = New System.Drawing.Point(971, 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.UseVisualStyleBackColor = True
@ -249,9 +257,10 @@ Partial Class GUI
'
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"
'
@ -261,31 +270,30 @@ 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"
'
'CheckBox_WholeMeshWidths
'
Me.CheckBox_WholeMeshWidths.AutoSize = True
Me.CheckBox_WholeMeshWidths.Checked = True
Me.CheckBox_WholeMeshWidths.CheckState = System.Windows.Forms.CheckState.Checked
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
@ -293,9 +301,9 @@ Partial Class GUI
'
'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(1384, 761)
Me.ClientSize = New System.Drawing.Size(1845, 937)
Me.Controls.Add(Me.AngleButton)
Me.Controls.Add(Me.Button_Square)
Me.Controls.Add(Me.Label7)
@ -320,6 +328,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"

View File

@ -2,59 +2,29 @@
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"
Dim filesFolder As String = filepath ' Hämta från settings
Dim HLCtFolder As String = filepath & "\X2021" ' Hämta från settings
Public Shared containerPanel As Panel
Dim gratingType, gratingMaterial, gratingMesh As String
Dim gratingSerrated As Boolean = False
Dim loadBarSpacing, crossBarSpacing, gratingHeight, loadBarThickness As Integer
Dim pointCounter As Integer
Dim angleFunctionActive As Boolean = False
Dim squareFunctionActive As Boolean = False
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
Dim excelSheet As Excel.Worksheet
Dim serratedCheckBox As New CheckBox
Dim serratedCheckBoxBol As Boolean = False
Dim lacqueredCheckBox As New CheckBox
Dim lacqueredCheckBoxBol As Boolean = False
Dim gratingLacquered As Boolean = False
Dim dataBase As New Dictionary(Of String, DataTable)
Public Shared dataBase As New Dictionary(Of String, DataTable)
' --- Start method (main) for GUI ---
Sub GUI_load() Handles MyBase.Load
containerPanel = DrawingPanel
Me.Width = 1400
Me.Height = 800
AddHandler containerPanel.Paint, AddressOf GUI_Drawing_Panel.DrawingPanel_Paint
AddHandler DrawingPanel.Paint, AddressOf GUI_Drawing_Panel.DrawingPanel_Paint
GUI_Drawing_Panel.Load_DrawingPanel()
adminClass.loadSettings(GUI_Settings.filesFolder, GUI_Settings.HLCtFolder, "SolidWorks")
adminClass.loadSettings(filesFolder, HLCtFolder, "SolidWorks")
'Program.Load_XCC(filesFolder, HLCtFolder)
Get_Database()
End Sub
Private Sub Get_Database()
excelWB = excelApp.Workbooks.Open(HLCtFolder & "\Databas.xlsx")
excelWB = excelApp.Workbooks.Open(GUI_Settings.HLCtFolder & "\Databas.xlsx")
For i = 1 To 3 'excelWB.Worksheets.Count
Dim activeSheet As Excel.Worksheet
@ -88,14 +58,29 @@ Public Class GUI
' HANTERA OLIKA LÄNGDER COLUMNER
End Sub
Public 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
Public 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
' ---------------------------------- GUI interactions ----------------------------------
' ---------------------------------- Gratings Data ----------------------------------
' --- When user changes grating type ---
Private Sub ComboBox_TypeChooser_TextChanged(sender As Object, e As EventArgs) Handles ComboBox_TypeChooser.TextChanged
GUI_Gratings_Data.TypeChanged(sender, e)
@ -105,38 +90,30 @@ Public Class GUI
' --- When user changes grating material ---
Private Sub ComboBox_Material_TextChanged(sender As Object, e As EventArgs) Handles ComboBox_Material.TextChanged
GUI_Gratings_Data.MaterialChanged(sender, e)
End Sub
' --- When user changes mesh size ---
Private Sub ComboBox_MeshSize_TextChanged(sender As Object, e As EventArgs) Handles ComboBox_MeshSize.TextChanged
GUI_Gratings_Data.MeshChanged(sender, e)
End Sub
' --- When user changes grating height ---
Private Sub ComboBox_Height_TextChanged(sender As Object, e As EventArgs) Handles ComboBox_Height.TextChanged
GUI_Gratings_Data.HeightChanged(sender, e)
End Sub
' --- When user changes grating thickness ---
Private Sub ComboBox_Thickness_TextChanged(sender As Object, e As EventArgs) Handles ComboBox_Thickness.TextChanged
GUI_Gratings_Data.ThicknessChanged(sender, e)
End Sub
Private Sub CheckBox_WholeMeshWidths_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox_WholeMeshWidths.CheckedChanged
GUI_Gratings_Data.WholeMeshWidthsChanged(sender, e)
End Sub
' --- Grating width changed ---
Private Sub WidthB_TextChanged(sender As Object, e As EventArgs) Handles ComboBox_Width.TextChanged
GUI_Gratings_Data.WidthChanged(sender, e)
End Sub
' --- Check if width is a number ---
@ -147,7 +124,6 @@ Public Class GUI
' --- Grating length changed ---
Private Sub LengthBox_TextChanged(sender As Object, e As EventArgs) Handles ComboBox_Length.TextChanged
GUI_Gratings_Data.LengthChanged(sender, e)
End Sub
' --- Check if length is a number ---
@ -155,23 +131,24 @@ Public Class GUI
GUI_Gratings_Data.Check_IfNumber(e)
End Sub
' ---------------------------------- Functions ----------------------------------
' --- When angle button is pressed ---
Private Sub AngleButton_Click(sender As Object, e As EventArgs) Handles AngleButton.Click
GUI_Functions.AngleButton(sender, e)
End Sub
' --- When square 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
' ---------------------------------- Settings ----------------------------------
' --- Settings button clicked ---
Private Sub SettingsButton_Click(sender As Object, e As EventArgs) Handles SettingsButton.Click
GUI_Settings.ButtonClicked(sender, e)
End Sub
' ---------------------------------- Export to SW ----------------------------------
' --- When export to SW button is pressed ---
Private Sub ExportSWButton_Click(sender As Object, e As EventArgs) Handles ExportSWButton.Click
SW_HLCt_Gratings.BuildGrating()

View File

@ -1,27 +1,22 @@
Public Class GUI_Drawing_Panel
Private Shared pCon1(3) As Decimal 'pCon(0) = pixel X, pCon(2) = SW X, etc.
Private Shared pCon2(3) As Decimal
Private Shared pCon3(3) As Decimal
Private Shared pCon4(3) As Decimal
Public Shared pCon1(3) As Decimal 'pCon(0) = pixel X, pCon(2) = SW X, etc.
Public Shared pCon2(3) As Decimal
Public Shared pCon3(3) As Decimal
Public Shared pCon4(3) As Decimal
Private Shared containerL, containerW, containerMidX, containerMidY As Integer
Public Shared containerL, containerW, containerMidX, containerMidY As Integer
Private Shared drawL As Integer = 1
Private Shared drawW As Integer = 1
Private Shared DirSymbolPoints As New Dictionary(Of String, Decimal())
Private Shared ArrowSymbolPoints As New Dictionary(Of String, Decimal())
Private Shared drawAspect, gratingAspect As Decimal
Private Shared scaleDiff As Decimal = 1
Public Shared scaleDiff As Decimal = 1
Public Shared pointsOrder As New List(Of String)
Public Shared points As New Dictionary(Of String, Decimal())
Private Shared gratingMaxW As Decimal = 1000
Private Shared gratingMaxL As Decimal = 1000
Private Shared pointsFunc As New Dictionary(Of String, Boolean)
Public Shared Sub Load_DrawingPanel()
Get_DrawboxParameters()
@ -36,8 +31,8 @@
' --- Retrive parameters for the drawing box ---
Private Shared Sub Get_DrawboxParameters()
containerL = GUI.containerPanel.Size.Width
containerW = GUI.containerPanel.Size.Height
containerL = GUI.DrawingPanel.Size.Width
containerW = GUI.DrawingPanel.Size.Height
containerMidX = containerL / 2
containerMidY = containerW / 2
@ -95,27 +90,27 @@
End Sub
' --- Updates all the gratings points ---
Private Shared Sub Update_GratingPoints()
gratingAspect = gratingMaxL / gratingMaxW
Public Shared Sub Update_GratingPoints()
gratingAspect = GUI_Gratings_Data.gratingMaxL / GUI_Gratings_Data.gratingMaxW
If gratingAspect > drawAspect Then
'Change draw height
scaleDiff = gratingMaxL / drawL
scaleDiff = GUI_Gratings_Data.gratingMaxL / drawL
pCon1(1) = containerMidY - gratingMaxW / (scaleDiff * 2)
pCon2(1) = containerMidY - gratingMaxW / (scaleDiff * 2)
pCon3(1) = containerMidY + gratingMaxW / (scaleDiff * 2)
pCon4(1) = containerMidY + gratingMaxW / (scaleDiff * 2)
pCon1(1) = containerMidY - GUI_Gratings_Data.gratingMaxW / (scaleDiff * 2)
pCon2(1) = containerMidY - GUI_Gratings_Data.gratingMaxW / (scaleDiff * 2)
pCon3(1) = containerMidY + GUI_Gratings_Data.gratingMaxW / (scaleDiff * 2)
pCon4(1) = containerMidY + GUI_Gratings_Data.gratingMaxW / (scaleDiff * 2)
Set_ContainerPointsX()
Else
'Change draw width
scaleDiff = gratingMaxW / drawW
scaleDiff = GUI_Gratings_Data.gratingMaxW / drawW
pCon1(0) = containerMidX - gratingMaxL / (scaleDiff * 2)
pCon2(0) = containerMidX + gratingMaxL / (scaleDiff * 2)
pCon3(0) = containerMidX + gratingMaxL / (scaleDiff * 2)
pCon4(0) = containerMidX - gratingMaxL / (scaleDiff * 2)
pCon1(0) = containerMidX - GUI_Gratings_Data.gratingMaxL / (scaleDiff * 2)
pCon2(0) = containerMidX + GUI_Gratings_Data.gratingMaxL / (scaleDiff * 2)
pCon3(0) = containerMidX + GUI_Gratings_Data.gratingMaxL / (scaleDiff * 2)
pCon4(0) = containerMidX - GUI_Gratings_Data.gratingMaxL / (scaleDiff * 2)
Set_ContainerPointsY()
End If
@ -124,25 +119,35 @@
GUI.Refresh()
'SW X-values
pCon1(2) = (-gratingMaxL / 2) / 1000
pCon2(2) = (gratingMaxL / 2) / 1000
pCon3(2) = (gratingMaxL / 2) / 1000
pCon4(2) = (-gratingMaxL / 2) / 1000
pCon1(2) = (-GUI_Gratings_Data.gratingMaxL / 2) / 1000
pCon2(2) = (GUI_Gratings_Data.gratingMaxL / 2) / 1000
pCon3(2) = (GUI_Gratings_Data.gratingMaxL / 2) / 1000
pCon4(2) = (-GUI_Gratings_Data.gratingMaxL / 2) / 1000
'SW Y-values
pCon1(3) = (gratingMaxW / 2) / 1000
pCon2(3) = (gratingMaxW / 2) / 1000
pCon3(3) = (-gratingMaxW / 2) / 1000
pCon4(3) = (-gratingMaxW / 2) / 1000
pCon1(3) = (GUI_Gratings_Data.gratingMaxW / 2) / 1000
pCon2(3) = (GUI_Gratings_Data.gratingMaxW / 2) / 1000
pCon3(3) = (-GUI_Gratings_Data.gratingMaxW / 2) / 1000
pCon4(3) = (-GUI_Gratings_Data.gratingMaxW / 2) / 1000
End Sub
' --- Sets the start points for the grating ---
Private Shared Sub Create_StartPoints()
For i = 1 To 4
points.Add("p" & i, CallByName(GUI, "pCon" & i, vbGet))
pointsFunc.Add("p" & i, True)
pointsOrder.Add("p" & i)
Next
points.Add("p1", pCon1)
GUI_Functions.pointsFunc.Add("p1", True)
pointsOrder.Add("p1")
points.Add("p2", pCon2)
GUI_Functions.pointsFunc.Add("p2", True)
pointsOrder.Add("p2")
points.Add("p3", pCon3)
GUI_Functions.pointsFunc.Add("p3", True)
pointsOrder.Add("p3")
points.Add("p4", pCon4)
GUI_Functions.pointsFunc.Add("p4", True)
pointsOrder.Add("p4")
End Sub
' --- Draw all the lines for the container and grating ---

View File

@ -1,57 +1,64 @@
Public Class GUI_Functions
Private Shared angleFunctionActive As Boolean = False
Private Shared squareFunctionActive As Boolean = False
Private Shared pointCounter As Integer
Public Shared pointsFunc As New Dictionary(Of String, Boolean)
Public Shared Sub AngleButton(sender As Object, e As EventArgs)
Me.Controls("AngleButton").Enabled = False
Me.Controls("Button_Square").Enabled = False
GUI.Controls("AngleButton").Enabled = False
GUI.Controls("Button_Square").Enabled = False
Dim buttonX As Integer = Me.Controls("AngleButton").Location.X
Dim buttonY As Integer = Me.Controls("AngleButton").Location.Y
Dim buttonX As Integer = GUI.Controls("AngleButton").Location.X
Dim buttonY As Integer = GUI.Controls("AngleButton").Location.Y
Create_TextBox("X_TextBox", "", buttonX + 20, buttonY + 40, 60)
AddHandler Me.Controls("X_TextBox").TextChanged, AddressOf FunctionText_Changed
Create_Label("X_Label", "1", buttonX, buttonY + 43)
GUI.Create_TextBox("X_TextBox", "", buttonX + 20, buttonY + 40, 60)
AddHandler GUI.Controls("X_TextBox").TextChanged, AddressOf FunctionText_Changed
GUI.Create_Label("X_Label", "1", buttonX, buttonY + 43)
Create_TextBox("Y_TextBox", "", buttonX + 130, buttonY + 40, 60)
AddHandler Me.Controls("Y_TextBox").TextChanged, AddressOf FunctionText_Changed
Create_Label("Y_Label", "2", buttonX + 110, buttonY + 43)
GUI.Create_TextBox("Y_TextBox", "", buttonX + 130, buttonY + 40, 60)
AddHandler GUI.Controls("Y_TextBox").TextChanged, AddressOf FunctionText_Changed
GUI.Create_Label("Y_Label", "2", buttonX + 110, buttonY + 43)
angleFunctionActive = True
End Sub
Public Shared Sub SquareButtton(sender As Object, e As EventArgs)
Me.Controls("AngleButton").Enabled = False
Me.Controls("Button_Square").Enabled = False
GUI.Controls("AngleButton").Enabled = False
GUI.Controls("Button_Square").Enabled = False
Dim buttonX As Integer = Me.Controls("Button_Square").Location.X
Dim buttonY As Integer = Me.Controls("Button_Square").Location.Y
Dim buttonX As Integer = GUI.Controls("Button_Square").Location.X
Dim buttonY As Integer = GUI.Controls("Button_Square").Location.Y
Create_TextBox("X_TextBox", "", buttonX + 20, buttonY + 40, 60)
AddHandler Me.Controls("X_TextBox").TextChanged, AddressOf FunctionText_Changed
Create_Label("X_Label", "1", buttonX, buttonY + 43)
GUI.Create_TextBox("X_TextBox", "", buttonX + 20, buttonY + 40, 60)
AddHandler GUI.Controls("X_TextBox").TextChanged, AddressOf FunctionText_Changed
GUI.Create_Label("X_Label", "1", buttonX, buttonY + 43)
Create_TextBox("Y_TextBox", "", buttonX + 130, buttonY + 40, 60)
AddHandler Me.Controls("Y_TextBox").TextChanged, AddressOf FunctionText_Changed
Create_Label("Y_Label", "2", buttonX + 110, buttonY + 43)
GUI.Create_TextBox("Y_TextBox", "", buttonX + 130, buttonY + 40, 60)
AddHandler GUI.Controls("Y_TextBox").TextChanged, AddressOf FunctionText_Changed
GUI.Create_Label("Y_Label", "2", buttonX + 110, buttonY + 43)
' Add option for corner or side
squareFunctionActive = True
End Sub
Private Sub FunctionText_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
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
If GUI.DrawingPanel.Controls.Count = 0 Then
' Create Buttons for all clickable points
For i = 0 To pointsOrder.Count - 1
If pointsFunc(pointsOrder(i)) Then
For i = 0 To GUI_Drawing_Panel.pointsOrder.Count - 1
If pointsFunc(GUI_Drawing_Panel.pointsOrder(i)) Then
Dim pointButton As New Button
pointButton.Width = 30
pointButton.Height = 30
pointButton.Left = points(pointsOrder(i))(0) - pointButton.Width / 2
pointButton.Top = points(pointsOrder(i))(1) - pointButton.Height / 2
pointButton.Left = GUI_Drawing_Panel.points(GUI_Drawing_Panel.pointsOrder(i))(0) - pointButton.Width / 2
pointButton.Top = GUI_Drawing_Panel.points(GUI_Drawing_Panel.pointsOrder(i))(1) - pointButton.Height / 2
pointButton.Name = pointsOrder(i) & "_Button"
pointButton.Name = GUI_Drawing_Panel.pointsOrder(i) & "_Button"
pointButton.Text = ""
pointButton.BackColor = Color.FromArgb(50, Color.Red)
@ -64,7 +71,7 @@
gp.AddEllipse(New Rectangle(New Point(0, 0), New Size(30, 30)))
pointButton.Region = New Region(gp)
containerPanel.Controls.Add(pointButton)
GUI.DrawingPanel.Controls.Add(pointButton)
AddHandler pointButton.Click, AddressOf PointButton_Click
End If
@ -75,88 +82,88 @@
End Sub
' --- When a function button is pressed ---
Private Sub PointButton_Click(sender As Button, e As EventArgs)
Private Shared Sub PointButton_Click(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)
Dim index As Integer = GUI_Drawing_Panel.pointsOrder.IndexOf(pointPressed)
' Remove point buttons
For i = 0 To pointsOrder.Count - 1
If pointsFunc(pointsOrder(i)) Then
RemoveHandler containerPanel.Controls(pointsOrder(i) & "_Button").Click, AddressOf PointButton_Click
containerPanel.Controls.RemoveByKey(pointsOrder(i) & "_Button")
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
'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 pXP As Decimal = GUI_Drawing_Panel.points(pointPressed)(0)
Dim pYP As Decimal = GUI_Drawing_Panel.points(pointPressed)(1)
Dim pXSW As Decimal = GUI_Drawing_Panel.points(pointPressed)(2)
Dim pYSW As Decimal = GUI_Drawing_Panel.points(pointPressed)(3)
Dim d1P As Decimal = Me.Controls("X_TextBox").Text / scaleDiff ' BEHÖVS Cdec??
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
Dim d1P As Decimal = GUI.Controls("X_TextBox").Text / GUI_Drawing_Panel.scaleDiff ' BEHÖVS Cdec??
Dim d2P As Decimal = GUI.Controls("Y_TextBox").Text / GUI_Drawing_Panel.scaleDiff
Dim d1SW As Decimal = GUI.Controls("X_TextBox").Text / 1000
Dim d2SW As Decimal = GUI.Controls("Y_TextBox").Text / 1000
Dim numOfNewPoints As Integer
If angleFunctionActive Then
If pXP < containerMidX Then
If pYP > containerMidY Then
If pXP < GUI_Drawing_Panel.containerMidX Then
If pYP > GUI_Drawing_Panel.containerMidY Then
'Kvadrant 4
points.Add("pA" & pointCounter * 2 - 1, {pXP + d1P, pYP, pXSW + d1SW, pYSW})
points.Add("pA" & pointCounter * 2, {pXP, pYP - d2P, pXSW, pYSW + d2SW})
GUI_Drawing_Panel.points.Add("pA" & pointCounter * 2 - 1, {pXP + d1P, pYP, pXSW + d1SW, pYSW})
GUI_Drawing_Panel.points.Add("pA" & pointCounter * 2, {pXP, pYP - d2P, pXSW, pYSW + d2SW})
Else
'Kvadrant 1
points.Add("pA" & pointCounter * 2 - 1, {pXP, pYP + d2P, pXSW, pYSW - d2SW})
points.Add("pA" & pointCounter * 2, {pXP + d1P, pYP, pXSW + d1SW, pYSW})
GUI_Drawing_Panel.points.Add("pA" & pointCounter * 2 - 1, {pXP, pYP + d2P, pXSW, pYSW - d2SW})
GUI_Drawing_Panel.points.Add("pA" & pointCounter * 2, {pXP + d1P, pYP, pXSW + d1SW, pYSW})
End If
Else
If pYP > containerMidY Then
If pYP > GUI_Drawing_Panel.containerMidY Then
'Kvadrant 3
points.Add("pA" & pointCounter * 2 - 1, {pXP, pYP - d2P, pXSW, pYSW + d2SW})
points.Add("pA" & pointCounter * 2, {pXP - d1P, pYP, pXSW - d1SW, pYSW})
GUI_Drawing_Panel.points.Add("pA" & pointCounter * 2 - 1, {pXP, pYP - d2P, pXSW, pYSW + d2SW})
GUI_Drawing_Panel.points.Add("pA" & pointCounter * 2, {pXP - d1P, pYP, pXSW - d1SW, pYSW})
Else
'Kvadrant 2
points.Add("pA" & pointCounter * 2 - 1, {pXP - d1P, pYP, pXSW - d1SW, pYSW})
points.Add("pA" & pointCounter * 2, {pXP, pYP + d2P, pXSW, pYSW - d2SW})
GUI_Drawing_Panel.points.Add("pA" & pointCounter * 2 - 1, {pXP - d1P, pYP, pXSW - d1SW, pYSW})
GUI_Drawing_Panel.points.Add("pA" & pointCounter * 2, {pXP, pYP + d2P, pXSW, pYSW - d2SW})
End If
End If
pointsFunc.Add("pA" & pointCounter * 2 - 1, False)
pointsFunc.Add("pA" & pointCounter * 2, False)
'Insert two new points
pointsOrder.Insert(index + 1, "pA" & pointCounter * 2 - 1)
pointsOrder.Insert(index + 2, "pA" & pointCounter * 2)
GUI_Drawing_Panel.pointsOrder.Insert(index + 1, "pA" & pointCounter * 2 - 1)
GUI_Drawing_Panel.pointsOrder.Insert(index + 2, "pA" & pointCounter * 2)
numOfNewPoints = 2
angleFunctionActive = False
Else
If pXP < containerMidX Then
If pYP > containerMidY Then
If pXP < GUI_Drawing_Panel.containerMidX Then
If pYP > GUI_Drawing_Panel.containerMidY Then
'Kvadrant 4
points.Add("pS" & pointCounter * 3 - 2, {pXP + d1P, pYP, pXSW + d1SW, pYSW})
points.Add("pS" & pointCounter * 3 - 1, {pXP + d1P, pYP - d2P, pXSW + d1SW, pYSW + d2SW})
points.Add("pS" & pointCounter * 3, {pXP, pYP - d2P, pXSW, pYSW + d2SW})
GUI_Drawing_Panel.points.Add("pS" & pointCounter * 3 - 2, {pXP + d1P, pYP, pXSW + d1SW, pYSW})
GUI_Drawing_Panel.points.Add("pS" & pointCounter * 3 - 1, {pXP + d1P, pYP - d2P, pXSW + d1SW, pYSW + d2SW})
GUI_Drawing_Panel.points.Add("pS" & pointCounter * 3, {pXP, pYP - d2P, pXSW, pYSW + d2SW})
Else
'Kvadrant 1
points.Add("pS" & pointCounter * 3 - 2, {pXP, pYP + d2P, pXSW, pYSW - d2SW})
points.Add("pS" & pointCounter * 3 - 1, {pXP + d1P, pYP + d2P, pXSW + d1SW, pYSW - d2SW})
points.Add("pS" & pointCounter * 3, {pXP + d1P, pYP, pXSW + d1SW, pYSW})
GUI_Drawing_Panel.points.Add("pS" & pointCounter * 3 - 2, {pXP, pYP + d2P, pXSW, pYSW - d2SW})
GUI_Drawing_Panel.points.Add("pS" & pointCounter * 3 - 1, {pXP + d1P, pYP + d2P, pXSW + d1SW, pYSW - d2SW})
GUI_Drawing_Panel.points.Add("pS" & pointCounter * 3, {pXP + d1P, pYP, pXSW + d1SW, pYSW})
End If
Else
If pYP > containerMidY Then
If pYP > GUI_Drawing_Panel.containerMidY Then
'Kvadrant 3
points.Add("pS" & pointCounter * 3 - 2, {pXP, pYP - d2P, pXSW, pYSW + d2SW})
points.Add("pS" & pointCounter * 3 - 1, {pXP - d1P, pYP - d2P, pXSW - d1SW, pYSW + d2SW})
points.Add("pS" & pointCounter * 3, {pXP - d1P, pYP, pXSW - d1SW, pYSW})
GUI_Drawing_Panel.points.Add("pS" & pointCounter * 3 - 2, {pXP, pYP - d2P, pXSW, pYSW + d2SW})
GUI_Drawing_Panel.points.Add("pS" & pointCounter * 3 - 1, {pXP - d1P, pYP - d2P, pXSW - d1SW, pYSW + d2SW})
GUI_Drawing_Panel.points.Add("pS" & pointCounter * 3, {pXP - d1P, pYP, pXSW - d1SW, pYSW})
Else
'Kvadrant 2
points.Add("pS" & pointCounter * 3 - 2, {pXP - d1P, pYP, pXSW - d1SW, pYSW})
points.Add("pS" & pointCounter * 3 - 1, {pXP - d1P, pYP + d2P, pXSW - d1SW, pYSW - d2SW})
points.Add("pS" & pointCounter * 3, {pXP, pYP + d2P, pXSW, pYSW - d2SW})
GUI_Drawing_Panel.points.Add("pS" & pointCounter * 3 - 2, {pXP - d1P, pYP, pXSW - d1SW, pYSW})
GUI_Drawing_Panel.points.Add("pS" & pointCounter * 3 - 1, {pXP - d1P, pYP + d2P, pXSW - d1SW, pYSW - d2SW})
GUI_Drawing_Panel.points.Add("pS" & pointCounter * 3, {pXP, pYP + d2P, pXSW, pYSW - d2SW})
End If
End If
pointsFunc.Add("pS" & pointCounter * 3 - 2, True)
@ -164,30 +171,30 @@
pointsFunc.Add("pS" & pointCounter * 3, True)
'Insert new points
pointsOrder.Insert(index + 1, "pS" & pointCounter * 3 - 2)
pointsOrder.Insert(index + 2, "pS" & pointCounter * 3 - 1)
pointsOrder.Insert(index + 3, "pS" & pointCounter * 3)
GUI_Drawing_Panel.pointsOrder.Insert(index + 1, "pS" & pointCounter * 3 - 2)
GUI_Drawing_Panel.pointsOrder.Insert(index + 2, "pS" & pointCounter * 3 - 1)
GUI_Drawing_Panel.pointsOrder.Insert(index + 3, "pS" & pointCounter * 3)
numOfNewPoints = 3
squareFunctionActive = False
End If
pointsOrder.RemoveAt(index)
GUI_Drawing_Panel.pointsOrder.RemoveAt(index)
'Redraw grating
Me.Refresh()
GUI.Refresh()
RemoveHandler Me.Controls("X_TextBox").TextChanged, AddressOf FunctionText_Changed
Me.Controls.RemoveByKey("X_TextBox")
RemoveHandler GUI.Controls("X_TextBox").TextChanged, AddressOf FunctionText_Changed
GUI.Controls.RemoveByKey("X_TextBox")
RemoveHandler Me.Controls("Y_TextBox").TextChanged, AddressOf FunctionText_Changed
Me.Controls.RemoveByKey("Y_TextBox")
RemoveHandler GUI.Controls("Y_TextBox").TextChanged, AddressOf FunctionText_Changed
GUI.Controls.RemoveByKey("Y_TextBox")
Me.Controls.RemoveByKey("X_Label")
Me.Controls.RemoveByKey("Y_Label")
GUI.Controls.RemoveByKey("X_Label")
GUI.Controls.RemoveByKey("Y_Label")
Me.Controls("AngleButton").Enabled = True
Me.Controls("Button_Square").Enabled = True
GUI.Controls("AngleButton").Enabled = True
GUI.Controls("Button_Square").Enabled = True
End Sub
End Class

View File

@ -1,4 +1,252 @@
Public Class GUI_Gratings_Data
Public Shared gratingMaxW As Decimal = 1000
Public Shared gratingMaxL As Decimal = 1000
Private Shared gratingType, gratingMaterial, gratingMesh As String
Private Shared gratingSerrated As Boolean = False
Private Shared loadBarSpacing, crossBarSpacing, gratingHeight, loadBarThickness As Integer
Private Shared serratedCheckBox As New CheckBox
Private Shared serratedCheckBoxBol As Boolean = False
Private Shared lacqueredCheckBox As New CheckBox
Private Shared lacqueredCheckBoxBol As Boolean = False
Private Shared gratingLacquered As Boolean = False
Public Shared Sub TypeChanged(sender As Object, e As EventArgs)
GUI.ComboBox_Material.Enabled = True
GUI.ComboBox_Material.Items.Clear()
gratingType = GUI.ComboBox_TypeChooser.Text
Dim materialDT As DataTable = GUI.dataBase("Material")
Dim typeInDT As String = materialDT.Rows(0)("TYPE")
For i = 0 To materialDT.Rows.Count - 1
If gratingType = materialDT.Rows(i)("TYPE") Then
GUI.ComboBox_Material.Items.Add(materialDT.Rows(i)("MATERIAL"))
End If
Try
typeInDT = materialDT.Rows(i + 1)("TYPE")
Catch ex As Exception
End Try
Next
GUI.ComboBox_Material.Text = GUI.ComboBox_Material.Items(0)
End Sub
Public Shared Sub MaterialChanged(sender As Object, e As EventArgs)
GUI.ComboBox_MeshSize.Enabled = True
gratingMaterial = GUI.ComboBox_Material.Text
Dim serratedDT As DataTable = GUI.dataBase("Serrated")
Dim removeCheckBox As Boolean = True
Dim typeInDT As String = serratedDT.Rows(0)("TYPE")
Dim materialInDT As String = serratedDT.Rows(0)("MATERIAL")
If serratedCheckBoxBol = False Then
For i = 0 To serratedDT.Rows.Count - 1
If gratingMaterial = materialInDT AndAlso gratingType = typeInDT Then
serratedCheckBox.Name = "CheckBox_Serrated"
serratedCheckBox.Text = "Serrated"
serratedCheckBox.Left = 115
serratedCheckBox.Top = 115
AddHandler serratedCheckBox.CheckedChanged, AddressOf CheckBox_Serrated_CheckedChanged
GUI.Controls.Add(serratedCheckBox)
serratedCheckBoxBol = True
Exit For
End If
Try
typeInDT = serratedDT.Rows(i + 1)("TYPE")
materialInDT = serratedDT.Rows(i + 1)("MATERIAL")
Catch ex As Exception
End Try
Next
Else
For i = 0 To serratedDT.Rows.Count - 1
If gratingMaterial = materialInDT AndAlso gratingType = typeInDT Then
removeCheckBox = False
Exit For
End If
Try
typeInDT = serratedDT.Rows(i + 1)("TYPE")
materialInDT = serratedDT.Rows(i + 1)("MATERIAL")
Catch ex As Exception
End Try
Next
If serratedCheckBoxBol = True AndAlso removeCheckBox = True Then
RemoveHandler serratedCheckBox.CheckedChanged, AddressOf CheckBox_Serrated_CheckedChanged
GUI.Controls.RemoveByKey("CheckBox_Serrated")
serratedCheckBoxBol = False
gratingSerrated = False
End If
End If
If lacqueredCheckBoxBol = False AndAlso (gratingMaterial = "Hot dip galvanized steel" OrElse gratingMaterial = "Untreated") Then
lacqueredCheckBox.Name = "CheckBox_Lacquered"
lacqueredCheckBox.Text = "Lacquered"
lacqueredCheckBox.Left = 115
lacqueredCheckBox.Top = 135
AddHandler lacqueredCheckBox.CheckedChanged, AddressOf CheckBox_Lacquered_CheckedChanged
GUI.Controls.Add(lacqueredCheckBox)
lacqueredCheckBoxBol = True
ElseIf lacqueredCheckBoxBol = True AndAlso gratingMaterial <> "Hot dip galvanized steel" AndAlso gratingMaterial <> "Untreated" Then
RemoveHandler lacqueredCheckBox.CheckedChanged, AddressOf CheckBox_Lacquered_CheckedChanged
GUI.Controls.RemoveByKey("CheckBox_Lacquered")
lacqueredCheckBoxBol = False
gratingLacquered = False
End If
' Untreated finns för alla som är varmförzinkade enligt Jakob Teams
Update_AvalaibleMeshes()
End Sub
Private Shared Sub CheckBox_Serrated_CheckedChanged(sender As Object, e As EventArgs)
If sender.Checked Then
gratingSerrated = True
Update_AvalaibleMeshes()
Else
gratingSerrated = False
Update_AvalaibleMeshes()
End If
End Sub
Private Shared Sub CheckBox_Lacquered_CheckedChanged(sender As Object, e As EventArgs)
'Här hanterar vi om den är lackad eller inte
'påverkar ej övrig kod (förutom kommentar att det är special order)
If sender.Checked Then
gratingLacquered = True
Else
gratingLacquered = False
End If
End Sub
Private Shared Sub Update_AvalaibleMeshes()
GUI.ComboBox_MeshSize.Items.Clear()
Dim meshesDT As DataTable = GUI.dataBase("Meshes")
Dim typeInDT As String = meshesDT.Rows(0)("TYPE")
Dim materialInDT As String = meshesDT.Rows(0)("MATERIAL")
Dim serratedInDT As Boolean = CBool(meshesDT.Rows(0)("SERRATED"))
For i = 0 To meshesDT.Rows.Count - 1
If gratingSerrated = serratedInDT AndAlso gratingMaterial = materialInDT AndAlso gratingType = typeInDT Then
Dim item As String
item = meshesDT.Rows(i)("LB-SPACING") & "x" & meshesDT.Rows(i)("CB-SPACING") & " (" & meshesDT.Rows(i)("NAME") & ")"
Dim addItem As Boolean = True
For j = 0 To GUI.ComboBox_MeshSize.Items.Count - 1
If item = GUI.ComboBox_MeshSize.Items(j) Then
addItem = False
Exit For
End If
Next
If addItem = True Then
GUI.ComboBox_MeshSize.Items.Add(item)
End If
End If
Try
typeInDT = meshesDT.Rows(i + 1)("TYPE")
materialInDT = meshesDT.Rows(i + 1)("MATERIAL")
serratedInDT = meshesDT.Rows(i + 1)("SERRATED")
Catch ex As Exception
End Try
Next
If GUI.ComboBox_MeshSize.Items.Count = 0 Then
GUI.ComboBox_MeshSize.Items.Add("")
End If
End Sub
Public Shared Sub MeshChanged(sender As Object, e As EventArgs)
GUI.ComboBox_Height.Enabled = True
GUI.ComboBox_Height.Items.Clear()
gratingMesh = GUI.ComboBox_MeshSize.Text
loadBarSpacing = CInt(gratingMesh.Split("x")(0))
crossBarSpacing = CInt(gratingMesh.Split("x")(1).Split(" ")(0))
' Add heights
If loadBarSpacing = 12 And crossBarSpacing = 100 Then
GUI.ComboBox_Height.Items.Add("20")
GUI.ComboBox_Height.Items.Add("25")
End If
End Sub
Public Shared Sub HeightChanged(sender As Object, e As EventArgs)
GUI.ComboBox_Thickness.Enabled = True
GUI.ComboBox_Thickness.Items.Clear()
gratingHeight = CInt(GUI.ComboBox_Height.Text)
' Add thicknesses
If gratingHeight = 20 Then
GUI.ComboBox_Thickness.Items.Add("2")
GUI.ComboBox_Thickness.Items.Add("3")
End If
End Sub
Public Shared Sub ThicknessChanged(sender As Object, e As EventArgs)
GUI.ComboBox_Width.Enabled = True
GUI.ComboBox_Width.Items.Clear()
GUI.ComboBox_Length.Enabled = True
GUI.ComboBox_Length.Items.Clear()
loadBarThickness = CInt(GUI.ComboBox_Thickness.Text)
' Add Widths
GUI.ComboBox_Width.Items.Add("300")
GUI.ComboBox_Width.Items.Add("500")
GUI.ComboBox_Width.Items.Add("1000")
GUI.ComboBox_Width.Text = GUI.ComboBox_Width.Items(0)
' Add Length
GUI.ComboBox_Length.Items.Add("500")
GUI.ComboBox_Length.Items.Add("1000")
GUI.ComboBox_Length.Text = GUI.ComboBox_Length.Items(0)
End Sub
Public Shared Sub WholeMeshWidthsChanged(sender As Object, e As EventArgs)
If sender.Checked Then
GUI.ComboBox_Width.DropDownStyle = ComboBoxStyle.DropDownList
Else
GUI.ComboBox_Width.DropDownStyle = ComboBoxStyle.DropDown
End If
End Sub
Public Shared Sub WidthChanged(sender As Object, e As EventArgs)
If GUI.ComboBox_Width.Text <> "" Then
If CDec(GUI.ComboBox_Width.Text) > 0 Then
gratingMaxW = CDec(GUI.ComboBox_Width.Text)
GUI_Drawing_Panel.Update_GratingPoints()
End If
End If
'If stocked length options exist
If gratingMaxW = 500 Then
Dim stockedCheckBox As New CheckBox
stockedCheckBox.Name = "CheckBox_Stocked"
stockedCheckBox.Text = "Only stocked lengths"
stockedCheckBox.Left = 94
stockedCheckBox.Top = 386
stockedCheckBox.Checked = True
GUI.Controls.Add(stockedCheckBox)
End If
End Sub
Public Shared Sub LengthChanged(sender As Object, e As EventArgs)
If GUI.ComboBox_Length.Text <> "" Then
If CDec(GUI.ComboBox_Length.Text) > 0 Then
gratingMaxL = CDec(GUI.ComboBox_Length.Text)
GUI_Drawing_Panel.Update_GratingPoints()
End If
End If
End Sub
' --- Creates the table with points data used in SW ---
Public Shared Function Create_ExportTable() As DataTable
Dim lSpacing As String = GUI.ComboBox_MeshSize.Text.Split("x")(0)
@ -49,9 +297,9 @@
pointTable.Columns.Add("X", GetType(Decimal))
pointTable.Columns.Add("Y", GetType(Decimal))
For i = 0 To GUI.pointsOrder.Count - 1
For i = 0 To GUI_Drawing_Panel.pointsOrder.Count - 1
Dim pTemp() As Decimal
pTemp = GUI.points(GUI.pointsOrder(i))
pTemp = GUI_Drawing_Panel.points(GUI_Drawing_Panel.pointsOrder(i))
pointTable.Rows.Add()
pointTable.Rows(i)("X") = pTemp(2)
@ -63,7 +311,7 @@
' --- Check if the key pressed is a number ---
Private Sub Check_IfNumber(e As KeyPressEventArgs)
Public Shared Sub Check_IfNumber(e As KeyPressEventArgs)
If Asc(e.KeyChar) <> 8 Then
If Asc(e.KeyChar) < 48 Or Asc(e.KeyChar) > 57 Then
e.Handled = True
@ -72,261 +320,20 @@
End Sub
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
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
Public Shared Sub TypeChanged(sender As Object, e As EventArgs)
ComboBox_Material.Enabled = True
ComboBox_Material.Items.Clear()
gratingType = ComboBox_TypeChooser.Text
Dim materialDT As DataTable = dataBase("Material")
Dim typeColumn As Integer = Get_ColumnIndex("TYPE", materialDT)
Dim materialColumn As Integer = Get_ColumnIndex("MATERIAL", materialDT)
Dim typeInDT As String = materialDT.Rows(0)(typeColumn)
For i = 0 To materialDT.Rows.Count - 1
If gratingType = materialDT.Rows(i)(typeColumn) Then
ComboBox_Material.Items.Add(materialDT.Rows(i)(materialColumn))
End If
Try
typeInDT = materialDT.Rows(i + 1)(typeColumn)
Catch ex As Exception
End Try
Next
ComboBox_Material.Text = ComboBox_Material.Items(0)
End Sub
Public Shared Sub MaterialChanged(sender As Object, e As EventArgs)
ComboBox_MeshSize.Enabled = True
gratingMaterial = ComboBox_Material.Text
Dim serratedDT As DataTable = dataBase("Serrated")
Dim removeCheckBox As Boolean = True
Dim typeInDT As String = serratedDT.Rows(0)("TYPE")
Dim materialInDT As String = serratedDT.Rows(0)("MATERIAL")
If serratedCheckBoxBol = False Then
For i = 0 To serratedDT.Rows.Count - 1
If gratingMaterial = materialInDT AndAlso gratingType = typeInDT Then
serratedCheckBox.Name = "CheckBox_Serrated"
serratedCheckBox.Text = "Serrated"
serratedCheckBox.Left = 115
serratedCheckBox.Top = 115
AddHandler serratedCheckBox.CheckedChanged, AddressOf CheckBox_Serrated_CheckedChanged
Me.Controls.Add(serratedCheckBox)
serratedCheckBoxBol = True
Exit For
End If
Try
typeInDT = serratedDT.Rows(i + 1)("TYPE")
materialInDT = serratedDT.Rows(i + 1)("MATERIAL")
Catch ex As Exception
End Try
Next
Else
For i = 0 To serratedDT.Rows.Count - 1
If gratingMaterial = materialInDT AndAlso gratingType = typeInDT Then
removeCheckBox = False
Exit For
End If
Try
typeInDT = serratedDT.Rows(i + 1)("TYPE")
materialInDT = serratedDT.Rows(i + 1)("MATERIAL")
Catch ex As Exception
End Try
Next
If serratedCheckBoxBol = True AndAlso removeCheckBox = True Then
RemoveHandler serratedCheckBox.CheckedChanged, AddressOf CheckBox_Serrated_CheckedChanged
Me.Controls.RemoveByKey("CheckBox_Serrated")
serratedCheckBoxBol = False
gratingSerrated = False
End If
End If
If lacqueredCheckBoxBol = False AndAlso (gratingMaterial = "Hot dip galvanized steel" OrElse gratingMaterial = "Untreated") Then
lacqueredCheckBox.Name = "CheckBox_Lacquered"
lacqueredCheckBox.Text = "Lacquered"
lacqueredCheckBox.Left = 115
lacqueredCheckBox.Top = 135
AddHandler lacqueredCheckBox.CheckedChanged, AddressOf CheckBox_Lacquered_CheckedChanged
Me.Controls.Add(lacqueredCheckBox)
lacqueredCheckBoxBol = True
ElseIf lacqueredCheckBoxBol = True AndAlso gratingMaterial <> "Hot dip galvanized steel" AndAlso gratingMaterial <> "Untreated" Then
RemoveHandler lacqueredCheckBox.CheckedChanged, AddressOf CheckBox_Lacquered_CheckedChanged
Me.Controls.RemoveByKey("CheckBox_Lacquered")
lacqueredCheckBoxBol = False
gratingLacquered = False
End If
' Untreated finns för alla som är varmförzinkade enligt Jakob Teams
Update_AvalaibleMeshes()
End Sub
Private Sub CheckBox_Serrated_CheckedChanged(sender As Object, e As EventArgs)
If sender.Checked Then
gratingSerrated = True
Update_AvalaibleMeshes()
Else
gratingSerrated = False
Update_AvalaibleMeshes()
End If
End Sub
Private Sub CheckBox_Lacquered_CheckedChanged(sender As Object, e As EventArgs)
'Här hanterar vi om den är lackad eller inte
'påverkar ej övrig kod (förutom kommentar att det är special order)
If sender.Checked Then
gratingLacquered = True
Else
gratingLacquered = False
End If
End Sub
Private Sub Update_AvalaibleMeshes()
ComboBox_MeshSize.Items.Clear()
Dim meshesDT As DataTable = dataBase("Meshes")
Dim typeColumn As Integer = Get_ColumnIndex("TYPE", meshesDT)
Dim materialColumn As Integer = Get_ColumnIndex("MATERIAL", meshesDT)
Dim serratedColumn As Integer = Get_ColumnIndex("SERRATED", meshesDT)
Dim typeInDT As String = meshesDT.Rows(0)(typeColumn)
Dim materialInDT As String = meshesDT.Rows(0)(materialColumn)
Dim serratedInDT As Boolean = CBool(meshesDT.Rows(0)(serratedColumn))
For i = 0 To meshesDT.Rows.Count - 1
If gratingSerrated = serratedInDT AndAlso gratingMaterial = materialInDT AndAlso gratingType = typeInDT Then
Dim item As String
item = meshesDT.Rows(i)("LB-SPACING") & "x" & meshesDT.Rows(i)("CB-SPACING") & " (" & meshesDT.Rows(i)("NAME") & ")"
Dim addItem As Boolean = True
For j = 0 To ComboBox_MeshSize.Items.Count - 1
If item = ComboBox_MeshSize.Items(j) Then
addItem = False
Exit For
End If
Next
If addItem = True Then
ComboBox_MeshSize.Items.Add(item)
End If
End If
Try
typeInDT = meshesDT.Rows(i + 1)(typeColumn)
materialInDT = meshesDT.Rows(i + 1)(materialColumn)
serratedInDT = meshesDT.Rows(i + 1)(serratedColumn)
Catch ex As Exception
End Try
Next
If ComboBox_MeshSize.Items.Count = 0 Then
ComboBox_MeshSize.Items.Add("")
End If
End Sub
Public Shared Sub MeshChanged(sender As Object, e As EventArgs)
ComboBox_Height.Enabled = True
ComboBox_Height.Items.Clear()
gratingMesh = ComboBox_MeshSize.Text
loadBarSpacing = CInt(gratingMesh.Split("x")(0))
crossBarSpacing = CInt(gratingMesh.Split("x")(1).Split(" ")(0))
' Add heights
If loadBarSpacing = 12 And crossBarSpacing = 100 Then
ComboBox_Height.Items.Add("20")
ComboBox_Height.Items.Add("25")
End If
End Sub
Public Shared Sub HeightChanged(sender As Object, e As EventArgs)
ComboBox_Thickness.Enabled = True
ComboBox_Thickness.Items.Clear()
gratingHeight = CInt(ComboBox_Height.Text)
' Add thicknesses
If gratingHeight = 20 Then
ComboBox_Thickness.Items.Add("2")
ComboBox_Thickness.Items.Add("3")
End If
End Sub
Public Shared Sub ThicknessChanged(sender As Object, e As EventArgs)
ComboBox_Width.Enabled = True
ComboBox_Width.Items.Clear()
ComboBox_Length.Enabled = True
ComboBox_Length.Items.Clear()
loadBarThickness = CInt(ComboBox_Thickness.Text)
' Add Widths
ComboBox_Width.Items.Add("300")
ComboBox_Width.Items.Add("500")
ComboBox_Width.Items.Add("1000")
ComboBox_Width.Text = ComboBox_Width.Items(0)
' Add Length
ComboBox_Length.Items.Add("500")
ComboBox_Length.Items.Add("1000")
ComboBox_Length.Text = ComboBox_Length.Items(0)
End Sub
Public Shared Sub WholeMeshWidthsChanged(sender As Object, e As EventArgs)
If CheckBox_WholeMeshWidths.Checked Then
ComboBox_Width.DropDownStyle = ComboBoxStyle.DropDownList
Else
ComboBox_Width.DropDownStyle = ComboBoxStyle.DropDown
End If
End Sub
Public Shared Sub WidthChanged(sender As Object, e As EventArgs)
If ComboBox_Width.Text <> "" Then
If CDec(ComboBox_Width.Text) > 0 Then
gratingMaxW = CDec(ComboBox_Width.Text)
Update_GratingPoints()
End If
End If
'If stocked length options exist
If gratingMaxW = 500 Then
Dim stockedCheckBox As New CheckBox
stockedCheckBox.Name = "CheckBox_Stocked"
stockedCheckBox.Text = "Only stocked lengths"
stockedCheckBox.Left = 94
stockedCheckBox.Top = 386
stockedCheckBox.Checked = True
Me.Controls.Add(stockedCheckBox)
End If
End Sub
Public Shared Sub LengthChanged(sender As Object, e As EventArgs)
If ComboBox_Length.Text <> "" Then
If CDec(ComboBox_Length.Text) > 0 Then
gratingMaxL = CDec(ComboBox_Length.Text)
Update_GratingPoints()
End If
End If
End Sub
End Class

View File

@ -1,6 +1,8 @@
Imports XCCLibrary
Imports SldWorks
Public Class GUI_Settings
Public Shared filesFolder As String = GUI.filepath ' Hämta från settings
Public Shared HLCtFolder As String = GUI.filepath & "\X2021" ' Hämta från settings
' --- Settings button clicked ---
Public Shared Sub ButtonClicked(sender As Object, e As EventArgs)