Files
EgtCAM5/MachineModel.vb
T
Emmanuele Sassi 2ee84a514d EgtCAM5 :
- Correzzione EgtSaveFile Dialog.
- Eliminazione Can da tutti i comandi dei bottoni nel programma.
2017-02-10 18:36:10 +00:00

137 lines
6.2 KiB
VB.net

Imports System.ComponentModel
Imports EgtUILib
Public Module MachineModel
#Region "Machining"
''' <summary>
''' Method that search the machines in the correct folder and add to the MachinesList those valid.
''' </summary>
Friend Function ReadActiveMachiningsFamilies() As MachiningsType()
Dim ActiveMachiningsFamiliesList As New List(Of MachiningsType)
If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_DRILLING, 0, m_sCurrMachIniFilePath) <> 0 Then
ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.DRILLING, .TypeName = EgtMsg(MSG_MACHININGSDBPAGE + 1)})
End If
If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_SAWING, 0, m_sCurrMachIniFilePath) <> 0 Then
ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.SAWING, .TypeName = EgtMsg(MSG_MACHININGSDBPAGE + 2)})
End If
If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_MILLING, 0, m_sCurrMachIniFilePath) <> 0 Then
ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.MILLING, .TypeName = EgtMsg(MSG_MACHININGSDBPAGE + 3)})
End If
If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_POCKETING, 0, m_sCurrMachIniFilePath) <> 0 Then
ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.POCKETING, .TypeName = EgtMsg(MSG_MACHININGSDBPAGE + 4)})
End If
If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_MORTISING, 0, m_sCurrMachIniFilePath) <> 0 Then
ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.MORTISING, .TypeName = EgtMsg(MSG_MACHININGSDBPAGE + 5)})
End If
If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_SAWROUGHING, 0, m_sCurrMachIniFilePath) <> 0 Then
ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.SAWROUGHING, .TypeName = EgtMsg(MSG_MACHININGSDBPAGE + 6)})
End If
If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_SAWFINISHING, 0, m_sCurrMachIniFilePath) <> 0 Then
ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.SAWFINISHING, .TypeName = EgtMsg(MSG_MACHININGSDBPAGE + 7)})
End If
If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_GENMACHINING, 0, m_sCurrMachIniFilePath) <> 0 Then
ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.GENMACHINING, .TypeName = EgtMsg(MSG_MACHININGSDBPAGE + 8)})
End If
If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_CHISELING, 0, m_sCurrMachIniFilePath) <> 0 Then
ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.CHISELING, .TypeName = EgtMsg(MSG_MACHININGSDBPAGE + 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
''' <summary>
''' Structure that represent a tool's family, containing family type and family name
''' </summary>
Public Class MachiningsType
Implements INotifyPropertyChanged
Friend TypeId As MCH_MY
Private m_TypeName As String
Public Property TypeName As String
Get
Return m_TypeName
End Get
Set(value As String)
m_TypeName = value
End Set
End Property
Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
Public Sub NotifyPropertyChanged(propName As String)
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propName))
End Sub
End Class
#End Region ' Machining
#Region "Tool"
''' <summary>
''' Method that search the machines in the correct folder and add to the MachinesList those valid.
''' </summary>
Friend Function ReadActiveToolsFamilies() As ToolsFamily()
Dim ActiveToolsFamiliesList As New List(Of ToolsFamily)
If EgtUILib.GetPrivateProfileInt(S_TOOLS, K_DRILLBIT, 0, m_sCurrMachIniFilePath) <> 0 Then
ActiveToolsFamiliesList.Add(New ToolsFamily(MCH_TF.DRILLBIT, EgtMsg(MSG_TOOLSDBPAGE + 1)))
End If
If EgtUILib.GetPrivateProfileInt(S_TOOLS, K_SAWBLADE, 0, m_sCurrMachIniFilePath) <> 0 Then
ActiveToolsFamiliesList.Add(New ToolsFamily(MCH_TF.SAWBLADE, EgtMsg(MSG_TOOLSDBPAGE + 2)))
End If
If EgtUILib.GetPrivateProfileInt(S_TOOLS, K_MILL, 0, m_sCurrMachIniFilePath) <> 0 Then
ActiveToolsFamiliesList.Add(New ToolsFamily(MCH_TF.MILL, EgtMsg(MSG_TOOLSDBPAGE + 3)))
End If
If EgtUILib.GetPrivateProfileInt(S_TOOLS, K_MORTISE, 0, m_sCurrMachIniFilePath) <> 0 Then
ActiveToolsFamiliesList.Add(New ToolsFamily(MCH_TF.MORTISE, EgtMsg(MSG_TOOLSDBPAGE + 4)))
End If
If EgtUILib.GetPrivateProfileInt(S_TOOLS, K_CHISEL, 0, m_sCurrMachIniFilePath) <> 0 Then
ActiveToolsFamiliesList.Add(New ToolsFamily(MCH_TF.CHISEL, EgtMsg(MSG_TOOLSDBPAGE + 9)))
End If
If EgtUILib.GetPrivateProfileInt(S_TOOLS, K_COMPO, 0, m_sCurrMachIniFilePath) <> 0 Then
ActiveToolsFamiliesList.Add(New ToolsFamily(MCH_TF.COMPO, EgtMsg(MSG_TOOLSDBPAGE + 5)))
End If
Return ActiveToolsFamiliesList.ToArray
End Function
''' <summary>
''' Structure that represent a tool's family, containing family type and family name
''' </summary>
Friend Class ToolsFamily
Private m_FamilyId As MCH_TF
Public ReadOnly Property FamilyId As MCH_TF
Get
Return m_FamilyId
End Get
End Property
Private m_FamilyName As String
Public ReadOnly Property FamilyName As String
Get
Return m_FamilyName
End Get
End Property
Sub New(nFamilyId As MCH_TF, sFamilyName As String)
m_FamilyId = nFamilyId
m_FamilyName = sFamilyName
End Sub
End Class
#End Region ' Tool
End Module