Files
egtbeamwall/EgtBEAMWALL.Supervisor/BTLParam/BTLFeatureVM.vb
T
2021-04-15 20:06:18 +02:00

536 lines
17 KiB
VB.net

Imports System.Collections.ObjectModel
Imports System.Collections.Specialized
Imports System.ComponentModel
Imports EgtBEAMWALL.Core
Imports EgtUILib
Imports EgtWPFLib5
Public Class BTLFeatureVM
Inherits VMBase
Private WithEvents m_BTLFeatureM As BTLFeatureM
Public ReadOnly Property BTLFeatureM As BTLFeatureM
Get
Return m_BTLFeatureM
End Get
End Property
Private m_BTLPartM As BTLPartM
Public ReadOnly Property nFeatureId As Integer
Get
Return m_BTLFeatureM.nFeatureId
End Get
End Property
Public Property GRPList As ObservableCollection(Of Integer)
Get
Return m_BTLFeatureM.GRPList
End Get
Set(value As ObservableCollection(Of Integer))
m_BTLFeatureM.GRPList = value
End Set
End Property
Public Property nSelGRP As Integer
Get
Return m_BTLFeatureM.nSelGRP
End Get
Set(value As Integer)
If value <> -1 Then
' aggiorno la feature con nuovo valore
Dim vPar() As Double = Nothing
Dim sPar As String = String.Empty
m_BTLFeatureM.CalcParamArray(vPar, sPar)
Dim bOK As Boolean = m_BTLFeatureM.UpdateParams(value, m_BTLFeatureM.nPRC, nSelSIDE, m_BTLFeatureM.sDES, m_BTLFeatureM.nPRID, m_BTLFeatureM.frFRAME, vPar, sPar)
If bOK Then
m_BTLFeatureM.nSelGRP = value
' seleziono feature in disegno
SelGeomFeature()
' rendo non calcolata questa feature
CalcFeatureUpdate(False, 0, 0, 0, "")
Else
NotifyPropertyChanged("nSelGRP")
End If
NotifyPropertyChanged(NameOf(nSelGRP))
EgtDraw()
End If
End Set
End Property
Friend ReadOnly Property sDescGRP As String
Get
Dim sDescConstruction As String = String.Empty
If CalcBeamPrivateProfileGRP(m_BTLFeatureM.nSelGRP) = 0 Then
sDescConstruction = "L"
Else
sDescConstruction = "T"
End If
sDescConstruction &= m_BTLFeatureM.nPRC.ToString("000")
Return sDescConstruction
End Get
End Property
Public Property nPRC As Integer
Get
Return m_BTLFeatureM.nPRC
End Get
Set(value As Integer)
m_BTLFeatureM.nPRC = value
End Set
End Property
Public Property SIDEList As ObservableCollection(Of Integer)
Get
Return m_BTLFeatureM.SIDEList
End Get
Set(value As ObservableCollection(Of Integer))
m_BTLFeatureM.SIDEList = value
End Set
End Property
' Lato
Public Property nSelSIDE As Integer
Get
Return m_BTLFeatureM.nSelSIDE
End Get
Set(value As Integer)
If value <> -1 Then
' aggiorno la feature con nuovo valore
Dim vPar() As Double = Nothing
Dim sPar As String = String.Empty
m_BTLFeatureM.CalcParamArray(vPar, sPar)
Dim bOK As Boolean = m_BTLFeatureM.UpdateParams(nSelGRP, m_BTLFeatureM.nPRC, value, m_BTLFeatureM.sDES, m_BTLFeatureM.nPRID, m_BTLFeatureM.frFRAME, vPar, sPar)
If bOK Then
m_BTLFeatureM.nSelSIDE = value
SelGeomFeature()
' rendo non calcolata questa feature
CalcFeatureUpdate(False, 0, 0, 0, "")
Else
NotifyPropertyChanged("nSelGRP")
End If
EgtDraw()
End If
End Set
End Property
Public ReadOnly Property sName As String
Get
Return m_BTLFeatureM.sName
End Get
End Property
Public Property bDO As Boolean
Get
Return m_BTLFeatureM.bDO
End Get
Set(value As Boolean)
If EgtBeamEnableProcess(nFeatureId, value) Then
m_BTLFeatureM.bDO = value
EgtDraw()
NotifyPropertyChanged("Calc_Background")
NotifyPropertyChanged("bDO")
End If
End Set
End Property
Public Property nPRID As Integer
Get
Return m_BTLFeatureM.nPRID
End Get
Set(value As Integer)
m_BTLFeatureM.nPRID = value
End Set
End Property
Public Property sDES As String
Get
Return m_BTLFeatureM.sDES
End Get
Set(value As String)
m_BTLFeatureM.sDES = value
End Set
End Property
Public Property frFRAME As Frame3d
Get
Return m_BTLFeatureM.frFRAME
End Get
Set(value As Frame3d)
m_BTLFeatureM.frFRAME = value
End Set
End Property
' proprieta' che mostra la descrizione in interfaccia
Public ReadOnly Property sDesc As String
Get
Return sDescGRP & " " & sName
End Get
End Property
Public ReadOnly Property sDrawPath As String
Get
Return Map.refMainWindowVM.MainWindowM.sResourcesRoot & "\Features\" & sDescGRP & ".png"
End Get
End Property
Public ReadOnly Property nState As CalcStates
Get
Return m_BTLFeatureM.nState
End Get
End Property
Public ReadOnly Property nCALC_ERR As Integer
Get
Return m_BTLFeatureM.nCALC_ERR
End Get
End Property
Public ReadOnly Property nCALC_ROT As Integer
Get
Return m_BTLFeatureM.nCALC_ROT
End Get
End Property
Public ReadOnly Property nCALC_FALL As Integer
Get
Return m_BTLFeatureM.nCALC_FALL
End Get
End Property
Public ReadOnly Property nCALC_MSG As String
Get
Return m_BTLFeatureM.sCALC_MSG
End Get
End Property
Public ReadOnly Property Calc_Background As SolidColorBrush
Get
If Not m_BTLFeatureM.bDO Then
Return Brushes.Aqua
ElseIf m_BTLFeatureM.nState = 0 Then
Return Brushes.Green
ElseIf m_BTLFeatureM.nState < 0 Then
Return Brushes.LightGray
ElseIf m_BTLFeatureM.nState > 0 Then
Return Brushes.Red
Else
Return Brushes.Red
End If
End Get
End Property
Public ReadOnly Property CALC_ROT_Visibility As Visibility
Get
Return If(m_BTLFeatureM.nCALC_ROT <> 0, Visibility.Visible, Visibility.Collapsed)
End Get
End Property
Public ReadOnly Property CALC_FALL_Visibility As Visibility
Get
Return If(m_BTLFeatureM.nCALC_FALL <> 0, Visibility.Visible, Visibility.Collapsed)
End Get
End Property
Public ReadOnly Property CALC_ERR_Letter As String
Get
Select Case m_BTLFeatureM.nCALC_ERR
Case 22
Return "c"
Case 19, 23, 24, 25
Return "e"
Case 17
Return "w"
Case < 0
Return "i"
Case Else
Return ""
End Select
End Get
End Property
Public ReadOnly Property CALC_ERR_Foreground As SolidColorBrush
Get
Select Case m_BTLFeatureM.nCALC_ERR
Case 19, 22, 23, 24, 25
Return Brushes.Red
Case 17
Return Brushes.Orange
Case < 0
Return Brushes.Green
Case Else
Return Brushes.Red
End Select
End Get
End Property
'Private m_PBTLParamVMList As ObservableCollection(Of BTLParamVM)
'Public Property PBTLParamVMList As ObservableCollection(Of BTLParamVM)
' Get
' Return m_PBTLParamVMList
' End Get
' Set(value As ObservableCollection(Of BTLParamVM))
' m_PBTLParamVMList = value
' End Set
'End Property
'Protected m_SelPBTLParam As BTLParamVM
'Public Property SelPBTLParam As BTLParamVM
' Get
' Return m_SelPBTLParam
' End Get
' Set(value As BTLParamVM)
' m_SelPBTLParam = value
' If Not IsNothing(m_SelPBTLParam) Then
' ' imposto path disegno da mostrare in BottomPanel
' Map.refBottomPanelVM.SetCurrDraw(sDrawPath)
' End If
' NotifyPropertyChanged(NameOf(SelPBTLParam))
' End Set
'End Property
'Private m_QBTLParamVMList As ObservableCollection(Of BTLParamVM)
'Public Property QBTLParamVMList As ObservableCollection(Of BTLParamVM)
' Get
' Return m_QBTLParamVMList
' End Get
' Set(value As ObservableCollection(Of BTLParamVM))
' m_QBTLParamVMList = value
' End Set
'End Property
'Protected m_SelQParam As BTLParamVM
'Public Property SelQBTLParam As BTLParamVM
' Get
' Return m_SelQParam
' End Get
' Set(value As BTLParamVM)
' m_SelQParam = value
' If Not IsNothing(m_SelQParam) Then
' ' imposto path disegno da mostrare in BottomPanel
' Map.refBottomPanelVM.SetCurrDraw(sDrawPath)
' End If
' NotifyPropertyChanged(NameOf(SelQBTLParam))
' End Set
'End Property
' Definizione comandi
Private m_cmdDeleteFeature As ICommand
#Region "CONSTRUCTOR"
'Sub New(ParentPart As BTLPartVM, nFeatureId As Integer)
' MyBase.New(ParentPart, nFeatureId)
' ' leggo gruppo, numero feature e lato
' EgtGetInfo(nFeatureId, BTL_FTR_GRP, m_nSelGRP)
' EgtGetInfo(nFeatureId, BTL_FTR_PRC, m_nPRC)
' EgtGetInfo(nFeatureId, BTL_FTR_SIDE, m_nSelSIDE)
' Dim nDO As Integer = 1
' If EgtGetInfo(nFeatureId, BTL_FTR_DO, nDO) Then
' m_bDO = (nDO <> 0)
' Else
' m_bDO = True
' End If
' ' leggo des,prid e frame
' EgtGetInfo(nFeatureId, BTL_FTR_DES, m_sDES)
' EgtGetInfo(nFeatureId, BTL_FTR_PRID, m_nPRID)
' EgtGetInfo(nFeatureId, BTL_FTR_FRAME, m_frFRAME)
' ' leggo calc error
' Dim nErr As Integer = 0
' Dim nRot As Integer = 0
' Dim nFall As Integer = 0
' Dim sMsg As String = ""
' Dim bCalc As Boolean = False
' bCalc = EgtGetInfo(m_nFeatureId, ITG_PROJ_ERR, nErr)
' EgtGetInfo(m_nFeatureId, ITG_PROJ_ROT, nRot)
' EgtGetInfo(m_nFeatureId, ITG_PROJ_FALL, nFall)
' EgtGetInfo(m_nFeatureId, ITG_PROJ_MSG, sMsg)
' CalcFeatureUpdate(bCalc, nErr, nRot, nFall, sMsg)
' ' leggo parametri della feature
' GetBeamPrivateProfileGRPList(CalcBeamPrivateProfileGRP(nSelGRP), m_nPRC, m_GRPList)
' GetBeamPrivateProfileName(m_nSelGRP, m_nPRC, Me)
' ' crea parametri per questa feature da file ini
' CreateFeatureParams()
' ReadFeatureParams()
'End Sub
Sub New(BTLFeatureM As BTLFeatureM, BTLPartM As BTLPartM)
m_BTLFeatureM = BTLFeatureM
'AddHandler m_BTLFeatureM.PBTLParamAdded, AddressOf OnPBTLParamAdded
'AddHandler m_BTLFeatureM.QBTLParamAdded, AddressOf OnQBTLParamAdded
m_BTLPartM = BTLPartM
'CreatePBTLParamVMList()
'CreateQBTLParamVMList()
NotifyPropertyChanged(NameOf(Calc_Background))
End Sub
Sub New(BTLFeatureM As BTLFeatureM)
m_BTLFeatureM = BTLFeatureM
'AddHandler m_BTLFeatureM.PBTLParamAdded, AddressOf OnPBTLParamAdded
'AddHandler m_BTLFeatureM.QBTLParamAdded, AddressOf OnQBTLParamAdded
m_BTLPartM = Nothing
'CreatePBTLParamVMList()
'CreateQBTLParamVMList()
NotifyPropertyChanged(NameOf(Calc_Background))
End Sub
#End Region ' CONSTRUCTOR
#Region "METHODS"
'Private Sub CreatePBTLParamVMList()
' Dim all As List(Of BTLParamVM) = (From BTLParamM In m_BTLFeatureM.GetPBTLParams()
' Select New BTLParamVM(BTLParamM, m_BTLFeatureM)).ToList()
' For Each BTLParamVM As BTLParamVM In all
' AddHandler BTLParamVM.PropertyChanged, AddressOf OnPBTLParamVMPropertyChanged
' Next
' m_PBTLParamVMList = New ObservableCollection(Of BTLParamVM)(all)
' AddHandler m_PBTLParamVMList.CollectionChanged, AddressOf OnPBTLParamVMListChanged
'End Sub
'Private Sub CreateQBTLParamVMList()
' Dim all As List(Of BTLParamVM) = (From BTLParamM In m_BTLFeatureM.GetQBTLParams()
' Select New BTLParamVM(BTLParamM, m_BTLFeatureM)).ToList()
' For Each BTLParamVM As BTLParamVM In all
' AddHandler BTLParamVM.PropertyChanged, AddressOf OnQBTLParamVMPropertyChanged
' Next
' m_QBTLParamVMList = New ObservableCollection(Of BTLParamVM)(all)
' AddHandler m_QBTLParamVMList.CollectionChanged, AddressOf OnQBTLParamVMListChanged
'End Sub
' funzione che aggiorna lo stato e gli errori dopo calcolo
Friend Sub CalcFeatureUpdate(bCalc As Boolean, ERR As Integer, ROT As Integer, FALL As Integer, MSG As String)
If Not bCalc Then
m_BTLFeatureM.nState = CalcStates.NOTCALCULATED
m_BTLFeatureM.nCALC_ERR = 0
m_BTLFeatureM.nCALC_ROT = 0
m_BTLFeatureM.nCALC_FALL = 0
m_BTLFeatureM.sCALC_MSG = ""
Else
m_BTLFeatureM.nCALC_ERR = ERR
m_BTLFeatureM.nCALC_ROT = ROT
m_BTLFeatureM.nCALC_FALL = FALL
m_BTLFeatureM.sCALC_MSG = MSG
If ERR = 0 Then
m_BTLFeatureM.nState = 0
ElseIf ERR > 1 Then
m_BTLFeatureM.nState = 1
ElseIf ERR < 1 Then
m_BTLFeatureM.nState = -1
End If
End If
NotifyPropertyChanged(NameOf(Calc_Background))
End Sub
' funzione che seleziona la feature nella geometria
Friend Shared Sub SelGeomFeature(Feature As BTLFeatureVM)
EgtDeselectAll()
If Not IsNothing(Feature) Then EgtSelectObj(Feature.nFeatureId)
End Sub
Friend Sub SelGeomFeature()
EgtDeselectAll()
EgtSelectObj(nFeatureId)
End Sub
Public Function Copy() As BTLFeatureM
' creo nuova feature
Dim vPar() As Double = Nothing
Dim sPar As String = String.Empty
m_BTLFeatureM.CalcParamArray(vPar, sPar)
' aggiorno la feature con nuovo valore
EgtBeamSetPart(m_BTLPartM.nPartId)
Dim nNewFeatureId As Integer = EgtBeamAddProcess(m_BTLFeatureM.nSelGRP, m_BTLFeatureM.nPRC, m_BTLFeatureM.nSelSIDE, m_BTLFeatureM.sDES,
m_BTLFeatureM.ParentPart.NewProcId(), m_BTLFeatureM.frFRAME, vPar, sPar)
' se è stata creata
If nNewFeatureId <> GDB_ID.NULL Then
Dim NewFeat As BTLFeatureM = BTLFeatureM.CreateBTLFeature(m_BTLPartM, nNewFeatureId)
' la aggiungo a struttura BTL corrente
m_BTLPartM.AddBTLFeature(NewFeat)
Return NewFeat
End If
Return Nothing
End Function
Public Function Copy(DestBTLPart As BTLPartM) As Boolean
' creo nuova feature
Dim vPar() As Double = Nothing
Dim sPar As String = String.Empty
m_BTLFeatureM.CalcParamArray(vPar, sPar)
' aggiorno la feature con nuovo valore
EgtBeamSetPart(DestBTLPart.nPartId)
Dim nNewFeatureId As Integer = EgtBeamAddProcess(m_BTLFeatureM.nSelGRP, m_BTLFeatureM.nPRC, m_BTLFeatureM.nSelSIDE, m_BTLFeatureM.sDES,
DestBTLPart.NewProcId(), m_BTLFeatureM.frFRAME, vPar, sPar)
' se è stata creata
If nNewFeatureId <> GDB_ID.NULL Then
Dim NewFeat As BTLFeatureM = BTLFeatureM.CreateBTLFeature(m_BTLPartM, nNewFeatureId)
' la aggiungo a struttura BTL pezzo di destinazione
DestBTLPart.AddBTLFeature(NewFeat)
Return True
End If
Return False
End Function
#End Region ' METHODS
#Region "COMMANDS"
#End Region ' COMMANDS
#Region "EVENTS"
'Private Sub OnPBTLParamAdded(sender As Object, e As BTLParamAddedEventArgs) Handles m_BTLFeatureM.PBTLParamAdded
' Dim BTLParamVM As BTLParamVM = New BTLParamVM(e.NewBTLParam, m_BTLFeatureM)
' PBTLParamVMList.Add(BTLParamVM)
'End Sub
'Private Sub OnQBTLParamAdded(sender As Object, e As BTLParamAddedEventArgs) Handles m_BTLFeatureM.QBTLParamAdded
' Dim BTLParamVM As BTLParamVM = New BTLParamVM(e.NewBTLParam, m_BTLFeatureM)
' QBTLParamVMList.Add(BTLParamVM)
'End Sub
'Private Sub OnPBTLParamVMListChanged(sender As Object, e As NotifyCollectionChangedEventArgs)
' If Not IsNothing(e.NewItems) AndAlso e.NewItems.Count > 0 Then
' For Each BTLParamVM As BTLParamVM In e.NewItems
' AddHandler BTLParamVM.PropertyChanged, AddressOf OnPBTLParamVMPropertyChanged
' Next
' End If
' If Not IsNothing(e.OldItems) AndAlso e.OldItems.Count > 0 Then
' For Each BTLParamVM As BTLParamVM In e.OldItems
' RemoveHandler BTLParamVM.PropertyChanged, AddressOf OnPBTLParamVMPropertyChanged
' Next
' End If
'End Sub
'Private Sub OnQBTLParamVMListChanged(sender As Object, e As NotifyCollectionChangedEventArgs)
' If Not IsNothing(e.NewItems) AndAlso e.NewItems.Count > 0 Then
' For Each BTLParamVM As BTLParamVM In e.NewItems
' AddHandler BTLParamVM.PropertyChanged, AddressOf OnQBTLParamVMPropertyChanged
' Next
' End If
' If Not IsNothing(e.OldItems) AndAlso e.OldItems.Count > 0 Then
' For Each BTLParamVM As BTLParamVM In e.OldItems
' RemoveHandler BTLParamVM.PropertyChanged, AddressOf OnQBTLParamVMPropertyChanged
' Next
' End If
'End Sub
'Private Sub OnPBTLParamVMPropertyChanged(sender As Object, e As PropertyChangedEventArgs)
' Select Case e.PropertyName
' Case "dValue", "sValue"
' ' riseleziono questa feature
' SelGeomFeature()
' ' rendo non calcolata questa feature
' CalcFeatureUpdate(False, 0, 0, 0, "")
' End Select
'End Sub
'Private Sub OnQBTLParamVMPropertyChanged(sender As Object, e As PropertyChangedEventArgs)
' Select Case e.PropertyName
' 'Case "sMATERIAL"
' End Select
'End Sub
#End Region ' EVENTS
End Class