Files
egtbeamwall/EgtBEAMWALL.ViewerOptimizer/MainMenu/MainMenuVM.vb
T
RenzoL f1640f75f8 - Creato l'oggetto EgtDataGridColumn per gestire diverse proprietà (Width, IsReadOnly, DisplayIndex, ecc.) per ogni colonna singolarmente di una EgtDataGrid
- Aggiunta gestione colonne (e relative proprietà) delle EgtDataGrid tramite lettura/scrittura su file ini
2021-07-12 17:29:51 +02:00

300 lines
12 KiB
VB.net

Imports System.Collections.ObjectModel
Imports System.IO
Imports EgtBEAMWALL.Core
Imports EgtBEAMWALL.Core.ConstBeam
Imports EgtUILib
Imports EgtWPFLib5
Public Class MainMenuVM
Inherits VMBase
#Region "FIELDS & PROPERTIES"
Private m_MainMenu_IsEnabled As Boolean = True
Public ReadOnly Property MainMenu_IsEnabled As Boolean
Get
Return m_MainMenu_IsEnabled
End Get
End Property
Public Property View_IsChecked As Boolean
Get
Return m_SelPage = Pages.VIEW
End Get
Set(value As Boolean)
If value Then SelPage = Pages.VIEW
End Set
End Property
Public Property Machining_IsChecked As Boolean
Get
Return m_SelPage = Pages.MACHINING
End Get
Set(value As Boolean)
If value Then SelPage = Pages.MACHINING
End Set
End Property
Public Property Supervisor_IsChecked As Boolean
Get
Return m_SelPage = Pages.SUPERVISOR
End Get
Set(value As Boolean)
If value Then SelPage = Pages.SUPERVISOR
End Set
End Property
Public Property Config_IsChecked As Boolean
Get
Return m_SelPage = Pages.CONFIG
End Get
Set(value As Boolean)
If value Then SelPage = Pages.CONFIG
End Set
End Property
Private m_SelPage As Integer = -1
Public Property SelPage As Integer
Get
Return m_SelPage
End Get
Set(value As Integer)
' lancio selezione pagina con verifica file modificato
SetSelPage(value)
End Set
End Property
' funzione che permette di cambiare pagina
' bVerifyModification: se vero verifica modifiche su file e chiede di salvare
Friend Sub SetSelPage(Page As Pages, Optional bVerifyModification As Boolean = True)
Dim bOk As Boolean = True
' Esco dallo stato corrente
Select Case m_SelPage
Case Pages.VIEW
bOk = ExitVIEW(bVerifyModification)
Case Pages.MACHINING
bOk = ExitMACHINING(bVerifyModification)
Case Pages.CONFIG
bOk = ExitCONFIG()
End Select
If bOk Then
' Entro nel nuovo stato
m_SelPage = Page
Select Case m_SelPage
Case Pages.VIEW
' Map.refMachGroupPanelVM.SetMachGroupState(False)
InitVIEW()
'Map.refTopCommandBarVM.IsEnabled = False
Case Pages.MACHINING
' Map.refMachGroupPanelVM.SetMachGroupState(True)
InitMACHINING()
'Map.refTopCommandBarVM.IsEnabled = True
Case Pages.CONFIG
InitCONFIG()
'Map.refMachGroupPanelVM.SetMachGroupState(False)
'Map.refCONFIGTabVM.InitCONFIGation()
'Map.refTopCommandBarVM.IsEnabled = False
End Select
End If
' aggiorno visualizzazione RadioButton
NotifyPropertyChanged("View_IsChecked")
NotifyPropertyChanged("Machining_IsChecked")
NotifyPropertyChanged("Supervisor_IsChecked")
NotifyPropertyChanged("Config_IsChecked")
Map.refProjectVM.NotifyPropertyChanged("SelItem")
End Sub
#Region "Messages"
Public ReadOnly Property Viewer_Msg As String
Get
Return EgtMsg(61830)
End Get
End Property
Public ReadOnly Property Optimizer_Msg As String
Get
Return EgtMsg(61831)
End Get
End Property
Public ReadOnly Property Configuration_Msg As String
Get
Return EgtMsg(61832)
End Get
End Property
#End Region ' Messages
#End Region ' Fields & Properties
#Region "CONSTRUCTOR"
Sub New()
' Creo riferimento a questa classe in EgtCAM5Map
Map.SetRefMainMenuVM(Me)
End Sub
#End Region ' CONSTRUCTOR
#Region "METHODS"
Friend Sub SetMainMenuIsEnabled(bIsEnabled As Boolean)
m_MainMenu_IsEnabled = bIsEnabled
NotifyPropertyChanged(NameOf(MainMenu_IsEnabled))
End Sub
Private Function InitVIEW() As Boolean
Map.refProjectVM.SetBottomPanel_Visibility(True)
Map.refProjectVM.SetLeftPanel_Visibility(True)
Map.refLeftPanelVM.UpdateView()
Map.refProjectVM.SetPartManager_Visibility(False)
Map.refProjectVM.SetFeatureManager_Visibility(True)
Map.refProjectVM.SetTopPanel_Visibility(False)
Map.refProjectVM.SetShowBeamPanel_Visibility(True)
Map.refProjectVM.SetProjManager_Visibility(True)
Map.refProjectVM.SetProdManager_Visibility(False)
Map.refProjectVM.NotifyAllPanelVisibility()
' apro progetto proj
If Not IsNothing(Map.refProjManagerVM.CurrProj) Then
If IsNothing(Map.refProjManagerVM.CurrProj) OrElse Map.refProjManagerVM.CurrProj.bReloadProject Then
'Map.refProjManagerVM.OpenProject(Map.refProjManagerVM.CurrProj)
If Map.refSceneHostVM.MainController.OpenProject(Map.refProjManagerVM.CurrProj.sProjPath, False) Then
' aggiorno le colonne in base al tipo progetto
Map.refRawPartListVM.UpdateColumns(Map.refProjectVM.BTLStructureVM.nPROJTYPE)
Map.refPartInRawPartListVM.UpdateColumns(Map.refProjectVM.BTLStructureVM.nPROJTYPE)
DbControllers.m_ProjController.LockByProjId(Map.refProjManagerVM.CurrProj.nProjId, True)
' aggiorno titolo
Map.refMainWindowVM.UpdateTitle()
Map.refProjManagerVM.NotifyPropertyChanged(NameOf(Map.refProjManagerVM.MruFileNames))
End If
Else
' verifico se il prod di provenienza ha piu' proj
If Not IsNothing(Map.refProdManagerVM.CurrProd) AndAlso Map.refProdManagerVM.CurrProd.nProjIdList.Count > 1 Then
' se si rigenero BTLStructure
Map.refProjectVM.BTLStructureVM = New BTLStructureVM(BTLStructureM.CreateBTLStructure(Map.refProjManagerVM.CurrProj.nProjId))
End If
' mostro tutti i pezzi
Map.refShowBeamPanelVM.ShowAll()
Map.refProjManagerVM.CurrProj.SetReloadProject(True)
End If
DbControllers.m_ProjController.LockByProjId(Map.refProjManagerVM.CurrProj.nProjId, True)
Else
Map.refSceneHostVM.MainController.NewProject()
Map.refProjectVM.BTLStructureVM = Nothing
Map.refProjectVM.MachGroupPanelVM = Nothing
End If
Map.refMainWindowVM.NotifyPropertyChanged(NameOf(Map.refMainWindowVM.nSelTabPage))
Map.refInstrumentPanelVM.NotifyPropertyChanged(NameOf(Map.refInstrumentPanelVM.ChangeParam_Visibility))
Return True
End Function
Private Function ExitVIEW(bVerifyModification As Boolean) As Boolean
' verifico se progetto modificato, e chiedo se salvare
If bVerifyModification Then
If Not ProjFileVM.VerifyProjectModification(Map.refProjManagerVM.CurrProj, ProjectType.PROJ) Then
Return False
End If
End If
' resetto eventuale visualizzazione statistiche
Map.refInstrumentPanelVM.ResetStatisticsIsChecked()
Map.refProjectVM.SetBottomPanel_Visibility(False)
Map.refProjectVM.SetLeftPanel_Visibility(True)
Map.refProjectVM.SetPartManager_Visibility(False)
Map.refProjectVM.SetFeatureManager_Visibility(False)
Map.refProjectVM.SetTopPanel_Visibility(True)
Map.refProjectVM.SetShowBeamPanel_Visibility(False)
Map.refProjectVM.SetProjManager_Visibility(False)
Map.refProjectVM.SetProdManager_Visibility(True)
Return True
End Function
Private Function InitMACHINING() As Boolean
Map.refProjectVM.SetBottomPanel_Visibility(False)
Map.refProjectVM.SetLeftPanel_Visibility(True)
Map.refLeftPanelVM.UpdateView()
Map.refProjectVM.SetPartManager_Visibility(False)
Map.refProjectVM.SetFeatureManager_Visibility(False)
Map.refProjectVM.SetTopPanel_Visibility(True)
Map.refProjectVM.SetShowBeamPanel_Visibility(False)
Map.refProjectVM.SetProjManager_Visibility(False)
Map.refProjectVM.SetProdManager_Visibility(True)
Map.refProjectVM.NotifyAllPanelVisibility()
' inizializzo gruppi di lavorazione
If Not IsNothing(Map.refProdManagerVM.CurrProd) AndAlso Not IsNothing(Map.refProdManagerVM.CurrProd.nProdId) AndAlso Map.refProdManagerVM.CurrProd.nProdId > 0 Then
If File.Exists(Map.refProdManagerVM.CurrProd.sProdPath) Then
' apro progetto
If Map.refProdManagerVM.CurrProd.bReloadProject Then
If Map.refSceneHostVM.MainController.OpenProject(Map.refProdManagerVM.CurrProd.sProdPath, False) Then
' aggiorno le colonne in base al tipo progetto
Map.refRawPartListVM.UpdateColumns(Map.refProjectVM.BTLStructureVM.nPROJTYPE)
Map.refPartInRawPartListVM.UpdateColumns(Map.refProjectVM.BTLStructureVM.nPROJTYPE)
DbControllers.m_ProdController.LockByProdId(Map.refProdManagerVM.CurrProd.nProdId, True)
' aggiorno titolo
Map.refMainWindowVM.UpdateTitle()
Map.refProdManagerVM.NotifyPropertyChanged(NameOf(Map.refProdManagerVM.MruFileNames))
End If
Else
' verifico se il prod ha piu' proj
If Map.refProdManagerVM.CurrProd.nProjIdList.Count > 1 Then
' se si rigenero BTLStructure
Map.refProjectVM.BTLStructureVM = New BTLStructureVM(BTLStructureM.CreateBTLStructure(0))
End If
' mostro tutti i pezzi
Map.refShowBeamPanelVM.ShowAll()
' carico lista dei MachGroup
Map.refProjectVM.MachGroupPanelVM = New MyMachGroupPanelVM(MyMachGroupPanelM.CreateMyMachGroupPanel(Map.refMachinePanelVM.MachineList.ToList()))
Map.refProjManagerVM.CurrProj.SetReloadProject(True)
End If
'DbControllers.m_ProdController.ResetController()
DbControllers.m_ProdController.LockByProdId(Map.refProdManagerVM.CurrProd.nProdId, True)
' seleziono prima barra
Map.refProjectVM.MachGroupPanelVM.SelFirstMachGroup()
Else
MessageBox.Show(EgtMsg(61871))
End If
Else
Map.refSceneHostVM.MainController.NewProject()
Map.refProjectVM.BTLStructureVM = Nothing
Map.refProjectVM.MachGroupPanelVM = Nothing
End If
Map.refMainWindowVM.NotifyPropertyChanged(NameOf(Map.refMainWindowVM.nSelTabPage))
Map.refInstrumentPanelVM.NotifyPropertyChanged(NameOf(Map.refInstrumentPanelVM.ChangeParam_Visibility))
Return True
End Function
Private Function ExitMACHINING(bVerifyModification As Boolean) As Boolean
' verifico se progetto modificato, e chiedo se salvare
If bVerifyModification Then
If Not ProdFileVM.VerifyProjectModification(Map.refProdManagerVM.CurrProd) Then
Return False
End If
End If
' resetto eventuale visualizzazione statistiche
Map.refInstrumentPanelVM.ResetStatisticsIsChecked()
Map.refProjectVM.SetBottomPanel_Visibility(True)
Map.refProjectVM.SetLeftPanel_Visibility(False)
Map.refProjectVM.SetPartManager_Visibility(False)
Map.refProjectVM.SetFeatureManager_Visibility(True)
Map.refProjectVM.SetTopPanel_Visibility(False)
Map.refProjectVM.SetShowBeamPanel_Visibility(True)
Map.refProjectVM.SetProjManager_Visibility(True)
Map.refProjectVM.SetProdManager_Visibility(False)
EgtResetCurrMachGroup()
Return True
End Function
Private Function InitCONFIG() As Boolean
Map.refMainWindowVM.NotifyPropertyChanged("nSelTabPage")
Return True
End Function
Private Function ExitCONFIG() As Boolean
Map.refConfigurationPageVM.VerifyConfigPageModification()
' resetto flag inserimento password
Map.refConfigurationPageVM.bModifyMachParam = False
Return True
End Function
#End Region ' METHODS
End Class