Imports EgtUILib Public Class CompoDimensionUC ' Constants Private Const NUM_VAR As Integer = 10 'Riferimento alla MainWindow Private m_MainWindow As MainWindow = DirectCast(Application.Current.MainWindow, MainWindow) ' Riferimento alla pagina Draw Private m_DrawPage As DrawPageUC ' Riferimento alla pagina di selezione dei componenti interni Friend m_InternalCompoPage As InternalComponentPageUC ' Riferimento alla pagina di selezione della alzatine Friend m_AlzFrontPage As AlzFrontUC ' solo se è configurato il direttorio della componente allora mostro il bottone Friend bEnableAlzFront As Boolean = False Private Sub CompoDimensionUC_Initialized(sender As Object, e As EventArgs) Handles Me.Initialized 'Creazione delle Page UserControl (per le componenti interne) m_InternalCompoPage = New InternalComponentPageUC 'Posizionemento nella griglia delle Page UserControl m_InternalCompoPage.SetValue(Grid.ColumnSpanProperty, 2) m_InternalCompoPage.SetValue(Grid.RowSpanProperty, 4) 'Creazione della Page UserControl (per le alzatine e i frontalini) m_AlzFrontPage = New AlzFrontUC 'Posizionamento nella griglia della Page UserControl m_AlzFrontPage.SetValue(Grid.ColumnSpanProperty, 2) m_AlzFrontPage.SetValue(Grid.RowSpanProperty, 4) Dim sCompoDir As String = String.Empty GetPrivateProfileString(S_ALZFRONT, K_COMPODIR, "", sCompoDir, m_MainWindow.GetIniFile()) ' definisco il nome dei comandi presenti nella pagine InternComponentBtn.Content = EgtMsg(MSG_COMPONENTPAGEUC + 47) ' Componenti interni If Not String.IsNullOrEmpty(sCompoDir) Then bEnableAlzFront = True AlzFrontBtn.Content = EgtMsg(91137) Else AlzFrontBtn.Visibility = Visibility.Collapsed End If AddBtn.Content = EgtMsg(MSG_COMPONENTPAGEUC + 48) ' Aggiungi CancelBtn.Content = EgtMsg(MSG_COMPONENTPAGEUC + 49) ' Rimuovi End Sub Private Sub CompoDimensionUC_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded ' Riferimento alla drawPage m_DrawPage = m_MainWindow.m_DrawPageUC ' Imposto questa come pagina correntemente visualizzata nella drawpage m_DrawPage.m_ActiveComponentPage = DrawPageUC.Pages.CompoDimension ' se arrivo dalla pagina delle componenti interne allora esco (non devo ricalcolare i parametri) If m_DrawPage.m_bBackFromInternalCompo Then ShowInternalBtn(True) ShowAlzFrontBtn(bEnableAlzFront) ' Se componente interno visualizzo bottoni aggiungi rimuovi ShowAddRemoveBtn(m_DrawPage.m_bInternalCompo) ' Imposto contesto corrente e faccio uno ZoomAll della scena con il componente EgtSetCurrentContext(m_MainWindow.m_DrawPageUC.DrawScene.GetCtx()) EgtZoom(ZM.ALL) ' termino il caricamento della pagina Return End If ' Se componente interno disabilito il bottone di ok della drawpage If m_DrawPage.m_bInternalCompo Then m_DrawPage.OkBtn.IsEnabled = False End If ' se componenti con buchi interni visualizzo bottoni appositi If m_DrawPage.sCompoName.StartsWith("PCucina") Or m_DrawPage.sCompoName.StartsWith("PBagno") Then ShowInternalBtn(True) ShowAlzFrontBtn(bEnableAlzFront) m_DrawPage.MessageGrid.Visibility = Visibility.Hidden Else ShowInternalBtn(False) ShowAlzFrontBtn(False) End If ' Se componente interno visualizzo bottoni aggiungi rimuovi ShowAddRemoveBtn(m_DrawPage.m_bInternalCompo) ' Imposto contesto corrente e faccio uno ZoomAll della scena con il componente EgtSetCurrentContext(m_MainWindow.m_DrawPageUC.DrawScene.GetCtx()) EgtZoom(ZM.ALL) End Sub Private Sub CompoDimensionUC_Unloaded(sender As Object, e As RoutedEventArgs) Handles Me.Unloaded m_DrawPage.OkBtn.IsEnabled = True End Sub ' rende visibile il bottone per inserire le componenti interne: solo nella pagine delle componenti Friend Sub ShowInternalBtn(value As Boolean) If value Then InternComponentBtn.Visibility = Windows.Visibility.Visible Else InternComponentBtn.Visibility = Windows.Visibility.Hidden End If End Sub ' rende visibile il bottone per inserire le azatine e i frontalini: solo nella pagina delle componenti Friend Sub ShowAlzFrontBtn(ByVal value As Boolean) If value Then AlzFrontBtn.Visibility = Visibility.Visible m_MainWindow.m_DrawPageUC.MessageGrid.Visibility = Visibility.Hidden Else AlzFrontBtn.Visibility = Visibility.Hidden m_MainWindow.m_DrawPageUC.MessageGrid.Visibility = Visibility.Visible End If End Sub ' definisce se rendere visbile oppure no i bottone "Aggiungi" e "Rimuovi": presenti solo nella componenti interne Friend Sub ShowAddRemoveBtn(value As Boolean) If value Then m_DrawPage.SideAngleBtn.IsEnabled = False m_DrawPage.FiloTopBtn.IsEnabled = False m_DrawPage.EngraveBtn.IsEnabled = False m_DrawPage.DripCutBtn.IsEnabled = False m_DrawPage.BackBtn.Visibility = Windows.Visibility.Hidden AddBtn.Visibility = Windows.Visibility.Visible CancelBtn.Visibility = Windows.Visibility.Visible Else m_DrawPage.SideAngleBtn.IsEnabled = m_MainWindow.m_DrawPageUC.bEnableSideAngle m_DrawPage.FiloTopBtn.IsEnabled = m_MainWindow.m_CurrentMachine.bMilling m_DrawPage.EngraveBtn.IsEnabled = True m_DrawPage.DripCutBtn.IsEnabled = m_MainWindow.GetKeyOption(MainWindow.KEY_OPT.UNDER_CUT) And Not String.IsNullOrWhiteSpace(m_MainWindow.m_CurrentMachine.sCurrDripSaw) m_DrawPage.BackBtn.Visibility = Windows.Visibility.Visible AddBtn.Visibility = Windows.Visibility.Hidden CancelBtn.Visibility = Windows.Visibility.Hidden End If End Sub Friend Function GetNameEdit(ByVal nInd As Integer) As TextBlock Select Case nInd Case 1 Return Label1 Case 2 Return Label2 Case 3 Return Label3 Case 4 Return Label4 Case 5 Return Label5 Case 6 Return Label6 Case 7 Return Label7 Case 8 Return Label8 Case 9 Return Label9 Case Else Return Label10 End Select End Function Friend Function GetValueEdit(ByVal nInd As Integer) As TextBox Select Case nInd Case 1 Return TextBox1 Case 2 Return TextBox2 Case 3 Return TextBox3 Case 4 Return TextBox4 Case 5 Return TextBox5 Case 6 Return TextBox6 Case 7 Return TextBox7 Case 8 Return TextBox8 Case 9 Return TextBox9 Case Else Return TextBox10 End Select End Function Private Sub EgtTextBox_EgtOpening(sender As Object, e As RoutedEventArgs) Handles TextBox6.EgtOpening, TextBox7.EgtOpening, TextBox8.EgtOpening, TextBox9.EgtOpening, TextBox10.EgtOpening Dim SelectedTextBox As TextBox = DirectCast(e.Source, TextBox) Select Case SelectedTextBox.Name Case "TextBox6" ' Indice variabile associata al bottone Dim nI As Integer = m_DrawPage.GetDefinedVarCount() - (NUM_VAR - 6) - 1 ' Recupero tipo della variabile associata If m_DrawPage.GetParamType(nI) = 1 Then TextBox6.IsReadOnly = True If TextBox6.Text = "False" Then TextBox6.Text = "True" Else TextBox6.Text = "False" End If TextBox6.ActivateCalculator = False m_DrawPage.UpdateView() Else TextBox6.ActivateCalculator = True TextBox6.IsReadOnly = False End If Case "TextBox7" ' Indice variabile associata al bottone Dim nI As Integer = m_DrawPage.GetDefinedVarCount() - (NUM_VAR - 7) - 1 ' Recupero tipo della variabile associata If m_DrawPage.GetParamType(nI) = 1 Then TextBox7.IsReadOnly = True If TextBox7.Text = "False" Then TextBox7.Text = "True" Else TextBox7.Text = "False" End If TextBox7.ActivateCalculator = False m_DrawPage.UpdateView() Else TextBox7.ActivateCalculator = True TextBox7.IsReadOnly = False End If Case "TextBox8" ' Indice variabile associata al bottone Dim nI As Integer = m_DrawPage.GetDefinedVarCount() - (NUM_VAR - 8) - 1 ' Recupero tipo della variabile associata If m_DrawPage.GetParamType(nI) = 1 Then TextBox8.IsReadOnly = True If TextBox8.Text = "False" Then TextBox8.Text = "True" Else TextBox8.Text = "False" End If TextBox8.ActivateCalculator = False m_DrawPage.UpdateView() Else TextBox8.ActivateCalculator = True TextBox8.IsReadOnly = False End If Case "TextBox9" ' Indice variabile associata al bottone Dim nI As Integer = m_DrawPage.GetDefinedVarCount() - (NUM_VAR - 9) - 1 ' Recupero tipo della variabile associata If m_DrawPage.GetParamType(nI) = 1 Then TextBox9.IsReadOnly = True If TextBox9.Text = "False" Then TextBox9.Text = "True" Else TextBox9.Text = "False" End If TextBox9.ActivateCalculator = False m_DrawPage.UpdateView() Else TextBox9.ActivateCalculator = True TextBox9.IsReadOnly = False End If Case "TextBox10" ' Indice variabile associata al bottone Dim nI As Integer = m_DrawPage.GetDefinedVarCount() - (NUM_VAR - 10) - 1 ' Recupero tipo della variabile associata If m_DrawPage.GetParamType(nI) = 1 Then TextBox10.IsReadOnly = True If TextBox10.Text = "False" Then TextBox10.Text = "True" Else TextBox10.Text = "False" End If TextBox10.ActivateCalculator = False m_DrawPage.UpdateView() Else TextBox10.ActivateCalculator = True TextBox10.IsReadOnly = False End If End Select End Sub Private Sub EgtCalculator_EgtClosed(sender As Object, e As EventArgs) Handles TextBox1.EgtClosed, TextBox2.EgtClosed, TextBox3.EgtClosed, TextBox4.EgtClosed, TextBox5.EgtClosed, TextBox6.EgtClosed, TextBox7.EgtClosed, TextBox8.EgtClosed, TextBox9.EgtClosed, TextBox10.EgtClosed m_DrawPage.UpdateView() End Sub Public Sub CollapsedAllParam() For i As Integer = 1 To NUM_VAR GetNameEdit(i).Visibility = Visibility.Collapsed GetValueEdit(i).Visibility = Visibility.Collapsed Next End Sub #Region "METHODS for InternalCompo" ' visualizzo la pagina per la selezione delle componenti interne Private Sub InternComponentBtn_Click(sender As Object, e As RoutedEventArgs) Handles InternComponentBtn.Click m_DrawPage.m_bBackFromInternalCompo = False ' imposto contesto EgtSetCurrentContext(m_DrawPage.DrawScene.GetCtx()) ' Nascondo layer etichette e quotature Dim Pz As Integer = EgtGetFirstGroupInGroup(GDB_ID.ROOT) EgtSetStatus(EgtGetFirstNameInGroup(Pz, "LayAux"), GDB_ST.OFF) EgtSetStatus(EgtGetFirstNameInGroup(Pz, "Etichette"), GDB_ST.OFF) EgtSetStatus(EgtGetFirstNameInGroup(Pz, "Quotature"), GDB_ST.OFF) EgtDraw() m_DrawPage.VariablesGrd.Children.Remove(Me) m_DrawPage.m_bInternalCompo = True m_DrawPage.LeftButtonGrd.Children.Add(m_InternalCompoPage) End Sub ' visualizzo la pagina per la selezione delle componenti interne Private Sub AlzFrontBtn_Click(sender As Object, e As RoutedEventArgs) Handles AlzFrontBtn.Click m_DrawPage.m_bBackFromInternalCompo = False ' imposto contesto EgtSetCurrentContext(m_DrawPage.DrawScene.GetCtx()) ' Nascondo layer etichette e quotature Dim Pz As Integer = EgtGetFirstGroupInGroup(GDB_ID.ROOT) EgtSetStatus(EgtGetFirstNameInGroup(Pz, "LayAux"), GDB_ST.OFF) EgtSetStatus(EgtGetFirstNameInGroup(Pz, "Etichette"), GDB_ST.OFF) EgtSetStatus(EgtGetFirstNameInGroup(Pz, "Quotature"), GDB_ST.OFF) EgtDraw() m_DrawPage.VariablesGrd.Children.Remove(Me) m_DrawPage.m_bInternalCompo = True m_DrawPage.LeftButtonGrd.Children.Add(m_AlzFrontPage) End Sub ' Bottone utilizzato per inserire le componenti interne Private Sub AddBtn_Click(sender As Object, e As RoutedEventArgs) Handles AddBtn.Click ' Se componente errato, non faccio alcunché If Not m_DrawPage.m_bDrawOk Then Return ' Recupero indice componente corrente Dim nCmp As Integer = 0 If EgtLuaGetGlobIntVar(DrawPageUC.LUA_CMP_INDEX, nCmp) And nCmp > 0 Then ' Nascondo eventuali etichette del componente Dim nId As Integer = EgtGetFirstNameInGroup(EgtGetFirstGroupInGroup(GDB_ID.ROOT), "HoleLabels") While nId <> GDB_ID.NULL Dim nCmpInfo As Integer = 0 If EgtGetInfo(nId, "ID", nCmpInfo) AndAlso nCmp = nCmpInfo Then EgtSetStatus(nId, GDB_ST.OFF) UpdateInLoopReference(nCmp) Exit While End If nId = EgtGetNextName(nId, "HoleLabels") End While End If ' Esco dalla pagina ExitInternalVariable() End Sub ' annulla l'inserimento della componente corrente Private Sub CancelBtn_Click(sender As Object, e As RoutedEventArgs) Handles CancelBtn.Click ' Cancello layer con contorno errato Dim nId As Integer = EgtGetFirstNameInGroup(EgtGetFirstGroupInGroup(GDB_ID.ROOT), "ErrorLay") EgtErase(nId) ' Se trovo componente corrente, lo cancello Dim nCmp As Integer = 0 If EgtLuaGetGlobIntVar(DrawPageUC.LUA_CMP_INDEX, nCmp) And nCmp > 0 Then Dim sCmp As String = nCmp.ToString() ' Lancio cancellazione If Not EgtLuaExecLine(DrawPageUC.LUA_REMOVEHOLE & "(" & nCmp & ")") Then EgtOutLog("Error in RemoveHole execution") Return End If ' altrimenti è errato ed è già stato cancellato, resetto errore di disegno Else m_DrawPage.m_bDrawOk = True End If ' Esco dalla pagina ExitInternalVariable() End Sub ' Esco dalla pagine delle variabili della componente interna: reimposto la pagina della componenti interne Private Sub ExitInternalVariable() ' Esco dalla pagina m_DrawPage.VariablesGrd.Children.Remove(Me) m_DrawPage.LeftButtonGrd.Children.Add(m_InternalCompoPage) ' Reset componente m_MainWindow.m_DrawPageUC.ResetCompoName() ' Deseleziono oggetto corrente e aggiorno visualizzazione EgtDeselectAll() EgtDraw() End Sub Private Sub UpdateInLoopReference(nCmp As Integer) ' aggiorno il layer "FiloTop" Dim nIdInLoop As Integer = EgtGetFirstNameInGroup(EgtGetFirstGroupInGroup(GDB_ID.ROOT), "InLoop") While nIdInLoop <> GDB_ID.NULL Dim nCmpInfoIL As Integer = 0 If EgtGetInfo(nIdInLoop, "ID", nCmpInfoIL) AndAlso nCmp = nCmpInfoIL Then Dim nLayFiloTop As Integer = GDB_ID.NULL EgtGetInfo(nIdInLoop, "FiloTopRef", nLayFiloTop) If nLayFiloTop <> GDB_ID.NULL Then Dim LocalList As New List(Of Integer) From {nIdInLoop} m_DrawPage.m_FiloTopUC.CreateFiloTopPreView(LocalList) EgtSetStatus(nLayFiloTop, GDB_ST.ON_) Exit While End If End If nIdInLoop = EgtGetNextName(nIdInLoop, "InLoop") End While End Sub ' riceve la info "ID" della componente Public Sub SetStatusVisibilityInLoopReference(nCmp As Integer, Status As GDB_ST) ' aggiorno il layer "FiloTop" Dim nIdInLoop As Integer = EgtGetFirstNameInGroup(EgtGetFirstGroupInGroup(GDB_ID.ROOT), "InLoop") While nIdInLoop <> GDB_ID.NULL Dim nCmpInfoIL As Integer = 0 If EgtGetInfo(nIdInLoop, "ID", nCmpInfoIL) AndAlso nCmp = nCmpInfoIL Then Dim nLayFiloTop As Integer = GDB_ID.NULL EgtGetInfo(nIdInLoop, "FiloTopRef", nLayFiloTop) If nLayFiloTop <> GDB_ID.NULL Then EgtSetStatus(nLayFiloTop, Status) Exit While End If End If nIdInLoop = EgtGetNextName(nIdInLoop, "InLoop") End While End Sub #End Region ' METHODS for InternalCompo End Class