Imports System.Windows.Threading Imports EgtBEAMWALL.Core Imports EgtWPFLib5 Imports System.Collections.ObjectModel Imports EgtUILib 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_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_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_OnlyProdLeftPanel_IsEnabled As Boolean = True Public Property OnlyProdLeftPanel_IsEnabled As Boolean Get Return m_OnlyProdLeftPanel_IsEnabled End Get Set(value As Boolean) m_OnlyProdLeftPanel_IsEnabled = value End Set End Property Friend Sub SetOnlyProdLeftPanel_IsEnabled(IsEnabled As Boolean) m_OnlyProdLeftPanel_IsEnabled = IsEnabled NotifyPropertyChanged(NameOf(OnlyProdLeftPanel_IsEnabled)) End Sub Private m_OnlyProdLeftPanel_Opacity As Double = 1 Public Property OnlyProdLeftPanel_Opacity As Double Get Return m_OnlyProdLeftPanel_Opacity End Get Set(value As Double) m_OnlyProdLeftPanel_Opacity = value End Set End Property Friend Sub SetOnlyProdLeftPanel_Opacity(Opacity As Double) m_OnlyProdLeftPanel_Opacity = Opacity NotifyPropertyChanged(NameOf(OnlyProdLeftPanel_Opacity)) 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.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 ' Gestione Tab con Strategy Friend Enum StrategyManagerTab As Integer NULL = -1 RAWPARTMANAGER = 0 FEATUREMANAGER = 1 STRATEGYMANAGER = 2 FEATUREMANAGERBTL = 3 End Enum Private m_SelManagerTab As StrategyManagerTab Public Property SelManagerTab As Integer Get Return m_SelManagerTab End Get Set(value As Integer) m_SelManagerTab = value End Set End Property Friend Sub SetSelManagerTab(bSelManagerTab As StrategyManagerTab) m_SelManagerTab = bSelManagerTab NotifyPropertyChanged(NameOf(SelManagerTab)) End Sub Friend Enum FeatureManagerTab As Integer NULL = -1 FEATURERAWPARTMANAGER = 0 STRATEGYMANAGERBTL = 1 End Enum Private m_SelFeatureManagerTab As FeatureManagerTab Public Property SelFeatureManagerTab As Integer Get Return m_SelFeatureManagerTab End Get Set(value As Integer) m_SelFeatureManagerTab = value End Set End Property Friend Sub SetSelFeatureManagerTab(bSelFeatureManagerTab As FeatureManagerTab) m_SelFeatureManagerTab = bSelFeatureManagerTab NotifyPropertyChanged(NameOf(SelFeatureManagerTab)) End Sub Private m_FeatureList_Visibility As Visibility = Visibility.Collapsed Public ReadOnly Property FeatureList_Visibility As Visibility Get Return m_FeatureList_Visibility End Get End Property Sub SetFeatureListVisibility(bVisible As Visibility) m_FeatureList_Visibility = bVisible NotifyPropertyChanged(NameOf(FeatureList_Visibility)) End Sub Private m_RawPartManagerVisibility As Visibility = Visibility.Collapsed Public ReadOnly Property RawPartManagerVisibility As Visibility Get Return m_RawPartManagerVisibility End Get End Property Sub SetRawPartManagerVisibility(bVisible As Visibility) m_RawPartManagerVisibility = bVisible NotifyPropertyChanged(NameOf(RawPartManagerVisibility)) End Sub Private m_StrategyManagerVisibility As Visibility = Visibility.Collapsed Public ReadOnly Property StrategyManagerVisibility As Visibility Get Return m_StrategyManagerVisibility End Get End Property Sub SetStrategyManagerVisibility(bVisible As Visibility) m_StrategyManagerVisibility = bVisible NotifyPropertyChanged(NameOf(StrategyManagerVisibility)) End Sub Private m_SceneShowBuldingVisibility As Visibility = Visibility.Collapsed Public ReadOnly Property SceneShowBuldingVisibility As Visibility Get Return m_SceneShowBuldingVisibility End Get End Property Sub SetSceneShowBuldingVisibility(bVisible As Visibility) m_SceneShowBuldingVisibility = bVisible NotifyPropertyChanged(NameOf(SceneShowBuldingVisibility)) End Sub Private m_ManagerTabVisibility As Visibility = Visibility.Visible Public ReadOnly Property ManagerTabVisibility As Visibility Get Return m_ManagerTabVisibility End Get End Property Sub SetManagerTabVisibility(bVisible As Visibility) m_ManagerTabVisibility = bVisible NotifyPropertyChanged(NameOf(ManagerTabVisibility)) End Sub #Region "Messages" Public ReadOnly Property Statistics_Msg As String Get Return EgtMsg(61923) End Get End Property Public ReadOnly Property Parameters_ToolTip As String Get Return EgtMsg(61898) End Get End Property #End Region ' Messages ' Definizione Comandi Private m_cmdVisualization As ICommand Private m_cmdOptimizer As ICommand Private m_cmdParameter As ICommand Private m_cmdBack As ICommand #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 DimensionsIniFile.ReadGridDimensions(ConstDims.PROJECT_ONLYPROD, 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.refMainMenuVM.SetMainMenuIsEnabled(bIsEnabled) If Not IsNothing(Map.refPartManagerVM) Then Map.refPartManagerVM.SetPartManagerIsEnabled(bIsEnabled) Map.refLeftPanelVM.SetLeftPanelIsEnabled(bIsEnabled) Map.refBTLPartManagerVM.SetBTLPartManagerIsEnabled(bIsEnabled) Map.refRawPartManagerVM.SetRawPartManagerIsEnabled(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) AndAlso 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) AndAlso Not IsNothing(Map.refQParameterListVM.colQParam_Value) Then Map.refQParameterListVM.colQParam_Value.IsReadOnly = True End If If Not IsNothing(Map.refQParameterListVM) AndAlso 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) AndAlso Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_Offset) Then Map.refPartInRawPartListVM.colPartInRawPart_Offset.IsReadOnly = True End If If Not IsNothing(Map.refPartInRawPartListVM) AndAlso Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_Rot) Then Map.refPartInRawPartListVM.colPartInRawPart_Rot.IsReadOnly = True End If If Not IsNothing(Map.refPartInRawPartListVM) AndAlso Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_Flip) Then Map.refPartInRawPartListVM.colPartInRawPart_Flip.IsReadOnly = True End If If Not IsNothing(Map.refPartInRawPartListVM) AndAlso Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_PosX) Then Map.refPartInRawPartListVM.colPartInRawPart_PosX.IsReadOnly = True End If If Not IsNothing(Map.refPartInRawPartListVM) AndAlso 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) AndAlso 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) AndAlso Not IsNothing(Map.refQParameterListVM.colQParam_Value) Then Map.refQParameterListVM.colQParam_Value.ResetToOrigIsReadOnly() End If If Not IsNothing(Map.refQParameterListVM) AndAlso 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) AndAlso Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_Offset) Then Map.refPartInRawPartListVM.colPartInRawPart_Offset.ResetToOrigIsReadOnly() End If If Not IsNothing(Map.refPartInRawPartListVM) AndAlso Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_Rot) Then Map.refPartInRawPartListVM.colPartInRawPart_Rot.ResetToOrigIsReadOnly() End If If Not IsNothing(Map.refPartInRawPartListVM) AndAlso Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_Flip) Then Map.refPartInRawPartListVM.colPartInRawPart_Flip.ResetToOrigIsReadOnly() End If If Not IsNothing(Map.refPartInRawPartListVM) AndAlso Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_PosX) Then Map.refPartInRawPartListVM.colPartInRawPart_PosX.ResetToOrigIsReadOnly() End If If Not IsNothing(Map.refPartInRawPartListVM) AndAlso 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(FeatureManager_Visibility)) NotifyPropertyChanged(NameOf(ShowBeamPanel_Visibility)) End Sub #End Region ' Methods #Region "COMMAND" #Region "Visualization" ''' ''' Returns a command that do Open. ''' 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 ''' ''' Execute the Open. This method is invoked by the OpenCommand. ''' Friend Sub Visualization() Dim StatisticsWndV As New StatisticsWndV(Application.Current.MainWindow, New StatisticsVM()) StatisticsWndV.ShowDialog() End Sub #End Region ' Visualization #Region "Ottimization" ''' ''' Returns a command that do Open. ''' 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 ''' ''' Execute the Open. This method is invoked by the OpenCommand. ''' Friend Sub Optimizer() Dim OptimizerStatisticsWndV As New OptimizerStatisticsWndV(Application.Current.MainWindow, New StatisticsVM()) OptimizerStatisticsWndV.ShowDialog() End Sub #End Region ' Ottimization #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 "Back_Command" Public ReadOnly Property Back_Command As ICommand Get If m_cmdBack Is Nothing Then m_cmdBack = New Command(AddressOf Back) End If Return m_cmdBack End Get End Property Public Sub Back() Map.refProjectVM.SetRawPartManagerVisibility(Visibility.Visible) If Not IsNothing(Map.refProjectVM.MachGroupPanelVM) Then Map.refProjectVM.SetFeatureListVisibility(Visibility.Visible) Map.refProjectVM.SetStrategyManagerVisibility(Visibility.Collapsed) Map.refProjectVM.SetSelManagerTab(ProjectVM.StrategyManagerTab.RAWPARTMANAGER) Map.refProjectVM.SetSelFeatureManagerTab(ProjectVM.FeatureManagerTab.FEATURERAWPARTMANAGER) ' Abilito LeftPanel Map.refProjectVM.SetOnlyProdLeftPanel_IsEnabled(True) Map.refProjectVM.SetOnlyProdLeftPanel_Opacity(1) End Sub #End Region ' Cancel_Command #End Region ' Command End Class