534 lines
16 KiB
VB.net
534 lines
16 KiB
VB.net
Imports XCCLibrary
|
|
|
|
Public Class temp1
|
|
'Anton was here
|
|
'So was Mehdi
|
|
'New branch
|
|
'Anton test 2
|
|
'tttest
|
|
Dim Control_ID
|
|
|
|
Sub GUI_load() Handles MyBase.Load
|
|
add_section()
|
|
|
|
Control_ID = 0
|
|
|
|
End Sub
|
|
Sub add_section()
|
|
' adding the tab page
|
|
Dim myTabPage As New TabPage
|
|
|
|
Dim TabContSec As TabControl
|
|
TabContSec = Section_gui
|
|
|
|
myTabPage.Text = "Section " & TabContSec.TabPages.Count + 1
|
|
myTabPage.Name = "Section_" & TabContSec.TabPages.Count + 1
|
|
|
|
TabContSec.TabPages.Add(myTabPage)
|
|
TabContSec.SelectedTab = myTabPage
|
|
|
|
' adding controls for section width and height
|
|
Dim Width_lbl As New Label
|
|
Width_lbl.Top = 10
|
|
Width_lbl.Left = 10
|
|
Width_lbl.Name = "Width_lb"
|
|
Width_lbl.Text = "Section Width"
|
|
myTabPage.Controls.Add(Width_lbl)
|
|
|
|
Dim Width_tbox As New TextBox
|
|
Width_tbox.Top = 10
|
|
Width_tbox.Left = 120
|
|
Width_tbox.Width = 120
|
|
Width_tbox.Name = "Width_tb"
|
|
myTabPage.Controls.Add(Width_tbox)
|
|
|
|
Dim Height_lbl As New Label
|
|
Height_lbl.Top = 35
|
|
Height_lbl.Left = 10
|
|
Height_lbl.Name = "Height_lb"
|
|
Height_lbl.Text = "Section Height"
|
|
myTabPage.Controls.Add(Height_lbl)
|
|
|
|
Dim Height_tbox As New TextBox
|
|
Height_tbox.Top = 35
|
|
Height_tbox.Left = 120
|
|
Height_tbox.Width = 120
|
|
Height_tbox.Name = "Height_tb"
|
|
myTabPage.Controls.Add(Height_tbox)
|
|
|
|
End Sub
|
|
Sub Del_section()
|
|
' Removing the tabpage
|
|
If Section_gui.TabPages.Count > 1 Then
|
|
Section_gui.TabPages.Remove(Section_gui.TabPages(Section_gui.TabPages.Count - 1))
|
|
End If
|
|
End Sub
|
|
|
|
Sub add_hanger()
|
|
'Setting an ID of the item
|
|
Control_ID += 1
|
|
|
|
' Geting the active tabpage and the location where to put the label
|
|
Dim myTabPage As TabPage
|
|
|
|
Dim TabContSec As TabControl
|
|
TabContSec = Section_gui
|
|
|
|
myTabPage = TabContSec.SelectedTab
|
|
|
|
Dim y_pos = get_latest_position(myTabPage)
|
|
|
|
y_pos = y_pos + 30
|
|
|
|
|
|
'adding the new controls
|
|
Dim Hanger_lbl As New Label
|
|
Hanger_lbl.Top = y_pos
|
|
Hanger_lbl.Left = 10
|
|
Hanger_lbl.Name = "Item_Hanger_" & Control_ID
|
|
Hanger_lbl.Text = "Hanger"
|
|
myTabPage.Controls.Add(Hanger_lbl)
|
|
|
|
Dim Pos_tbox As New TextBox
|
|
Pos_tbox.Top = y_pos
|
|
Pos_tbox.Left = 180
|
|
Pos_tbox.Width = 60
|
|
Pos_tbox.Name = "Hanger_Pos_tb_" & Control_ID
|
|
myTabPage.Controls.Add(Pos_tbox)
|
|
|
|
Dim Pos_lbl As New Label
|
|
Pos_lbl.Top = y_pos
|
|
Pos_lbl.Left = 120
|
|
Pos_lbl.Name = "Hanger_Pos_lb_" & Control_ID
|
|
Pos_lbl.Text = "Position"
|
|
myTabPage.Controls.Add(Pos_lbl)
|
|
|
|
End Sub
|
|
|
|
Sub add_hooks()
|
|
'Setting an ID of the item
|
|
Control_ID += 1
|
|
|
|
' Geting the active tabpage and the location where to put the label
|
|
Dim myTabPage As TabPage
|
|
|
|
Dim TabContSec As TabControl
|
|
TabContSec = Section_gui
|
|
|
|
myTabPage = TabContSec.SelectedTab
|
|
|
|
Dim y_pos = get_latest_position(myTabPage)
|
|
|
|
y_pos = y_pos + 30
|
|
|
|
|
|
'adding the new controls
|
|
Dim Hooks_lbl As New Label
|
|
Hooks_lbl.Top = y_pos
|
|
Hooks_lbl.Left = 10
|
|
Hooks_lbl.Name = "Item_Hooks_" & Control_ID
|
|
Hooks_lbl.Text = "Hooks"
|
|
myTabPage.Controls.Add(Hooks_lbl)
|
|
|
|
Dim Pos_tbox As New TextBox
|
|
Pos_tbox.Top = y_pos
|
|
Pos_tbox.Left = 180
|
|
Pos_tbox.Width = 60
|
|
Pos_tbox.Name = "Hooks_Pos_tb_" & Control_ID
|
|
myTabPage.Controls.Add(Pos_tbox)
|
|
|
|
Dim Pos_lbl As New Label
|
|
Pos_lbl.Top = y_pos
|
|
Pos_lbl.Left = 120
|
|
Pos_lbl.Name = "Hooks_Pos_lb_" & Control_ID
|
|
Pos_lbl.Text = "Position"
|
|
myTabPage.Controls.Add(Pos_lbl)
|
|
|
|
Dim Nr_tbox As New TextBox
|
|
Nr_tbox.Top = y_pos
|
|
Nr_tbox.Left = 320
|
|
Nr_tbox.Width = 60
|
|
Nr_tbox.Name = "Hooks_Nr_tb_" & Control_ID
|
|
myTabPage.Controls.Add(Nr_tbox)
|
|
|
|
Dim Nr_lbl As New Label
|
|
Nr_lbl.Top = y_pos
|
|
Nr_lbl.Left = 260
|
|
Nr_lbl.Name = "Hooks_Nr_lb_" & Control_ID
|
|
Nr_lbl.Text = "Quantity"
|
|
myTabPage.Controls.Add(Nr_lbl)
|
|
|
|
End Sub
|
|
|
|
Sub add_basket()
|
|
'Setting an ID of the item
|
|
Control_ID += 1
|
|
|
|
' Geting the active tabpage and the location where to put the label
|
|
Dim myTabPage As TabPage
|
|
|
|
Dim TabContSec As TabControl
|
|
TabContSec = Section_gui
|
|
|
|
myTabPage = TabContSec.SelectedTab
|
|
|
|
Dim y_pos = get_latest_position(myTabPage)
|
|
|
|
y_pos = y_pos + 30
|
|
|
|
|
|
'adding the new controls
|
|
Dim Basket_lbl As New Label
|
|
Basket_lbl.Top = y_pos
|
|
Basket_lbl.Left = 10
|
|
Basket_lbl.Name = "Item_Basket_" & Control_ID
|
|
Basket_lbl.Text = "Basket"
|
|
myTabPage.Controls.Add(Basket_lbl)
|
|
|
|
|
|
Dim Pos_tbox As New TextBox
|
|
Pos_tbox.Top = y_pos
|
|
Pos_tbox.Left = 180
|
|
Pos_tbox.Width = 60
|
|
Pos_tbox.Name = "Basket_Pos_tb_" & Control_ID
|
|
myTabPage.Controls.Add(Pos_tbox)
|
|
|
|
Dim Pos_lbl As New Label
|
|
Pos_lbl.Top = y_pos
|
|
Pos_lbl.Left = 120
|
|
Pos_lbl.Name = "Basket_Pos_lb_" & Control_ID
|
|
Pos_lbl.Text = "Position"
|
|
myTabPage.Controls.Add(Pos_lbl)
|
|
|
|
|
|
|
|
Dim Depth_tbox As New TextBox
|
|
Depth_tbox.Top = y_pos
|
|
Depth_tbox.Left = 320
|
|
Depth_tbox.Width = 60
|
|
Depth_tbox.Name = "Basket_Depth_tb_" & Control_ID
|
|
myTabPage.Controls.Add(Depth_tbox)
|
|
|
|
Dim Depth_lbl As New Label
|
|
Depth_lbl.Top = y_pos
|
|
Depth_lbl.Left = 260
|
|
Depth_lbl.Name = "Basket_Depth_lb_" & Control_ID
|
|
Depth_lbl.Text = "Depth"
|
|
myTabPage.Controls.Add(Depth_lbl)
|
|
|
|
|
|
|
|
Dim Height_cmb As New ComboBox
|
|
Height_cmb.Top = y_pos
|
|
Height_cmb.Left = 460
|
|
Height_cmb.Width = 60
|
|
Height_cmb.Name = "Basket_Height_cmb_" & Control_ID
|
|
Height_cmb.Items.Add("150")
|
|
Height_cmb.Items.Add("300")
|
|
Height_cmb.Items.Add("450")
|
|
myTabPage.Controls.Add(Height_cmb)
|
|
|
|
Dim Height_lbl As New Label
|
|
Height_lbl.Top = y_pos
|
|
Height_lbl.Left = 400
|
|
Height_lbl.Name = "Basket_Height_lb_" & Control_ID
|
|
Height_lbl.Text = "Height"
|
|
myTabPage.Controls.Add(Height_lbl)
|
|
|
|
End Sub
|
|
|
|
Sub add_shelf()
|
|
'Setting an ID of the item
|
|
Control_ID += 1
|
|
|
|
' Geting the active tabpage and the location where to put the label
|
|
Dim myTabPage As TabPage
|
|
|
|
Dim TabContSec As TabControl
|
|
TabContSec = Section_gui
|
|
|
|
myTabPage = TabContSec.SelectedTab
|
|
|
|
Dim y_pos = get_latest_position(myTabPage)
|
|
|
|
y_pos = y_pos + 30
|
|
|
|
|
|
'adding the new controls
|
|
Dim Shelf_lbl As New Label
|
|
Shelf_lbl.Top = y_pos
|
|
Shelf_lbl.Left = 10
|
|
Shelf_lbl.Name = "Item_Shelf_" & Control_ID
|
|
Shelf_lbl.Text = "Shelf"
|
|
myTabPage.Controls.Add(Shelf_lbl)
|
|
|
|
|
|
Dim Pos_tbox As New TextBox
|
|
Pos_tbox.Top = y_pos
|
|
Pos_tbox.Left = 180
|
|
Pos_tbox.Width = 60
|
|
Pos_tbox.Name = "Shelf_Pos_tb_" & Control_ID
|
|
myTabPage.Controls.Add(Pos_tbox)
|
|
|
|
Dim Pos_lbl As New Label
|
|
Pos_lbl.Top = y_pos
|
|
Pos_lbl.Left = 120
|
|
Pos_lbl.Name = "Shelf_Pos_lb_" & Control_ID
|
|
Pos_lbl.Text = "Position"
|
|
myTabPage.Controls.Add(Pos_lbl)
|
|
|
|
|
|
|
|
Dim Depth_tbox As New TextBox
|
|
Depth_tbox.Top = y_pos
|
|
Depth_tbox.Left = 320
|
|
Depth_tbox.Width = 60
|
|
Depth_tbox.Name = "Shelf_Depth_tb_" & Control_ID
|
|
myTabPage.Controls.Add(Depth_tbox)
|
|
|
|
Dim Depth_lbl As New Label
|
|
Depth_lbl.Top = y_pos
|
|
Depth_lbl.Left = 260
|
|
Depth_lbl.Name = "Shelf_Depth_lb_" & Control_ID
|
|
Depth_lbl.Text = "Depth"
|
|
myTabPage.Controls.Add(Depth_lbl)
|
|
|
|
|
|
|
|
Dim Type_cmb As New ComboBox
|
|
Type_cmb.Top = y_pos
|
|
Type_cmb.Left = 460
|
|
Type_cmb.Width = 60
|
|
Type_cmb.Name = "Shelf_type_cmb_" & Control_ID
|
|
Type_cmb.Items.Add("Flat")
|
|
Type_cmb.Items.Add("Wire")
|
|
myTabPage.Controls.Add(Type_cmb)
|
|
|
|
Dim Height_lbl As New Label
|
|
Height_lbl.Top = y_pos
|
|
Height_lbl.Left = 400
|
|
Height_lbl.Name = "Shelf_type_lb_" & Control_ID
|
|
Height_lbl.Text = "Type"
|
|
myTabPage.Controls.Add(Height_lbl)
|
|
|
|
End Sub
|
|
|
|
Sub add_drying_rack()
|
|
'Setting an ID of the item
|
|
Control_ID += 1
|
|
|
|
' Geting the active tabpage and the location where to put the label
|
|
Dim myTabPage As TabPage
|
|
|
|
Dim TabContSec As TabControl
|
|
TabContSec = Section_gui
|
|
|
|
myTabPage = TabContSec.SelectedTab
|
|
|
|
Dim y_pos = get_latest_position(myTabPage)
|
|
|
|
y_pos = y_pos + 30
|
|
|
|
|
|
'adding the new controls
|
|
Dim Drying_lbl As New Label
|
|
Drying_lbl.Top = y_pos
|
|
Drying_lbl.Left = 10
|
|
Drying_lbl.Name = "Item_Drying_" & Control_ID
|
|
Drying_lbl.Text = "Drying Rack"
|
|
myTabPage.Controls.Add(Drying_lbl)
|
|
|
|
|
|
Dim Pos_tbox As New TextBox
|
|
Pos_tbox.Top = y_pos
|
|
Pos_tbox.Left = 180
|
|
Pos_tbox.Width = 60
|
|
Pos_tbox.Name = "Drying_Pos_tb_" & Control_ID
|
|
myTabPage.Controls.Add(Pos_tbox)
|
|
|
|
Dim Pos_lbl As New Label
|
|
Pos_lbl.Top = y_pos
|
|
Pos_lbl.Left = 120
|
|
Pos_lbl.Name = "Drying_Pos_lb_" & Control_ID
|
|
Pos_lbl.Text = "Position"
|
|
myTabPage.Controls.Add(Pos_lbl)
|
|
|
|
|
|
Dim Right_cb As New CheckBox
|
|
Right_cb.Top = y_pos
|
|
Right_cb.Left = 380
|
|
Right_cb.Name = "Drying_Right_cb_" & Control_ID
|
|
Right_cb.Text = "Right"
|
|
myTabPage.Controls.Add(Right_cb)
|
|
|
|
|
|
|
|
Dim Mid_cb As New CheckBox
|
|
Mid_cb.Top = y_pos
|
|
Mid_cb.Left = 320
|
|
Mid_cb.Name = "Drying_mid_cb_" & Control_ID
|
|
Mid_cb.Text = "Mid"
|
|
myTabPage.Controls.Add(Mid_cb)
|
|
|
|
|
|
Dim Left_cb As New CheckBox
|
|
Left_cb.Top = y_pos
|
|
Left_cb.Left = 260
|
|
Left_cb.Name = "Drying_left_cb_" & Control_ID
|
|
Left_cb.Text = "Left"
|
|
myTabPage.Controls.Add(Left_cb)
|
|
End Sub
|
|
Function get_latest_position(myTabPage)
|
|
Dim Y_pos As Integer = 0
|
|
|
|
For Each ctl As Control In myTabPage.Controls
|
|
If ctl.Location.Y > Y_pos Then
|
|
Y_pos = ctl.Location.Y
|
|
End If
|
|
Next
|
|
|
|
Return Y_pos
|
|
End Function
|
|
|
|
Function Populate_table_from_GUI()
|
|
' creating a set of tables, the data in the tables will be one row per item in the GUI and one table per section tab
|
|
Dim Input As New DataSet
|
|
|
|
Dim sectionTable As New DataTable
|
|
sectionTable.Columns.Add("Section_width")
|
|
sectionTable.Columns.Add("Section_height")
|
|
sectionTable.Columns.Add("Type")
|
|
sectionTable.Columns.Add("Position")
|
|
sectionTable.Columns.Add("Depth")
|
|
sectionTable.Columns.Add("Item_Height")
|
|
sectionTable.Columns.Add("Type_of_shelf")
|
|
sectionTable.Columns.Add("Quantity")
|
|
sectionTable.Columns.Add("Right")
|
|
sectionTable.Columns.Add("Mid")
|
|
sectionTable.Columns.Add("Left")
|
|
|
|
|
|
' loop through all the tabs in the tab control and get the data
|
|
Dim TabContSec As TabControl
|
|
TabContSec = Section_gui
|
|
|
|
For i = 0 To TabContSec.TabCount - 1
|
|
sectionTable.Clear()
|
|
sectionTable.TableName = "Section_" & i + 1
|
|
|
|
Dim MyTabPage = TabContSec.TabPages(i)
|
|
TabContSec.SelectedTab = MyTabPage
|
|
|
|
' Geting the data of the section
|
|
Dim section_width = MyTabPage.Controls("Width_tb").Text
|
|
Dim section_height = MyTabPage.Controls("Height_tb").Text
|
|
|
|
For Each c As Control In MyTabPage.Controls
|
|
|
|
' using the name of the Item label to get the Item ID and type
|
|
If c.Name.Contains("Item") Then
|
|
Dim Splitname = c.Name.Split("_")
|
|
Dim Item_Type = Splitname(1)
|
|
Dim Item_ID = Splitname(2)
|
|
|
|
Dim ItemRowNr As Integer
|
|
|
|
' adding a new row for the new item and start populating relevent colums with info from the GUI
|
|
sectionTable.Rows.Add()
|
|
ItemRowNr = sectionTable.Rows.Count - 1
|
|
sectionTable.Rows(ItemRowNr)("Section_width") = section_width
|
|
sectionTable.Rows(ItemRowNr)("Section_height") = section_height
|
|
|
|
sectionTable.Rows(ItemRowNr)("Type") = Item_Type
|
|
|
|
If Item_Type = "Basket" Then
|
|
sectionTable.Rows(ItemRowNr)("Position") = MyTabPage.Controls("Basket_Pos_tb_" & Item_ID).Text
|
|
sectionTable.Rows(ItemRowNr)("Depth") = MyTabPage.Controls("Basket_Depth_tb_" & Item_ID).Text
|
|
sectionTable.Rows(ItemRowNr)("Item_Height") = MyTabPage.Controls("Basket_Height_cmb_" & Item_ID).Text
|
|
|
|
ElseIf Item_Type = "Hanger" Then
|
|
sectionTable.Rows(ItemRowNr)("Position") = MyTabPage.Controls("Hanger_Pos_tb_" & Item_ID).Text
|
|
|
|
ElseIf Item_Type = "Hooks" Then
|
|
sectionTable.Rows(ItemRowNr)("Position") = MyTabPage.Controls("Hooks_Pos_tb_" & Item_ID).Text
|
|
sectionTable.Rows(ItemRowNr)("Quantity") = MyTabPage.Controls("Hooks_Nr_tb_" & Item_ID).Text
|
|
|
|
ElseIf Item_Type = "Drying" Then
|
|
sectionTable.Rows(ItemRowNr)("Position") = MyTabPage.Controls("Drying_Pos_tb_" & Item_ID).Text
|
|
Dim CB As CheckBox
|
|
|
|
CB = MyTabPage.Controls("Drying_Right_cb_" & Item_ID)
|
|
sectionTable.Rows(ItemRowNr)("Right") = CB.Checked
|
|
|
|
CB = MyTabPage.Controls("Drying_mid_cb_" & Item_ID)
|
|
sectionTable.Rows(ItemRowNr)("Mid") = CB.Checked
|
|
|
|
CB = MyTabPage.Controls("Drying_left_cb_" & Item_ID)
|
|
sectionTable.Rows(ItemRowNr)("Left") = CB.Checked
|
|
|
|
ElseIf Item_Type = "Shelf" Then
|
|
sectionTable.Rows(ItemRowNr)("Position") = MyTabPage.Controls("Shelf_Pos_tb_" & Item_ID).Text
|
|
sectionTable.Rows(ItemRowNr)("Depth") = MyTabPage.Controls("Shelf_Depth_tb_" & Item_ID).Text
|
|
sectionTable.Rows(ItemRowNr)("Type_of_shelf") = MyTabPage.Controls("Shelf_type_cmb_" & Item_ID).Text
|
|
End If
|
|
|
|
End If
|
|
Next
|
|
Input.Tables.Add(sectionTable.Copy)
|
|
Next
|
|
|
|
Return Input
|
|
End Function
|
|
|
|
Private Sub Rail_btn_Click(sender As Object, e As EventArgs) Handles Rail_btn.Click
|
|
add_section()
|
|
End Sub
|
|
|
|
Private Sub Del_rail_btn_Click(sender As Object, e As EventArgs) Handles Del_rail_btn.Click
|
|
Del_section()
|
|
End Sub
|
|
|
|
Private Sub Hanger_btn_Click(sender As Object, e As EventArgs) Handles Hanger_btn.Click
|
|
add_hanger()
|
|
End Sub
|
|
|
|
Private Sub Hooks_btn_Click(sender As Object, e As EventArgs) Handles Hooks_btn.Click
|
|
add_hooks()
|
|
End Sub
|
|
|
|
Private Sub Basket_btn_Click(sender As Object, e As EventArgs) Handles Basket_btn.Click
|
|
add_basket()
|
|
End Sub
|
|
|
|
Private Sub Shelf_btn_Click(sender As Object, e As EventArgs) Handles Shelf_btn.Click
|
|
add_shelf()
|
|
End Sub
|
|
|
|
Private Sub Drying_btn_Click(sender As Object, e As EventArgs) Handles Drying_btn.Click
|
|
add_drying_rack()
|
|
End Sub
|
|
|
|
Private Sub Build_btn_Click(sender As Object, e As EventArgs) Handles Build_btn.Click
|
|
|
|
adminClass.loadSettings("C:\Users\Asus_station3\Desktop", "D:\OneDrive - XperDi AB\XperDi\DLL_Test\Wardrobe", "SolidWorks")
|
|
XCCBaseClass.newDesign()
|
|
'comment test
|
|
ExternalClass.PopulateTamplateXMLGroup()
|
|
Dim Input As DataSet
|
|
Input = Populate_table_from_GUI()
|
|
|
|
Program.Add_Parts(Input)
|
|
|
|
importClass.copyGroupsByDataSet(ExternalClass.groupds_new)
|
|
Dim GrNr = groupClass.NewGroupID
|
|
Dim Design_table = designModel.selectDesign("*")
|
|
Dim Design_name = Design_table.rows(0)("designName") '"135_0922244" 'CADLinkerClass.New_Design_Name '
|
|
groupClass.InstantiateGroup(Design_name, GrNr, "START")
|
|
|
|
'
|
|
End Sub
|
|
|
|
Private Sub Update_KB_Click(sender As Object, e As EventArgs) Handles Update_KB.Click
|
|
Program.UpdateKB()
|
|
End Sub
|
|
End Class |