Imports System.IO Imports EgtUILib Public Module MachineUtility #Region "Machining" ''' ''' Method that search the machines in the correct folder and add to the MachinesList those valid. ''' Public Function ReadMachiningFamilies(sMachineIniPath As String) As MachiningsType() Dim ActiveMachiningsFamiliesList As New List(Of MachiningsType) If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_DRILLING, 0, sMachineIniPath) <> 0 Then ActiveMachiningsFamiliesList.Add(New MachiningsType With {.Id = MCH_MY.DRILLING, .Name = EgtMsg(MSG_MACHININGDB + 1)}) End If If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_SAWING, 0, sMachineIniPath) <> 0 Then ActiveMachiningsFamiliesList.Add(New MachiningsType With {.Id = MCH_MY.SAWING, .Name = EgtMsg(MSG_MACHININGDB + 2)}) End If If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_MILLING, 0, sMachineIniPath) <> 0 Then ActiveMachiningsFamiliesList.Add(New MachiningsType With {.Id = MCH_MY.MILLING, .Name = EgtMsg(MSG_MACHININGDB + 3)}) End If If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_POCKETING, 0, sMachineIniPath) <> 0 Then ActiveMachiningsFamiliesList.Add(New MachiningsType With {.Id = MCH_MY.POCKETING, .Name = EgtMsg(MSG_MACHININGDB + 4)}) End If If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_MORTISING, 0, sMachineIniPath) <> 0 Then ActiveMachiningsFamiliesList.Add(New MachiningsType With {.Id = MCH_MY.MORTISING, .Name = EgtMsg(MSG_MACHININGDB + 5)}) End If If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_SAWROUGHING, 0, sMachineIniPath) <> 0 Then ActiveMachiningsFamiliesList.Add(New MachiningsType With {.Id = MCH_MY.SAWROUGHING, .Name = EgtMsg(MSG_MACHININGDB + 6)}) End If If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_SAWFINISHING, 0, sMachineIniPath) <> 0 Then ActiveMachiningsFamiliesList.Add(New MachiningsType With {.Id = MCH_MY.SAWFINISHING, .Name = EgtMsg(MSG_MACHININGDB + 7)}) End If If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_GENMACHINING, 0, sMachineIniPath) <> 0 Then ActiveMachiningsFamiliesList.Add(New MachiningsType With {.Id = MCH_MY.GENMACHINING, .Name = EgtMsg(MSG_MACHININGDB + 8)}) End If If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_CHISELING, 0, sMachineIniPath) <> 0 Then ActiveMachiningsFamiliesList.Add(New MachiningsType With {.Id = MCH_MY.CHISELING, .Name = EgtMsg(MSG_MACHININGDB + 9)}) End If Return ActiveMachiningsFamiliesList.ToArray End Function 'Friend Sub LoadMachiningListByType(MachiningList As List(Of String), nType As MCH_MY) ' Dim MachiningName As String = String.Empty ' EgtMdbGetFirstMachining(nType, MachiningName) ' While Not String.IsNullOrWhiteSpace(MachiningName) ' MachiningList.Add(MachiningName) ' EgtMdbGetNextMachining(nType, MachiningName) ' End While 'End Sub '' Funzione che imposta la macchina corrente se la trova, altrimenti chiede se ricaricarla o annullare 'Friend Function EgtTrySettingCurrMachine(sMachineName As String) As Boolean ' If EgtSetCurrMachine(sMachineName) Then ' Return True ' End If ' If MessageBox.Show(String.Format(EgtMsg(MSG_DOORSERRORS + 13) & Environment.NewLine & EgtMsg(MSG_DOORSERRORS + 14), sMachineName), EgtMsg(MSG_MESSAGEBOX + 1), MessageBoxButton.YesNo, MessageBoxImage.Error) = MessageBoxResult.Yes Then ' Return EgtTrySettingCurrMachine(sMachineName) ' End If ' Return False 'End Function ' Funzione che verifica l'esistenza e la connessione della cartella Machines Public Function VerifyMachinesDir(sMachinesDirPath As String) As Boolean ' verifico l'esistenza della cartella Machines If String.IsNullOrWhiteSpace(sMachinesDirPath) Then Return False End If Return RecursiveVerifyMachinesDir(sMachinesDirPath) End Function Private Function RecursiveVerifyMachinesDir(sMachinesDirPath As String) As Boolean If Directory.Exists(sMachinesDirPath) Then Return True Else If MessageBox.Show(String.Format(EgtMsg(MSG_DOORSERRORS + 13) & Environment.NewLine & EgtMsg(MSG_DOORSERRORS + 14), sMachinesDirPath), EgtMsg(MSG_MESSAGEBOX + 1), MessageBoxButton.YesNo, MessageBoxImage.Error) = MessageBoxResult.Yes Then Return RecursiveVerifyMachinesDir(sMachinesDirPath) End If Return False End If End Function ''' ''' Structure that represent a machining's family, containing family type and family name ''' Public Class MachiningsType Inherits VMBase Public Id As MCH_MY Private m_Name As String Public Property Name As String Get Return m_Name End Get Set(value As String) m_Name = value End Set End Property End Class #End Region ' Machining #Region "Tool" ''' ''' Method that search the machines in the correct folder and add to the MachinesList those valid. ''' Friend Function ReadToolFamilies(sMachineIniPath As String) As ToolsFamily() Dim ActiveToolsFamiliesList As New List(Of ToolsFamily) If EgtUILib.GetPrivateProfileInt(S_TOOLS, K_DRILLBIT, 0, sMachineIniPath) <> 0 Then ActiveToolsFamiliesList.Add(New ToolsFamily(MCH_TF.DRILLBIT, EgtMsg(MSG_TOOLDB + 1))) End If If EgtUILib.GetPrivateProfileInt(S_TOOLS, K_SAWBLADE, 0, sMachineIniPath) <> 0 Then ActiveToolsFamiliesList.Add(New ToolsFamily(MCH_TF.SAWBLADE, EgtMsg(MSG_TOOLDB + 2))) End If If EgtUILib.GetPrivateProfileInt(S_TOOLS, K_MILL, 0, sMachineIniPath) <> 0 Then ActiveToolsFamiliesList.Add(New ToolsFamily(MCH_TF.MILL, EgtMsg(MSG_TOOLDB + 3))) End If If EgtUILib.GetPrivateProfileInt(S_TOOLS, K_MORTISE, 0, sMachineIniPath) <> 0 Then ActiveToolsFamiliesList.Add(New ToolsFamily(MCH_TF.MORTISE, EgtMsg(MSG_TOOLDB + 4))) End If If EgtUILib.GetPrivateProfileInt(S_TOOLS, K_CHISEL, 0, sMachineIniPath) <> 0 Then ActiveToolsFamiliesList.Add(New ToolsFamily(MCH_TF.CHISEL, EgtMsg(MSG_TOOLDB + 9))) End If If EgtUILib.GetPrivateProfileInt(S_TOOLS, K_COMPO, 0, sMachineIniPath) <> 0 Then ActiveToolsFamiliesList.Add(New ToolsFamily(MCH_TF.COMPO, EgtMsg(MSG_TOOLDB + 5))) End If Return ActiveToolsFamiliesList.ToArray End Function ''' ''' Structure that represent a tool's family, containing family type and family name ''' Friend Class ToolsFamily Private m_Id As MCH_TF Public ReadOnly Property Id As MCH_TF Get Return m_Id End Get End Property Private m_Name As String Public ReadOnly Property Name As String Get Return m_Name End Get End Property Sub New(nFamilyId As MCH_TF, sFamilyName As String) m_Id = nFamilyId m_Name = sFamilyName End Sub End Class #End Region ' Tool End Module