181 lines
6.0 KiB
VB.net
181 lines
6.0 KiB
VB.net
Imports XCCLibrary
|
|
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
|
|
|
|
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)
|
|
|
|
' --- 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
|
|
|
|
|
|
|
|
GUI_Drawing_Panel.Load_DrawingPanel()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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")
|
|
|
|
For i = 1 To 3 'excelWB.Worksheets.Count
|
|
Dim activeSheet As Excel.Worksheet
|
|
activeSheet = excelWB.Sheets(i)
|
|
|
|
Dim tempDT As New DataTable
|
|
|
|
Dim numOfColumns As Integer = 0
|
|
Dim columnCounter As Integer = 1
|
|
Dim columnName As String = activeSheet.Cells(1, columnCounter).Value
|
|
While columnName <> ""
|
|
tempDT.Columns.Add(columnName, GetType(String))
|
|
columnCounter = columnCounter + 1
|
|
columnName = activeSheet.Cells(1, columnCounter).Value
|
|
numOfColumns = numOfColumns + 1
|
|
End While
|
|
|
|
Dim rowCounter As Integer = 2
|
|
Dim rowValue As String = activeSheet.Cells(rowCounter, 1).Value
|
|
While rowValue <> ""
|
|
tempDT.Rows.Add()
|
|
For j = 0 To numOfColumns - 1
|
|
tempDT.Rows(tempDT.Rows.Count - 1)(j) = activeSheet.Cells(rowCounter, j + 1).Value
|
|
Next
|
|
rowCounter = rowCounter + 1
|
|
rowValue = activeSheet.Cells(rowCounter, 1).Value
|
|
End While
|
|
|
|
dataBase.Add(activeSheet.Name, tempDT)
|
|
Next
|
|
' HANTERA OLIKA LÄNGDER PÅ COLUMNER
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
' ---------------------------------- GUI interactions ----------------------------------
|
|
|
|
' --- 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)
|
|
End Sub
|
|
|
|
|
|
' --- 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 ---
|
|
Private Sub ComboBox_Width_KeyPress(sender As Object, e As KeyPressEventArgs) Handles ComboBox_Width.KeyPress
|
|
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
|
|
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
|
|
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
|
|
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 button clicked ---
|
|
Private Sub SettingsButton_Click(sender As Object, e As EventArgs) Handles SettingsButton.Click
|
|
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
|
|
SW_HLCt_Gratings.BuildGrating()
|
|
SW_Drawing_Gratings.CreateDrawing()
|
|
End Sub
|
|
|
|
End Class |