Files
egtbeamwall/EgtBEAMWALL.ViewerOptimizer/InstrumentPanel/MyInstrumentPanelVM.vb
T
Demetrio Cassarino a12ab8f531 -pulizia codice
2024-06-13 17:36:10 +02:00

358 lines
13 KiB
VB.net

Imports System.Collections.ObjectModel
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
Public ReadOnly Property ChangeMaterial_Visibility As Visibility
Get
Return If(Map.refMainWindowVM.MainWindowM.nUserLevel > 5 AndAlso Map.refMainMenuVM.SelPage = Pages.VIEW, Visibility.Visible, Visibility.Collapsed)
End Get
End Property
Public ReadOnly Property Statistic_Visibility As Visibility
Get
Return If(Map.refMainMenuVM.SelPage = Pages.VIEW OrElse Map.refMainMenuVM.SelPage = Pages.MACHINING, Visibility.Visible, Visibility.Collapsed)
End Get
End Property
Public ReadOnly Property VisStatistic_Visibility As Visibility
Get
Return If(Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE, Visibility.Visible, Visibility.Collapsed)
End Get
End Property
Public ReadOnly Property OtStatistic_Visibility As Visibility
Get
Return If(Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE, 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
Private m_Statistics_IsEnabled As Boolean = True
Public Property Statistics_IsEnabled As Boolean
Get
Return m_Statistics_IsEnabled
End Get
Set(value As Boolean)
m_Statistics_IsEnabled = value
End Set
End Property
' flag per verificare se è stato selezionato il pulsante VIS o OTT se 0 = VIS se 1 = OTT
Private m_bVisOtt_Selected As Boolean = False
Public Property bVisOtt_Selected As Boolean
Get
Return m_bVisOtt_Selected
End Get
Set(value As Boolean)
m_bVisOtt_Selected = value
NotifyPropertyChanged(NameOf(bVisOtt_Selected))
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
If Not IsNothing(Map.refProjectVM.MachGroupPanelVM) Then Map.refProjectVM.MachGroupPanelVM.CalcGlobalUpdate()
' aggiorno conto materiali usati
If Not IsNothing(ProjectManagerVM.CurrProd) Then Map.refStatisticsVM.LoadRawPart()
' 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
Private m_VisStatistic_IsEnabled As Boolean = True
Public Property VisStatistic_IsEnabled As Boolean
Get
Return m_VisStatistic_IsEnabled
End Get
Set(value As Boolean)
m_VisStatistic_IsEnabled = value
End Set
End Property
Private m_OtStatistic_IsEnabled As Boolean = True
Public Property OtStatistic_IsEnabled As Boolean
Get
Return m_OtStatistic_IsEnabled
End Get
Set(value As Boolean)
m_OtStatistic_IsEnabled = value
End Set
End Property
' Definizione comandi
Private m_cmdData As ICommand
Private m_cmdChangeParameter As ICommand
Private m_cmdChangeMaterial As ICommand
Private m_cmdStatistics As ICommand
Private m_cmdVisualization As ICommand
Private m_cmdOptimizer As ICommand
#Region "Messages"
Public ReadOnly Property ChangeParam_ToolTip As String
Get
Return EgtMsg(61900)
End Get
End Property
Public ReadOnly Property ChangeMaterial_ToolTip As String
Get
Return EgtMsg(61961)
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))
If Map.refFreeContourManagerVM.bIsActive Then
m_Statistics_IsEnabled = bIsEnabled
m_VisStatistic_IsEnabled = bIsEnabled
m_OtStatistic_IsEnabled = bIsEnabled
Else
m_Statistics_IsEnabled = True
m_VisStatistic_IsEnabled = True
m_OtStatistic_IsEnabled = True
End If
NotifyPropertyChanged(NameOf(Statistics_IsEnabled))
NotifyPropertyChanged(NameOf(VisStatistic_IsEnabled))
NotifyPropertyChanged(NameOf(OtStatistic_IsEnabled))
End Sub
#End Region ' METHODS
#Region "COMMANDS"
#Region "ChangeParameter"
''' <summary>
''' Returns a command that do Open.
''' </summary>
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
''' <summary>
''' Execute the Open. This method is invoked by the OpenCommand.
''' </summary>
Friend Sub ChangeParameter()
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)))) Then Return
Dim ChangeParameterWndVM As New ChangeParameterWndVM
Dim ChangeParameterWnd As New ChangeParameterWndV(Application.Current.MainWindow, ChangeParameterWndVM)
If ChangeParameterWnd.ShowDialog() Then
LoadingWndHelper.OpenLoadingWnd(ActiveIds.CHANGEPARAM, 1, EgtMsg(63014), "", 100) ' Modifying parameters
' 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 Math.Abs( Param.dValue - ChangeParameterWndVM.SelParam.dActualValue) < EPS_SMALL Then
Param.UpdateParamValue(ChangeParameterWndVM.SelParam.dNewValue, "")
End If
Case BTLParamType.STRING_
If Param.sValue = ChangeParameterWndVM.SelParam.sActualValue Then
Param.UpdateParamValue(0, ChangeParameterWndVM.SelParam.sNewValue)
End If
End Select
Next
End If
Next
Next
End If
LoadingWndHelper.CloseLoadingWnd(ActiveIds.CHANGEPARAM)
End If
End Sub
#End Region ' ChangeParameter
#Region "ChangeMaterial"
''' <summary>
''' Returns a command that do Open.
''' </summary>
Public ReadOnly Property ChangeMaterial_Command As ICommand
Get
If m_cmdChangeMaterial Is Nothing Then
m_cmdChangeMaterial = New Command(AddressOf ChangeMaterial)
End If
Return m_cmdChangeMaterial
End Get
End Property
''' <summary>
''' Execute the Open. This method is invoked by the OpenCommand.
''' </summary>
Friend Sub ChangeMaterial()
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)))) Then Return
Dim ChangeMaterialWndVM As New ChangeMaterialWndVM
Dim ChangeMaterialWnd As New ChangeMaterialWndV(Application.Current.MainWindow, ChangeMaterialWndVM)
If ChangeMaterialWnd.ShowDialog() Then
LoadingWndHelper.OpenLoadingWnd(ActiveIds.CHANGEMATERIAL, 1, EgtMsg(63021), "", 100) ' Modifying materials
' faccio passare pezzi
If Not IsNothing(ChangeMaterialWndVM.SelProjMaterial) AndAlso Not IsNothing(ChangeMaterialWndVM.SelWhMaterial) Then
For Each Part In Map.refProjectVM.BTLStructureVM.BTLPartVMList.Where(Function(x) x.sMATERIAL = ChangeMaterialWndVM.SelProjMaterial)
Part.sMATERIAL = ChangeMaterialWndVM.SelWhMaterial
Next
End If
LoadingWndHelper.CloseLoadingWnd(ActiveIds.CHANGEMATERIAL)
End If
End Sub
#End Region ' ChangeMaterial
#Region "Visualization"
''' <summary>
''' Returns a command that do Open.
''' </summary>
Public ReadOnly Property Visualization_Command As ICommand
Get
If m_cmdVisualization Is Nothing Then
m_cmdVisualization = New Command(AddressOf Visualization)
End If
Return m_cmdVisualization
End Get
End Property
''' <summary>
''' Execute the Open. This method is invoked by the OpenCommand.
''' </summary>
Friend Sub Visualization()
m_bVisOtt_Selected = False
Dim StatisticsWndV As New StatisticsWndV(Application.Current.MainWindow, New StatisticsVM())
StatisticsWndV.ShowDialog()
End Sub
#End Region ' Visualization
#Region "Ottimization"
''' <summary>
''' Returns a command that do Open.
''' </summary>
Public ReadOnly Property Optimizer_Command As ICommand
Get
If m_cmdOptimizer Is Nothing Then
m_cmdOptimizer = New Command(AddressOf Optimizer)
End If
Return m_cmdOptimizer
End Get
End Property
''' <summary>
''' Execute the Open. This method is invoked by the OpenCommand.
''' </summary>
Friend Sub Optimizer()
m_bVisOtt_Selected = True
Dim OptimizerStatisticsWndV As New OptimizerStatisticsWndV(Application.Current.MainWindow, New StatisticsVM())
OptimizerStatisticsWndV.ShowDialog()
End Sub
#End Region ' Ottimization
#End Region ' COMMANDS
End Class