Imports System.Collections.ObjectModel Imports OmagCUT.TreeViewItem Imports System.ComponentModel Imports EgtUILib Imports EgtWPFLib Public Class ToolsDbPageUC ' Riferimento alla MainWindow Private m_MainWindow As MainWindow = DirectCast(Application.Current.MainWindow, MainWindow) ' Riferimento alla macchina corrente Private m_CurrMachine As CurrentMachine = m_MainWindow.m_CurrentMachine ' Lista degli utensili Dim ToolsList As New ObservableCollection(Of CathegoryItem) ' Proprietà Private m_bFirst As Boolean = True ' Stringa identificativa variabile geometrica in modifica Private m_sCurrVar As String = String.Empty ' Parametri dell'utensile corrente Private m_nToolType As Integer = MCH_TY.NONE Private m_sToolName As String = String.Empty Private m_sEndLife As String = String.Empty ' Array che contengono i tipi di Coolant Dim ToolCoolant() As String Dim SawCoolant() As String ' Conservo l'utensile precedentemente selezionato per usarlo nel caso si selezioni annulla quando si cambia utensile selezionato Private m_OldItem As Object ' Dichiarazione Scene Friend WithEvents ToolScene As New Scene Dim ToolSceneHost As New System.Windows.Forms.Integration.WindowsFormsHost Private Sub ToolsDbPage_Initialized(sender As Object, e As EventArgs) ' Assegnazione scena all'host e posizionamento nella ToolsDbPageGrid ToolSceneHost.Child = ToolScene ToolSceneHost.SetValue(Grid.ColumnProperty, 2) ToolSceneHost.SetValue(Grid.RowProperty, 0) Me.ToolsDbPageGrid.Children.Add(ToolSceneHost) ' Assegno la lista degli utensili come sorgente del treeview ToolTreeView.ItemsSource = ToolsList ' Imposto testo delle combobox da file dei messaggi ToolCoolant = {EgtMsg(MSG_COMBOBOXPARAM + 1), EgtMsg(MSG_COMBOBOXPARAM + 2), EgtMsg(MSG_COMBOBOXPARAM + 3), EgtMsg(MSG_COMBOBOXPARAM + 4)} SawCoolant = {EgtMsg(MSG_COMBOBOXPARAM + 1), EgtMsg(MSG_COMBOBOXPARAM + 3)} ' Imposto i messaggi letti dal file dei messaggi NewBtn.Content = EgtMsg(MSG_MACHINEPAGEUC + 15) SaveBtn.Content = EgtMsg(MSG_MACHINEPAGEUC + 17) RemoveBtn.Content = EgtMsg(MSG_MACHINEPAGEUC + 18) NameTxBl.Text = EgtMsg(MSG_TOOLSDBPAGEUC + 1) TCPosTxBl.Text = EgtMsg(MSG_TOOLSDBPAGEUC + 2) HeadTxBl.Text = EgtMsg(MSG_TOOLSDBPAGEUC + 3) ExitTxBl.Text = EgtMsg(MSG_TOOLSDBPAGEUC + 4) SpeedGpBx.Header = EgtMsg(MSG_TOOLSDBPAGEUC + 5) SpeedTxBl.Text = EgtMsg(MSG_TOOLSDBPAGEUC + 6) MaxSpeedTxBl.Text = EgtMsg(MSG_TOOLSDBPAGEUC + 7) FeedGpBx.Header = EgtMsg(MSG_TOOLSDBPAGEUC + 8) FeedTxBl.Text = EgtMsg(MSG_TOOLSDBPAGEUC + 9) TipFeedTxBl.Text = EgtMsg(MSG_TOOLSDBPAGEUC + 10) StartFeedTxBl.Text = EgtMsg(MSG_TOOLSDBPAGEUC + 11) EndFeedTxBl.Text = EgtMsg(MSG_TOOLSDBPAGEUC + 12) CoolantTxBl.Text = EgtMsg(MSG_TOOLSDBPAGEUC + 13) CorrTxBl.Text = EgtMsg(MSG_TOOLSDBPAGEUC + 14) OffsetGpBx.Header = EgtMsg(MSG_TOOLSDBPAGEUC + 15) LonOffsetTxBl.Text = EgtMsg(MSG_TOOLSDBPAGEUC + 16) RadOffsetTxBl.Text = EgtMsg(MSG_TOOLSDBPAGEUC + 17) MaxAbsorptionTxBl.Text = EgtMsg(MSG_TOOLSDBPAGEUC + 18) MinFeedTxBl.Text = EgtMsg(MSG_TOOLSDBPAGEUC + 19) MaxMatTxBl.Text = EgtMsg(MSG_TOOLSDBPAGEUC + 20) UserNotesTxBl.Text = EgtMsg(MSG_TOOLSDBPAGEUC + 25) SerNbrTxBl.Text = EgtMsg(MSG_TOOLSDBPAGEUC + 26) ' Serial Number CodeTxBl.Text = EgtMsg(MSG_TOOLSDBPAGEUC + 27) ' Code SupplierTxBl.Text = EgtMsg(MSG_TOOLSDBPAGEUC + 28) ' Supplier EndLifeTxBl.Text = EgtMsg(MSG_TOOLSDBPAGEUC + 29) ' End Life ' Associo TextBox e Label Dim TempLabel1 As New Label TempLabel1.Content = SpeedTxBl.Text SpeedTxBx.Tag = TempLabel1 Dim TempLabel2 As New Label TempLabel2.Content = MaxSpeedTxBl.Text MaxSpeedTxBx.Tag = TempLabel2 Dim TempLabel3 As New Label TempLabel3.Content = FeedTxBl.Text FeedTxBx.Tag = TempLabel3 Dim TempLabel4 As New Label TempLabel4.Content = TipFeedTxBl.Text TipFeedTxBx.Tag = TempLabel4 Dim TempLabel5 As New Label TempLabel5.Content = StartFeedTxBl.Text StartFeedTxBx.Tag = TempLabel5 Dim TempLabel6 As New Label TempLabel6.Content = EndFeedTxBl.Text EndFeedTxBx.Tag = TempLabel6 Dim TempLabel7 As New Label TempLabel7.Content = CorrTxBl.Text CorrTxBx.Tag = TempLabel7 Dim TempLabel8 As New Label TempLabel8.Content = LonOffsetTxBl.Text LonOffsetTxBx.Tag = TempLabel8 Dim TempLabel9 As New Label TempLabel9.Content = RadOffsetTxBl.Text RadOffsetTxBx.Tag = TempLabel9 Dim TempLabel10 As New Label TempLabel10.Content = MaxAbsorptionTxBl.Text MaxAbsorptionTxBx.Tag = TempLabel10 Dim TempLabel11 As New Label TempLabel11.Content = MinFeedTxBl.Text MinFeedTxBx.Tag = TempLabel11 Dim TempLabel12 As New Label TempLabel12.Content = MaxMatTxBl.Text MaxMatTxBx.Tag = TempLabel12 End Sub Private Sub ToolsDbPage_Loaded(sender As Object, e As RoutedEventArgs) If m_bFirst Then ' imposto colore di default Dim DefColor As New Color3d(0, 0, 0) GetPrivateProfileColor(S_GEOMDB, K_DEFAULTCOLOR, DefColor, m_MainWindow.GetIniFile()) ToolScene.SetDefaultMaterial(DefColor) ' imposto colori sfondo ToolScene.SetViewBackground(GetBackTopColor(), GetBackBottomColor()) ' imposto colore di evidenziazione Dim MarkColor As New Color3d(255, 255, 0) GetPrivateProfileColor(S_SCENE, K_MARK, MarkColor, m_MainWindow.GetIniFile()) ToolScene.SetMarkMaterial(MarkColor) ' imposto colore per superfici selezionate Dim SelSurfColor As New Color3d(255, 255, 192) GetPrivateProfileColor(S_SCENE, K_SELSURF, SelSurfColor, m_MainWindow.GetIniFile()) ToolScene.SetSelSurfMaterial(SelSurfColor) ' imposto tipo e colore del rettangolo di zoom Dim bOutline As Boolean = True Dim ZwColor As New Color3d(0, 0, 0) GetPrivateProfileZoomWin(S_SCENE, K_ZOOMWIN, bOutline, ZwColor, m_MainWindow.GetIniFile()) ToolScene.SetZoomWinAttribs(bOutline, ZwColor) ' imposto colore della linea di distanza Dim DstLnColor As New Color3d(255, 0, 0) GetPrivateProfileColor(S_SCENE, K_DISTLINE, DstLnColor, m_MainWindow.GetIniFile()) ToolScene.SetDistLineMaterial(DstLnColor) ' imposto parametri OpenGL Dim nDriver As Integer = GetPrivateProfileInt(S_OPENGL, K_DRIVER, 3, m_MainWindow.GetIniFile()) Dim b2Buff As Boolean = (GetPrivateProfileInt(S_OPENGL, K_DOUBLEBUFFER, 1, m_MainWindow.GetIniFile()) <> 0) Dim nColorBits As Integer = GetPrivateProfileInt(S_OPENGL, K_COLORBITS, 32, m_MainWindow.GetIniFile()) Dim nDepthBits As Integer = GetPrivateProfileInt(S_OPENGL, K_DEPTHBITS, 32, m_MainWindow.GetIniFile()) ToolScene.SetViewAttributes(nDriver, b2Buff, nColorBits, nDepthBits) ' inizializzo la scena (DB geometrico + visualizzazione) ToolScene.Init() ' dimensione lineare max in pixel delle textures Dim nTxrMaxLinPix As Integer = GetPrivateProfileInt(S_SCENE, K_TEXMAXLINPIX, 4096, m_MainWindow.GetIniFile()) EgtSetTextureMaxLinPixels(nTxrMaxLinPix) ' inibisco selezione diretta da Scene ToolScene.SetStatusNull() ' Inizializzo le famiglie di utensili nell'albero EgtSetCurrentContext(m_MainWindow.m_CurrentProjectPageUC.CurrentProjectScene.GetCtx()) InitializeToolFamily(m_CurrMachine.bSaw, MCH_TF.SAWBLADE, EgtMsg(MSG_TOOLSDBPAGEUC + 31)) InitializeToolFamily(m_CurrMachine.bDrill, MCH_TF.DRILLBIT, EgtMsg(MSG_TOOLSDBPAGEUC + 32)) InitializeToolFamily(m_CurrMachine.bMill, MCH_TF.MILL, EgtMsg(MSG_TOOLSDBPAGEUC + 33)) InitializeToolFamily(m_CurrMachine.bMillNoTip, MCH_TF.MILL, EgtMsg(MSG_TOOLSDBPAGEUC + 34)) InitializeToolFamily(m_CurrMachine.bWaterJet, MCH_TF.WATERJET, EgtMsg(MSG_TOOLSDBPAGEUC + 35)) ' Sposto tutti i parametri in su di una riga se testa e uscita sono disattivati If Not m_CurrMachine.bShowHeadExit Then MoveParam() End If m_bFirst = False Else EgtSetCurrentContext(m_MainWindow.m_CurrentProjectPageUC.CurrentProjectScene.GetCtx()) End If InitializeFirstSelectedItem() End Sub 'Funzione che permette l'inizializzazione di albero e parametri all'apertura della pagina ToolsDb Private Sub InitializeFirstSelectedItem() If ToolsList.Count > 0 Then For Each ToolFamily In ToolsList If ToolFamily.Items.Count > 0 Then ToolFamily.IsExpanded = True ToolFamily.Items(0).IsSelected = True EgtTdbSetCurrTool(ToolFamily.Items(0).Name) m_OldItem = ToolFamily.Items(0) GetToolParams() ViewToolParams() ViewToolDraw() Exit Sub End If Next ToolsList.Item(0).IsSelected = True HideToolParams() End If End Sub Private Sub MoveParam() SpeedGpBx.SetValue(Grid.RowProperty, 3) FeedGpBx.SetValue(Grid.RowProperty, 7) CoolantTxBl.SetValue(Grid.RowProperty, 13) CoolantCmBx.SetValue(Grid.RowProperty, 13) CorrTxBl.SetValue(Grid.RowProperty, 13) CorrTxBx.SetValue(Grid.RowProperty, 13) OffsetGpBx.SetValue(Grid.RowProperty, 16) AbsorptionBrd.SetValue(Grid.RowProperty, 23) MaxMatTxBl.SetValue(Grid.RowProperty, 20) MaxMatTxBx.SetValue(Grid.RowProperty, 20) SerNbrTxBl.SetValue(Grid.RowProperty, 27) SerNbrTxBx.SetValue(Grid.RowProperty, 27) CodeTxBl.SetValue(Grid.RowProperty, 27) CodeTxBx.SetValue(Grid.RowProperty, 27) SupplierTxBl.SetValue(Grid.RowProperty, 29) SupplierTxBx.SetValue(Grid.RowProperty, 29) EndLifeTxBl.SetValue(Grid.RowProperty, 29) EndLifeChBx.SetValue(Grid.RowProperty, 29) End Sub Private Sub NewBtn_Click(sender As Object, e As RoutedEventArgs) Handles NewBtn.Click EgtSetCurrentContext(m_MainWindow.m_CurrentProjectPageUC.CurrentProjectScene.GetCtx()) If TypeOf ToolTreeView.SelectedItem Is CathegoryItem Then Dim SelectedCathegory As CathegoryItem = ToolTreeView.SelectedItem Dim NewName As String = SelectedCathegory.Name EgtTdbGetToolNewName(NewName) If EgtTdbAddTool(NewName, SelectedCathegory.nFType) Then For Each ToolFamily In ToolsList If ToolFamily.nFType = SelectedCathegory.nFType Then Dim NewToolItem As New CustomItem(NewName, SelectedCathegory.nFType) ToolFamily.Items.Add(NewToolItem) NewToolItem.IsSelected = True ToolFamily.IsExpanded = True m_OldItem = ToolTreeView.SelectedItem Exit For End If Next ' Determino il tipo di utensile Dim nType As Integer EgtTdbGetCurrToolParam( MCH_TP.TYPE, nType) ' Imposto testa e uscita ' Sempre lame su H1.1 e utensili foretto, fresa e mola da scasso su H1.2 If ( nType And MCH_TF.WATERJET) = 0 then Dim bSaw As Boolean = ((nType And MCH_TF.SAWBLADE) <> 0) EgtTdbSetCurrToolParam( MCH_TP.HEAD, "H1") EgtTdbSetCurrToolParam( MCH_TP.EXIT_, If(bSaw, 1, 2)) ' Waterjet sempre su H2.1 Else EgtTdbSetCurrToolParam( MCH_TP.HEAD, "H2") EgtTdbSetCurrToolParam( MCH_TP.EXIT_, 1) End If ' Per macchine senza ToolChanger, resetto la posizione su questo If m_CurrMachine.ShowToolChanger = 0 Then EgtTdbSetCurrToolParam(MCH_TP.TCPOS, "") End If ' Imposto dimensioni standard If (nType And MCH_TF.DRILLBIT) <> 0 Then EgtTdbSetCurrToolParam(MCH_TP.LEN, 80.0) EgtTdbSetCurrToolParam(MCH_TP.TOTLEN, 80.0) EgtTdbSetCurrToolParam(MCH_TP.DIAM, 20.0) EgtTdbSetCurrToolParam(MCH_TP.TOTDIAM, 20.0) EgtTdbSetCurrToolParam(MCH_TP.MAXMAT, 40.0) ElseIf (nType And MCH_TF.SAWBLADE) <> 0 Then EgtTdbSetCurrToolParam(MCH_TP.LEN, 80.0) EgtTdbSetCurrToolParam(MCH_TP.TOTLEN, 80.0) EgtTdbSetCurrToolParam(MCH_TP.DIAM, 600.0) EgtTdbSetCurrToolParam(MCH_TP.TOTDIAM, 600.0) EgtTdbSetCurrToolParam(MCH_TP.THICK, 5.0) EgtTdbSetCurrToolParam(MCH_TP.MAXMAT, 40.0) ElseIf (nType And MCH_TF.MILL) <> 0 Then EgtTdbSetCurrToolParam(MCH_TP.LEN, 80.0) EgtTdbSetCurrToolParam(MCH_TP.TOTLEN, 80.0) EgtTdbSetCurrToolParam(MCH_TP.DIAM, 20.0) EgtTdbSetCurrToolParam(MCH_TP.TOTDIAM, 20.0) EgtTdbSetCurrToolParam(MCH_TP.MAXMAT, 40.0) ElseIf (nType And MCH_TF.WATERJET) <> 0 Then EgtTdbSetCurrToolParam(MCH_TP.LEN, 5.0) EgtTdbSetCurrToolParam(MCH_TP.TOTLEN, 5.0) EgtTdbSetCurrToolParam(MCH_TP.DIAM, 1.0) EgtTdbSetCurrToolParam(MCH_TP.TOTDIAM, 1.0) EgtTdbSetCurrToolParam(MCH_TP.MAXMAT, 45.0) End If ' Gestione speciale eventuali note tipo Hofmann ManageSpecialNotes() ' Salvo e aggiorno interfaccia utente EgtTdbSaveCurrTool() GetToolParams() ViewToolParams() ViewToolDraw() End If ElseIf TypeOf ToolTreeView.SelectedItem Is CustomItem Then Dim SelectedCathegory As CustomItem = ToolTreeView.SelectedItem Dim NewName As String = SelectedCathegory.Name EgtTdbGetToolNewName(NewName) If EgtTdbCopyTool(SelectedCathegory.Name, NewName) Then ' Gestione speciale eventuali note tipo Hofmann ManageSpecialNotes() ' Annullo disegno EgtTdbSetCurrToolParam(MCH_TP.DRAW, "") EgtTdbSaveCurrTool() ' Aggiorno lista utensili Dim CurrType As Integer EgtTdbGetCurrToolParam(MCH_TP.TYPE, CurrType) For Each ToolFamily In ToolsList If (ToolFamily.nFType And CurrType) <> 0 Then Dim NewToolItem As New CustomItem(NewName, CurrType) ToolFamily.Items.Add(NewToolItem) NewToolItem.IsSelected = True GetToolParams() m_OldItem = ToolTreeView.SelectedItem Exit For End If Next End If End If End Sub Private Function GetSpecials() As Boolean ' Note speciali devono essere visualizzate con l'utensile corrente If m_CurrMachine.ShowSpecials = 0 Then Return False Dim nType As Integer EgtTdbGetCurrToolParam(MCH_TP.TYPE, nType) If nType <> MCH_TY.SAW_STD And m_CurrMachine.ShowSpecials = 2 Then Return False ' Imposto valori di default CodeTxBx.Text = "" SupplierTxBx.Text = "" SerNbrTxBx.Text = "" EndLifeChBx.IsChecked = False m_sEndLife = "" UserNotesTxBx.Text = "" ' Recupero le note utente Dim sUserNotes As String = "" EgtTdbGetCurrToolParam(MCH_TP.USERNOTES, sUserNotes) ' Se esistono If Not String.IsNullOrWhiteSpace(sUserNotes) Then ' Stringa con note rimanenti Dim sToShow As String = "" ' Le divido in parti Dim sItems() As String = sUserNotes.Split(";".ToCharArray) For i As Integer = 0 To sItems.Count() - 1 If sItems(i).Contains("CODE=") Then CodeTxBx.Text = sItems(i).Substring( 5) ElseIf sItems(i).Contains("SUPPL=") Then SupplierTxBx.Text = sItems(i).Substring( 6) ElseIf sItems(i).Contains("S/N=") Then SerNbrTxBx.Text = sItems(i).Substring( 4) ElseIf sItems(i).Contains("END=") Then EndLifeChBx.IsChecked = True m_sEndLife = sItems(i).Substring( 4) ElseIf Not String.IsNullOrWhiteSpace(sItems(i)) sToShow &= sItems(i) & ";" End If Next UserNotesTxBx.Text = sToShow End If Return True End Function Private Function SetSpecials() As Boolean ' Note speciali devono essere visualizzate con l'utensile corrente If m_CurrMachine.ShowSpecials = 0 Then Return False Dim nType As Integer EgtTdbGetCurrToolParam(MCH_TP.TYPE, nType) If nType <> MCH_TY.SAW_STD And m_CurrMachine.ShowSpecials = 2 Then Return False ' Ricreo la stringa Dim sUserNotes As String = "" sUserNotes &= "CODE=" & CodeTxBx.Text & ";" sUserNotes &= "SUPPL=" & SupplierTxBx.Text & ";" sUserNotes &= "S/N=" & SerNbrTxBx.Text & ";" If EndLifeChBx.IsChecked Then If String.IsNullOrWhiteSpace( m_sEndLife) Then m_sEndLife = My.Computer.Clock.LocalTime.ToString("dd.MM.yyyy HH:mm:ss") End If sUserNotes &= "END=" & m_sEndLife & ";" End If sUserNotes &= UserNotesTxBx.Text EgtTdbSetCurrToolParam(MCH_TP.USERNOTES, sUserNotes) Return True End Function Private Sub ManageSpecialNotes() ' Note utente devono essere visualizzate con l'utensile corrente If m_CurrMachine.ShowUserNotes = 0 And m_CurrMachine.ShowSpecials = 0 Then Return Dim nType As Integer EgtTdbGetCurrToolParam(MCH_TP.TYPE, nType) If nType <> MCH_TY.SAW_STD And m_CurrMachine.ShowUserNotes = 2 Then Return ' Recupero le note utente Dim sUserNotes As String = "" EgtTdbGetCurrToolParam(MCH_TP.USERNOTES, sUserNotes) ' Se esistono If Not String.IsNullOrEmpty(sUserNotes) Then ' Le divido in parti Dim bIsCode As Boolean = False Dim bIsSuppl As Boolean = False Dim bIsSN As Boolean = False Dim sItems() As String = sUserNotes.Split(";".ToCharArray) For i As Integer = 0 To sItems.Count() - 1 If sItems(i).Contains("CODE=") Then bIsCode = True ElseIf sItems(i).Contains("SUPPL=") Then bIsSuppl = True ElseIf sItems(i).Contains("S/N=") Then bIsSN = True ElseIf sItems(i).Contains("START=") Then sItems(i) = "" ElseIf sItems(i).Contains("PROD=") Then sItems(i) = "" ElseIf sItems(i).Contains("END=") Then sItems(i) = "" End If Next sUserNotes = "" For i As Integer = 0 To sItems.Count() - 1 If Not String.IsNullOrWhiteSpace(sItems(i)) Then sUserNotes &= sItems(i) & ";" End If Next If Not bIsCode Then sUserNotes &= "CODE= ;" If Not bIsSuppl Then sUserNotes &= "SUPPL= ;" If Not bIsSN Then sUserNotes &= "S/N= ;" Else sUserNotes = "CODE= ; SUPPL= ; S/N= ;" End If sUserNotes &= "START=" & My.Computer.Clock.LocalTime.ToString("dd.MM.yyyy HH:mm:ss") & ";" sUserNotes &= "PROD=0;" EgtTdbSetCurrToolParam(MCH_TP.USERNOTES, sUserNotes) End Sub Private Sub SaveBtn_Click(sender As Object, e As RoutedEventArgs) Handles SaveBtn.Click EgtSetCurrentContext(m_MainWindow.m_CurrentProjectPageUC.CurrentProjectScene.GetCtx()) SetToolParams() EgtTdbSaveCurrTool() m_sToolName = NameTxBx.Text Dim CurrTool As CustomItem = TryCast(m_OldItem, CustomItem) If CurrTool IsNot Nothing Then CurrTool.Name = m_sToolName End If End Sub Private Sub RemoveBtn_Click(sender As Object, e As RoutedEventArgs) Handles RemoveBtn.Click If TypeOf ToolTreeView.SelectedItem Is CustomItem Then Dim SelectedItem As CustomItem = ToolTreeView.SelectedItem EgtSetCurrentContext(m_MainWindow.m_CurrentProjectPageUC.CurrentProjectScene.GetCtx()) ' Cancello l'utensile EgtTdbRemoveTool(SelectedItem.Name) ' Rimuovo il nome dell'albero For Each ToolFamily In ToolsList If (ToolFamily.nFType And SelectedItem.nType) <> 0 Then ToolFamily.Items.Remove(SelectedItem) If ToolFamily.Items.Count = 0 Then ToolFamily.IsSelected = True HideToolParams() HideToolDraw() Else ToolFamily.Items(0).IsSelected = True EgtTdbSetCurrTool(ToolFamily.Items(0).Name) m_OldItem = ToolFamily.Items(0) GetToolParams() ViewToolParams() ViewToolDraw() End If End If Next End If End Sub Private Sub OkBtn_Click(sender As Object, e As RoutedEventArgs) Handles OkBtn.Click ' Se necessario, chiedo se salvare l'utensile corrente If Not SaveCurrTool() Then Return ' Salvo il DB utensili EgtTdbSave() ' Esco dalla pagina m_MainWindow.m_MachinePageUC.MachinePageGrid.Children.Remove(m_MainWindow.m_MachinePageUC.m_ToolsDbPageUC) m_MainWindow.m_MachinePageUC.MachinePageGrid.Children.Add(m_MainWindow.m_MachinePageUC.m_AlarmsPageUC) m_MainWindow.m_MachinePageUC.m_ActiveMachinePage = MachinePageUC.MachinePages.Alarms m_MainWindow.m_MachinePageUC.ToolsDBBtn.IsChecked = False m_MainWindow.m_MachinePageUC.AlarmsBtn.IsChecked = True End Sub Friend Sub InitializeToolFamily(bEnabled As Boolean, nFType As Integer, sFName As String) If Not bEnabled Then Return ' Inserisco categoria ed eventuali elementi Dim ToolCathegory As New CathegoryItem(sFName, nFType) Dim nType As Integer = 0 Dim ToolName As String = String.Empty If EgtTdbGetFirstTool(nFType, ToolName, nType) Then ToolCathegory.Items.Add(New CustomItem(ToolName, nType)) While EgtTdbGetNextTool(nFType, ToolName, nType) ToolCathegory.Items.Add(New CustomItem(ToolName, nType)) End While End If ToolsList.Add(ToolCathegory) End Sub Private Sub GetToolParams() EgtSetCurrentContext(m_MainWindow.m_CurrentProjectPageUC.CurrentProjectScene.GetCtx()) EgtTdbGetCurrToolParam(MCH_TP.TYPE, m_nToolType) Dim ToolString As String = String.Empty Dim ToolInt As Integer = 0 Dim ToolDouble As Double = 0 EgtTdbGetCurrToolParam(MCH_TP.NAME, m_sToolName) NameTxBx.Text = m_sToolName EgtTdbGetCurrToolParam(MCH_TP.TCPOS, ToolString) TCPosTxBx.Text = ToolString EgtTdbGetCurrToolParam(MCH_TP.MAXMAT, ToolDouble) MaxMatTxBx.Text = LenToString(ToolDouble, 3) EgtTdbGetCurrToolParam(MCH_TP.LONOFFSET, ToolDouble) LonOffsetTxBx.Text = LenToString(ToolDouble, 3) EgtTdbGetCurrToolParam(MCH_TP.RADOFFSET, ToolDouble) RadOffsetTxBx.Text = LenToString(ToolDouble, 3) EgtTdbGetCurrToolParam(MCH_TP.COOLANT, ToolInt) Dim ToolType As Integer EgtTdbGetCurrToolParam(MCH_TP.TYPE, ToolType) If (ToolType And MCH_TF.SAWBLADE) <> 0 Then CoolantCmBx.ItemsSource = SawCoolant If ToolInt = 0 Then CoolantCmBx.SelectedIndex = 0 ElseIf ToolInt = 2 Then CoolantCmBx.SelectedIndex = 1 End If Else CoolantCmBx.ItemsSource = ToolCoolant CoolantCmBx.SelectedIndex = ToolInt End If EgtTdbGetCurrToolParam(MCH_TP.CORR, ToolInt) CorrTxBx.Text = ToolInt.ToString() EgtTdbGetCurrToolParam(MCH_TP.MAXSPEED, ToolDouble) MaxSpeedTxBx.Text = DoubleToString(ToolDouble, 3) EgtTdbGetCurrToolParam(MCH_TP.SPEED, ToolDouble) SpeedTxBx.Text = DoubleToString(ToolDouble, 3) EgtTdbGetCurrToolParam(MCH_TP.FEED, ToolDouble) FeedTxBx.Text = LenToString(ToolDouble, 3) EgtTdbGetCurrToolParam(MCH_TP.TIPFEED, ToolDouble) TipFeedTxBx.Text = LenToString(ToolDouble, 3) EgtTdbGetCurrToolParam(MCH_TP.STARTFEED, ToolDouble) StartFeedTxBx.Text = LenToString(ToolDouble, 3) EgtTdbGetCurrToolParam(MCH_TP.ENDFEED, ToolDouble) EndFeedTxBx.Text = LenToString(ToolDouble, 3) EgtTdbGetCurrToolParam(MCH_TP.MAXABSORPTION, ToolDouble) MaxAbsorptionTxBx.Text = DoubleToString(ToolDouble, 3) EgtTdbGetCurrToolParam(MCH_TP.MINFEED, ToolDouble) MinFeedTxBx.Text = LenToString(ToolDouble, 3) EgtTdbGetCurrToolParam(MCH_TP.HEAD, ToolString) HeadTxBx.Text = ToolString EgtTdbGetCurrToolParam(MCH_TP.EXIT_, ToolInt) ExitTxBx.Text = ToolInt.ToString() if Not GetSpecials() Then EgtTdbGetCurrToolParam(MCH_TP.USERNOTES, ToolString) UserNotesTxBx.Text = ToolString End If End Sub Private Sub SetToolParams() EgtSetCurrentContext(m_MainWindow.m_CurrentProjectPageUC.CurrentProjectScene.GetCtx()) Dim dTemp As Double Dim nTemp As Integer EgtTdbSetCurrToolParam(MCH_TP.NAME, NameTxBx.Text) EgtTdbSetCurrToolParam(MCH_TP.TCPOS, TCPosTxBx.Text) If m_nToolType = MCH_TY.SAW_STD Or m_nToolType = MCH_TY.WATERJET Then StringToLen(MaxMatTxBx.Text, dTemp) EgtTdbSetCurrToolParam(MCH_TP.MAXMAT, dTemp) End If If m_nToolType <> MCH_TY.DRILL_STD Then StringToLen(LonOffsetTxBx.Text, dTemp) EgtTdbSetCurrToolParam(MCH_TP.LONOFFSET, dTemp) StringToLen(RadOffsetTxBx.Text, dTemp) EgtTdbSetCurrToolParam(MCH_TP.RADOFFSET, dTemp) End If Dim sUuid As String = "" EgtTdbGetCurrToolParam(MCH_TP.UUID, sUuid) EgtTdbSetCurrToolParam(MCH_TP.DRAW, sUuid & ".nge") If m_nToolType = MCH_TY.SAW_STD Then If CoolantCmBx.SelectedIndex = 0 Then nTemp = 0 ElseIf CoolantCmBx.SelectedIndex = 1 Then nTemp = 2 End If Else nTemp = CoolantCmBx.SelectedIndex End If EgtTdbSetCurrToolParam(MCH_TP.COOLANT, nTemp) Int32.TryParse(CorrTxBx.Text, nTemp) EgtTdbSetCurrToolParam(MCH_TP.CORR, nTemp) StringToDouble(MaxSpeedTxBx.Text, dTemp) EgtTdbSetCurrToolParam(MCH_TP.MAXSPEED, dTemp) StringToDouble(SpeedTxBx.Text, dTemp) EgtTdbSetCurrToolParam(MCH_TP.SPEED, dTemp) StringToLen(FeedTxBx.Text, dTemp) EgtTdbSetCurrToolParam(MCH_TP.FEED, dTemp) StringToLen(TipFeedTxBx.Text, dTemp) EgtTdbSetCurrToolParam(MCH_TP.TIPFEED, dTemp) StringToLen(StartFeedTxBx.Text, dTemp) EgtTdbSetCurrToolParam(MCH_TP.STARTFEED, dTemp) StringToLen(EndFeedTxBx.Text, dTemp) EgtTdbSetCurrToolParam(MCH_TP.ENDFEED, dTemp) StringToDouble(MaxAbsorptionTxBx.Text, dTemp) EgtTdbSetCurrToolParam(MCH_TP.MAXABSORPTION, dTemp) StringToLen(MinFeedTxBx.Text, dTemp) EgtTdbSetCurrToolParam(MCH_TP.MINFEED, dTemp) EgtTdbSetCurrToolParam(MCH_TP.HEAD, HeadTxBx.Text) Int32.TryParse(ExitTxBx.Text, nTemp) EgtTdbSetCurrToolParam(MCH_TP.EXIT_, nTemp) if Not SetSpecials() Then EgtTdbSetCurrToolParam(MCH_TP.USERNOTES, UserNotesTxBx.Text) End If End Sub Private Sub ViewToolParams() NameTxBl.Visibility = Windows.Visibility.Visible NameTxBx.Visibility = Windows.Visibility.Visible Dim bShowTcPos As Boolean = ((m_nToolType = MCH_TY.SAW_STD And m_CurrMachine.ShowToolChanger <> 0) Or m_CurrMachine.ShowToolChanger = 1) TCPosBrd.Visibility = If(bShowTcPos, Windows.Visibility.Visible, Windows.Visibility.Hidden) HeadExitBrd.Visibility = If(m_CurrMachine.bShowHeadExit, Windows.Visibility.Visible, Windows.Visibility.Hidden) SpeedGpBx.Visibility = If(m_nToolType <> MCH_TY.WATERJET, Windows.Visibility.Visible, Windows.Visibility.Hidden) FeedGpBx.Visibility = Windows.Visibility.Visible CoolantTxBl.Visibility = If(m_nToolType <> MCH_TY.WATERJET, Windows.Visibility.Visible, Windows.Visibility.Hidden) CoolantCmBx.Visibility = If(m_nToolType <> MCH_TY.WATERJET, Windows.Visibility.Visible, Windows.Visibility.Hidden) CorrTxBl.Visibility = Windows.Visibility.Hidden CorrTxBx.Visibility = Windows.Visibility.Hidden MaxMatTxBl.Visibility = If(m_nToolType = MCH_TY.SAW_STD Or m_nToolType = MCH_TY.WATERJET, Windows.Visibility.Visible, Windows.Visibility.Hidden) MaxMatTxBx.Visibility = If(m_nToolType = MCH_TY.SAW_STD Or m_nToolType = MCH_TY.WATERJET, Windows.Visibility.Visible, Windows.Visibility.Hidden) OffsetGpBx.Visibility = If(m_nToolType <> MCH_TY.DRILL_STD, Windows.Visibility.Visible, Windows.Visibility.Hidden) LonOffsetTxBl.Visibility = If(m_nToolType <> MCH_TY.WATERJET, Windows.Visibility.Visible, Windows.Visibility.Hidden) LonOffsetTxBx.Visibility = If(m_nToolType <> MCH_TY.WATERJET, Windows.Visibility.Visible, Windows.Visibility.Hidden) If m_nToolType = MCH_TY.DRILL_STD Then AbsorptionBrd.SetValue(Grid.RowProperty, 19) Else AbsorptionBrd.SetValue(Grid.RowProperty, 23) End If AbsorptionBrd.Visibility = If(m_nToolType <> MCH_TY.WATERJET, Windows.Visibility.Visible, Windows.Visibility.Hidden) Dim bShowUserNotes As Boolean = ((m_nToolType = MCH_TY.SAW_STD And m_CurrMachine.ShowUserNotes <> 0) Or m_CurrMachine.ShowUserNotes = 1) UserNotesTxBl.Visibility = If(bShowUserNotes, Windows.Visibility.Visible, Windows.Visibility.Hidden) UserNotesTxBx.Visibility = If(bShowUserNotes, Windows.Visibility.Visible, Windows.Visibility.Hidden) Dim bShowSpecials As Boolean = ((m_nToolType = MCH_TY.SAW_STD And m_CurrMachine.ShowSpecials <> 0) Or m_CurrMachine.ShowSpecials = 1) SerNbrTxBl.Visibility = If(bShowSpecials, Windows.Visibility.Visible, Windows.Visibility.Hidden) SerNbrTxBx.Visibility = If(bShowSpecials, Windows.Visibility.Visible, Windows.Visibility.Hidden) CodeTxBl.Visibility = If(bShowSpecials, Windows.Visibility.Visible, Windows.Visibility.Hidden) CodeTxBx.Visibility = If(bShowSpecials, Windows.Visibility.Visible, Windows.Visibility.Hidden) SupplierTxBl.Visibility = If(bShowSpecials, Windows.Visibility.Visible, Windows.Visibility.Hidden) SupplierTxBx.Visibility = If(bShowSpecials, Windows.Visibility.Visible, Windows.Visibility.Hidden) EndLifeTxBl.Visibility = If(bShowSpecials, Windows.Visibility.Visible, Windows.Visibility.Hidden) EndLifeChBx.Visibility = If(bShowSpecials, Windows.Visibility.Visible, Windows.Visibility.Hidden) End Sub Private Sub HideToolParams() NameTxBl.Visibility = Windows.Visibility.Hidden NameTxBx.Visibility = Windows.Visibility.Hidden TCPosBrd.Visibility = Windows.Visibility.Hidden HeadExitBrd.Visibility = Windows.Visibility.Hidden SpeedGpBx.Visibility = Windows.Visibility.Hidden FeedGpBx.Visibility = Windows.Visibility.Hidden CoolantTxBl.Visibility = Windows.Visibility.Hidden CoolantCmBx.Visibility = Windows.Visibility.Hidden CorrTxBl.Visibility = Windows.Visibility.Hidden CorrTxBx.Visibility = Windows.Visibility.Hidden MaxMatTxBl.Visibility = Windows.Visibility.Hidden MaxMatTxBx.Visibility = Windows.Visibility.Hidden OffsetGpBx.Visibility = Windows.Visibility.Hidden AbsorptionBrd.Visibility = Windows.Visibility.Hidden UserNotesTxBl.Visibility = Windows.Visibility.Hidden UserNotesTxBx.Visibility = Windows.Visibility.Hidden SerNbrTxBl.Visibility = Windows.Visibility.Hidden SerNbrTxBx.Visibility = Windows.Visibility.Hidden CodeTxBl.Visibility = Windows.Visibility.Hidden CodeTxBx.Visibility = Windows.Visibility.Hidden SupplierTxBl.Visibility = Windows.Visibility.Hidden SupplierTxBx.Visibility = Windows.Visibility.Hidden EndLifeTxBl.Visibility = Windows.Visibility.Hidden EndLifeChBx.Visibility = Windows.Visibility.Hidden End Sub Private Sub ToolTreeView_PreviewMouseUp(sender As Object, e As MouseButtonEventArgs) Handles ToolTreeView.PreviewMouseUp ' Se necessario, chiedo se salvare l'utensile corrente If Not SaveCurrTool() Then Dim PreviousTool As CustomItem = m_OldItem PreviousTool.IsSelected = True Exit Sub End If ' Aggiorno If TypeOf ToolTreeView.SelectedItem Is CathegoryItem Then Dim SelectedCathegory As CathegoryItem = ToolTreeView.SelectedItem SelectedCathegory.IsExpanded = Not SelectedCathegory.IsExpanded HideToolParams() HideToolDraw() ElseIf TypeOf ToolTreeView.SelectedItem Is CustomItem Then Dim SelectedTool As CustomItem = ToolTreeView.SelectedItem EgtSetCurrentContext(m_MainWindow.m_CurrentProjectPageUC.CurrentProjectScene.GetCtx()) EgtTdbSetCurrTool(SelectedTool.Name) GetToolParams() ViewToolParams() ViewToolDraw() End If m_OldItem = ToolTreeView.SelectedItem End Sub Private Sub ViewToolDraw() ' Preparo dati per modello dell'utensile e lo creo If Not PrepareToolDraw() OrElse Not CreateToolDraw() Then EgtSetCurrentContext(ToolScene.GetCtx()) EgtNewFile() End If ' Aggiorno visualizzazione EgtSetCurrentContext(ToolScene.GetCtx()) EgtSetView(VT.TOP, False) EgtZoom(ZM.ALL) End Sub Private Sub HideToolDraw() EgtSetCurrentContext(ToolScene.GetCtx()) EgtNewFile() EgtDraw() End Sub Private Sub OnMyMouseDownScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles ToolScene.OnMouseDownScene ' Annullo nome variabile corrente m_sCurrVar = String.Empty ' Si può selezionare solo con il tasto sinistro e se stato NULL If e.Button <> Windows.Forms.MouseButtons.Left Or Not ToolScene.IsStatusNull() Then Return End If ' Verifico se selezionato testo di quota EgtSetObjFilterForSelWin(False, False, False, False, True) Dim nSel As Integer EgtSelect(e.Location, Scene.DIM_SEL, Scene.DIM_SEL, nSel) Dim nId As Integer = EgtGetFirstObjInSelWin() While nId <> GDB_ID.NULL ' Recupero eventuale info di variabile Dim sVar As String = String.Empty If EgtGetInfo(nId, "Var", sVar) Then m_sCurrVar = sVar EgtSelectObj(nId) EgtDraw() Exit While End If nId = EgtGetNextObjInSelWin() End While ' Se non modifica variabile If String.IsNullOrWhiteSpace(m_sCurrVar) Then Return ' Recupero il valore della variabile Dim dVal As Double If Not GetVariableValue(dVal) Then Return ' Recupero indice messaggio titolo per calcolatrice Dim nMsg As Integer = 0 Select Case GetVariableType() Case MCH_TP.LEN nMsg = MSG_TOOLSDBPAGEUC + 21 ' Lunghezza Case MCH_TP.DIAM nMsg = MSG_TOOLSDBPAGEUC + 22 ' Diametro Case MCH_TP.THICK nMsg = MSG_TOOLSDBPAGEUC + 23 ' Spessore Case MCH_TP.MAXMAT nMsg = MSG_TOOLSDBPAGEUC + 24 ' Tagliente End Select ' Predispongo calcolatrice (converto sempre in UIUnits perchè tutte lunghezze) Dim EgtCalculator As New EgtCalculatorWD(m_MainWindow, EgtToUiUnits(dVal), 300, WidthType.PIXEL, 0, 0, EgtMsg(nMsg)) ' Se inserito valore valido e confermato If EgtCalculator.DialogResult Then RecreateToolDraw(EgtFromUiUnits(EgtCalculator.dResult)) End If ' Aggiorno visualizzazione EgtSetCurrentContext(ToolScene.GetCtx()) EgtDeselectAll() EgtSetView(VT.TOP, False) EgtZoom(ZM.ALL) End Sub Private Sub RecreateToolDraw(ByVal dVal As Double) ' Salvo il vecchio valore Dim dOldVal As Double GetVariableValue( dOldVal) ' Aggiorno dati utensile SetVariableValue(dVal) ' Creo utensile If CreateToolDraw() Then Return ' Creazione fallita, ritorno ai valori precedenti SetVariableValue(dOldVal) CreateToolDraw() End Sub Private Function GetVariableValue(ByRef dVal As Double) As Boolean ' Recupero valore variabile EgtSetCurrentContext(m_MainWindow.m_CurrentProjectPageUC.CurrentProjectScene.GetCtx()) Return EgtTdbGetCurrToolParam(GetVariableType(), dVal) End Function Private Function SetVariableValue(ByVal dVal As Double) As Boolean ' Recupero tipo di variabile EgtSetCurrentContext(m_MainWindow.m_CurrentProjectPageUC.CurrentProjectScene.GetCtx()) Dim nType As Integer = GetVariableType() If m_nToolType = MCH_TY.SAW_STD Then Select Case nType Case MCH_TP.LEN ' lunghezza totale maggiorata di 1 mm per non essere riconosciuta come lama piatta EgtTdbSetCurrToolParam(MCH_TP.TOTLEN, dVal + 1) Case MCH_TP.DIAM EgtTdbSetCurrToolParam(MCH_TP.TOTDIAM, dVal) End Select ElseIf m_nToolType = MCH_TY.DRILL_STD Then Select Case nType Case MCH_TP.LEN EgtTdbSetCurrToolParam(MCH_TP.TOTLEN, dVal) Case MCH_TP.DIAM EgtTdbSetCurrToolParam(MCH_TP.TOTDIAM, dVal) End Select ElseIf m_nToolType = MCH_TY.MILL_STD Then Select Case nType Case MCH_TP.LEN EgtTdbSetCurrToolParam(MCH_TP.TOTLEN, dVal) Case MCH_TP.DIAM EgtTdbSetCurrToolParam(MCH_TP.TOTDIAM, dVal) End Select ElseIf m_nToolType = MCH_TY.MILL_NOTIP Then Select Case nType Case MCH_TP.LEN EgtTdbSetCurrToolParam(MCH_TP.TOTLEN, dVal) Case MCH_TP.DIAM EgtTdbSetCurrToolParam(MCH_TP.TOTDIAM, dVal) End Select ElseIf m_nToolType = MCH_TY.WATERJET Then Select Case nType Case MCH_TP.LEN EgtTdbSetCurrToolParam(MCH_TP.TOTLEN, dVal) Case MCH_TP.DIAM EgtTdbSetCurrToolParam(MCH_TP.TOTDIAM, dVal) End Select End If Return EgtTdbSetCurrToolParam(nType, dVal) End Function Private Function GetVariableType() As Integer Dim nType As Integer = MCH_TP.NONE If m_sCurrVar = "LEN" Then nType = MCH_TP.LEN ElseIf m_sCurrVar = "DIAM" Then nType = MCH_TP.DIAM ElseIf m_sCurrVar = "THICK" Then nType = MCH_TP.THICK ElseIf m_sCurrVar = "MAXMAT" Then nType = MCH_TP.MAXMAT End If Return nType End Function Private Function PrepareToolDraw() As Boolean Select Case m_nToolType Case MCH_TY.DRILL_STD ' assegno parametri geometrici EgtSetCurrentContext(m_MainWindow.m_CurrentProjectPageUC.CurrentProjectScene.GetCtx()) Dim dToolLen As Double EgtTdbGetCurrToolParam(MCH_TP.LEN, dToolLen) If dToolLen < EPS_SMALL Then dToolLen = 120 EgtTdbSetCurrToolParam(MCH_TP.LEN, dToolLen) EgtTdbSetCurrToolParam(MCH_TP.TOTLEN, dToolLen) EgtOutLog("ToolLen too small ->" & DoubleToString(dToolLen, 1)) End If Dim dToolDiam As Double EgtTdbGetCurrToolParam(MCH_TP.DIAM, dToolDiam) If dToolDiam < EPS_SMALL Then dToolDiam = 20 EgtTdbSetCurrToolParam(MCH_TP.DIAM, dToolDiam) EgtTdbSetCurrToolParam(MCH_TP.TOTDIAM, dToolDiam) EgtOutLog("ToolDiam too small ->" & DoubleToString(dToolDiam, 1)) End If Dim dToolMaxMat As Double EgtTdbGetCurrToolParam(MCH_TP.MAXMAT, dToolMaxMat) If dToolMaxMat < EPS_SMALL Then dToolMaxMat = 40 EgtTdbSetCurrToolParam(MCH_TP.MAXMAT, dToolMaxMat) EgtOutLog("ToolMaxMat too small ->" & DoubleToString(dToolMaxMat, 1)) End If ' passo all'ambiente di disegno dell'utensile EgtSetCurrentContext(ToolScene.GetCtx()) Return True Case MCH_TY.SAW_STD ' assegno parametri geometrici EgtSetCurrentContext(m_MainWindow.m_CurrentProjectPageUC.CurrentProjectScene.GetCtx()) Dim dToolLen As Double EgtTdbGetCurrToolParam(MCH_TP.LEN, dToolLen) If dToolLen < EPS_SMALL Then dToolLen = 5 EgtTdbSetCurrToolParam(MCH_TP.LEN, dToolLen) EgtTdbSetCurrToolParam(MCH_TP.TOTLEN, dToolLen) EgtOutLog("ToolLen too small ->" & DoubleToString(dToolLen, 1)) End If Dim dToolDiam As Double EgtTdbGetCurrToolParam(MCH_TP.DIAM, dToolDiam) If dToolDiam < EPS_SMALL Then dToolDiam = 200 EgtTdbSetCurrToolParam(MCH_TP.DIAM, dToolDiam) EgtTdbSetCurrToolParam(MCH_TP.TOTDIAM, dToolDiam) EgtOutLog("ToolDiam too small ->" & DoubleToString(dToolDiam, 1)) End If Dim dToolThick As Double EgtTdbGetCurrToolParam(MCH_TP.THICK, dToolThick) If dToolThick < EPS_SMALL Then dToolThick = 5 EgtTdbSetCurrToolParam(MCH_TP.THICK, dToolThick) EgtOutLog("ToolThick too small ->" & DoubleToString(dToolThick, 1)) End If Dim dToolMaxMat As Double EgtTdbGetCurrToolParam(MCH_TP.MAXMAT, dToolMaxMat) If dToolMaxMat < EPS_SMALL Then dToolMaxMat = 40 EgtTdbSetCurrToolParam(MCH_TP.MAXMAT, dToolMaxMat) EgtOutLog("ToolMaxMat too small ->" & DoubleToString(dToolMaxMat, 1)) End If ' passo all'ambiente di disegno dell'utensile EgtSetCurrentContext(ToolScene.GetCtx()) Return True Case MCH_TY.MILL_STD ' assegno parametri geometrici EgtSetCurrentContext(m_MainWindow.m_CurrentProjectPageUC.CurrentProjectScene.GetCtx()) Dim dToolLen As Double EgtTdbGetCurrToolParam(MCH_TP.LEN, dToolLen) If dToolLen < EPS_SMALL Then dToolLen = 120 EgtTdbSetCurrToolParam(MCH_TP.LEN, dToolLen) EgtTdbSetCurrToolParam(MCH_TP.TOTLEN, dToolLen) EgtOutLog("ToolLen too small ->" & DoubleToString(dToolLen, 1)) End If Dim dToolDiam As Double EgtTdbGetCurrToolParam(MCH_TP.DIAM, dToolDiam) If dToolDiam < EPS_SMALL Then dToolDiam = 20 EgtTdbSetCurrToolParam(MCH_TP.DIAM, dToolDiam) EgtTdbSetCurrToolParam(MCH_TP.TOTDIAM, dToolDiam) EgtOutLog("ToolDiam too small ->" & DoubleToString(dToolDiam, 1)) End If Dim dToolMaxMat As Double EgtTdbGetCurrToolParam(MCH_TP.MAXMAT, dToolMaxMat) If dToolMaxMat < EPS_SMALL Then dToolMaxMat = 40 EgtTdbSetCurrToolParam(MCH_TP.MAXMAT, dToolMaxMat) EgtOutLog("ToolMaxMat too small ->" & DoubleToString(dToolMaxMat, 1)) End If ' passo all'ambiente di disegno dell'utensile EgtSetCurrentContext(ToolScene.GetCtx()) Return True Case MCH_TY.MILL_NOTIP ' assegno parametri geometrici EgtSetCurrentContext(m_MainWindow.m_CurrentProjectPageUC.CurrentProjectScene.GetCtx()) Dim dToolLen As Double EgtTdbGetCurrToolParam(MCH_TP.LEN, dToolLen) If dToolLen < EPS_SMALL Then dToolLen = 120 EgtTdbSetCurrToolParam(MCH_TP.LEN, dToolLen) EgtTdbSetCurrToolParam(MCH_TP.TOTLEN, dToolLen) EgtOutLog("ToolLen too small ->" & DoubleToString(dToolLen, 1)) End If Dim dToolDiam As Double EgtTdbGetCurrToolParam(MCH_TP.DIAM, dToolDiam) If dToolDiam < EPS_SMALL Then dToolDiam = 20 EgtTdbSetCurrToolParam(MCH_TP.DIAM, dToolDiam) EgtTdbSetCurrToolParam(MCH_TP.TOTDIAM, dToolDiam) EgtOutLog("ToolDiam too small ->" & DoubleToString(dToolDiam, 1)) End If Dim dToolMaxMat As Double EgtTdbGetCurrToolParam(MCH_TP.MAXMAT, dToolMaxMat) If dToolMaxMat < EPS_SMALL Then dToolMaxMat = 40 EgtTdbSetCurrToolParam(MCH_TP.MAXMAT, dToolMaxMat) EgtOutLog("ToolMaxMat too small ->" & DoubleToString(dToolMaxMat, 1)) End If ' passo all'ambiente di disegno dell'utensile EgtSetCurrentContext(ToolScene.GetCtx()) Return True Case MCH_TY.WATERJET ' assegno parametri geometrici EgtSetCurrentContext(m_MainWindow.m_CurrentProjectPageUC.CurrentProjectScene.GetCtx()) Dim dToolLen As Double EgtTdbGetCurrToolParam(MCH_TP.LEN, dToolLen) If dToolLen < EPS_SMALL Then dToolLen = 120 EgtTdbSetCurrToolParam(MCH_TP.LEN, dToolLen) EgtTdbSetCurrToolParam(MCH_TP.TOTLEN, dToolLen) EgtOutLog("ToolLen too small ->" & DoubleToString(dToolLen, 1)) End If Dim dToolDiam As Double EgtTdbGetCurrToolParam(MCH_TP.DIAM, dToolDiam) If dToolDiam < EPS_SMALL Then dToolDiam = 20 EgtTdbSetCurrToolParam(MCH_TP.DIAM, dToolDiam) EgtTdbSetCurrToolParam(MCH_TP.TOTDIAM, dToolDiam) EgtOutLog("ToolDiam too small ->" & DoubleToString(dToolDiam, 1)) End If Dim dToolMaxMat As Double EgtTdbGetCurrToolParam(MCH_TP.MAXMAT, dToolMaxMat) If dToolMaxMat < EPS_SMALL Then dToolMaxMat = 40 EgtTdbSetCurrToolParam(MCH_TP.MAXMAT, dToolMaxMat) EgtOutLog("ToolMaxMat too small ->" & DoubleToString(dToolMaxMat, 1)) End If ' passo all'ambiente di disegno dell'utensile EgtSetCurrentContext(ToolScene.GetCtx()) Return True End Select Return False End Function Private Function CreateToolDraw() As Boolean Dim nErr As Integer = EgtTdbCurrToolDraw( m_MainWindow.m_CurrentProjectPageUC.CurrentProjectScene.GetCtx(), ToolScene.GetCtx()) EgtSetCurrentContext(ToolScene.GetCtx()) Return (nErr = 0) End Function Friend Function SaveCurrTool() As Boolean SetToolParams() ' Se dati utensile modificati If EgtTdbIsCurrToolModified() Then Dim SaveCurrToolWnd As EgtMsgBox If m_MainWindow.IsSiemensPc Then SaveCurrToolWnd = New EgtMsgBox(m_MainWindow, Me.ActualWidth / 15 * 5, EgtMsgBox.WidthType.PIXEL, "", EgtMsg(MSG_EGTMSGBOX + 2), EgtMsgBox.Buttons.YES_NO_CANCEL, EgtMsgBox.Icons.NULL) Else SaveCurrToolWnd = New EgtMsgBox(m_MainWindow, "", EgtMsg(MSG_EGTMSGBOX + 2), EgtMsgBox.Buttons.YES_NO_CANCEL, EgtMsgBox.Icons.NULL) End If Select Case SaveCurrToolWnd.m_nPressedBtn Case 0 ' Annulla Return False Case 1 ' Si EgtTdbSaveCurrTool() m_sToolName = NameTxBx.Text Dim CurrTool As CustomItem = TryCast(m_OldItem, CustomItem) If CurrTool IsNot Nothing Then CurrTool.Name = m_sToolName End If Case 2 ' No EgtTdbSetCurrTool(m_sToolName) GetToolParams() End Select End If Return True End Function Private Sub NameTxBx_EgtClosed(sender As Object, e As EventArgs) Handles NameTxBx.EgtClosed ' Elimino spazi iniziali e finali NameTxBx.Text = NameTxBx.Text.Trim() ' Se cambiato nome If NameTxBx.Text <> m_sToolName Then ' Imposto contesto macchina EgtSetCurrentContext(m_MainWindow.m_CurrentProjectPageUC.CurrentProjectScene.GetCtx()) ' Verifico se nome già esistente Dim TempName As String = NameTxBx.Text EgtTdbGetToolNewName(TempName) ' se già esistente, avviso e rifiuto If TempName <> NameTxBx.Text Then ' Nome già utilizzato Dim InfoBox As New EgtMsgBox(m_MainWindow, "", EgtMsg(91104), EgtMsgBox.Buttons.OK, EgtMsgBox.Icons.ESCLAMATION) ' Ripristino il precedente NameTxBx.Text = m_sToolName End If End If End Sub End Class