Division of functions into new classes
This commit is contained in:
parent
f9809a9085
commit
5b1ef57515
Binary file not shown.
Binary file not shown.
|
|
@ -46,7 +46,7 @@ Partial Class GUI
|
|||
Me.Label9 = New System.Windows.Forms.Label()
|
||||
Me.ComboBox_Material = New System.Windows.Forms.ComboBox()
|
||||
Me.Label_Material = New System.Windows.Forms.Label()
|
||||
Me.CheckBox1 = New System.Windows.Forms.CheckBox()
|
||||
Me.CheckBox_WholeMeshWidths = New System.Windows.Forms.CheckBox()
|
||||
Me.SuspendLayout()
|
||||
'
|
||||
'DrawingPanel
|
||||
|
|
@ -277,29 +277,29 @@ Partial Class GUI
|
|||
Me.Label_Material.TabIndex = 28
|
||||
Me.Label_Material.Text = "Material"
|
||||
'
|
||||
'CheckBox1
|
||||
'CheckBox_WholeMeshWidths
|
||||
'
|
||||
Me.CheckBox1.AutoSize = True
|
||||
Me.CheckBox1.Checked = True
|
||||
Me.CheckBox1.CheckState = System.Windows.Forms.CheckState.Checked
|
||||
Me.CheckBox1.Location = New System.Drawing.Point(94, 368)
|
||||
Me.CheckBox1.Margin = New System.Windows.Forms.Padding(2)
|
||||
Me.CheckBox1.Name = "CheckBox1"
|
||||
Me.CheckBox1.Size = New System.Drawing.Size(121, 18)
|
||||
Me.CheckBox1.TabIndex = 29
|
||||
Me.CheckBox1.Text = "Whole mesh widths"
|
||||
Me.CheckBox1.UseCompatibleTextRendering = True
|
||||
Me.CheckBox1.UseVisualStyleBackColor = True
|
||||
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.Name = "CheckBox_WholeMeshWidths"
|
||||
Me.CheckBox_WholeMeshWidths.Size = New System.Drawing.Size(121, 18)
|
||||
Me.CheckBox_WholeMeshWidths.TabIndex = 29
|
||||
Me.CheckBox_WholeMeshWidths.Text = "Whole mesh widths"
|
||||
Me.CheckBox_WholeMeshWidths.UseCompatibleTextRendering = True
|
||||
Me.CheckBox_WholeMeshWidths.UseVisualStyleBackColor = True
|
||||
'
|
||||
'GUI
|
||||
'
|
||||
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
|
||||
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
|
||||
Me.ClientSize = New System.Drawing.Size(1155, 687)
|
||||
Me.ClientSize = New System.Drawing.Size(1384, 761)
|
||||
Me.Controls.Add(Me.AngleButton)
|
||||
Me.Controls.Add(Me.Button_Square)
|
||||
Me.Controls.Add(Me.Label7)
|
||||
Me.Controls.Add(Me.CheckBox1)
|
||||
Me.Controls.Add(Me.CheckBox_WholeMeshWidths)
|
||||
Me.Controls.Add(Me.ComboBox_Material)
|
||||
Me.Controls.Add(Me.Label_Material)
|
||||
Me.Controls.Add(Me.Label9)
|
||||
|
|
@ -350,5 +350,5 @@ Partial Class GUI
|
|||
Friend WithEvents Label9 As Label
|
||||
Friend WithEvents ComboBox_Material As ComboBox
|
||||
Friend WithEvents Label_Material As Label
|
||||
Friend WithEvents CheckBox1 As CheckBox
|
||||
Friend WithEvents CheckBox_WholeMeshWidths As CheckBox
|
||||
End Class
|
||||
|
|
|
|||
720
Wardrobe/GUI.vb
720
Wardrobe/GUI.vb
|
|
@ -8,27 +8,7 @@ Public Class GUI
|
|||
Dim filesFolder As String = filepath ' Hämta från settings
|
||||
Dim HLCtFolder As String = filepath & "\X2021" ' Hämta från settings
|
||||
|
||||
Dim containerPanel As Panel
|
||||
|
||||
Dim containerL, containerW, containerMidX, containerMidY As Integer
|
||||
Dim gratingMaxW As Decimal = 1000
|
||||
Dim gratingMaxL As Decimal = 1000
|
||||
Dim drawL As Integer = 1
|
||||
Dim drawW As Integer = 1
|
||||
Dim drawAspect, gratingAspect As Decimal
|
||||
Dim scaleDiff As Decimal = 1
|
||||
|
||||
Public pCon1(3) As Decimal 'pCon(0) = pixel X, pCon(2) = SW X, etc.
|
||||
Public pCon2(3) As Decimal
|
||||
Public pCon3(3) As Decimal
|
||||
Public pCon4(3) As Decimal
|
||||
|
||||
Dim DirSymbolPoints As New Dictionary(Of String, Decimal())
|
||||
Dim ArrowSymbolPoints As New Dictionary(Of String, Decimal())
|
||||
|
||||
Dim points As New Dictionary(Of String, Decimal())
|
||||
Dim pointsFunc As New Dictionary(Of String, Boolean)
|
||||
Dim pointsOrder As New List(Of String)
|
||||
Public Shared containerPanel As Panel
|
||||
|
||||
Dim gratingType, gratingMaterial, gratingMesh As String
|
||||
Dim gratingSerrated As Boolean = False
|
||||
|
|
@ -57,21 +37,19 @@ Public Class GUI
|
|||
containerPanel = DrawingPanel
|
||||
Me.Width = 1400
|
||||
Me.Height = 800
|
||||
AddHandler containerPanel.Paint, AddressOf DrawingPanel_Paint
|
||||
AddHandler containerPanel.Paint, AddressOf GUI_Drawing_Panel.DrawingPanel_Paint
|
||||
|
||||
Get_DrawboxParameters()
|
||||
|
||||
Set_ContainerPointsX()
|
||||
Set_ContainerPointsY()
|
||||
|
||||
Create_DirSymbolPoints()
|
||||
Create_ArrowSymbolPoints()
|
||||
GUI_Drawing_Panel.Load_DrawingPanel()
|
||||
|
||||
Update_GratingPoints()
|
||||
|
||||
Create_StartPoints()
|
||||
|
||||
Program.Load_XCC(filesFolder, HLCtFolder)
|
||||
|
||||
|
||||
|
||||
adminClass.loadSettings(filesFolder, HLCtFolder, "SolidWorks")
|
||||
'Program.Load_XCC(filesFolder, HLCtFolder)
|
||||
Get_Database()
|
||||
End Sub
|
||||
|
||||
|
|
@ -110,250 +88,9 @@ Public Class GUI
|
|||
' HANTERA OLIKA LÄNGDER PÅ COLUMNER
|
||||
End Sub
|
||||
|
||||
' --- Retrive parameters for the drawing box ---
|
||||
Private Sub Get_DrawboxParameters()
|
||||
containerL = containerPanel.Size.Width
|
||||
containerW = containerPanel.Size.Height
|
||||
|
||||
containerMidX = containerL / 2
|
||||
containerMidY = containerW / 2
|
||||
|
||||
drawL = containerL - 80
|
||||
drawW = containerW - 80
|
||||
|
||||
drawAspect = drawL / drawW
|
||||
End Sub
|
||||
|
||||
' --- Set containers points X-values ---
|
||||
Private Sub Set_ContainerPointsX()
|
||||
pCon1(0) = containerMidX - drawL / 2
|
||||
pCon2(0) = containerMidX + drawL / 2
|
||||
pCon3(0) = containerMidX + drawL / 2
|
||||
pCon4(0) = containerMidX - drawL / 2
|
||||
End Sub
|
||||
|
||||
' --- Set containers points Y-values ---
|
||||
Private Sub Set_ContainerPointsY()
|
||||
pCon1(1) = containerMidY - drawW / 2
|
||||
pCon2(1) = containerMidY - drawW / 2
|
||||
pCon3(1) = containerMidY + drawW / 2
|
||||
pCon4(1) = containerMidY + drawW / 2
|
||||
End Sub
|
||||
|
||||
' --- Create points for grating direction symbol ---
|
||||
Private Sub Create_DirSymbolPoints()
|
||||
DirSymbolPoints.Add("p1", {-30 + containerMidX, -2 + containerMidY})
|
||||
DirSymbolPoints.Add("p2", {20 + containerMidX, -2 + containerMidY})
|
||||
DirSymbolPoints.Add("p3", {12 + containerMidX, -10 + containerMidY})
|
||||
DirSymbolPoints.Add("p4", {15 + containerMidX, -13 + containerMidY})
|
||||
DirSymbolPoints.Add("p5", {30 + containerMidX, 2 + containerMidY})
|
||||
DirSymbolPoints.Add("p6", {-20 + containerMidX, 2 + containerMidY})
|
||||
DirSymbolPoints.Add("p7", {-12 + containerMidX, 10 + containerMidY})
|
||||
DirSymbolPoints.Add("p8", {-15 + containerMidX, 13 + containerMidY})
|
||||
DirSymbolPoints.Add("p9", {-30 + containerMidX, -2 + containerMidY})
|
||||
End Sub
|
||||
|
||||
' --- Create points for arrow symbol ---
|
||||
Private Sub Create_ArrowSymbolPoints()
|
||||
Dim offset As Integer = 20
|
||||
ArrowSymbolPoints.Add("p1", {offset, containerW - offset})
|
||||
ArrowSymbolPoints.Add("p2", {offset, containerW - offset - 40})
|
||||
ArrowSymbolPoints.Add("p3", {offset - 5, containerW - offset - 35})
|
||||
ArrowSymbolPoints.Add("p4", {offset, containerW - offset - 40})
|
||||
ArrowSymbolPoints.Add("p5", {offset + 5, containerW - offset - 35})
|
||||
ArrowSymbolPoints.Add("p6", {offset, containerW - offset - 40})
|
||||
ArrowSymbolPoints.Add("p7", {offset, containerW - offset})
|
||||
ArrowSymbolPoints.Add("p8", {offset + 40, containerW - offset})
|
||||
ArrowSymbolPoints.Add("p9", {offset + 35, containerW - offset - 5})
|
||||
ArrowSymbolPoints.Add("p10", {offset + 40, containerW - offset})
|
||||
ArrowSymbolPoints.Add("p11", {offset + 35, containerW - offset + 5})
|
||||
End Sub
|
||||
|
||||
' --- Updates all the gratings points ---
|
||||
Private Sub Update_GratingPoints()
|
||||
gratingAspect = gratingMaxL / gratingMaxW
|
||||
|
||||
If gratingAspect > drawAspect Then
|
||||
'Change draw height
|
||||
scaleDiff = 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)
|
||||
|
||||
Set_ContainerPointsX()
|
||||
Else
|
||||
'Change draw width
|
||||
scaleDiff = 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)
|
||||
|
||||
Set_ContainerPointsY()
|
||||
End If
|
||||
|
||||
'Redraw grating
|
||||
Me.Refresh()
|
||||
|
||||
'SW X-values
|
||||
pCon1(2) = (-gratingMaxL / 2) / 1000
|
||||
pCon2(2) = (gratingMaxL / 2) / 1000
|
||||
pCon3(2) = (gratingMaxL / 2) / 1000
|
||||
pCon4(2) = (-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
|
||||
End Sub
|
||||
|
||||
' --- Draw all the lines for the container and grating ---
|
||||
Private Sub DrawingPanel_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs)
|
||||
' Draw outer grating (red)
|
||||
Dim penCon As Pen = New Pen(Color.DarkRed, 1)
|
||||
penCon.DashPattern = {4, 8}
|
||||
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)))
|
||||
e.Graphics.DrawLine(penCon, CInt(pCon4(0)), CInt(pCon4(1)), CInt(pCon1(0)), CInt(pCon1(1)))
|
||||
|
||||
' Draw grating direction symbol
|
||||
Dim symPen As Pen = New Pen(Color.Black, 1)
|
||||
For i = 1 To DirSymbolPoints.Count - 1
|
||||
e.Graphics.DrawLine(symPen, DirSymbolPoints("p" & i)(0), DirSymbolPoints("p" & i)(1), DirSymbolPoints("p" & i + 1)(0), DirSymbolPoints("p" & i + 1)(1))
|
||||
Next
|
||||
|
||||
' Draw arrow symbol
|
||||
For i = 1 To ArrowSymbolPoints.Count - 1
|
||||
e.Graphics.DrawLine(symPen, ArrowSymbolPoints("p" & i)(0), ArrowSymbolPoints("p" & i)(1), ArrowSymbolPoints("p" & i + 1)(0), ArrowSymbolPoints("p" & i + 1)(1))
|
||||
Next
|
||||
e.Graphics.TranslateTransform(20, containerW - 20)
|
||||
e.Graphics.DrawString("Length", New Font("Microsoft Sans Serif", 8), Brushes.Black, New Point(45, -7))
|
||||
e.Graphics.RotateTransform(-90)
|
||||
e.Graphics.DrawString("Width", New Font("Microsoft Sans Serif", 8), Brushes.Black, New Point(45, -4))
|
||||
e.Graphics.RotateTransform(90)
|
||||
e.Graphics.TranslateTransform(-20, -containerW + 20)
|
||||
|
||||
' Draw actual grating (black)
|
||||
Dim pen As Pen = New Pen(Color.Black, 2)
|
||||
For i = 0 To pointsOrder.Count - 1
|
||||
Dim pTemp1() As Decimal
|
||||
Dim pTemp2() As Decimal
|
||||
|
||||
pTemp1 = points(pointsOrder(i))
|
||||
Try
|
||||
pTemp2 = points(pointsOrder(i + 1))
|
||||
Catch ex As Exception
|
||||
pTemp2 = points(pointsOrder(0))
|
||||
End Try
|
||||
|
||||
e.Graphics.DrawLine(pen, CInt(pTemp1(0)), CInt(pTemp1(1)), CInt(pTemp2(0)), CInt(pTemp2(1)))
|
||||
Next
|
||||
End Sub
|
||||
|
||||
' --- Sets the start points for the grating ---
|
||||
Private Sub Create_StartPoints()
|
||||
For i = 1 To 4
|
||||
points.Add("p" & i, CallByName(Me, "pCon" & i, vbGet))
|
||||
pointsFunc.Add("p" & i, True)
|
||||
pointsOrder.Add("p" & i)
|
||||
Next
|
||||
End Sub
|
||||
|
||||
' --- Generate a table containing all the points X- and Y-values ---
|
||||
Private Function Create_PointTable()
|
||||
Dim pointTable As New DataTable
|
||||
pointTable.Columns.Add("X", GetType(Decimal))
|
||||
pointTable.Columns.Add("Y", GetType(Decimal))
|
||||
|
||||
For i = 0 To pointsOrder.Count - 1
|
||||
Dim pTemp() As Decimal
|
||||
pTemp = points(pointsOrder(i))
|
||||
|
||||
pointTable.Rows.Add()
|
||||
pointTable.Rows(i)("X") = pTemp(2)
|
||||
pointTable.Rows(i)("Y") = pTemp(3)
|
||||
Next
|
||||
|
||||
Return pointTable
|
||||
End Function
|
||||
|
||||
' --- Check if the key pressed is a number ---
|
||||
Private 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
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
' --- Creates the table with points data used in SW ---
|
||||
Private Function Create_ExportTable() As DataTable
|
||||
Dim lSpacing As String = ComboBox_MeshSize.Text.Split("x")(0)
|
||||
Dim cSpacing As String = ComboBox_MeshSize.Text.Split("x")(1).Split(" ")(0)
|
||||
|
||||
Dim gratingTable As New DataTable
|
||||
gratingTable.Columns.Add("TYPE", GetType(String))
|
||||
gratingTable.Columns.Add("SERRATED", GetType(Boolean))
|
||||
gratingTable.Columns.Add("WIDTH", GetType(Decimal))
|
||||
gratingTable.Columns.Add("LENGTH", GetType(Decimal))
|
||||
gratingTable.Columns.Add("LOADBAR_THICKNESS", GetType(Decimal))
|
||||
gratingTable.Columns.Add("LOADBAR_HEIGHT", GetType(Decimal))
|
||||
gratingTable.Columns.Add("LOADBAR_SPACING", GetType(Decimal))
|
||||
gratingTable.Columns.Add("CROSSBAR_SPACING", GetType(Decimal))
|
||||
gratingTable.Columns.Add("CROSSBAR_DIAMETER", GetType(Decimal))
|
||||
gratingTable.Columns.Add("CROSSBAR_THICKNESS", GetType(Decimal))
|
||||
gratingTable.Columns.Add("CROSSBAR_HEIGHT", GetType(Decimal))
|
||||
|
||||
gratingTable.Rows.Add()
|
||||
|
||||
gratingTable.Rows(0)("SERRATED") = False 'Hämta från GUI
|
||||
gratingTable.Rows(0)("WIDTH") = CDec(ComboBox_Width.Text)
|
||||
gratingTable.Rows(0)("LENGTH") = CDec(ComboBox_Length.Text)
|
||||
gratingTable.Rows(0)("LOADBAR_THICKNESS") = CDec(ComboBox_Thickness.Text)
|
||||
gratingTable.Rows(0)("LOADBAR_HEIGHT") = CDec(ComboBox_Height.Text)
|
||||
gratingTable.Rows(0)("LOADBAR_SPACING") = CDec(lSpacing)
|
||||
gratingTable.Rows(0)("CROSSBAR_SPACING") = CDec(cSpacing)
|
||||
|
||||
If ComboBox_TypeChooser.Text = "Pressure Welded" Then
|
||||
gratingTable.Rows(0)("TYPE") = "pressure_welded" ' Här behövs namn på HLCt modellen
|
||||
gratingTable.Rows(0)("CROSSBAR_DIAMETER") = 5
|
||||
gratingTable.Rows(0)("CROSSBAR_THICKNESS") = 0
|
||||
gratingTable.Rows(0)("CROSSBAR_HEIGHT") = 0
|
||||
Else
|
||||
gratingTable.Rows(0)("TYPE") = "type_a" ' Här behövs namn på HLCt modellen
|
||||
gratingTable.Rows(0)("CROSSBAR_DIAMETER") = 0
|
||||
gratingTable.Rows(0)("CROSSBAR_THICKNESS") = 2
|
||||
gratingTable.Rows(0)("CROSSBAR_HEIGHT") = 15
|
||||
End If
|
||||
|
||||
Return gratingTable
|
||||
End Function
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
||||
|
|
@ -361,489 +98,84 @@ Public Class GUI
|
|||
|
||||
' --- When user changes grating type ---
|
||||
Private Sub ComboBox_TypeChooser_TextChanged(sender As Object, e As EventArgs) Handles ComboBox_TypeChooser.TextChanged
|
||||
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)
|
||||
GUI_Gratings_Data.TypeChanged(sender, e)
|
||||
End Sub
|
||||
|
||||
Private Function Get_ColumnIndex(columnName As String, activeDT As DataTable)
|
||||
Dim columnIndex As Integer = -1
|
||||
Dim columnCounter As Integer = 0
|
||||
While columnIndex = -1
|
||||
If activeDT.Columns(columnCounter).ColumnName = columnName Then
|
||||
columnIndex = columnCounter
|
||||
End If
|
||||
columnCounter = columnCounter + 1
|
||||
End While
|
||||
|
||||
Return columnIndex
|
||||
End Function
|
||||
|
||||
' --- When user changes grating material ---
|
||||
Private Sub ComboBox_Material_TextChanged(sender As Object, e As EventArgs) Handles ComboBox_Material.TextChanged
|
||||
ComboBox_MeshSize.Enabled = True
|
||||
gratingMaterial = ComboBox_Material.Text
|
||||
GUI_Gratings_Data.MaterialChanged(sender, e)
|
||||
|
||||
Dim serratedDT As DataTable = dataBase("Serrated")
|
||||
Dim typeColumn As Integer = Get_ColumnIndex("TYPE", serratedDT)
|
||||
Dim materialColumn As Integer = Get_ColumnIndex("MATERIAL", serratedDT)
|
||||
|
||||
Dim removeCheckBox As Boolean = True
|
||||
Dim typeInDT As String = serratedDT.Rows(0)(typeColumn)
|
||||
Dim materialInDT As String = serratedDT.Rows(0)(materialColumn)
|
||||
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)(typeColumn)
|
||||
materialInDT = serratedDT.Rows(i + 1)(materialColumn)
|
||||
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)(typeColumn)
|
||||
materialInDT = serratedDT.Rows(i + 1)(materialColumn)
|
||||
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
|
||||
|
||||
' --- When user changes mesh size ---
|
||||
Private Sub ComboBox_MeshSize_TextChanged(sender As Object, e As EventArgs) Handles ComboBox_MeshSize.TextChanged
|
||||
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))
|
||||
GUI_Gratings_Data.MeshChanged(sender, e)
|
||||
|
||||
' Add heights
|
||||
If loadBarSpacing = 12 And crossBarSpacing = 100 Then
|
||||
ComboBox_Height.Items.Add("20")
|
||||
ComboBox_Height.Items.Add("25")
|
||||
End If
|
||||
End Sub
|
||||
|
||||
' --- When user changes grating height ---
|
||||
Private Sub ComboBox_Height_TextChanged(sender As Object, e As EventArgs) Handles ComboBox_Height.TextChanged
|
||||
ComboBox_Thickness.Enabled = True
|
||||
ComboBox_Thickness.Items.Clear()
|
||||
gratingHeight = CInt(ComboBox_Height.Text)
|
||||
GUI_Gratings_Data.HeightChanged(sender, e)
|
||||
|
||||
' Add thicknesses
|
||||
If gratingHeight = 20 Then
|
||||
ComboBox_Thickness.Items.Add("2")
|
||||
ComboBox_Thickness.Items.Add("3")
|
||||
End If
|
||||
End Sub
|
||||
|
||||
' --- When user changes grating thickness ---
|
||||
Private Sub ComboBox_Thickness_TextChanged(sender As Object, e As EventArgs) Handles ComboBox_Thickness.TextChanged
|
||||
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)
|
||||
GUI_Gratings_Data.ThicknessChanged(sender, e)
|
||||
|
||||
' Add Length
|
||||
ComboBox_Length.Items.Add("500")
|
||||
ComboBox_Length.Items.Add("1000")
|
||||
ComboBox_Length.Text = ComboBox_Length.Items(0)
|
||||
End Sub
|
||||
|
||||
Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged
|
||||
If CheckBox1.Checked Then
|
||||
ComboBox_Width.DropDownStyle = ComboBoxStyle.DropDownList
|
||||
Else
|
||||
ComboBox_Width.DropDownStyle = ComboBoxStyle.DropDown
|
||||
End If
|
||||
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)
|
||||
|
||||
|
||||
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
|
||||
|
||||
' --- Check if width is a number ---
|
||||
Private Sub ComboBox_Width_KeyPress(sender As Object, e As KeyPressEventArgs) Handles ComboBox_Width.KeyPress
|
||||
Check_IfNumber(e)
|
||||
GUI_Gratings_Data.Check_IfNumber(e)
|
||||
End Sub
|
||||
|
||||
' --- Grating length changed ---
|
||||
Private Sub LengthBox_TextChanged(sender As Object, e As EventArgs) Handles ComboBox_Length.TextChanged
|
||||
If ComboBox_Length.Text <> "" Then
|
||||
If CDec(ComboBox_Length.Text) > 0 Then
|
||||
gratingMaxL = CDec(ComboBox_Length.Text)
|
||||
Update_GratingPoints()
|
||||
End If
|
||||
End If
|
||||
GUI_Gratings_Data.LengthChanged(sender, e)
|
||||
|
||||
End Sub
|
||||
|
||||
' --- Check if length is a number ---
|
||||
Private Sub ComboBox_Length_KeyPress(sender As Object, e As KeyPressEventArgs) Handles ComboBox_Length.KeyPress
|
||||
Check_IfNumber(e)
|
||||
GUI_Gratings_Data.Check_IfNumber(e)
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
' --- When angle button is pressed ---
|
||||
Private Sub AngleButton_Click(sender As Object, e As EventArgs) Handles AngleButton.Click
|
||||
Me.Controls("AngleButton").Enabled = False
|
||||
Me.Controls("Button_Square").Enabled = False
|
||||
GUI_Functions.AngleButton(sender, e)
|
||||
|
||||
Dim buttonX As Integer = Me.Controls("AngleButton").Location.X
|
||||
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 FunctionText_Changed
|
||||
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)
|
||||
|
||||
angleFunctionActive = True
|
||||
End Sub
|
||||
|
||||
' --- When square button is pressed ---
|
||||
Private Sub Button_Square_Click(sender As Object, e As EventArgs) Handles Button_Square.Click
|
||||
Me.Controls("AngleButton").Enabled = False
|
||||
Me.Controls("Button_Square").Enabled = False
|
||||
GUI_Functions.SquareButtton(sender, e)
|
||||
|
||||
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 FunctionText_Changed
|
||||
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)
|
||||
|
||||
' 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
|
||||
' Create Buttons for all clickable points
|
||||
For i = 0 To pointsOrder.Count - 1
|
||||
If pointsFunc(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.Name = pointsOrder(i) & "_Button"
|
||||
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
|
||||
|
||||
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)
|
||||
|
||||
AddHandler pointButton.Click, AddressOf PointButton_Click
|
||||
End If
|
||||
Next
|
||||
pointCounter = pointCounter + 1
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
' --- When a function button is pressed ---
|
||||
Private 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)
|
||||
|
||||
' 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")
|
||||
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 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 numOfNewPoints As Integer
|
||||
|
||||
If angleFunctionActive Then
|
||||
If pXP < containerMidX Then
|
||||
If pYP > 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})
|
||||
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})
|
||||
End If
|
||||
Else
|
||||
If pYP > 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})
|
||||
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})
|
||||
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)
|
||||
|
||||
numOfNewPoints = 2
|
||||
angleFunctionActive = False
|
||||
|
||||
Else
|
||||
If pXP < containerMidX Then
|
||||
If pYP > 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})
|
||||
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})
|
||||
End If
|
||||
Else
|
||||
If pYP > 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})
|
||||
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})
|
||||
End If
|
||||
End If
|
||||
pointsFunc.Add("pS" & pointCounter * 3 - 2, True)
|
||||
pointsFunc.Add("pS" & pointCounter * 3 - 1, False)
|
||||
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)
|
||||
|
||||
numOfNewPoints = 3
|
||||
|
||||
squareFunctionActive = False
|
||||
|
||||
End If
|
||||
pointsOrder.RemoveAt(index)
|
||||
|
||||
'Redraw grating
|
||||
Me.Refresh()
|
||||
|
||||
RemoveHandler Me.Controls("X_TextBox").TextChanged, AddressOf FunctionText_Changed
|
||||
Me.Controls.RemoveByKey("X_TextBox")
|
||||
|
||||
RemoveHandler Me.Controls("Y_TextBox").TextChanged, AddressOf FunctionText_Changed
|
||||
Me.Controls.RemoveByKey("Y_TextBox")
|
||||
|
||||
Me.Controls.RemoveByKey("X_Label")
|
||||
Me.Controls.RemoveByKey("Y_Label")
|
||||
|
||||
Me.Controls("AngleButton").Enabled = True
|
||||
Me.Controls("Button_Square").Enabled = True
|
||||
End Sub
|
||||
|
||||
' --- Settings button clicked ---
|
||||
Private Sub SettingsButton_Click(sender As Object, e As EventArgs) Handles SettingsButton.Click
|
||||
Program.Update_KB()
|
||||
GUI_Settings.ButtonClicked(sender, e)
|
||||
End Sub
|
||||
|
||||
' --- When export to SW button is pressed ---
|
||||
Private Sub ExportSWButton_Click(sender As Object, e As EventArgs) Handles ExportSWButton.Click
|
||||
Dim exportTable As DataTable
|
||||
exportTable = Create_ExportTable()
|
||||
|
||||
|
||||
Program.Build_Grating(exportTable)
|
||||
|
||||
'Test för att SW API
|
||||
Dim pointTable As New DataTable
|
||||
pointTable = Create_PointTable()
|
||||
|
||||
Program.Export_SW(pointTable, 0.025) 'Make variable ref to Height
|
||||
|
||||
SW_HLCt_Gratings.BuildGrating()
|
||||
SW_Drawing_Gratings.CreateDrawing()
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
|
@ -0,0 +1,191 @@
|
|||
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
|
||||
|
||||
Private 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 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()
|
||||
Set_ContainerPointsX()
|
||||
Set_ContainerPointsY()
|
||||
|
||||
Create_DirSymbolPoints()
|
||||
Create_ArrowSymbolPoints()
|
||||
Update_GratingPoints()
|
||||
Create_StartPoints()
|
||||
End Sub
|
||||
|
||||
' --- Retrive parameters for the drawing box ---
|
||||
Private Shared Sub Get_DrawboxParameters()
|
||||
containerL = GUI.containerPanel.Size.Width
|
||||
containerW = GUI.containerPanel.Size.Height
|
||||
|
||||
containerMidX = containerL / 2
|
||||
containerMidY = containerW / 2
|
||||
|
||||
drawL = containerL - 80
|
||||
drawW = containerW - 80
|
||||
|
||||
drawAspect = drawL / drawW
|
||||
End Sub
|
||||
|
||||
' --- Set containers points X-values ---
|
||||
Private Shared Sub Set_ContainerPointsX()
|
||||
pCon1(0) = containerMidX - drawL / 2
|
||||
pCon2(0) = containerMidX + drawL / 2
|
||||
pCon3(0) = containerMidX + drawL / 2
|
||||
pCon4(0) = containerMidX - drawL / 2
|
||||
End Sub
|
||||
|
||||
' --- Set containers points Y-values ---
|
||||
Private Shared Sub Set_ContainerPointsY()
|
||||
pCon1(1) = containerMidY - drawW / 2
|
||||
pCon2(1) = containerMidY - drawW / 2
|
||||
pCon3(1) = containerMidY + drawW / 2
|
||||
pCon4(1) = containerMidY + drawW / 2
|
||||
End Sub
|
||||
|
||||
|
||||
' --- Create points for grating direction symbol ---
|
||||
Private Shared Sub Create_DirSymbolPoints()
|
||||
DirSymbolPoints.Add("p1", {-30 + containerMidX, -2 + containerMidY})
|
||||
DirSymbolPoints.Add("p2", {20 + containerMidX, -2 + containerMidY})
|
||||
DirSymbolPoints.Add("p3", {12 + containerMidX, -10 + containerMidY})
|
||||
DirSymbolPoints.Add("p4", {15 + containerMidX, -13 + containerMidY})
|
||||
DirSymbolPoints.Add("p5", {30 + containerMidX, 2 + containerMidY})
|
||||
DirSymbolPoints.Add("p6", {-20 + containerMidX, 2 + containerMidY})
|
||||
DirSymbolPoints.Add("p7", {-12 + containerMidX, 10 + containerMidY})
|
||||
DirSymbolPoints.Add("p8", {-15 + containerMidX, 13 + containerMidY})
|
||||
DirSymbolPoints.Add("p9", {-30 + containerMidX, -2 + containerMidY})
|
||||
End Sub
|
||||
|
||||
' --- Create points for arrow symbol ---
|
||||
Private Shared Sub Create_ArrowSymbolPoints()
|
||||
Dim offset As Integer = 20
|
||||
ArrowSymbolPoints.Add("p1", {offset, containerW - offset})
|
||||
ArrowSymbolPoints.Add("p2", {offset, containerW - offset - 40})
|
||||
ArrowSymbolPoints.Add("p3", {offset - 5, containerW - offset - 35})
|
||||
ArrowSymbolPoints.Add("p4", {offset, containerW - offset - 40})
|
||||
ArrowSymbolPoints.Add("p5", {offset + 5, containerW - offset - 35})
|
||||
ArrowSymbolPoints.Add("p6", {offset, containerW - offset - 40})
|
||||
ArrowSymbolPoints.Add("p7", {offset, containerW - offset})
|
||||
ArrowSymbolPoints.Add("p8", {offset + 40, containerW - offset})
|
||||
ArrowSymbolPoints.Add("p9", {offset + 35, containerW - offset - 5})
|
||||
ArrowSymbolPoints.Add("p10", {offset + 40, containerW - offset})
|
||||
ArrowSymbolPoints.Add("p11", {offset + 35, containerW - offset + 5})
|
||||
End Sub
|
||||
|
||||
' --- Updates all the gratings points ---
|
||||
Private Shared Sub Update_GratingPoints()
|
||||
gratingAspect = gratingMaxL / gratingMaxW
|
||||
|
||||
If gratingAspect > drawAspect Then
|
||||
'Change draw height
|
||||
scaleDiff = 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)
|
||||
|
||||
Set_ContainerPointsX()
|
||||
Else
|
||||
'Change draw width
|
||||
scaleDiff = 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)
|
||||
|
||||
Set_ContainerPointsY()
|
||||
End If
|
||||
|
||||
'Redraw grating
|
||||
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
|
||||
|
||||
'SW Y-values
|
||||
pCon1(3) = (gratingMaxW / 2) / 1000
|
||||
pCon2(3) = (gratingMaxW / 2) / 1000
|
||||
pCon3(3) = (-gratingMaxW / 2) / 1000
|
||||
pCon4(3) = (-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
|
||||
End Sub
|
||||
|
||||
' --- 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, 1)
|
||||
penCon.DashPattern = {4, 8}
|
||||
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)))
|
||||
e.Graphics.DrawLine(penCon, CInt(pCon4(0)), CInt(pCon4(1)), CInt(pCon1(0)), CInt(pCon1(1)))
|
||||
|
||||
' Draw grating direction symbol
|
||||
Dim symPen As Pen = New Pen(Color.Black, 1)
|
||||
For i = 1 To DirSymbolPoints.Count - 1
|
||||
e.Graphics.DrawLine(symPen, DirSymbolPoints("p" & i)(0), DirSymbolPoints("p" & i)(1), DirSymbolPoints("p" & i + 1)(0), DirSymbolPoints("p" & i + 1)(1))
|
||||
Next
|
||||
|
||||
' Draw arrow symbol
|
||||
For i = 1 To ArrowSymbolPoints.Count - 1
|
||||
e.Graphics.DrawLine(symPen, ArrowSymbolPoints("p" & i)(0), ArrowSymbolPoints("p" & i)(1), ArrowSymbolPoints("p" & i + 1)(0), ArrowSymbolPoints("p" & i + 1)(1))
|
||||
Next
|
||||
e.Graphics.TranslateTransform(20, containerW - 20)
|
||||
e.Graphics.DrawString("Length", New Font("Microsoft Sans Serif", 8), Brushes.Black, New Point(45, -7))
|
||||
e.Graphics.RotateTransform(-90)
|
||||
e.Graphics.DrawString("Width", New Font("Microsoft Sans Serif", 8), Brushes.Black, New Point(45, -4))
|
||||
e.Graphics.RotateTransform(90)
|
||||
e.Graphics.TranslateTransform(-20, -containerW + 20)
|
||||
|
||||
' Draw actual grating (black)
|
||||
Dim pen As Pen = New Pen(Color.Black, 2)
|
||||
For i = 0 To pointsOrder.Count - 1
|
||||
Dim pTemp1() As Decimal
|
||||
Dim pTemp2() As Decimal
|
||||
|
||||
pTemp1 = points(pointsOrder(i))
|
||||
Try
|
||||
pTemp2 = points(pointsOrder(i + 1))
|
||||
Catch ex As Exception
|
||||
pTemp2 = points(pointsOrder(0))
|
||||
End Try
|
||||
|
||||
e.Graphics.DrawLine(pen, CInt(pTemp1(0)), CInt(pTemp1(1)), CInt(pTemp2(0)), CInt(pTemp2(1)))
|
||||
Next
|
||||
End Sub
|
||||
End Class
|
||||
|
|
@ -0,0 +1,193 @@
|
|||
Public Class GUI_Functions
|
||||
Public Shared Sub AngleButton(sender As Object, e As EventArgs)
|
||||
Me.Controls("AngleButton").Enabled = False
|
||||
Me.Controls("Button_Square").Enabled = False
|
||||
|
||||
Dim buttonX As Integer = Me.Controls("AngleButton").Location.X
|
||||
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 FunctionText_Changed
|
||||
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)
|
||||
|
||||
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
|
||||
|
||||
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 FunctionText_Changed
|
||||
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)
|
||||
|
||||
' 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
|
||||
' Create Buttons for all clickable points
|
||||
For i = 0 To pointsOrder.Count - 1
|
||||
If pointsFunc(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.Name = pointsOrder(i) & "_Button"
|
||||
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
|
||||
|
||||
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)
|
||||
|
||||
AddHandler pointButton.Click, AddressOf PointButton_Click
|
||||
End If
|
||||
Next
|
||||
pointCounter = pointCounter + 1
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
' --- When a function button is pressed ---
|
||||
Private 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)
|
||||
|
||||
' 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")
|
||||
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 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 numOfNewPoints As Integer
|
||||
|
||||
If angleFunctionActive Then
|
||||
If pXP < containerMidX Then
|
||||
If pYP > 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})
|
||||
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})
|
||||
End If
|
||||
Else
|
||||
If pYP > 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})
|
||||
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})
|
||||
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)
|
||||
|
||||
numOfNewPoints = 2
|
||||
angleFunctionActive = False
|
||||
|
||||
Else
|
||||
If pXP < containerMidX Then
|
||||
If pYP > 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})
|
||||
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})
|
||||
End If
|
||||
Else
|
||||
If pYP > 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})
|
||||
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})
|
||||
End If
|
||||
End If
|
||||
pointsFunc.Add("pS" & pointCounter * 3 - 2, True)
|
||||
pointsFunc.Add("pS" & pointCounter * 3 - 1, False)
|
||||
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)
|
||||
|
||||
numOfNewPoints = 3
|
||||
|
||||
squareFunctionActive = False
|
||||
|
||||
End If
|
||||
pointsOrder.RemoveAt(index)
|
||||
|
||||
'Redraw grating
|
||||
Me.Refresh()
|
||||
|
||||
RemoveHandler Me.Controls("X_TextBox").TextChanged, AddressOf FunctionText_Changed
|
||||
Me.Controls.RemoveByKey("X_TextBox")
|
||||
|
||||
RemoveHandler Me.Controls("Y_TextBox").TextChanged, AddressOf FunctionText_Changed
|
||||
Me.Controls.RemoveByKey("Y_TextBox")
|
||||
|
||||
Me.Controls.RemoveByKey("X_Label")
|
||||
Me.Controls.RemoveByKey("Y_Label")
|
||||
|
||||
Me.Controls("AngleButton").Enabled = True
|
||||
Me.Controls("Button_Square").Enabled = True
|
||||
End Sub
|
||||
End Class
|
||||
|
|
@ -0,0 +1,334 @@
|
|||
Public Class GUI_Gratings_Data
|
||||
' --- 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)
|
||||
Dim cSpacing As String = GUI.ComboBox_MeshSize.Text.Split("x")(1).Split(" ")(0)
|
||||
|
||||
Dim gratingTable As New DataTable
|
||||
gratingTable.Columns.Add("TYPE", GetType(String))
|
||||
gratingTable.Columns.Add("SERRATED", GetType(Boolean))
|
||||
gratingTable.Columns.Add("WIDTH", GetType(Decimal))
|
||||
gratingTable.Columns.Add("LENGTH", GetType(Decimal))
|
||||
gratingTable.Columns.Add("LOADBAR_THICKNESS", GetType(Decimal))
|
||||
gratingTable.Columns.Add("LOADBAR_HEIGHT", GetType(Decimal))
|
||||
gratingTable.Columns.Add("LOADBAR_SPACING", GetType(Decimal))
|
||||
gratingTable.Columns.Add("CROSSBAR_SPACING", GetType(Decimal))
|
||||
gratingTable.Columns.Add("CROSSBAR_DIAMETER", GetType(Decimal))
|
||||
gratingTable.Columns.Add("CROSSBAR_THICKNESS", GetType(Decimal))
|
||||
gratingTable.Columns.Add("CROSSBAR_HEIGHT", GetType(Decimal))
|
||||
|
||||
gratingTable.Rows.Add()
|
||||
|
||||
gratingTable.Rows(0)("SERRATED") = False 'Hämta från GUI
|
||||
gratingTable.Rows(0)("WIDTH") = CDec(GUI.ComboBox_Width.Text)
|
||||
gratingTable.Rows(0)("LENGTH") = CDec(GUI.ComboBox_Length.Text)
|
||||
gratingTable.Rows(0)("LOADBAR_THICKNESS") = CDec(GUI.ComboBox_Thickness.Text)
|
||||
gratingTable.Rows(0)("LOADBAR_HEIGHT") = CDec(GUI.ComboBox_Height.Text)
|
||||
gratingTable.Rows(0)("LOADBAR_SPACING") = CDec(lSpacing)
|
||||
gratingTable.Rows(0)("CROSSBAR_SPACING") = CDec(cSpacing)
|
||||
|
||||
If GUI.ComboBox_TypeChooser.Text = "Pressure Welded" Then
|
||||
gratingTable.Rows(0)("TYPE") = "pressure_welded" ' Här behövs namn på HLCt modellen
|
||||
gratingTable.Rows(0)("CROSSBAR_DIAMETER") = 5
|
||||
gratingTable.Rows(0)("CROSSBAR_THICKNESS") = 0
|
||||
gratingTable.Rows(0)("CROSSBAR_HEIGHT") = 0
|
||||
Else
|
||||
gratingTable.Rows(0)("TYPE") = "type_a" ' Här behövs namn på HLCt modellen
|
||||
gratingTable.Rows(0)("CROSSBAR_DIAMETER") = 0
|
||||
gratingTable.Rows(0)("CROSSBAR_THICKNESS") = 2
|
||||
gratingTable.Rows(0)("CROSSBAR_HEIGHT") = 15
|
||||
End If
|
||||
|
||||
Return gratingTable
|
||||
End Function
|
||||
|
||||
|
||||
' --- Generate a table containing all the points X- and Y-values ---
|
||||
Public Shared Function Create_PointTable()
|
||||
Dim pointTable As New DataTable
|
||||
pointTable.Columns.Add("X", GetType(Decimal))
|
||||
pointTable.Columns.Add("Y", GetType(Decimal))
|
||||
|
||||
For i = 0 To GUI.pointsOrder.Count - 1
|
||||
Dim pTemp() As Decimal
|
||||
pTemp = GUI.points(GUI.pointsOrder(i))
|
||||
|
||||
pointTable.Rows.Add()
|
||||
pointTable.Rows(i)("X") = pTemp(2)
|
||||
pointTable.Rows(i)("Y") = pTemp(3)
|
||||
Next
|
||||
|
||||
Return pointTable
|
||||
End Function
|
||||
|
||||
|
||||
' --- Check if the key pressed is a number ---
|
||||
Private 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
|
||||
End If
|
||||
End If
|
||||
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
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
Imports XCCLibrary
|
||||
Imports SldWorks
|
||||
Public Class GUI_Settings
|
||||
|
||||
' --- Settings button clicked ---
|
||||
Public Shared Sub ButtonClicked(sender As Object, e As EventArgs)
|
||||
adminClass.updateDatabase()
|
||||
End Sub
|
||||
End Class
|
||||
|
|
@ -1,45 +1,11 @@
|
|||
Imports XCCLibrary
|
||||
Imports SldWorks
|
||||
Public Class Program
|
||||
Public Class SW_Drawing_Gratings
|
||||
Public Shared Sub CreateDrawing()
|
||||
Dim pointTable As New DataTable
|
||||
pointTable = GUI_Gratings_Data.Create_PointTable()
|
||||
|
||||
Public Shared Sub Load_XCC(filesFolder As String, HLCtFolder As String)
|
||||
adminClass.loadSettings(filesFolder, HLCtFolder, "SolidWorks")
|
||||
End Sub
|
||||
|
||||
Public Shared Sub Update_KB()
|
||||
adminClass.updateDatabase()
|
||||
End Sub
|
||||
|
||||
Public Shared Sub Build_Grating(impTable As DataTable)
|
||||
XCCBaseClass.newDesign()
|
||||
ExternalClass.PopulateTamplateXMLGroup()
|
||||
|
||||
Dim inst_ As Integer = 0
|
||||
Dim parentID As Integer = 0
|
||||
Dim gratingParameters As DataRow = impTable.Rows(0)
|
||||
inst_ = ExternalClass.instantiate_parts(parentID, gratingParameters("TYPE"), "") ' Ange pressure welded eller type A, Serrated?
|
||||
ExternalClass.modify_parameter_value("DP_GRATING_WIDTH", inst_, gratingParameters("WIDTH"))
|
||||
ExternalClass.modify_parameter_value("DP_GRATING_LENGTH", inst_, gratingParameters("LENGTH"))
|
||||
ExternalClass.modify_parameter_value("DP_LOADBAR_THICKNESS", inst_, gratingParameters("LOADBAR_THICKNESS"))
|
||||
ExternalClass.modify_parameter_value("DP_LOADBAR_HEIGHT", inst_, gratingParameters("LOADBAR_HEIGHT"))
|
||||
ExternalClass.modify_parameter_value("DP_LOADBAR_SPACING", inst_, gratingParameters("LOADBAR_SPACING"))
|
||||
ExternalClass.modify_parameter_value("DP_CROSSBAR_SPACING", inst_, gratingParameters("CROSSBAR_SPACING"))
|
||||
|
||||
If gratingParameters("TYPE") = "pressure_welded" Then
|
||||
ExternalClass.modify_parameter_value("DP_CROSSBAR_DIAMETER", inst_, gratingParameters("CROSSBAR_DIAMETER"))
|
||||
Else
|
||||
ExternalClass.modify_parameter_value("DP_CROSSBAR_THICKNESS", inst_, gratingParameters("CROSSBAR_THICKNESS"))
|
||||
ExternalClass.modify_parameter_value("DP_CROSSBAR_HEIGHT", inst_, gratingParameters("CROSSBAR_HEIGHT"))
|
||||
End If
|
||||
|
||||
importClass.copyGroupsByDataSet(ExternalClass.groupds_new)
|
||||
Dim grNr = groupClass.NewGroupID
|
||||
Dim designTable = designModel.selectDesign("*")
|
||||
Dim designName = designTable.rows(0)("designName")
|
||||
groupClass.InstantiateGroup(designName, grNr, "START")
|
||||
End Sub
|
||||
|
||||
Public Shared Sub Export_SW(pointTable As DataTable, gratingHeight As Decimal)
|
||||
Dim gratingHeight As Decimal = 0.025 ' Behövs variabel
|
||||
Dim swApp As SldWorks.SldWorks
|
||||
swApp = CType(System.Runtime.InteropServices.Marshal.GetActiveObject("SldWorks.Application"), SldWorks.SldWorks)
|
||||
Dim Model As ModelDoc2
|
||||
|
|
@ -108,10 +74,9 @@ Public Class Program
|
|||
|
||||
Model.ClearSelection2(True)
|
||||
Create_Drawing(iPart)
|
||||
|
||||
End Sub
|
||||
|
||||
Public Shared Sub Create_Drawing(iModel As SldWorks.IModelDoc2)
|
||||
Private Shared Sub Create_Drawing(iModel As SldWorks.IModelDoc2)
|
||||
Dim swApp As SldWorks.SldWorks
|
||||
swApp = CType(System.Runtime.InteropServices.Marshal.GetActiveObject("SldWorks.Application"), SldWorks.SldWorks)
|
||||
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
Imports XCCLibrary
|
||||
Imports SldWorks
|
||||
Public Class SW_HLCt_Gratings
|
||||
Public Shared Sub BuildGrating()
|
||||
Dim exportTable As DataTable
|
||||
exportTable = GUI_Gratings_Data.Create_ExportTable()
|
||||
|
||||
XCCBaseClass.newDesign()
|
||||
ExternalClass.PopulateTamplateXMLGroup()
|
||||
|
||||
Dim inst_ As Integer
|
||||
Dim parentID As Integer = 0
|
||||
Dim gratingParameters As DataRow = exportTable.Rows(0)
|
||||
inst_ = ExternalClass.instantiate_parts(parentID, gratingParameters("TYPE"), "") ' Ange pressure_welded eller type A, Serrated?
|
||||
ExternalClass.modify_parameter_value("DP_GRATING_WIDTH", inst_, gratingParameters("WIDTH"))
|
||||
ExternalClass.modify_parameter_value("DP_GRATING_LENGTH", inst_, gratingParameters("LENGTH"))
|
||||
ExternalClass.modify_parameter_value("DP_LOADBAR_THICKNESS", inst_, gratingParameters("LOADBAR_THICKNESS"))
|
||||
ExternalClass.modify_parameter_value("DP_LOADBAR_HEIGHT", inst_, gratingParameters("LOADBAR_HEIGHT"))
|
||||
ExternalClass.modify_parameter_value("DP_LOADBAR_SPACING", inst_, gratingParameters("LOADBAR_SPACING"))
|
||||
ExternalClass.modify_parameter_value("DP_CROSSBAR_SPACING", inst_, gratingParameters("CROSSBAR_SPACING"))
|
||||
|
||||
If gratingParameters("TYPE") = "pressure_welded" Then
|
||||
ExternalClass.modify_parameter_value("DP_CROSSBAR_DIAMETER", inst_, gratingParameters("CROSSBAR_DIAMETER"))
|
||||
Else
|
||||
ExternalClass.modify_parameter_value("DP_CROSSBAR_THICKNESS", inst_, gratingParameters("CROSSBAR_THICKNESS"))
|
||||
ExternalClass.modify_parameter_value("DP_CROSSBAR_HEIGHT", inst_, gratingParameters("CROSSBAR_HEIGHT"))
|
||||
End If
|
||||
|
||||
importClass.copyGroupsByDataSet(ExternalClass.groupds_new)
|
||||
Dim grNr = groupClass.NewGroupID
|
||||
Dim designTable = designModel.selectDesign("*")
|
||||
Dim designName = designTable.rows(0)("designName")
|
||||
groupClass.InstantiateGroup(designName, grNr, "START")
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
|
@ -74,7 +74,10 @@
|
|||
<Import Include="System.Xml.Linq" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.vb" />
|
||||
<Compile Include="GUI_Drawing_Panel.vb" />
|
||||
<Compile Include="GUI_Functions.vb" />
|
||||
<Compile Include="GUI_Gratings_Data.vb" />
|
||||
<Compile Include="GUI_Settings.vb" />
|
||||
<Compile Include="GUI.vb">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
|
@ -98,6 +101,8 @@
|
|||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<Compile Include="SW_Drawing_Gratings.vb" />
|
||||
<Compile Include="SW_HLCt_Gratings.vb" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="GUI.resx">
|
||||
|
|
|
|||
Loading…
Reference in New Issue