Imports System.Collections.ObjectModel
Imports EgtWPFLib5
Imports EgtBEAMWALL.Core
Public Class MyInstrumentPanelVM
Inherits InstrumentPanelVM
' Definizione comandi
Private m_cmdData As ICommand
Private m_cmdChangeParameter As ICommand
Private m_cmdVerify As ICommand
Private m_cmdSimulate As ICommand
Public Overrides Function OnPostGetDistIsChecked() As Boolean
Map.refSceneHostVM.MainScene.SetStatusNull()
Return True
End Function
#Region "COMMANDS"
#Region "Data"
'''
''' Returns a command that do Open.
'''
Public ReadOnly Property Data_Command As ICommand
Get
If m_cmdData Is Nothing Then
m_cmdData = New Command(AddressOf Data)
End If
Return m_cmdData
End Get
End Property
'''
''' Execute the Open. This method is invoked by the OpenCommand.
'''
Friend Sub Data()
Dim BTLDataWnd As New BTLDataWndV(Application.Current.MainWindow, New BTLDataWndVM())
BTLDataWnd.ShowDialog()
End Sub
#End Region ' Data
#Region "ChangeParameter"
'''
''' Returns a command that do Open.
'''
Public ReadOnly Property ChangeParameter_Command As ICommand
Get
If m_cmdChangeParameter Is Nothing Then
m_cmdChangeParameter = New Command(AddressOf ChangeParameter)
End If
Return m_cmdChangeParameter
End Get
End Property
'''
''' Execute the Open. This method is invoked by the OpenCommand.
'''
Friend Sub ChangeParameter()
Dim ChangeParameterWndVM As New ChangeParameterWndVM
Dim ChangeParameterWnd As New ChangeParameterWndV(Application.Current.MainWindow, ChangeParameterWndVM)
If ChangeParameterWnd.ShowDialog() Then
' faccio passare pezzi
If Not IsNothing(ChangeParameterWndVM.SelParam) Then
For Each Part In Map.refProjectVM.BTLStructure.PartList
For Each Feature In Part.FeatureList.Where(Function(x) x.nPRC = ChangeParameterWndVM.SelPRC.nPRC AndAlso CalcBeamPrivateProfileGRP(x.nSelGRP) = ChangeParameterWndVM.SelPRC.nGRP)
If ChangeParameterWndVM.SelParam.nType = BTLParamType.CHECKBOX AndAlso Feature.bDO = ChangeParameterWndVM.SelParam.bActualValue Then
Feature.bDO = ChangeParameterWndVM.SelParam.bNewValue
Else
Dim ParamList As ObservableCollection(Of Core.BTLParam)
If ChangeParameterWndVM.SelParam.bIsP Then
ParamList = Feature.PParamList
Else
ParamList = Feature.QParamList
End If
For Each Param In ParamList.Where(Function(x) x.sName = ChangeParameterWndVM.SelParam.sName)
Select Case Param.nType
Case BTLParamType.DOUBLE_, BTLParamType.LENGTH
If Param.dValue = ChangeParameterWndVM.SelParam.dActualValue Then
DirectCast(Param, BTLParam).UpdateParamValue(ChangeParameterWndVM.SelParam.dNewValue, "")
' rinfresco valori parametri feature correntemente selezionata
If Not IsNothing(Map.refProjectVM.BTLStructure.SelPart) AndAlso
Not IsNothing(Map.refProjectVM.BTLStructure.SelPart.SelFeature) AndAlso
Map.refProjectVM.BTLStructure.SelPart.SelFeature Is Feature Then
Param.NotifyPropertyChanged("sValue")
End If
End If
Case BTLParamType.STRING_
If Param.sValue = ChangeParameterWndVM.SelParam.sActualValue Then
DirectCast(Param, BTLParam).UpdateParamValue(0, ChangeParameterWndVM.SelParam.sNewValue)
' rinfresco valori parametri feature correntemente selezionata
If Not IsNothing(Map.refProjectVM.BTLStructure.SelPart) AndAlso
Not IsNothing(Map.refProjectVM.BTLStructure.SelPart.SelFeature) AndAlso
Map.refProjectVM.BTLStructure.SelPart.SelFeature.nPRC = ChangeParameterWndVM.SelPRC.nPRC AndAlso
Map.refProjectVM.BTLStructure.SelPart.SelFeature.nSelGRP = ChangeParameterWndVM.SelPRC.nGRP Then
Param.NotifyPropertyChanged("sValue")
End If
End If
End Select
Next
End If
Next
'' faccio passare feature
'For Each Feature In Part.FeatureList
' If Feature.nPRC = ChangeParameterWndVM.SelPRC.nPRC Then
' For Each Param In Feature.PParamList
' If Param.sName = ChangeParameterWndVM.SelParam.sName Then
' Select Case Param.nType
' Case BTLParamType.DOUBLE_, BTLParamType.LENGTH
' If Param.dValue = ChangeParameterWndVM.SelParam.dActualValue Then
' Param.dValue = ChangeParameterWndVM.SelParam.dValue
' End If
' Case BTLParamType.STRING_
' If Param.sValue = ChangeParameterWndVM.SelParam.sActualValue Then
' Param.sValue = ChangeParameterWndVM.SelParam.sValue
' End If
' End Select
' End If
' Next
' End If
'Next
Next
End If
End If
End Sub
#End Region ' ChangeParameter
#Region "Verify"
'''
''' Returns a command that do Open.
'''
Public ReadOnly Property Verify_Command As ICommand
Get
If m_cmdVerify Is Nothing Then
m_cmdVerify = New Command(AddressOf Verify)
End If
Return m_cmdVerify
End Get
End Property
'''
''' Execute the Open. This method is invoked by the OpenCommand.
'''
Friend Sub Verify()
Dim Calc As New CalcIntegration
Dim BarList() As CalcIntegration.Bar
If Map.refMainMenuVM.SelPage = Pages.VIEW Then
If ((Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift) Then
Dim TempBarList(Map.refProjectVM.BTLStructure.PartList.Count - 1) As CalcIntegration.Bar
For PartIndex = 0 To Map.refProjectVM.BTLStructure.PartList.Count - 1
Dim CurrPart As BTLPart = Map.refProjectVM.BTLStructure.PartList(PartIndex)
Dim Bar As New CalcIntegration.Bar With {.nBarId = CurrPart.nPartId,
.nBarType = ProjectType.PROJ,
.bBarOk = True}
Select Case CurrPart.nState
Case Core.CalcStates.OK
Bar.nCmdType = CalcIntegration.CmdType.GENERATE
Case Else
Bar.nCmdType = CalcIntegration.CmdType.CHECKGEN
End Select
TempBarList(PartIndex) = Bar
Next
BarList = TempBarList
ElseIf Not IsNothing(Map.refProjectVM.BTLStructure.SelPart) Then
Dim TempBarList(0) As CalcIntegration.Bar
Dim Bar As New CalcIntegration.Bar With {.nBarId = Map.refProjectVM.BTLStructure.SelPart.nPartId,
.nBarType = ProjectType.PROJ,
.bBarOk = True}
Select Case Map.refProjectVM.BTLStructure.SelPart.nState
Case Core.CalcStates.OK
Bar.nCmdType = CalcIntegration.CmdType.GENERATE
Case Else
Bar.nCmdType = CalcIntegration.CmdType.CHECKGEN
End Select
TempBarList(0) = Bar
BarList = TempBarList
Else
Return
End If
Calc.Run(BarList, Map.refProjManagerVM.CurrProj.sProjDirPath, AddressOf ManageCalc)
ElseIf Map.refMainMenuVM.SelPage = Pages.MACHINING Then
If ((Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift) Then
Dim TempBarList(Map.refMachGroupPanelVM.MachGroupList.Count - 1) As CalcIntegration.Bar
For PartIndex = 0 To Map.refMachGroupPanelVM.MachGroupList.Count - 1
Dim CurrPart As MyMachGroup = Map.refMachGroupPanelVM.MachGroupList(PartIndex)
Dim Bar As New CalcIntegration.Bar With {.nBarId = CurrPart.Id,
.nBarType = ProjectType.PROD,
.bBarOk = True}
Select Case CurrPart.nState
Case Core.CalcStates.OK
Bar.nCmdType = CalcIntegration.CmdType.GENERATE
Case Else
Bar.nCmdType = CalcIntegration.CmdType.CHECKGEN
End Select
TempBarList(PartIndex) = Bar
Next
BarList = TempBarList
ElseIf Not IsNothing(Map.refMachGroupPanelVM.SelectedMachGroup) Then
Dim TempBarList(0) As CalcIntegration.Bar
Dim Bar As New CalcIntegration.Bar With {.nBarId = Map.refMachGroupPanelVM.SelectedMachGroup.Id,
.nBarType = ProjectType.PROD,
.bBarOk = True}
Dim SelMachGroup As MyMachGroup = DirectCast(Map.refMachGroupPanelVM.SelectedMachGroup, MyMachGroup)
Select Case SelMachGroup.nState
Case Core.CalcStates.OK
Bar.nCmdType = CalcIntegration.CmdType.GENERATE
Case Else
Bar.nCmdType = CalcIntegration.CmdType.CHECKGEN
End Select
TempBarList(0) = Bar
BarList = TempBarList
Else
Return
End If
Calc.Run(BarList, Map.refProdManagerVM.CurrProd.sProdDirPath, AddressOf ManageCalc)
End If
End Sub
Private Sub ManageCalc(dProgress As Double, sProgress As String, ByRef bCancel As Boolean)
If dProgress = 0 Then
Map.refMyStatusBarVM.SetLoadingProgress_Visibility(True)
Map.refMyStatusBarVM.SetStopProgress_IsActive(True)
Map.refMyStatusBarVM.SetStopProgress_IsEnabled(True)
Map.refMyStatusBarVM.SetOutputMessage(sProgress)
Map.refMyStatusBarVM.SetStopProgress_IsActive(True)
Map.refMyStatusBarVM.SetStopProgress_IsEnabled(True)
ElseIf dProgress = 1 Then
Map.refMyStatusBarVM.SetLoadingProgress_Visibility(False)
Map.refMyStatusBarVM.SetStopProgress_IsActive(False)
Map.refMyStatusBarVM.SetStopProgress_IsEnabled(False)
Map.refMyStatusBarVM.SetOutputMessage(sProgress, 3)
End If
bCancel = Map.refMyStatusBarVM.bStopProgress
Map.refMyStatusBarVM.SetLoadingProgress(dProgress * 100)
Map.refMyStatusBarVM.SetOutputMessage(sProgress)
End Sub
#End Region ' Verify
#Region "Simulate"
'''
''' Returns a command that do Open.
'''
Public ReadOnly Property Simulate_Command As ICommand
Get
If m_cmdSimulate Is Nothing Then
m_cmdSimulate = New Command(AddressOf Simulate)
End If
Return m_cmdSimulate
End Get
End Property
'''
''' Execute the Open. This method is invoked by the OpenCommand.
'''
Friend Sub Simulate()
Dim Calc As New CalcIntegration
Dim BarList() As CalcIntegration.Bar
If Map.refMainMenuVM.SelPage = Pages.VIEW Then
If Not IsNothing(Map.refProjectVM.BTLStructure.SelPart) Then
Dim TempBarList(0) As CalcIntegration.Bar
Dim Bar As New CalcIntegration.Bar With {.nBarId = Map.refProjectVM.BTLStructure.SelPart.nPartId,
.nBarType = ProjectType.PROJ,
.bBarOk = True,
.nCmdType = CalcIntegration.CmdType.SIMULATE}
TempBarList(0) = Bar
BarList = TempBarList
Else
Return
End If
Calc.Run(BarList, Map.refProjManagerVM.CurrProj.sProjDirPath, AddressOf ManageCalc)
ElseIf Map.refMainMenuVM.SelPage = Pages.MACHINING Then
If Not IsNothing(Map.refMachGroupPanelVM.SelectedMachGroup) Then
Dim TempBarList(0) As CalcIntegration.Bar
Dim Bar As New CalcIntegration.Bar With {.nBarId = Map.refMachGroupPanelVM.SelectedMachGroup.Id,
.nBarType = ProjectType.PROD,
.bBarOk = True,
.nCmdType = CalcIntegration.CmdType.SIMULATE}
TempBarList(0) = Bar
BarList = TempBarList
Else
Return
End If
Calc.Run(BarList, Map.refProdManagerVM.CurrProd.sProdDirPath, AddressOf ManageCalc)
End If
End Sub
#End Region ' Simulate
#End Region ' COMMANDS
End Class