76bbaba786
- migliorie a Fast Grid.
234 lines
9.1 KiB
VB.net
234 lines
9.1 KiB
VB.net
Imports EgtUILib
|
|
|
|
Public Class FastGridSlabManager
|
|
|
|
' Riferimento alla MainWindow
|
|
Private m_MainWindow As MainWindow = DirectCast(Application.Current.MainWindow, MainWindow)
|
|
|
|
' Flag prima apertura
|
|
Private m_bFirst As Boolean = True
|
|
' Dati ordine
|
|
Private m_nCurrSlab As Integer = 0
|
|
Private m_nPieceType As Integer = 0
|
|
Private m_PieceDimensionsX(4) As Integer
|
|
Private m_PieceDimensionsY(4) As Integer
|
|
Private m_sCompoDir As String = String.Empty
|
|
|
|
Private Sub FastGridSlabManager_Initialized(sender As Object, e As EventArgs) Handles Me.Initialized
|
|
' Imposto i messaggi letti dal file dei messaggi
|
|
OrderTxBl.Text = EgtMsg(MSG_FASTGRIDPAGEUC) 'Order name - Nome ordine
|
|
CurrSlabTxBl.Text = EgtMsg(MSG_FASTGRIDPAGEUC + 1) 'Curr slab - Lastra corrente
|
|
PieceTypeGpBx.Header = EgtMsg(MSG_FASTGRIDPAGEUC + 3) 'Piece type - Tipo pezzo
|
|
ConfirmOrderBtn.Content = EgtMsg(MSG_FASTGRIDPAGEUC + 5) 'Confirm order - Conferma ordine
|
|
InsertPiecesBtn.Content = EgtMsg(MSG_FASTGRIDPAGEUC + 4) 'Insert pieces - Inserisci pezzi
|
|
LastSlabBtn.Content = EgtMsg(MSG_FASTGRIDPAGEUC + 2) 'Last slab - Ultima lastra
|
|
' Leggo dati da ini
|
|
GetPrivateProfileString(S_FASTGRID, K_FG_ORDER, "", OrderTxBx.Text, m_MainWindow.GetIniFile())
|
|
m_nCurrSlab = GetPrivateProfileInt(S_FASTGRID, K_FG_CURRSLAB, 0, m_MainWindow.GetIniFile())
|
|
m_nPieceType = GetPrivateProfileInt(S_FASTGRID, K_FG_PIECETYPE, 0, m_MainWindow.GetIniFile())
|
|
End Sub
|
|
|
|
Private Sub FastGridSlabManager_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
|
|
' Se prima esecuzione
|
|
If m_bFirst Then
|
|
' Leggo direttorio componenti
|
|
GetPrivateProfileString(S_COMPO, K_COMPODIR, "", m_sCompoDir, m_MainWindow.GetIniFile())
|
|
m_bFirst = False
|
|
End If
|
|
' recupero dimensioni del grezzo e kerf
|
|
m_MainWindow.m_CadCutPageUC.m_NestPage.LoadParams()
|
|
' Recupero dimensioni pezzi da ini
|
|
For Index = 1 To 5
|
|
GetPieceDimensions(Index)
|
|
Next
|
|
' Ne imposto i valori
|
|
CurrSlabTxBx.Text = m_nCurrSlab
|
|
Type1Btn.IsChecked = False
|
|
Type2Btn.IsChecked = False
|
|
Type3Btn.IsChecked = False
|
|
Type4Btn.IsChecked = False
|
|
Type5Btn.IsChecked = False
|
|
Select Case m_nPieceType
|
|
Case 1
|
|
Type1Btn.IsChecked = True
|
|
Case 2
|
|
Type2Btn.IsChecked = True
|
|
Case 3
|
|
Type3Btn.IsChecked = True
|
|
Case 4
|
|
Type4Btn.IsChecked = True
|
|
Case 5
|
|
Type5Btn.IsChecked = True
|
|
End Select
|
|
' Verifico se c'e' un ordine in corso
|
|
CurrSlabTxBx.IsEnabled = False
|
|
If m_nCurrSlab > 0 Then
|
|
OrderTxBx.IsEnabled = False
|
|
PieceTypeGpBx.IsEnabled = False
|
|
ConfirmOrderBtn.IsEnabled = False
|
|
InsertPiecesBtn.IsEnabled = True
|
|
LastSlabBtn.IsEnabled = True
|
|
Else
|
|
OrderTxBx.IsEnabled = True
|
|
PieceTypeGpBx.IsEnabled = True
|
|
ConfirmOrderBtn.IsEnabled = True
|
|
InsertPiecesBtn.IsEnabled = False
|
|
LastSlabBtn.IsEnabled = False
|
|
End If
|
|
EgtZoom(ZM.ALL)
|
|
End Sub
|
|
|
|
Private Sub InsertPiecesBtn_Click(sender As Object, e As RoutedEventArgs) Handles InsertPiecesBtn.Click
|
|
m_MainWindow.m_CurrentProjectPageUC.SetProjectOrder(OrderTxBx.Text)
|
|
' Lancio l'inserimento dei pezzi
|
|
ExecInsert()
|
|
' Aggiorno visualizzazione
|
|
EgtZoom(ZM.ALL)
|
|
End Sub
|
|
|
|
Private Sub LastSlabBtn_Click(sender As Object, e As RoutedEventArgs) Handles LastSlabBtn.Click
|
|
CheckLastSlab()
|
|
End Sub
|
|
|
|
Friend Sub CheckLastSlab()
|
|
If LastSlabBtn.IsChecked Then
|
|
m_MainWindow.m_CurrentProjectPageUC.SetLastSlab(True)
|
|
Else
|
|
m_MainWindow.m_CurrentProjectPageUC.SetLastSlab(False)
|
|
End If
|
|
End Sub
|
|
|
|
Private Function ExecInsert() As Boolean
|
|
' Carico lua per creare rettangoli
|
|
Dim sLuaPath = m_sCompoDir & "\Rettangolo.lua"
|
|
If Not EgtLuaExecFile(sLuaPath) Then Return False
|
|
' Inserisco nel gruppo un nuovo componente per ogni pezzo da inserire
|
|
For i As Integer = 1 To 100
|
|
EgtLuaSetGlobNumVar("CMP.V1", m_PieceDimensionsX(m_nPieceType - 1))
|
|
EgtLuaSetGlobNumVar("CMP.V2", m_PieceDimensionsY(m_nPieceType - 1))
|
|
' Esecuzione componente
|
|
If Not EgtLuaExecLine("CMP_Draw(false)") Then Continue For
|
|
' Recupero Id del nuovo componente
|
|
Dim nId As Integer = EgtGetLastPart()
|
|
If nId = GDB_ID.NULL Then Continue For
|
|
' Muovo la regione in Z per evitare problemi in visualizzazione
|
|
Dim nRegId = EgtGetFirstNameInGroup(nId, NAME_REGION)
|
|
EgtMove(nRegId, New Vector3d(0, 0, DELTAZ_REG), GDB_RT.GLOB)
|
|
' Aggiusto per lavorazioni
|
|
AdjustFlatPart(nId)
|
|
' Provo ad inserirlo
|
|
If Not m_MainWindow.m_CadCutPageUC.m_NestPage.InsertOnePart(nId) Then
|
|
EgtErase( nId)
|
|
Exit For
|
|
End If
|
|
Next
|
|
EgtLuaResetGlobVar("CMP")
|
|
EgtLuaResetGlobVar("CMP_Draw")
|
|
Return True
|
|
End Function
|
|
|
|
Private Sub OrderTxBx_EgtClosed(sender As Object, e As EventArgs) Handles OrderTxBx.EgtClosed
|
|
WritePrivateProfileString(S_FASTGRID, K_FG_ORDER, OrderTxBx.Text, m_MainWindow.GetIniFile())
|
|
End Sub
|
|
|
|
Private Sub PiecesTypeBtn_Click(sender As Object, e As RoutedEventArgs) Handles Type1Btn.Click, Type2Btn.Click, Type3Btn.Click, Type4Btn.Click, Type5Btn.Click
|
|
If sender Is Type1Btn Then
|
|
m_nPieceType = 1
|
|
Type1Btn.IsChecked = True
|
|
Type2Btn.IsChecked = False
|
|
Type3Btn.IsChecked = False
|
|
Type4Btn.IsChecked = False
|
|
Type5Btn.IsChecked = False
|
|
ElseIf sender Is Type2Btn Then
|
|
m_nPieceType = 2
|
|
Type1Btn.IsChecked = False
|
|
Type2Btn.IsChecked = True
|
|
Type3Btn.IsChecked = False
|
|
Type4Btn.IsChecked = False
|
|
Type5Btn.IsChecked = False
|
|
ElseIf sender Is Type3Btn Then
|
|
m_nPieceType = 3
|
|
Type1Btn.IsChecked = False
|
|
Type2Btn.IsChecked = False
|
|
Type3Btn.IsChecked = True
|
|
Type4Btn.IsChecked = False
|
|
Type5Btn.IsChecked = False
|
|
ElseIf sender Is Type4Btn Then
|
|
m_nPieceType = 4
|
|
Type1Btn.IsChecked = False
|
|
Type2Btn.IsChecked = False
|
|
Type3Btn.IsChecked = False
|
|
Type4Btn.IsChecked = True
|
|
Type5Btn.IsChecked = False
|
|
ElseIf sender Is Type5Btn Then
|
|
m_nPieceType = 5
|
|
Type1Btn.IsChecked = False
|
|
Type2Btn.IsChecked = False
|
|
Type3Btn.IsChecked = False
|
|
Type4Btn.IsChecked = False
|
|
Type5Btn.IsChecked = True
|
|
Else
|
|
Return
|
|
End If
|
|
WritePrivateProfileString(S_FASTGRID, K_FG_PIECETYPE, m_nPieceType, m_MainWindow.GetIniFile())
|
|
End Sub
|
|
|
|
Private Sub ConfirmOrderBtn_Click(sender As Object, e As RoutedEventArgs) Handles ConfirmOrderBtn.Click
|
|
If Not String.IsNullOrEmpty(OrderTxBx.Text) And m_nPieceType > 0 And m_nPieceType <= 5 Then
|
|
m_nCurrSlab = 1
|
|
CurrSlabTxBx.Text = 1
|
|
WritePrivateProfileString(S_FASTGRID, K_FG_CURRSLAB, m_nCurrSlab, m_MainWindow.GetIniFile())
|
|
OrderTxBx.IsEnabled = False
|
|
PieceTypeGpBx.IsEnabled = False
|
|
ConfirmOrderBtn.IsEnabled = False
|
|
InsertPiecesBtn.IsEnabled = True
|
|
LastSlabBtn.IsEnabled = True
|
|
Else
|
|
' segnalare che i dati ordine non sono accettabili
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub GetPieceDimensions(Index As Integer)
|
|
Dim DimensionString As String = ""
|
|
GetPrivateProfileString(S_FASTGRID, Index, "", DimensionString, m_MainWindow.GetIniFile())
|
|
Dim DimensionSplit() As String = DimensionString.Split(","c)
|
|
If DimensionSplit.Count = 3 Then
|
|
m_PieceDimensionsX(Index - 1) = DimensionSplit(0)
|
|
m_PieceDimensionsY(Index - 1) = DimensionSplit(1)
|
|
Select Case Index
|
|
Case 1
|
|
Type1Btn.Content = DimensionSplit(2)
|
|
Case 2
|
|
Type2Btn.Content = DimensionSplit(2)
|
|
Case 3
|
|
Type3Btn.Content = DimensionSplit(2)
|
|
Case 4
|
|
Type4Btn.Content = DimensionSplit(2)
|
|
Case 5
|
|
Type5Btn.Content = DimensionSplit(2)
|
|
End Select
|
|
End If
|
|
End Sub
|
|
|
|
Friend Sub CurrSlabIncrement()
|
|
' verifico se è attiva l'opzione ultima lastra
|
|
If LastSlabBtn.IsChecked Then
|
|
' l'ordine è finito
|
|
m_nCurrSlab = 0
|
|
OrderTxBx.Text = ""
|
|
OrderTxBx.IsEnabled = True
|
|
PieceTypeGpBx.IsEnabled = True
|
|
ConfirmOrderBtn.IsEnabled = True
|
|
InsertPiecesBtn.IsEnabled = False
|
|
LastSlabBtn.IsEnabled = False
|
|
Else
|
|
' incremento il contatore lastra
|
|
m_nCurrSlab += 1
|
|
WritePrivateProfileString(S_FASTGRID, K_FG_CURRSLAB, m_nCurrSlab, m_MainWindow.GetIniFile())
|
|
End If
|
|
CurrSlabTxBx.Text = m_nCurrSlab
|
|
End Sub
|
|
|
|
End Class
|