Files
egtbeamwall/EgtBEAMWALL.Core/Part.vb
T
Emmanuele Sassi 268f7c412f Corretto Proj in Part
Aggiornamenti per gestione Prod
2021-03-05 18:32:45 +01:00

363 lines
9.1 KiB
VB.net

Imports System.Collections.ObjectModel
Imports System.IO
Imports System.Windows.Input
Imports System.Windows.Media
Imports EgtUILib
Imports EgtWPFLib5
Public MustInherit Class Part
Inherits VMBase
#Region "FIELDS & PROPERTIES"
Protected m_ParentMachGroup As MyMachGroup
Public ReadOnly Property ParentMachGroup As MyMachGroup
Get
Return m_ParentMachGroup
End Get
End Property
' Id geometrico del pezzo
Protected m_nPartId As Integer
Public ReadOnly Property nPartId As Integer
Get
Return m_nPartId
End Get
End Property
Friend Sub SetPartId(nPartId As Integer)
m_nPartId = nPartId
End Sub
' Proj del pezzo
Protected m_nProjId As Integer = 0
Public Property nProjId As Integer
Get
Return m_nProjId
End Get
Set(value As Integer)
m_nProjId = value
End Set
End Property
' Info del pezzo
Protected m_nPDN As Integer
Public ReadOnly Property nPDN As Integer
Get
Return m_nPDN
End Get
End Property
Protected m_sNAM As String
Public ReadOnly Property sNAM As String
Get
Return m_sNAM
End Get
End Property
Protected m_dL As Double
Public Property dL As Double
Get
Return m_dL
End Get
Set(value As Double)
m_dL = value
End Set
End Property
Protected m_dW As Double
Public Property dW As Double
Get
Return m_dW
End Get
Set(value As Double)
m_dW = value
End Set
End Property
Protected m_dH As Double
Public Property dH As Double
Get
Return m_dH
End Get
Set(value As Double)
m_dH = value
End Set
End Property
Protected m_dPOSX As Double
Public Property sPOSX As String
Get
Return LenToString(m_dPOSX, 3)
End Get
Set(value As String)
StringToLen(value, m_dPOSX)
End Set
End Property
Public Property dPOSX As Double
Get
Return m_dPOSX
End Get
Set(value As Double)
m_dPOSX = value
NotifyPropertyChanged("sPOSX")
End Set
End Property
Protected m_nCNT As Integer
Public Property nCNT As Integer
Get
Return m_nCNT
End Get
Set(value As Integer)
m_nCNT = value
End Set
End Property
Protected m_nINVERTED As Integer
Public ReadOnly Property sINVERTED As String
Get
Return m_nINVERTED & "°"
End Get
End Property
Public Sub SetInverted(nInverted As Integer)
m_nINVERTED = nInverted
End Sub
Protected m_nROTATED As Integer
Public ReadOnly Property sROTATED As String
Get
Return m_nROTATED & "°"
End Get
End Property
Public Sub SetRotated(nRotated As Integer)
m_nROTATED = nRotated
End Sub
Protected m_sMATERIAL As String
Public Property sMATERIAL As String
Get
Return m_sMATERIAL
End Get
Set(value As String)
m_sMATERIAL = value
End Set
End Property
Protected m_nGlobalState As CalcStates = -1
Public ReadOnly Property nGlobalState As CalcStates
Get
Return m_nGlobalState
End Get
End Property
Protected m_nState As CalcStates = -1
Public Property nState As CalcStates
Get
Return m_nState
End Get
Set(value As CalcStates)
m_nState = value
End Set
End Property
Public ReadOnly Property Calc_Background As SolidColorBrush
Get
If m_nGlobalState = 0 Then
Return Brushes.Green
ElseIf m_nGlobalState < 0 Then
Return Brushes.LightGray
ElseIf m_nGlobalState > 0 Then
Return Brushes.Red
End If
End Get
End Property
Protected m_nCALC_ERR As Integer
Public ReadOnly Property nCALC_ERR As Integer
Get
Return m_nCALC_ERR
End Get
End Property
Protected m_sCALC_MSG As String = String.Empty
Public ReadOnly Property nCALC_MSG As String
Get
Return m_sCALC_MSG
End Get
End Property
Protected m_nCALC_ROT As Integer
Public Property nCALC_ROT As Integer
Get
Return m_nCALC_ROT
End Get
Set(value As Integer)
m_nCALC_ROT = value
End Set
End Property
Protected m_nCALC_FALL As Integer
Public Property nCALC_FALL As Integer
Get
Return m_nCALC_FALL
End Get
Set(value As Integer)
m_nCALC_FALL = value
End Set
End Property
Protected m_nCALC_TIME As Integer
Public Property nCALC_TIME As Integer
Get
Return m_nCALC_TIME
End Get
Set(value As Integer)
m_nCALC_TIME = value
End Set
End Property
' lista delle feature del pezzo
Protected m_FeatureList As ObservableCollection(Of BTLFeature)
Public Property FeatureList As ObservableCollection(Of BTLFeature)
Get
Return m_FeatureList
End Get
Set(value As ObservableCollection(Of BTLFeature))
m_FeatureList = value
End Set
End Property
Protected m_SelFeature As BTLFeature
Public Property SelFeature As Core.BTLFeature
Get
Return m_SelFeature
End Get
Set(value As Core.BTLFeature)
m_SelFeature = value
EgtDeselectAll()
If Not IsNothing(value) Then EgtSelectObj(m_SelFeature.nFeatureId)
EgtDraw()
NotifyPropertyChanged("SelFeature")
End Set
End Property
' definizione comandi
Private m_cmdDeletePart As ICommand
#End Region ' FIELDS & PROPERTIES
#Region "CONSTRUCTOR"
Sub New(nParentMachGroup As MyMachGroup, nPartId As Integer)
m_ParentMachGroup = nParentMachGroup
SetPartId(nPartId)
m_FeatureList = New ObservableCollection(Of BTLFeature)
End Sub
#End Region ' CONSTRUCTOR
' funzione che aggiorna lo stato e gli errori dopo calcolo
Public Sub CalcPartUpdate(bCalc As Boolean, ERR As Integer, ROT As Integer, FALL As Integer, MSG As String)
If Not bCalc Then
nState = CalcStates.NOTCALCULATED
m_nCALC_ERR = 0
m_nCALC_ROT = 0
m_nCALC_FALL = 0
m_sCALC_MSG = ""
Else
m_nCALC_ERR = ERR
m_nCALC_ROT = ROT
m_nCALC_FALL = 0
m_sCALC_MSG = MSG
If ERR = 0 Then
nState = CalcStates.OK
ElseIf ERR > 1 Then
nState = CalcStates.ERROR_
ElseIf ERR < 1 Then
nState = CalcStates.NOTCALCULATED
End If
End If
NotifyPropertyChanged("Calc_Background")
End Sub
' funzione che aggiorna lo stato e gli errori dopo calcolo
Public Sub CalcFeatureUpdate()
m_nGlobalState = nState
For Each Feature In FeatureList
If Not Feature.bDO Then
ElseIf Feature.nState < 0 Then
m_nGlobalState = CalcStates.NOTCALCULATED
Exit For
ElseIf Feature.nState > 0 AndAlso m_nGlobalState = CalcStates.OK Then
m_nGlobalState = CalcStates.ERROR_
End If
Next
NotifyPropertyChanged("Calc_Background")
End Sub
#Region "COMMANDS"
#Region "DeletePart"
' Returns a command that manage the MainWindow_Unloaded command
Public ReadOnly Property DeletePart_Command() As ICommand
Get
If m_cmdDeletePart Is Nothing Then
m_cmdDeletePart = New Command(AddressOf DeletePart)
End If
Return m_cmdDeletePart
End Get
End Property
' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded.
Public Overridable Sub DeletePart()
EgtRemovePartFromRawPart(Me.m_nPartId)
' elimino pezzo copia
EgtErase(Me.m_nPartId)
' elimino info pezzo su mach group
Dim sInfo As String = ""
Dim Index As Integer = 1
Dim sSplitInfo() As String
Dim bFound As Boolean = False
While EgtGetInfo(m_ParentMachGroup.Id, MGR_RPT_PART & Index, sInfo)
If Not String.IsNullOrWhiteSpace(sInfo) Then
sSplitInfo = sInfo.Split(","c)
If bFound Then
EgtSetInfo(m_ParentMachGroup.Id, MGR_RPT_PART & Index - 1, sInfo)
End If
If sSplitInfo(0) = nPartId Then
bFound = True
End If
End If
Index += 1
End While
If bFound Then
EgtSetInfo(m_ParentMachGroup.Id, MGR_RPT_PART & Index - 1, "")
End If
' rimuovo dalla lista pezzi
Index = ParentMachGroup.PartList.IndexOf(Me)
If Index = 0 Then
If ParentMachGroup.PartList.Count > 0 Then
ParentMachGroup.SelPart = ParentMachGroup.PartList(0)
Else
ParentMachGroup.SelPart = Nothing
End If
ElseIf Index = ParentMachGroup.PartList.Count - 1 Then
If ParentMachGroup.PartList.Count > 1 Then
ParentMachGroup.SelPart = ParentMachGroup.PartList(ParentMachGroup.PartList.Count - 2)
Else
ParentMachGroup.SelPart = Nothing
End If
Else
ParentMachGroup.SelPart = ParentMachGroup.PartList(Index - 1)
End If
ParentMachGroup.PartList.Remove(Me)
End Sub
#End Region ' DeletePart
#End Region ' COMMANDS
End Class