Serrated checkbox conditions

This commit is contained in:
Mans 2021-02-05 10:41:55 +01:00
parent 27a464dd6a
commit a9567f6b39
2 changed files with 67 additions and 35 deletions

Binary file not shown.

View File

@ -31,7 +31,7 @@ Public Class GUI
Dim pointsOrder As New List(Of String)
Dim gratingType, gratingMaterial, gratingMesh As String
Dim gratingSerrated As Boolean
Dim gratingSerrated As Boolean = False
Dim loadBarSpacing, crossBarSpacing, gratingHeight, loadBarThickness As Integer
Dim pointCounter As Integer
@ -42,6 +42,8 @@ Public Class GUI
Dim excelWB As Excel.Workbook
Dim excelSheet As Excel.Worksheet
Dim serratedCheckBoxBol As Boolean = False
' --- Start method (main) for GUI ---
Sub GUI_load() Handles MyBase.Load
containerPanel = DrawingPanel
@ -319,28 +321,15 @@ Public Class GUI
gratingType = ComboBox_TypeChooser.Text
ComboBox_Material.Enabled = True
ComboBox_Material.Items.Clear()
Dim materialSheet As Excel.Worksheet
materialSheet = excelWB.Sheets("Material")
Dim typeColumn As Integer = 0
Dim columnCounter As Integer = 1
While typeColumn = 0
If materialSheet.Cells(1, columnCounter).value = "TYPE" Then
typeColumn = materialSheet.Cells(1, columnCounter).column
End If
columnCounter = columnCounter + 1
End While
Dim typeColumn As Integer
typeColumn = Get_ColumnIndex("TYPE", materialSheet)
Dim materialColumn As Integer = 0
columnCounter = 1
While materialColumn = 0
If materialSheet.Cells(1, columnCounter).value = "MATERIAL" Then
materialColumn = materialSheet.Cells(1, columnCounter).column
End If
columnCounter = columnCounter + 1
End While
Dim materialColumn As Integer
materialColumn = Get_ColumnIndex("MATERIAL", materialSheet)
Dim typeInExcel As String
Dim rowCounter As Integer = 2
@ -357,30 +346,73 @@ Public Class GUI
ComboBox_Material.Text = ComboBox_Material.Items(0)
End Sub
Private Function Get_ColumnIndex(columnName As String, activeSheet As Excel.Worksheet)
Dim columnIndex As Integer = 0
Dim columnCounter As Integer = 1
While columnIndex = 0
If activeSheet.Cells(1, columnCounter).value = columnName Then
columnIndex = activeSheet.Cells(1, columnCounter).column
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
ComboBox_MeshSize.Items.Clear()
gratingMaterial = ComboBox_Material.Text
gratingSerrated = False 'FIXA
' Add toothing option
If gratingType = "Pressure Welded" Then
If gratingMaterial = "Standard" Or gratingMaterial = "Stainless Steel (Pickled)" Then
Dim serratedCheckBox As New CheckBox
serratedCheckBox.Name = "CheckBox_Serrated"
serratedCheckBox.Text = "Serrated"
serratedCheckBox.Left = 115
serratedCheckBox.Top = 115
Me.Controls.Add(serratedCheckBox)
Dim serratedSheet As Excel.Worksheet
serratedSheet = excelWB.Sheets("Serrated")
Dim typeColumn As Integer
typeColumn = Get_ColumnIndex("TYPE", serratedSheet)
Dim materialColumn As Integer
materialColumn = Get_ColumnIndex("MATERIAL", serratedSheet)
Dim typeInExcel As String
Dim materialInExcel As String
Dim removeCheckBox As Boolean = True
Dim rowCounter As Integer = 2
materialInExcel = serratedSheet.Cells(rowCounter, materialColumn).value
typeInExcel = serratedSheet.Cells(rowCounter, typeColumn).value
If serratedCheckBoxBol = False Then
While typeInExcel <> ""
If gratingType = typeInExcel And gratingMaterial = materialInExcel Then
Dim serratedCheckBox As New CheckBox
serratedCheckBox.Name = "CheckBox_Serrated"
serratedCheckBox.Text = "Serrated"
serratedCheckBox.Left = 115
serratedCheckBox.Top = 115
Me.Controls.Add(serratedCheckBox)
serratedCheckBoxBol = True
Exit While
End If
rowCounter = rowCounter + 1
typeInExcel = serratedSheet.Cells(rowCounter, typeColumn).value
materialInExcel = serratedSheet.Cells(rowCounter, materialColumn).value
End While
Else
While typeInExcel <> ""
If gratingType = typeInExcel And gratingMaterial = materialInExcel Then
removeCheckBox = False
Exit While
End If
rowCounter = rowCounter + 1
typeInExcel = serratedSheet.Cells(rowCounter, typeColumn).value
materialInExcel = serratedSheet.Cells(rowCounter, materialColumn).value
End While
If serratedCheckBoxBol = True And removeCheckBox = True Then
Me.Controls.RemoveByKey("CheckBox_Serrated")
serratedCheckBoxBol = False
End If
ElseIf gratingMaterial = "Standard" Or gratingMaterial = "Aluminum" Then
Dim serratedCheckBox As New CheckBox
serratedCheckBox.Name = "CheckBox_Serrated"
serratedCheckBox.Text = "Serrated"
serratedCheckBox.Left = 115
serratedCheckBox.Top = 115
Me.Controls.Add(serratedCheckBox)
End If
' Add Meshes