Imports System.Collections.ObjectModel
Imports EgtBEAMWALL.Core
Imports EgtUILib
Imports EgtWPFLib5
Imports System.IO
Public Class LeftPanelVM
Inherits VMBase
#Region "FIELDS & PROPERTIES"
Private Property m_GridDims As New ObservableCollection(Of GridDimension)
Public Property GridDims As ObservableCollection(Of GridDimension)
Get
Return m_GridDims
End Get
Set
m_GridDims = Value
NotifyPropertyChanged(NameOf(GridDims))
End Set
End Property
Private m_LeftPanel_IsEnabled As Boolean = True
Public ReadOnly Property LeftPanel_IsEnabled As Boolean
Get
Return m_LeftPanel_IsEnabled
End Get
End Property
Public ReadOnly Property SearchFilter_IsEnabled As Boolean
Get
Return Not Map.refFreeContourManagerVM.bIsActive
End Get
End Property
Private m_Parameters_IsEnabled As Boolean = False
Public ReadOnly Property Parameters_IsEnabled As Boolean
Get
Return m_Parameters_IsEnabled
End Get
End Property
Friend Sub SetParametersIsEnabled(bIsEnabled As Boolean)
m_Parameters_IsEnabled = bIsEnabled
NotifyPropertyChanged(NameOf(Parameters_IsEnabled))
End Sub
Private m_Data_IsEnabled As Boolean = False
Public ReadOnly Property Data_IsEnabled As Boolean
Get
Return m_Data_IsEnabled
End Get
End Property
Friend Sub SetData_IsEnabled(bIsEnabled As Boolean)
m_Data_IsEnabled = bIsEnabled
NotifyPropertyChanged(NameOf(Data_IsEnabled))
End Sub
Private m_OnlyProdPartManagerVisibility As Visibility = Visibility.Collapsed
Public ReadOnly Property OnlyProdPartManagerVisibility As Visibility
Get
Return m_OnlyProdPartManagerVisibility
End Get
End Property
Friend Sub SetOnlyProdPartManager_Visibility(value As Visibility)
m_OnlyProdPartManagerVisibility = value
NotifyPropertyChanged(NameOf(OnlyProdPartManagerVisibility))
End Sub
Private m_IsFilterBtnOpen As Boolean = False
Public Property IsFilterBtnOpen As Boolean
Get
Return m_IsFilterBtnOpen
End Get
Set(value As Boolean)
m_IsFilterBtnOpen = value
End Set
End Property
Friend Sub SetIsFilterBtnOpen(bIsFilterBtnOpen As Boolean)
m_IsFilterBtnOpen = bIsFilterBtnOpen
NotifyPropertyChanged(NameOf(IsFilterBtnOpen))
End Sub
' Definizione comandi
Private m_cmdData As ICommand
Private m_cmdParameter As ICommand
Private m_cmdVerifyAll As ICommand
Private m_cmdShowPopUpFilterBtnCmd As ICommand
Private m_cmdBackRotation As ICommand
Private m_cmdInvert As ICommand
#Region "Messages"
Public ReadOnly Property SearchFilter_Msg As String
Get
Return EgtMsg(61949)
End Get
End Property
Public ReadOnly Property Section_Msg As String
Get
Return EgtMsg(61771)
End Get
End Property
Public ReadOnly Property Group_Msg As String
Get
Return EgtMsg(61624)
End Get
End Property
Public ReadOnly Property SubGroup_Msg As String
Get
Return EgtMsg(61623)
End Get
End Property
Public ReadOnly Property ParType_Msg As String
Get
Return EgtMsg(61950)
End Get
End Property
Public ReadOnly Property ParValue_Msg As String
Get
Return EgtMsg(61951)
End Get
End Property
Public ReadOnly Property Pdn_Msg As String
Get
Return EgtMsg(61809)
End Get
End Property
Public ReadOnly Property Description_Msg As String
Get
Return EgtMsg(62511)
End Get
End Property
Public ReadOnly Property Data_ToolTip As String
Get
Return EgtMsg(61897)
End Get
End Property
Public ReadOnly Property Parameters_ToolTip As String
Get
Return EgtMsg(61898)
End Get
End Property
Public ReadOnly Property VerifyAll_ToolTip As String
Get
Return EgtMsg(61928)
End Get
End Property
#End Region ' Messages
#End Region 'FIELDS & PROPERTIES
#Region "CONSTRUCTOR"
Sub New()
' imposto riferimento su mappa
Map.SetRefLeftPanelVM(Me)
' imposto dimensioni colonne/righe della Grid
DimensionsIniFile.ReadGridDimensions(ConstDims.LEFTPANEL_VIEW, GridDims)
End Sub
#End Region ' Constructor
#Region "METHODS"
Friend Sub SetLeftPanelIsEnabled(bIsEnabled As Boolean)
m_LeftPanel_IsEnabled = bIsEnabled
NotifyPropertyChanged(NameOf(LeftPanel_IsEnabled))
NotifyPropertyChanged(NameOf(SearchFilter_IsEnabled))
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 ' 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 "Parameter"
'''
''' Returns a command that do Open.
'''
Public ReadOnly Property Parameter_Command As ICommand
Get
If m_cmdParameter Is Nothing Then
m_cmdParameter = New Command(AddressOf Parameter)
End If
Return m_cmdParameter
End Get
End Property
'''
''' Execute the Open. This method is invoked by the OpenCommand.
'''
Friend Sub Parameter()
Dim PartParametersWnd As New PartParametersWndV(Application.Current.MainWindow, New PartParametersWndVM())
PartParametersWnd.ShowDialog()
End Sub
#End Region ' Parameter
#Region "VerifyAll"
'''
''' Returns a command that do Open.
'''
Public ReadOnly Property VerifyAll_Command As ICommand
Get
If m_cmdVerifyAll Is Nothing Then
m_cmdVerifyAll = New Command(AddressOf VerifyAll)
End If
Return m_cmdVerifyAll
End Get
End Property
'''
''' Execute the Open. This method is invoked by the OpenCommand.
'''
Friend Sub VerifyAll()
If (Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso (IsNothing(ProjectManagerVM.CurrProj) OrElse IsNothing(Map.refProjectVM.BTLStructureVM))) OrElse
(Map.refMainMenuVM.SelPage = Pages.MACHINING AndAlso (IsNothing(ProjectManagerVM.CurrProd) OrElse IsNothing(Map.refProjectVM.MachGroupPanelVM))) OrElse
(Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso (IsNothing(ProjectManagerVM.CurrProj) OrElse IsNothing(Map.refProjectVM.BTLStructureVM)) AndAlso (IsNothing(ProjectManagerVM.CurrProd) OrElse IsNothing(Map.refProjectVM.MachGroupPanelVM))) Then Return
' se modalita' assemblato
Configuration.AssembledMode(Map.refShowBeamPanelVM.ShowBuilding_IsChecked)
Dim BarList() As EgtBEAMWALL.Core.Bar = Nothing
Dim ProjType As BWType
If Map.refMainMenuVM.SelPage = Pages.VIEW Then
ProjType = ProjectManagerVM.CurrProj.nType
If Not CreateBarListToVerify(Pages.VIEW, ProjType, BarList) Then Return
' lancio calcolo
EgtBEAMWALL.Core.CalcIntegration.Run(BarList, ProjectManagerVM.CurrProj.sProjDirPath, AddressOf ManageCalc)
ElseIf Map.refMainMenuVM.SelPage = Pages.MACHINING Then
ProjType = ProjectManagerVM.CurrProd.nType
If Not CreateBarListToVerify(Pages.MACHINING, ProjType, BarList) Then Return
' lancio calcolo
EgtBEAMWALL.Core.CalcIntegration.Run(BarList, ProjectManagerVM.CurrProd.sProdDirPath, AddressOf ManageCalc)
ElseIf Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then
ProjType = ProjectManagerVM.CurrProd.nType
If Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART OrElse Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PARTLIST Then
If Not CreateBarListToVerify(Pages.VIEW, ProjType, BarList) Then Return
' lancio calcolo
EgtBEAMWALL.Core.CalcIntegration.Run(BarList, ProjectManagerVM.CurrProj.sProjDirPath, AddressOf ManageCalc)
ElseIf Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.MACHGROUP Then
If Not CreateBarListToVerify(Pages.MACHINING, ProjType, BarList) Then Return
' lancio calcolo
EgtBEAMWALL.Core.CalcIntegration.Run(BarList, ProjectManagerVM.CurrProd.sProdDirPath, AddressOf ManageCalc)
End If
End If
End Sub
Private Function CreateBarListToVerify(SelPage As Pages, ProjType As BWType, ByRef BarList As Bar()) As Boolean
If SelPage = Pages.VIEW Then
Dim TempBarList As New List(Of EgtBEAMWALL.Core.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 EgtBEAMWALL.Core.Bar With {.nBarId = CurrPart.nPartId,
.nProgramPage = ProjectType.PROJ,
.nProjType = ProjType,
.bBarOk = True,
.nMachineName = Map.refMachinePanelVM.SelectedMachine.Name,
.nGlobState = CurrPart.nGlobalState}
Select Case CurrPart.nGlobalState
Case Core.CalcStates.OK, CalcStates.INFO
Bar.nCmdType = CalcIntegration.CmdTypes.GENERATE
Case Else
If CurrPart.nGlobalState = CalcStates.NOTCALCULATED OrElse CurrPart.nFeaturesGlobalState > CalcStates.INFO Then
Dim sBTLPartFilePath As String = ProjectManagerVM.CurrProj.sProjDirPath & "\" & CurrPart.nPDN.ToString() & ".ori.bwe"
If File.Exists(sBTLPartFilePath) Then File.Delete(sBTLPartFilePath)
End If
Bar.nCmdType = CalcIntegration.CmdTypes.CHECKGEN
End Select
TempBarList.Add(Bar)
Next
BarList = TempBarList.ToArray()
' disabilito interfaccia
Map.refProjectVM.SetCalcRunning(True)
ElseIf SelPage = Pages.MACHINING Then
Dim TempBarList As New List(Of EgtBEAMWALL.Core.Bar)
For PartIndex = 0 To Map.refMachGroupPanelVM.MachGroupVMList.Count - 1
Dim CurrMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.MachGroupVMList(PartIndex)
' se e' gia' stato assegnato a supervisor, la salto e vado alla prossima barra
If CurrMachGroup.nProduction_State >= ItemState.Assigned Then Continue For
Dim MachineName As String = ""
EgtGetMachGroupMachineName(CurrMachGroup.Id, MachineName)
Dim Bar As New EgtBEAMWALL.Core.Bar With {.nBarId = CurrMachGroup.Id,
.nProgramPage = ProjectType.PROD,
.nProjType = ProjType,
.bBarOk = True,
.nMachineName = MachineName,
.nGlobState = CurrMachGroup.nGlobalState}
Select Case CurrMachGroup.nGlobalState
Case Core.CalcStates.OK, CalcStates.INFO
Bar.nCmdType = CalcIntegration.CmdTypes.GENERATE
Case Else
If CurrMachGroup.nGlobalState = CalcStates.NOTCALCULATED OrElse (CurrMachGroup.nPartsGlobalState > CalcStates.INFO) Then
Dim sMachGroupFilePath As String = ProjectManagerVM.CurrProd.sProdDirPath & "\" & CurrMachGroup.Name.ToString() & ".ori.bwe"
If File.Exists(sMachGroupFilePath) Then File.Delete(sMachGroupFilePath)
End If
Bar.nCmdType = CalcIntegration.CmdTypes.CHECKGEN
End Select
TempBarList.Add(Bar)
Next
If TempBarList.Count = 0 Then Return False
BarList = TempBarList.ToArray()
' disabilito interfaccia
Map.refProjectVM.SetCalcRunning(True)
End If
Return True
End Function
#End Region ' VerifyAll
#Region "ShowPopUpFilterBtnCommand"
Public ReadOnly Property ShowPopUpFilterBtnCommand As ICommand
Get
If m_cmdShowPopUpFilterBtnCmd Is Nothing Then
m_cmdShowPopUpFilterBtnCmd = New Command(AddressOf ShowPopUpFilterBtn)
End If
Return m_cmdShowPopUpFilterBtnCmd
End Get
End Property
Public Sub ShowPopUpFilterBtn(ByVal param As Object)
If m_IsFilterBtnOpen Then
SetIsFilterBtnOpen(False)
Else
SetIsFilterBtnOpen(True)
End If
End Sub
#End Region ' ShowPopUpFilterBtnCommand
#Region "BackRotation"
'''
''' Returns a command that do Exec.
'''
Public ReadOnly Property BackRotation_Command As ICommand
Get
If m_cmdBackRotation Is Nothing Then
m_cmdBackRotation = New Command(AddressOf BackRotation)
End If
Return m_cmdBackRotation
End Get
End Property
'''
''' Execute the Exec. This method is invoked by the ExecCommand.
'''
Public Sub BackRotation()
If IsNothing(ProjectManagerVM.CurrProj) OrElse IsNothing(Map.refProjectVM.BTLStructureVM) Then Return
' salvo sezione impostata
Dim CurrSection As SectionXMaterial = Map.refProjectVM.BTLStructureVM.SelSection
' se modalita' assemblato
Dim bShowBuilding As Boolean = Map.refShowBeamPanelVM.ShowBuilding_IsChecked
Configuration.AssembledMode(bShowBuilding)
' ruoto i pezzi selezionati
For Each Part In Map.refProjectVM.BTLStructureVM.SelBTLParts
Part.BackRotation(False, False)
Next
' se assemblato lo ripristino
If bShowBuilding Then Map.refProjectVM.BTLStructureVM.ShowBuilding(True, False)
' se progetto travi e sezione precedente diversa da vuota (tutti i pezzi)
If Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.BEAM AndAlso CurrSection <> SectionXMaterial.Empty Then
' se esiste, imposto sezione inversa
Dim InverseSection As SectionXMaterial = Map.refProjectVM.BTLStructureVM.SectionList.FirstOrDefault(Function(x) x.dH = CurrSection.dW AndAlso x.dW = CurrSection.dH AndAlso x.sMaterial(0) = CurrSection.sMaterial(0))
If Not IsNothing(InverseSection) Then Map.refProjectVM.BTLStructureVM.SetSelSection(InverseSection)
End If
EgtDraw()
End Sub
#End Region ' BackRotation
#Region "Invert"
'''
''' Returns a command that do Exec.
'''
Public ReadOnly Property Invert_Command As ICommand
Get
If m_cmdInvert Is Nothing Then
m_cmdInvert = New Command(AddressOf Invert)
End If
Return m_cmdInvert
End Get
End Property
'''
''' Execute the Exec. This method is invoked by the ExecCommand.
'''
Public Sub Invert()
If ((Map.refMainMenuVM.SelPage = Pages.VIEW OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE) AndAlso IsNothing(ProjectManagerVM.CurrProj)) OrElse IsNothing(Map.refProjectVM.BTLStructureVM) Then Return
' se modalita' assemblato
Dim bShowBuilding As Boolean = Map.refShowBeamPanelVM.ShowBuilding_IsChecked
Configuration.AssembledMode(bShowBuilding)
' inverto i pezzi selezionati
For Each Part In Map.refProjectVM.BTLStructureVM.SelBTLParts
Part.Invert()
Next
' se assemblato lo ripristino
If bShowBuilding Then Map.refProjectVM.BTLStructureVM.ShowBuilding(True, False)
End Sub
#End Region ' Invert
#End Region ' COMMANDS
End Class