410 lines
11 KiB
VB.net
410 lines
11 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports System.Collections.Specialized
|
|
Imports System.ComponentModel
|
|
Imports System.IO
|
|
Imports System.Windows.Input
|
|
Imports System.Windows.Media
|
|
Imports EgtBEAMWALL.Core
|
|
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
|
|
Public MustInherit Class PartVM
|
|
Inherits VMBase
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
Protected m_PartM As PartM
|
|
Public ReadOnly Property PartM As PartM
|
|
Get
|
|
Return m_PartM
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ParentMachGroup As MyMachGroupM
|
|
Get
|
|
Return m_PartM.ParentMachGroup
|
|
End Get
|
|
End Property
|
|
|
|
' Id geometrico del pezzo
|
|
Public ReadOnly Property nPartId As Integer
|
|
Get
|
|
Return m_PartM.nPartId
|
|
End Get
|
|
End Property
|
|
|
|
' Proj del pezzo
|
|
Public Property nProjId As Integer
|
|
Get
|
|
Return m_PartM.nProjId
|
|
End Get
|
|
Set(value As Integer)
|
|
m_PartM.nProjId = value
|
|
End Set
|
|
End Property
|
|
|
|
' Info del pezzo
|
|
Public ReadOnly Property nPDN As Integer
|
|
Get
|
|
Return m_PartM.nPDN
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property sNAM As String
|
|
Get
|
|
Return m_PartM.sNAM
|
|
End Get
|
|
End Property
|
|
|
|
Public Property dL As Double
|
|
Get
|
|
Return m_PartM.dL
|
|
End Get
|
|
Set(value As Double)
|
|
m_PartM.dL = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property dW As Double
|
|
Get
|
|
Return m_PartM.dW
|
|
End Get
|
|
Set(value As Double)
|
|
m_PartM.dW = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property dH As Double
|
|
Get
|
|
Return m_PartM.dH
|
|
End Get
|
|
Set(value As Double)
|
|
m_PartM.dH = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property sPOSX As String
|
|
Get
|
|
Return LenToString(m_PartM.dPOSX, 3)
|
|
End Get
|
|
Set(value As String)
|
|
StringToLen(value, m_PartM.dPOSX)
|
|
End Set
|
|
End Property
|
|
Public Property dPOSX As Double
|
|
Get
|
|
Return m_PartM.dPOSX
|
|
End Get
|
|
Set(value As Double)
|
|
m_PartM.dPOSX = value
|
|
NotifyPropertyChanged(NameOf(sPOSX))
|
|
End Set
|
|
End Property
|
|
|
|
Public Property nCNT As Integer
|
|
Get
|
|
Return m_PartM.nCNT
|
|
End Get
|
|
Set(value As Integer)
|
|
m_PartM.nCNT = value
|
|
End Set
|
|
End Property
|
|
|
|
Public ReadOnly Property sINVERTED As String
|
|
Get
|
|
Return m_PartM.nINVERTED & "°"
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property sROTATED As String
|
|
Get
|
|
Return m_PartM.nROTATED & "°"
|
|
End Get
|
|
End Property
|
|
|
|
Public Property sMATERIAL As String
|
|
Get
|
|
Return m_PartM.sMATERIAL
|
|
End Get
|
|
Set(value As String)
|
|
m_PartM.sMATERIAL = value
|
|
End Set
|
|
End Property
|
|
|
|
Public ReadOnly Property nGlobalState As CalcStates
|
|
Get
|
|
Return m_PartM.nGlobalState
|
|
End Get
|
|
End Property
|
|
|
|
Public Property nState As CalcStates
|
|
Get
|
|
Return m_PartM.nState
|
|
End Get
|
|
Set(value As CalcStates)
|
|
m_PartM.nState = value
|
|
End Set
|
|
End Property
|
|
|
|
Public ReadOnly Property Calc_Background As SolidColorBrush
|
|
Get
|
|
If m_PartM.nGlobalState = 0 Then
|
|
Return Brushes.Green
|
|
ElseIf m_PartM.nGlobalState < 0 Then
|
|
Return Brushes.LightGray
|
|
ElseIf m_PartM.nGlobalState > 0 Then
|
|
Return Brushes.Red
|
|
Else
|
|
Return Brushes.Red
|
|
End If
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property nCALC_ERR As Integer
|
|
Get
|
|
Return m_PartM.nCALC_ERR
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property sCALC_MSG As String
|
|
Get
|
|
Return m_PartM.sCALC_MSG
|
|
End Get
|
|
End Property
|
|
|
|
Public Property nCALC_ROT As Integer
|
|
Get
|
|
Return m_PartM.nCALC_ROT
|
|
End Get
|
|
Set(value As Integer)
|
|
m_PartM.nCALC_ROT = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property nCALC_FALL As Integer
|
|
Get
|
|
Return m_PartM.nCALC_FALL
|
|
End Get
|
|
Set(value As Integer)
|
|
m_PartM.nCALC_FALL = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property nCALC_TIME As Integer
|
|
Get
|
|
Return m_PartM.nCALC_TIME
|
|
End Get
|
|
Set(value As Integer)
|
|
m_PartM.nCALC_TIME = value
|
|
End Set
|
|
End Property
|
|
|
|
' lista delle feature del pezzo
|
|
Protected m_FeatureVMList As ObservableCollection(Of BTLFeatureVM)
|
|
Public Property FeatureVMList As ObservableCollection(Of BTLFeatureVM)
|
|
Get
|
|
Return m_FeatureVMList
|
|
End Get
|
|
Set(value As ObservableCollection(Of BTLFeatureVM))
|
|
m_FeatureVMList = value
|
|
End Set
|
|
End Property
|
|
|
|
Protected m_SelFeatureVM As BTLFeatureVM
|
|
Public Property SelFeatureVM As BTLFeatureVM
|
|
Get
|
|
Return m_SelFeatureVM
|
|
End Get
|
|
Set(value As BTLFeatureVM)
|
|
m_SelFeatureVM = value
|
|
EgtDeselectAll()
|
|
If Not IsNothing(value) Then EgtSelectObj(m_SelFeatureVM.nFeatureId)
|
|
EgtDraw()
|
|
NotifyPropertyChanged(NameOf(m_SelFeatureVM))
|
|
End Set
|
|
End Property
|
|
|
|
Public Property dtStartTime As DateTime
|
|
Get
|
|
Return m_PartM.dtStartTime
|
|
End Get
|
|
Set(value As DateTime)
|
|
m_PartM.dtStartTime = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property dtEndTime As DateTime
|
|
Get
|
|
Return m_PartM.dtEndTime
|
|
End Get
|
|
Set(value As DateTime)
|
|
m_PartM.dtEndTime = value
|
|
End Set
|
|
End Property
|
|
|
|
' definizione comandi
|
|
Private m_cmdDeletePart As ICommand
|
|
|
|
#End Region ' FIELDS & PROPERTIES
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New(PartM As PartM)
|
|
m_PartM = PartM
|
|
AddHandler m_PartM.BTLFeatureAdded, AddressOf OnBTLFeatureAdded
|
|
CreateBTLFeatureVMList()
|
|
End Sub
|
|
'Sub New(nParentMachGroup As MyMachGroupM, nPartId As Integer)
|
|
' m_ParentMachGroup = nParentMachGroup
|
|
' SetPartId(nPartId)
|
|
' m_FeatureVMList = New ObservableCollection(Of BTLFeatureM)
|
|
'End Sub
|
|
|
|
#End Region ' CONSTRUCTOR
|
|
|
|
Private Sub CreateBTLFeatureVMList()
|
|
Dim all As List(Of BTLFeatureVM) = (From BTLFeatureM In m_PartM.GetBTLFeatures()
|
|
Select New BTLFeatureVM(BTLFeatureM)).ToList()
|
|
|
|
For Each BTLFeatureVM As BTLFeatureVM In all
|
|
AddHandler BTLFeatureVM.PropertyChanged, AddressOf OnBTLFeatureVMPropertyChanged
|
|
Next
|
|
|
|
m_FeatureVMList = New ObservableCollection(Of BTLFeatureVM)(all)
|
|
AddHandler m_FeatureVMList.CollectionChanged, AddressOf OnBTLFeatureVMListChanged
|
|
End Sub
|
|
|
|
' 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_PartM.nCALC_ERR = 0
|
|
m_PartM.nCALC_ROT = 0
|
|
m_PartM.nCALC_FALL = 0
|
|
m_PartM.sCALC_MSG = ""
|
|
Else
|
|
m_PartM.nCALC_ERR = ERR
|
|
m_PartM.nCALC_ROT = ROT
|
|
m_PartM.nCALC_FALL = 0
|
|
m_PartM.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(NameOf(Calc_Background))
|
|
End Sub
|
|
|
|
' funzione che aggiorna lo stato e gli errori dopo calcolo
|
|
Public Sub CalcFeatureUpdate()
|
|
m_PartM.nGlobalState = nState
|
|
For Each Feature In FeatureVMList
|
|
If Not Feature.bDO Then
|
|
|
|
ElseIf Feature.nState < 0 Then
|
|
m_PartM.nGlobalState = CalcStates.NOTCALCULATED
|
|
Exit For
|
|
ElseIf Feature.nState > 0 AndAlso m_PartM.nGlobalState = CalcStates.OK Then
|
|
m_PartM.nGlobalState = CalcStates.ERROR_
|
|
End If
|
|
Next
|
|
NotifyPropertyChanged(NameOf(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(m_PartM.nPartId)
|
|
' elimino pezzo copia
|
|
EgtErase(m_PartM.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.PartMList.IndexOf(Me)
|
|
'''If Index = 0 Then
|
|
''' If ParentMachGroup.PartMList.Count > 0 Then
|
|
''' ParentMachGroup.SelPart = ParentMachGroup.PartMList(0)
|
|
''' Else
|
|
''' ParentMachGroup.SelPart = Nothing
|
|
''' End If
|
|
'''ElseIf Index = ParentMachGroup.PartMList.Count - 1 Then
|
|
''' If ParentMachGroup.PartMList.Count > 1 Then
|
|
''' ParentMachGroup.SelPart = ParentMachGroup.PartMList(ParentMachGroup.PartMList.Count - 2)
|
|
''' Else
|
|
''' ParentMachGroup.SelPart = Nothing
|
|
''' End If
|
|
'''Else
|
|
''' ParentMachGroup.SelPart = ParentMachGroup.PartMList(Index - 1)
|
|
'''End If
|
|
'''ParentMachGroup.PartMList.Remove(Me)
|
|
End Sub
|
|
|
|
#End Region ' DeletePart
|
|
|
|
#End Region ' COMMANDS
|
|
|
|
|
|
#Region "EVENTS"
|
|
|
|
Private Sub OnBTLFeatureAdded(sender As Object, e As BTLFeatureAddedEventArgs)
|
|
Dim BTLFeatureVM As BTLFeatureVM = New BTLFeatureVM(e.NewBTLFeature)
|
|
FeatureVMList.Add(BTLFeatureVM)
|
|
End Sub
|
|
|
|
Private Sub OnBTLFeatureVMListChanged(sender As Object, e As NotifyCollectionChangedEventArgs)
|
|
If Not IsNothing(e.NewItems) AndAlso e.NewItems.Count > 0 Then
|
|
For Each BTLFeatureVM As BTLFeatureVM In e.NewItems
|
|
AddHandler BTLFeatureVM.PropertyChanged, AddressOf OnBTLFeatureVMPropertyChanged
|
|
Next
|
|
End If
|
|
If Not IsNothing(e.OldItems) AndAlso e.OldItems.Count > 0 Then
|
|
For Each BTLFeatureVM As BTLFeatureVM In e.OldItems
|
|
RemoveHandler BTLFeatureVM.PropertyChanged, AddressOf OnBTLFeatureVMPropertyChanged
|
|
Next
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub OnBTLFeatureVMPropertyChanged(sender As Object, e As PropertyChangedEventArgs)
|
|
'Select Case e.PropertyName
|
|
' Case NameOf(sender.nSelGRP), NameOf(sender.nSelSIDE)
|
|
'End Select
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
End Class
|