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 Private Sub CompoDimensionUC_Initialized(sender As Object, e As EventArgs) Handles Me.Initialized 'Creazione delle Page UserControl m_InternalCompoPage = New InternalComponentPageUC 'Posizionemento nella griglia delle Page UserControl m_InternalCompoPage.SetValue(Grid.ColumnSpanProperty, 2) m_InternalCompoPage.SetValue(Grid.RowSpanProperty, 4) InternComponentBtn.Content = EgtMsg(MSG_COMPONENTPAGEUC + 47) ' Componenti interni 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 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) Else ShowInternalBtn(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 Friend Sub ShowInternalBtn(value As Boolean) If value Then InternComponentBtn.Visibility = Windows.Visibility.Visible Else InternComponentBtn.Visibility = Windows.Visibility.Hidden End If End Sub Friend Sub ShowAddRemoveBtn(value As Boolean) If value Then m_DrawPage.SideAngleBtn.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 = 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 Private Sub InternComponentBtn_Click(sender As Object, e As RoutedEventArgs) Handles InternComponentBtn.Click ' 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 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) Exit While End If nId = EgtGetNextName(nId, "HoleLabels") End While End If ' 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 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 ' Sistemo interfaccia 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 End Class