Imports System.Collections.ObjectModel Imports EgtUILib Imports EgtWPFLib5 Public Class ShellNumberParamPanelVM Inherits MachiningCathegory #Region "FIELDS & PROPERTIES" ' Definizione comandi Private m_cmdOk As ICommand Private m_cmdCancel As ICommand #End Region ' FIELDS & PROPERTIES #Region "CONSTRUCTORS" Sub New() ' Creo riferimento a questa classe in EgtCAM5Map Map.SetRefShellNumberParamPanelVM(Me) End Sub #End Region ' CONSTRUCTORS #Region "METHODS" Friend Sub Init() If IsNothing(Map.refShellNumberPanelVM.SelShellNumber) Then ' ripristino modalita' standard Map.refRightPanelVM.SetSelPanel(RightPanelVM.Panels.NULL) Return End If Dim nPartId As Integer = Map.refTopPanelVM.SelPart.nPartId Dim nShellNumberId As Integer = GDB_ID.NULL Select Case Map.refShellNumberPanelVM.SelShellNumber.Type Case RibEntity.RibTypes.FROMDRAW nShellNumberId = Map.refShellNumberPanelVM.SelShellNumber.nCurveId Case RibEntity.RibTypes.FROMIMPORT nShellNumberId = Map.refShellNumberPanelVM.SelShellNumber.nExtrusionId End Select m_Type = Cathegories.SHELL_NUMBER m_sName = "Reduce Shell Number" m_MachiningParamList = New List(Of MachiningParam)({New ShellNumberNumericMachiningParam(MachiningParam.Params.SHELLNBRDIFFERENCE, nShellNumberId, nPartId), New ShellNumberNumericMachiningParam(MachiningParam.Params.SHELLNBRCOASTING, nShellNumberId, nPartId), New ShellNumberNumericMachiningParam(MachiningParam.Params.SHELLNBRWIPE, nShellNumberId, nPartId), New ShellNumberNumericMachiningParam(MachiningParam.Params.SHELLNBRWIPEDIR, nShellNumberId, nPartId)}) NotifyPropertyChanged(NameOf(MachiningParamList)) NotifyPropertyChanged(NameOf(sName)) End Sub Friend Sub SaveCurrParams() For Each Param In m_MachiningParamList Param.SaveParam() Next End Sub Friend Sub ResetCurrParams() For Each Param In m_MachiningParamList Param.ResetParam() Next End Sub Friend Sub WriteParamsInShellNumber(nRibId As Integer) ' se parametri modificati Dim bModified As Boolean = False For Each Param As ShellNumberNumericMachiningParam In m_MachiningParamList If Param.bIsModified AndAlso Not bModified Then bModified = True Param.WriteParamInShellNumber(nRibId) Next If bModified Then ' Imposto flag di ricalcolo slice EgtSetInfo(Map.refTopPanelVM.SelPart.nPartId, MAC_TORECALC_SLICE, True) End If End Sub #End Region ' METHODS #Region "COMMANDS" #Region "Ok" Public ReadOnly Property Ok_Command As ICommand Get If m_cmdOk Is Nothing Then m_cmdOk = New Command(AddressOf Ok) End If Return m_cmdOk End Get End Property Public Sub Ok() If Not IsNothing(Map.refShellNumberPanelVM.SelShellNumber) Then ' scrivo i parametri modificati Select Case Map.refShellNumberPanelVM.SelShellNumber.Type Case ShellNumberEntity.ShellNumberTypes.FROMDRAW WriteParamsInShellNumber(Map.refShellNumberPanelVM.SelShellNumber.nCurveId) WriteParamsInShellNumber(Map.refShellNumberPanelVM.SelShellNumber.nExtrusionId) Case ShellNumberEntity.ShellNumberTypes.FROMIMPORT WriteParamsInShellNumber(Map.refShellNumberPanelVM.SelShellNumber.nExtrusionId) End Select End If ' ripristino modalita' standard Map.refRightPanelVM.SetSelPanel(RightPanelVM.Panels.NULL) Map.refShellNumberPanelVM.ResetMachParamIsChecked() End Sub #End Region ' Ok #Region "Cancel" Public ReadOnly Property Cancel_Command As ICommand Get If m_cmdCancel Is Nothing Then m_cmdCancel = New Command(AddressOf Cancel) End If Return m_cmdCancel End Get End Property Public Sub Cancel() ' ripristino modalita' standard Map.refRightPanelVM.SetSelPanel(RightPanelVM.Panels.NULL) Map.refShellNumberPanelVM.ResetMachParamIsChecked() End Sub #End Region ' Cancel #End Region ' COMMANDS End Class Public Class ShellNumberNumericMachiningParam Inherits NumericMachiningParam Public Overrides Property sValue As String Get Return If(m_bIsLen, LenToString(m_dValue, 1), m_dValue) End Get Set(value As String) If m_bIsLen Then StringToLen(value, m_dValue) Else m_dValue = value End If NotifyPropertyChanged(NameOf(sValue)) NotifyPropertyChanged(NameOf(bIsModifiedFromPart)) End Set End Property Private m_dPartValue As Double Public ReadOnly Property dPartValue As Double Get Return m_dPartValue End Get End Property Public ReadOnly Property bIsModifiedFromPart As Boolean Get Return m_dValue <> m_dPartValue End Get End Property ' Definizione comandi Private m_cmdResetParam As ICommand Sub New(Type As Params, nShellNumberId As Integer, nPartId As Integer) MyBase.New(Type) Dim bReadFromPart As Boolean = False Select Case Type Case Params.SHELLNBRDIFFERENCE bReadFromPart = EgtGetInfo(nShellNumberId, MAC_SHELLNBRDIFFERENCE, m_dValue) EgtGetInfo(nPartId, MAC_SHELLNBRDIFFERENCE, m_dPartValue) m_bIsLen = True Case Params.SHELLNBRCOASTING bReadFromPart = EgtGetInfo(nShellNumberId, MAC_SHELLNBRCOASTING, m_dValue) EgtGetInfo(nPartId, MAC_SHELLNBRCOASTING, m_dPartValue) m_bIsLen = True Case Params.SHELLNBRWIPE bReadFromPart = EgtGetInfo(nShellNumberId, MAC_SHELLNBRWIPE, m_dValue) EgtGetInfo(nPartId, MAC_SHELLNBRWIPE, m_dPartValue) m_bIsLen = True Case Params.SHELLNBRWIPEDIR bReadFromPart = EgtGetInfo(nShellNumberId, MAC_SHELLNBRWIPEDIR, m_dValue) EgtGetInfo(nPartId, MAC_SHELLNBRWIPEDIR, m_dPartValue) m_bIsLen = True End Select m_dOrigValue = m_dValue If Not bReadFromPart Then m_dValue = m_dPartValue m_dOrigValue = m_dPartValue End If End Sub Friend Sub WriteParamInShellNumber(nShellNumberId As Integer) Dim sWriteValue As String = "" If m_bIsLen Then sWriteValue = LenToString(m_dValue, 2) Else sWriteValue = DoubleToString(m_dValue, 2) End If Select Case Type Case Params.SHELLNBRDIFFERENCE If bIsModifiedFromPart Then EgtSetInfo(nShellNumberId, MAC_SHELLNBRDIFFERENCE, sWriteValue) Else EgtRemoveInfo(nShellNumberId, MAC_SHELLNBRDIFFERENCE) End If Case Params.SHELLNBRCOASTING If bIsModifiedFromPart Then EgtSetInfo(nShellNumberId, MAC_SHELLNBRCOASTING, sWriteValue) Else EgtRemoveInfo(nShellNumberId, MAC_SHELLNBRCOASTING) End If Case Params.SHELLNBRWIPE If bIsModifiedFromPart Then EgtSetInfo(nShellNumberId, MAC_SHELLNBRWIPE, sWriteValue) Else EgtRemoveInfo(nShellNumberId, MAC_SHELLNBRWIPE) End If Case Params.SHELLNBRWIPEDIR If bIsModifiedFromPart Then EgtSetInfo(nShellNumberId, MAC_SHELLNBRWIPEDIR, sWriteValue) Else EgtRemoveInfo(nShellNumberId, MAC_SHELLNBRWIPEDIR) End If End Select End Sub Friend Overrides Sub SaveParam() m_dOrigValue = m_dValue End Sub Friend Overrides Sub ResetParam() m_dValue = m_dOrigValue End Sub #Region "COMMANDS" #Region "ResetParam" Public ReadOnly Property ResetParam_Command As ICommand Get If m_cmdResetParam Is Nothing Then m_cmdResetParam = New Command(AddressOf ResetParamCmd) End If Return m_cmdResetParam End Get End Property Public Sub ResetParamCmd() m_dValue = m_dPartValue NotifyPropertyChanged(NameOf(sValue)) NotifyPropertyChanged(NameOf(bIsModifiedFromPart)) End Sub #End Region ' ResetParam #End Region ' COMMANDS End Class