Imports System.Collections.ObjectModel
Imports System.IO
Imports EgtUILib
Imports EgtWPFLib5
Imports EgtBEAMWALL.Core
Public Class MyInstrumentPanelVM
Inherits InstrumentPanelVM
Public ReadOnly Property ChangeParam_Visibility As Visibility
Get
Return If(Map.refMainMenuVM.SelPage = Pages.VIEW, Visibility.Visible, Visibility.Collapsed)
End Get
End Property
Private m_InstrumentPanel_IsEnabled As Boolean = True
Public Property InstrumentPanel_IsEnabled As Boolean
Get
Return m_InstrumentPanel_IsEnabled
End Get
Set(value As Boolean)
m_InstrumentPanel_IsEnabled = value
End Set
End Property
Dim m_PrevBottomPanelPage As BottomPanelVM.PartFeatureTab = BottomPanelVM.PartFeatureTab.STRUCTURE_
Private m_Statistics_IsChecked As Boolean = False
Public Property Statistics_IsChecked As Boolean
Get
Return m_Statistics_IsChecked
End Get
Set(value As Boolean)
m_Statistics_IsChecked = value
If Map.refMainMenuVM.SelPage = Pages.VIEW Then
If value Then
' salvo pagina precedente
m_PrevBottomPanelPage = Map.refBottomPanelVM.SelPartFeatureTab
' aggiorno valori totali
Map.refProjectVM.BTLStructureVM.CalcGlobalUpdate()
' seleziono pagina Statistics
Map.refBottomPanelVM.SetSelPartFeatureTab(BottomPanelVM.PartFeatureTab.STATISTICS)
Else
' seleziono pagina precedente
Map.refBottomPanelVM.SetSelPartFeatureTab(m_PrevBottomPanelPage)
End If
ElseIf Map.refMainMenuVM.SelPage = Pages.MACHINING Then
If value Then
' aggiorno valori totali
Map.refProjectVM.MachGroupPanelVM.CalcGlobalUpdate()
' seleziono pagina Statistics
Map.refTopPanelVM.SetSelTab(TopPanelVM.Tabs.STATISTICS)
Else
' seleziono pagina precedente
Map.refTopPanelVM.SetSelTab(TopPanelVM.Tabs.OPTIMIZATION)
End If
End If
End Set
End Property
Friend Sub SetStatisticsIsChecked(value As Boolean)
m_Statistics_IsChecked = value
NotifyPropertyChanged(NameOf(Statistics_IsChecked))
End Sub
' Definizione comandi
Private m_cmdData As ICommand
Private m_cmdChangeParameter As ICommand
Private m_cmdVerify As ICommand
Private m_cmdSimulate As ICommand
Private m_cmdStatistics As ICommand
#Region "Messages"
Public ReadOnly Property ChangeParam_ToolTip As String
Get
Return EgtMsg(61900)
End Get
End Property
Public ReadOnly Property Verify_ToolTip As String
Get
Return EgtMsg(61901)
End Get
End Property
Public ReadOnly Property Simulate_ToolTip As String
Get
Return EgtMsg(61902)
End Get
End Property
Public ReadOnly Property Statistics_Msg As String
Get
Return EgtMsg(61923)
End Get
End Property
#End Region ' Messages
#Region "CONSTRUCTORS"
Sub New()
' imposto riferimento in Map
Map.SetRefInstrumentPanelVM(Me)
End Sub
#End Region ' CONSTRUCTORS
#Region "METHODS"
Public Overrides Function OnPostGetDistIsChecked() As Boolean
If Not Map.refFreeContourManagerVM.bIsActive Then Map.refSceneHostVM.MainScene.SetStatusNull()
Return True
End Function
Friend Sub SetGetDistance_IsChecked(bIsChecked As Boolean)
GetDistIsChecked = bIsChecked
End Sub
Friend Sub ResetStatisticsIsChecked()
If Statistics_IsChecked Then
Statistics_IsChecked = False
NotifyPropertyChanged(NameOf(Statistics_IsChecked))
End If
End Sub
Friend Sub SetInstrumentPanelIsEnabled(bIsEnabled As Boolean)
m_InstrumentPanel_IsEnabled = bIsEnabled
NotifyPropertyChanged(NameOf(InstrumentPanel_IsEnabled))
End Sub
#End Region ' METHODS
#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()
If (Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso (IsNothing(Map.refProjManagerVM.CurrProj) OrElse IsNothing(Map.refProjectVM.BTLStructureVM)) OrElse
(Map.refMainMenuVM.SelPage = Pages.MACHINING AndAlso (IsNothing(Map.refProdManagerVM.CurrProd) OrElse IsNothing(Map.refProjectVM.MachGroupPanelVM)))) Then Return
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.BTLStructureVM.BTLPartVMList
For Each Feature In Part.BTLFeatureVMList.Where(Function(x) x.nPRC = ChangeParameterWndVM.SelPRC.nPRC AndAlso CalcBeamPrivateProfileGRP(x.nSelGRP) = ChangeParameterWndVM.SelPRC.nGRP)
If ChangeParameterWndVM.SelParam.BTLParamM.nType = BTLParamType.CHECKBOX AndAlso Feature.bDO = ChangeParameterWndVM.SelParam.bActualValue Then
Feature.bDO = ChangeParameterWndVM.SelParam.bNewValue
Else
Dim ParamList As ObservableCollection(Of BTLParamVM)
If ChangeParameterWndVM.SelParam.BTLParamM.bIsP Then
ParamList = Feature.PBTLParamVMList
Else
ParamList = Feature.QBTLParamVMList
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
Param.UpdateParamValue(ChangeParameterWndVM.SelParam.dNewValue, "")
'' rinfresco valori parametri feature correntemente selezionata
'If Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) AndAlso
' Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM) AndAlso
' Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM Is Feature Then
' Param.NotifyPropertyChanged("sValue")
'End If
End If
Case BTLParamType.STRING_
If Param.sValue = ChangeParameterWndVM.SelParam.sActualValue Then
Param.UpdateParamValue(0, ChangeParameterWndVM.SelParam.sNewValue)
'' rinfresco valori parametri feature correntemente selezionata
'If Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) AndAlso
' Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM) AndAlso
' Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM.nPRC = ChangeParameterWndVM.SelPRC.nPRC AndAlso
' Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM.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()
If (Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso (IsNothing(Map.refProjManagerVM.CurrProj) OrElse IsNothing(Map.refProjectVM.BTLStructureVM)) OrElse
(Map.refMainMenuVM.SelPage = Pages.MACHINING AndAlso (IsNothing(Map.refProdManagerVM.CurrProd) OrElse IsNothing(Map.refProjectVM.MachGroupPanelVM)))) Then Return
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 As New List(Of CalcIntegration.Bar)
For PartIndex = 0 To Map.refProjectVM.BTLStructureVM.BTLPartVMList.Count - 1
Dim CurrPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.BTLPartVMList(PartIndex)
If Not CurrPart.bDO Then Continue For
Dim Bar As New CalcIntegration.Bar With {.nBarId = CurrPart.nPartId,
.nBarType = ProjectType.PROJ,
.bBarOk = True}
Select Case CurrPart.nGlobalState
Case Core.CalcStates.OK, CalcStates.INFO
Bar.nCmdType = CalcIntegration.CmdType.GENERATE
Case Else
Dim sBTLPartFilePath As String = Map.refProjManagerVM.CurrProj.sProjDirPath & "\" & CurrPart.nPDN.ToString() & ".ori.bwe"
If File.Exists(sBTLPartFilePath) Then File.Delete(sBTLPartFilePath)
Bar.nCmdType = CalcIntegration.CmdType.CHECKGEN
End Select
TempBarList.Add(Bar)
Next
BarList = TempBarList.ToArray()
ElseIf Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) Then
Dim TempBarList(0) As CalcIntegration.Bar
If Not Map.refProjectVM.BTLStructureVM.SelBTLPart.bDO Then Return
Dim Bar As New CalcIntegration.Bar With {.nBarId = Map.refProjectVM.BTLStructureVM.SelBTLPart.nPartId,
.nBarType = ProjectType.PROJ,
.bBarOk = True}
Select Case Map.refProjectVM.BTLStructureVM.SelBTLPart.nGlobalState
Case Core.CalcStates.OK, CalcStates.INFO
Bar.nCmdType = CalcIntegration.CmdType.GENERATE
Case Else
Dim sBTLPartFilePath As String = Map.refProjManagerVM.CurrProj.sProjDirPath & "\" & Map.refProjectVM.BTLStructureVM.SelBTLPart.nPDN.ToString() & ".ori.bwe"
If File.Exists(sBTLPartFilePath) Then File.Delete(sBTLPartFilePath)
Bar.nCmdType = CalcIntegration.CmdType.CHECKGEN
End Select
TempBarList(0) = Bar
BarList = TempBarList
Else
Return
End If
' disabilito interfaccia
Map.refProjectVM.ManageIsEnabled(False)
' lancio calcolo
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.MachGroupVMList.Count - 1) As CalcIntegration.Bar
For PartIndex = 0 To Map.refMachGroupPanelVM.MachGroupVMList.Count - 1
Dim CurrMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.MachGroupVMList(PartIndex)
Dim Bar As New CalcIntegration.Bar With {.nBarId = CurrMachGroup.Id,
.nBarType = ProjectType.PROD,
.bBarOk = True}
Select Case CurrMachGroup.nGlobalState
Case Core.CalcStates.OK, CalcStates.INFO
Bar.nCmdType = CalcIntegration.CmdType.GENERATE
Case Else
Dim sMachGroupFilePath As String = Map.refProdManagerVM.CurrProd.sProdDirPath & "\" & CurrMachGroup.Name.ToString() & ".ori.bwe"
If File.Exists(sMachGroupFilePath) Then File.Delete(sMachGroupFilePath)
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 MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup
Select Case SelMachGroup.nGlobalState
Case Core.CalcStates.OK, CalcStates.INFO
Bar.nCmdType = CalcIntegration.CmdType.GENERATE
Case Else
Dim sMachGroupFilePath As String = Map.refProdManagerVM.CurrProd.sProdDirPath & "\" & SelMachGroup.Name.ToString() & ".ori.bwe"
If File.Exists(sMachGroupFilePath) Then File.Delete(sMachGroupFilePath)
Bar.nCmdType = CalcIntegration.CmdType.CHECKGEN
End Select
TempBarList(0) = Bar
BarList = TempBarList
Else
Return
End If
' disabilito interfaccia
Map.refProjectVM.ManageIsEnabled(False)
' lancio calcolo
Calc.Run(BarList, Map.refProdManagerVM.CurrProd.sProdDirPath, AddressOf ManageCalc)
End If
End Sub
' funzione che gestisce risposta da thread di verifica, aggiorna progress e segnala comando di interruzione
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.BTLStructureVM.SelBTLPart) Then
Dim TempBarList(0) As CalcIntegration.Bar
Dim Bar As New CalcIntegration.Bar With {.nBarId = Map.refProjectVM.BTLStructureVM.SelBTLPart.nPartId,
.nBarType = ProjectType.PROJ,
.bBarOk = True,
.nCmdType = CalcIntegration.CmdType.SIMULATE}
If Map.refProjectVM.BTLStructureVM.SelBTLPart.nGlobalState <> Core.CalcStates.OK Then
Dim sBTLPartFilePath As String = Map.refProjManagerVM.CurrProj.sProjDirPath & "\" & Map.refProjectVM.BTLStructureVM.SelBTLPart.nPDN.ToString() & ".ori.bwe"
If File.Exists( sBTLPartFilePath) Then File.Delete( sBTLPartFilePath)
End If
TempBarList(0) = Bar
BarList = TempBarList
Else
Return
End If
' disabilito interfaccia
Map.refProjectVM.ManageIsEnabled(False)
' lancio simulazione
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}
Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup
If SelMachGroup.nGlobalState <> Core.CalcStates.OK Then
Dim sMachGroupFilePath As String = Map.refProdManagerVM.CurrProd.sProdDirPath & "\" & SelMachGroup.Name.ToString() & ".ori.bwe"
If File.Exists( sMachGroupFilePath) Then File.Delete( sMachGroupFilePath)
End If
TempBarList(0) = Bar
BarList = TempBarList
Else
Return
End If
' disabilito interfaccia
Map.refProjectVM.ManageIsEnabled(False)
' lancio simulazione
Calc.Run(BarList, Map.refProdManagerVM.CurrProd.sProdDirPath, AddressOf ManageCalc)
End If
End Sub
#End Region ' Simulate
#End Region ' COMMANDS
End Class