Files
egtbeamwall/EgtBEAMWALL.ViewerOptimizer/Project/ProjectVM.vb
T
2025-03-31 17:28:39 +02:00

462 lines
19 KiB
VB.net

Imports System.Windows.Threading
Imports EgtBEAMWALL.Core
Imports EgtWPFLib5
Imports System.Collections.ObjectModel
Public Class ProjectVM
Inherits VMBase
#Region "FIELDS & PROPERTIES"
Private m_Calc_Timer As New DispatcherTimer
Friend Event OnPreControllerExec(sFilePath As String)
Friend Event OnPostControllerExec()
' Flag per non salvare Script appena eseguito in elenco MruScript
Private m_bScriptInMru As Boolean = True
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_BTLStructureVM As BTLStructureVM
Public Property BTLStructureVM As BTLStructureVM
Get
Return m_BTLStructureVM
End Get
Set(value As BTLStructureVM)
m_BTLStructureVM = value
NotifyPropertyChanged(NameOf(BTLStructureVM))
End Set
End Property
Private m_MachGroupPanelVM As MyMachGroupPanelVM
Public Property MachGroupPanelVM As MyMachGroupPanelVM
Get
Return m_MachGroupPanelVM
End Get
Set(value As MyMachGroupPanelVM)
m_MachGroupPanelVM = value
NotifyPropertyChanged(NameOf(MachGroupPanelVM))
End Set
End Property
Private m_bCalcRunning As Boolean = False
Public ReadOnly Property bCalcRunning As Boolean
Get
Return m_bCalcRunning
End Get
End Property
Private m_bLockUX As Boolean = False
Private m_LeftPanel_Visibility As Boolean = True
Public Property LeftPanel_Visibility As Visibility
Get
Return If(m_LeftPanel_Visibility, Visibility.Visible, Visibility.Collapsed)
End Get
Set(value As Visibility)
m_LeftPanel_Visibility = (value = Visibility.Visible)
End Set
End Property
Friend Sub SetLeftPanel_Visibility(IsVisible As Boolean)
m_LeftPanel_Visibility = IsVisible
End Sub
Private m_TopPanel_Visibility As Boolean = False
Public Property TopPanel_Visibility As Visibility
Get
Return If(m_TopPanel_Visibility, Visibility.Visible, Visibility.Collapsed)
End Get
Set(value As Visibility)
m_TopPanel_Visibility = (value = Visibility.Visible)
End Set
End Property
Friend Sub SetTopPanel_Visibility(IsVisible As Boolean)
m_TopPanel_Visibility = IsVisible
End Sub
Private m_BottomPanel_Visibility As Boolean = True
Public Property BottomPanel_Visibility As Visibility
Get
Return If(m_BottomPanel_Visibility, Visibility.Visible, Visibility.Collapsed)
End Get
Set(value As Visibility)
m_BottomPanel_Visibility = (value = Visibility.Visible)
End Set
End Property
Friend Sub SetBottomPanel_Visibility(IsVisible As Boolean)
m_BottomPanel_Visibility = IsVisible
End Sub
Private m_PartManager_Visibility As Boolean = True
Public ReadOnly Property PartManager_Visibility As Visibility
Get
Return If(Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refProjectVM.BTLStructureVM.SelectionType = BTLStructureVM.SelectionTypes.SELECT_ AndAlso Not Map.refFreeContourManagerVM.bIsActive, Visibility.Visible, Visibility.Collapsed)
End Get
End Property
Private m_FeatureManager_Visibility As Boolean = True
Public Property FeatureManager_Visibility As Visibility
Get
Return If(m_FeatureManager_Visibility, Visibility.Visible, Visibility.Collapsed)
End Get
Set(value As Visibility)
m_FeatureManager_Visibility = (value = Visibility.Visible)
End Set
End Property
Friend Sub SetFeatureManager_Visibility(IsVisible As Boolean)
m_FeatureManager_Visibility = IsVisible
End Sub
Private m_ShowBeamPanel_Visibility As Boolean = True
Public Property ShowBeamPanel_Visibility As Visibility
Get
Return If(m_ShowBeamPanel_Visibility, Visibility.Visible, Visibility.Collapsed)
End Get
Set(value As Visibility)
m_ShowBeamPanel_Visibility = (value = Visibility.Visible)
End Set
End Property
Friend Sub SetShowBeamPanel_Visibility(IsVisible As Boolean)
m_ShowBeamPanel_Visibility = IsVisible
End Sub
Private m_ProjManager_Visibility As Boolean = True
Public Property ProjManager_Visibility As Visibility
Get
Return If(m_ProjManager_Visibility, Visibility.Visible, Visibility.Collapsed)
End Get
Set(value As Visibility)
m_ProjManager_Visibility = (value = Visibility.Visible)
End Set
End Property
Friend Sub SetProjManager_Visibility(IsVisible As Boolean)
m_ProjManager_Visibility = IsVisible
If Not IsNothing(Map.refProjManagerVM) Then Map.refProjManagerVM.NotifyPropertyChanged(NameOf(Map.refProjManagerVM.GoToProd_Visibility))
End Sub
Private m_ProdManager_Visibility As Boolean = True
Public Property ProdManager_Visibility As Visibility
Get
Return If(m_ProdManager_Visibility, Visibility.Visible, Visibility.Collapsed)
End Get
Set(value As Visibility)
m_ProdManager_Visibility = (value = Visibility.Visible)
End Set
End Property
Friend Sub SetProdManager_Visibility(IsVisible As Boolean)
m_ProdManager_Visibility = IsVisible
If Not IsNothing(Map.refProdManagerVM) Then Map.refProdManagerVM.NotifyPropertyChanged(NameOf(Map.refProdManagerVM.GoToProj_Visibility))
End Sub
Private m_OptimizePanel_Visibility As Boolean = True
Public Property OptimizePanel_Visibility As Visibility
Get
Return If(m_OptimizePanel_Visibility, Visibility.Visible, Visibility.Collapsed)
End Get
Set(value As Visibility)
m_OptimizePanel_Visibility = (value = Visibility.Visible)
End Set
End Property
Friend Sub SetOptimizePanel_Visibility(IsVisible As Boolean)
m_OptimizePanel_Visibility = IsVisible
NotifyPropertyChanged(NameOf(OptimizePanel_Visibility))
Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.CalcRotFlip_Visibility))
Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.Optimize_Visibility))
Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.OriginType_Visibility))
Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.ViewPage_Visibility))
Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.MachiningPage_Visibility))
Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.NestingOption_Visibility))
End Sub
Friend Sub NotifyCalcPanel_Visibility()
Map.refCALCPanelVM.NotifyPropertyChanged(NameOf(Map.refCALCPanelVM.ViewPage_Visibility))
Map.refCALCPanelVM.NotifyPropertyChanged(NameOf(Map.refCALCPanelVM.Edit_Visibility))
End Sub
Private m_FreeContourManager_Visibility As Boolean = False
Public Property FreeContourManager_Visibility As Visibility
Get
Return If(m_FreeContourManager_Visibility, Visibility.Visible, Visibility.Collapsed)
End Get
Set(value As Visibility)
m_FreeContourManager_Visibility = (value = Visibility.Visible)
End Set
End Property
Friend Sub SetFreeContourManager_Visibility(IsVisible As Boolean)
m_FreeContourManager_Visibility = IsVisible
NotifyPropertyChanged(NameOf(FreeContourManager_Visibility))
End Sub
' OnlyProdProject
Private m_OnlyProdManager_Visibility As Boolean = True
Public Property OnlyProdManager_Visibility As Visibility
Get
Return If(m_OnlyProdManager_Visibility, Visibility.Visible, Visibility.Collapsed)
End Get
Set(value As Visibility)
m_OnlyProdManager_Visibility = (value = Visibility.Visible)
End Set
End Property
Friend Sub SetOnlyProdManager_Visibility(IsVisible As Boolean)
m_OnlyProdManager_Visibility = IsVisible
End Sub
Private m_OnlyProdLeftPanel_Visibility As Boolean = True
Public Property OnlyProdLeftPanel_Visibility As Visibility
Get
Return If(m_OnlyProdLeftPanel_Visibility, Visibility.Visible, Visibility.Collapsed)
End Get
Set(value As Visibility)
m_OnlyProdLeftPanel_Visibility = (value = Visibility.Visible)
End Set
End Property
Friend Sub SetOnlyProdLeftPanel_Visibility(IsVisible As Boolean)
m_OnlyProdLeftPanel_Visibility = IsVisible
End Sub
Private m_OnlyProdOptimizePanel_Visibility As Boolean = True
Public Property OnlyProdOptimizePanel_Visibility As Visibility
Get
Return If(m_OnlyProdOptimizePanel_Visibility, Visibility.Visible, Visibility.Collapsed)
End Get
Set(value As Visibility)
m_OnlyProdOptimizePanel_Visibility = (value = Visibility.Visible)
End Set
End Property
Friend Sub SetOnlyProdOptimizePanel_Visibility(IsVisible As Boolean)
m_OnlyProdOptimizePanel_Visibility = IsVisible
NotifyPropertyChanged(NameOf(OnlyProdOptimizePanel_Visibility))
Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.CalcRotFlip_Visibility))
Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.Optimize_Visibility))
Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.OriginType_Visibility))
Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.ViewPage_Visibility))
Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.MachiningPage_Visibility))
Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.NestingOption_Visibility))
End Sub
Public ReadOnly Property SpecialPanel_Visibility As Visibility
Get
Return If(Map.refMainWindowVM.MainWindowM.bSpecialPanel AndAlso Map.refMainWindowVM.MainWindowM.nUserLevel > 5, Visibility.Visible, Visibility.Collapsed)
End Get
End Property
Private m_MacroFeature_IsEnabled As Boolean = False
Public Property MacroFeature_IsEnabled As Boolean
Get
Return m_MacroFeature_IsEnabled
End Get
Set(value As Boolean)
m_MacroFeature_IsEnabled = value
NotifyPropertyChanged(NameOf(MacroFeature_IsEnabled))
End Set
End Property
Enum GridSelTypes As Integer
PARTLIST = 1
PART = 2
MACHGROUP = 3
End Enum
Private m_LastSelGridType As GridSelTypes
Public ReadOnly Property LastSelGridType As GridSelTypes
Get
Return m_LastSelGridType
End Get
End Property
Friend Sub SetLastSelGridType(value As GridSelTypes)
m_LastSelGridType = value
End Sub
#End Region ' Fields & Properties
#Region "CONSTRUCTOR"
Sub New()
' Creo riferimento a questa classe in Map
Map.SetRefProjectVM(Me)
' imposto timer per aggiornamenti Calc
m_Calc_Timer.Interval = TimeSpan.FromMilliseconds(500)
AddHandler m_Calc_Timer.Tick, AddressOf Calc_Timer_Tick
' imposto dimensioni colonne/righe della Grid
Dim ProjectGridDim As String = If(Map.refMainWindowVM.MainWindowM.bOnlyProd, ConstDims.PROJECT_ONLYPROD, ConstDims.PROJECT_VIEW)
DimensionsIniFile.ReadGridDimensions(ProjectGridDim, GridDims)
End Sub
#End Region ' Constructor
#Region "METHODS"
Friend Sub SetCalcRunning(value As Boolean)
If value Then m_Calc_Timer.Start()
m_bCalcRunning = value
End Sub
Friend Sub ManageIsEnabled(bIsEnabled As Boolean)
Map.refInstrumentPanelVM.SetInstrumentPanelIsEnabled(bIsEnabled)
Map.refCALCPanelVM.SetCalcPanelIsEnabled(bIsEnabled)
Map.refMainMenuVM.SetMainMenuIsEnabled(bIsEnabled)
Map.refPartManagerVM.SetPartManagerIsEnabled(bIsEnabled)
Map.refLeftPanelVM.SetLeftPanelIsEnabled(bIsEnabled)
Map.refBTLPartManagerVM.SetBTLPartManagerIsEnabled(bIsEnabled)
Map.refFeatureListManagerVM.SetLeftPanelIsEnabled(bIsEnabled)
If Not IsNothing(Map.refProjManagerVM) Then Map.refProjManagerVM.SetProjManagerIsEnabled(bIsEnabled)
If Not IsNothing(Map.refProdManagerVM) Then Map.refProdManagerVM.SetProdManagerIsEnabled(bIsEnabled)
If Not IsNothing(Map.refTopPanelVM) Then Map.refTopPanelVM.SetTopPanelIsEnabled(bIsEnabled)
Map.refRawPartManagerVM.SetRawPartManagerIsEnabled(bIsEnabled)
Map.refPartInRawPartManagerVM.SetPartInRawPartManagerIsEnabled(bIsEnabled)
Map.refOptimizePanelVM.SetOptimizePanelIsEnabled(bIsEnabled)
Map.refFeatureManagerVM.SetFeatureManagerIsEnabled(bIsEnabled)
End Sub
Private Sub Calc_Timer_Tick()
If m_bCalcRunning <> m_bLockUX Then
' se calcolo iniziato
If m_bCalcRunning Then
ManageIsEnabled(False)
' aggiungere gestione colonne editabili delle tabelle
If Not IsNothing(Map.refPartListVM.colPart_Do) Then
Map.refPartListVM.colPart_Do.IsReadOnly = True
End If
If Not IsNothing(Map.refFeatureListVM.colFeature_Do) Then
Map.refFeatureListVM.colFeature_Do.IsReadOnly = True
End If
If Not IsNothing(Map.refPParameterListVM.colPParam_Value) Then
Map.refPParameterListVM.colPParam_Value.IsReadOnly = True
End If
If Not IsNothing(Map.refQParameterListVM.colQParam_Value) Then
Map.refQParameterListVM.colQParam_Value.IsReadOnly = True
End If
If Not IsNothing(Map.refQParameterListVM.colQParam_Custom) Then
Map.refQParameterListVM.colQParam_Custom.IsReadOnly = True
End If
If Not IsNothing(Map.refRawPartListVM.colRawPart_StartCut) Then
Map.refRawPartListVM.colRawPart_StartCut.IsReadOnly = True
End If
If Not IsNothing(Map.refRawPartListVM.colRawPart_W) Then
Map.refRawPartListVM.colRawPart_W.IsReadOnly = True
End If
If Not IsNothing(Map.refRawPartListVM.colRawPart_L) Then
Map.refRawPartListVM.colRawPart_L.IsReadOnly = True
End If
If Not IsNothing(Map.refRawPartListVM.colRawPart_PosZ) Then
Map.refRawPartListVM.colRawPart_PosZ.IsReadOnly = True
End If
If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_Offset) Then
Map.refPartInRawPartListVM.colPartInRawPart_Offset.IsReadOnly = True
End If
If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_Rot) Then
Map.refPartInRawPartListVM.colPartInRawPart_Rot.IsReadOnly = True
End If
If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_Flip) Then
Map.refPartInRawPartListVM.colPartInRawPart_Flip.IsReadOnly = True
End If
If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_PosX) Then
Map.refPartInRawPartListVM.colPartInRawPart_PosX.IsReadOnly = True
End If
If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_PosY) Then
Map.refPartInRawPartListVM.colPartInRawPart_PosY.IsReadOnly = True
End If
If Not IsNothing(Map.refFeatureInPartInRawPartListVM.colFeatureInPartInRawPart_Do) Then
Map.refFeatureInPartInRawPartListVM.colFeatureInPartInRawPart_Do.IsReadOnly = True
End If
m_bLockUX = True
' se calcolo finito
Else
ManageIsEnabled(True)
' aggiungere gestione colonne editabili delle tabelle
If Not IsNothing(Map.refPartListVM.colPart_Do) Then
Map.refPartListVM.colPart_Do.ResetToOrigIsReadOnly()
End If
If Not IsNothing(Map.refFeatureListVM.colFeature_Do) Then
Map.refFeatureListVM.colFeature_Do.ResetToOrigIsReadOnly()
End If
If Not IsNothing(Map.refPParameterListVM.colPParam_Value) Then
Map.refPParameterListVM.colPParam_Value.ResetToOrigIsReadOnly()
End If
If Not IsNothing(Map.refQParameterListVM.colQParam_Value) Then
Map.refQParameterListVM.colQParam_Value.ResetToOrigIsReadOnly()
End If
If Not IsNothing(Map.refQParameterListVM.colQParam_Custom) Then
Map.refQParameterListVM.colQParam_Custom.ResetToOrigIsReadOnly()
End If
If Not IsNothing(Map.refRawPartListVM.colRawPart_StartCut) Then
Map.refRawPartListVM.colRawPart_StartCut.ResetToOrigIsReadOnly()
End If
If m_BTLStructureVM.nPROJTYPE <> BWType.BEAM AndAlso Not IsNothing(Map.refRawPartListVM.colRawPart_W) Then
Map.refRawPartListVM.colRawPart_W.ResetToOrigIsReadOnly()
End If
If Not IsNothing(Map.refRawPartListVM.colRawPart_L) Then
Map.refRawPartListVM.colRawPart_L.ResetToOrigIsReadOnly()
End If
If Not IsNothing(Map.refRawPartListVM.colRawPart_PosZ) Then
Map.refRawPartListVM.colRawPart_PosZ.ResetToOrigIsReadOnly()
End If
If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_Offset) Then
Map.refPartInRawPartListVM.colPartInRawPart_Offset.ResetToOrigIsReadOnly()
End If
If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_Rot) Then
Map.refPartInRawPartListVM.colPartInRawPart_Rot.ResetToOrigIsReadOnly()
End If
If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_Flip) Then
Map.refPartInRawPartListVM.colPartInRawPart_Flip.ResetToOrigIsReadOnly()
End If
If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_PosX) Then
Map.refPartInRawPartListVM.colPartInRawPart_PosX.ResetToOrigIsReadOnly()
End If
If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_PosY) Then
Map.refPartInRawPartListVM.colPartInRawPart_PosY.ResetToOrigIsReadOnly()
End If
If Not IsNothing(Map.refFeatureInPartInRawPartListVM.colFeatureInPartInRawPart_Do) Then
Map.refFeatureInPartInRawPartListVM.colFeatureInPartInRawPart_Do.ResetToOrigIsReadOnly()
End If
' fermo il timer
If Not m_bCalcRunning Then
m_Calc_Timer.Stop()
m_bLockUX = False
End If
End If
End If
End Sub
Friend Sub ManageQParamsRowVisibility(bVisible As Boolean)
If bVisible Then
DimensionsIniFile.ReadGridDimensions(ConstDims.TOPPANEL_OPTIMIZER, GridDims)
Else
GridDimension.SetSoftwareMod(True)
Dim FeatureRow = m_GridDims(4)
Dim QParRow = m_GridDims(5)
m_GridDims(4).GridLen = New GridLength(1, GridUnitType.Star)
m_GridDims(4).NotifyPropertyChanged(NameOf(FeatureRow.GridLen))
m_GridDims(5).GridLen = New GridLength(0)
m_GridDims(5).NotifyPropertyChanged(NameOf(QParRow.GridLen))
GridDimension.SetSoftwareMod(False)
End If
End Sub
Friend Sub NotifyAllPanelVisibility()
NotifyPropertyChanged(NameOf(LeftPanel_Visibility))
NotifyPropertyChanged(NameOf(TopPanel_Visibility))
NotifyPropertyChanged(NameOf(BottomPanel_Visibility))
NotifyPropertyChanged(NameOf(PartManager_Visibility))
NotifyPropertyChanged(NameOf(FeatureManager_Visibility))
NotifyPropertyChanged(NameOf(ShowBeamPanel_Visibility))
NotifyPropertyChanged(NameOf(ProjManager_Visibility))
NotifyPropertyChanged(NameOf(ProdManager_Visibility))
NotifyCalcPanel_Visibility()
End Sub
#End Region ' Methods
End Class