Files
OmagVIEWPlus/MainWindow/MainWindowVM.vb
T
Nicola Pievani d950fc1060 OmagVIEWPlus 2.2j1:
-> nuova definizione dei pezzi (classe Part)
-> nuova gestione dei magazzini
-> aggiunta pagina per la selezione dei pezzi manuali
-> nuova configurazione delle variabili.
2020-10-09 08:13:48 +00:00

223 lines
7.0 KiB
VB.net

Imports EgtUILib
Imports EgtWPFLib5
Imports System.IO
Public Class MainWindowVM
Inherits VMBase
Private m_SceneHostV As SceneHostV
Private m_UnloadingAreaV As UnloadingAreaV
Private m_MySceneHostVM As MySceneHostVM
Private m_UnloadingAreaVM As UnloadingAreaVM
Private m_WaitingConfirmManualPart As Boolean = False
Public ReadOnly Property WaitingConfirmManualPart As Boolean
Get
Return m_WaitingConfirmManualPart
End Get
End Property
Private m_SceneIsChecked As Boolean = False
Public Property SceneIsChecked As Boolean
Get
Return m_SceneIsChecked
End Get
Set(value As Boolean)
m_SceneIsChecked = value
m_UnloadingAreaIsChecked = Not value
Map.refSceneHostVM.NotifyPropertyChanged("IsLayoutCheched")
Map.refSceneHostVM.NotifyPropertyChanged("VisibilityManulaPartCommand")
EgtZoom(ZM.ALL)
NotifyPropertyChanged("PageControl")
End Set
End Property
Private m_UnloadingAreaIsChecked As Boolean = True
Public Property UnloadingAreaIsChecked As Boolean
Get
Return m_UnloadingAreaIsChecked
End Get
Set(value As Boolean)
m_UnloadingAreaIsChecked = value
m_SceneIsChecked = Not value
Map.refUnloadingAreaVM.NotifyPropertyChanged("refScenaIsChecked")
NotifyPropertyChanged("PageControl")
End Set
End Property
Public ReadOnly Property PageControl As ContentControl
Get
If m_SceneIsChecked Then
NotifyPropertyChanged("SceneIsChecked")
NotifyPropertyChanged("UnloadingAreaIsChecked")
Return m_SceneHostV
Else
NotifyPropertyChanged("SceneIsChecked")
NotifyPropertyChanged("UnloadingAreaIsChecked")
Return m_UnloadingAreaV
End If
End Get
End Property
' Riferimento al Model della MainWindow
Private m_MainWindowM As MainWindowM
Friend ReadOnly Property MainWindowM As MainWindowM
Get
Return m_MainWindowM
End Get
End Property
' Dichiarazione della classe di connessione al PLC
Friend m_CNCommunication As NCCommunication
' Variabile che indica che il programma è stato avviato correttamente (sia la mappa che l'ambiente Egt)
Private m_bInitStatus As Boolean
Friend ReadOnly Property bInitStatus As Boolean
Get
Return m_bInitStatus
End Get
End Property
' Titolo
Private m_Title As String
Public Property Title As String
Get
Return m_Title
End Get
Set(value As String)
m_Title = value
NotifyPropertyChanged("Title")
End Set
End Property
Private m_ContentControl As UserControl
Public Property ContentControl As UserControl
Get
Return m_ContentControl
End Get
Set(value As UserControl)
m_ContentControl = value
End Set
End Property
' definizione comandi
Private m_cmdAboutBox As ICommand
Private m_cmdCloseApplication As ICommand
Private m_cmdOpenScene As ICommand
Private m_cmdOpenUnloadingArea As ICommand
#Region "CONSTRUCTOR"
Sub New()
' Avvio l'inizializzazione della mappa passandogli il riferimento al MainWindowVM
Map.BeginInit(Me)
' Creo Model della MainWindow
m_MainWindowM = New MainWindowM
' Genero il contenuto della scena
m_MySceneHostVM = New MySceneHostVM()
' Genero la scena
m_SceneHostV = New SceneHostV
' Genero il contenuto dell'UnloadingArea
m_UnloadingAreaVM = New UnloadingAreaVM
' Genero UnloadingArea
m_UnloadingAreaV = New UnloadingAreaV
End Sub
#End Region ' CONSTRUCTOR
#Region "METHODS"
Friend Sub SetTitle(sTitle As String)
m_Title = sTitle
NotifyPropertyChanged("Title")
End Sub
Friend Sub ContentRendered()
' Verifico che l'inizializzazione di tutte le parti del programma sia andata a buon fine
If Map.EndInit() Then
m_bInitStatus = True
' altrimenti chiudo il programma
Else
m_bInitStatus = False
End If
' Creazione gestore comunicazione con PLC
m_CNCommunication = New NCCommunication
'SetTitle("OmagVIEWPlus")
End Sub
Friend Function StartUnloadingProject() As Boolean
' prima di iniziare verifico la presenza del file .new
' carico progetto corrente solo se il file non è stato confermato
If Not m_WaitingConfirmManualPart Then
m_WaitingConfirmManualPart = MainWindowM.LoadProject()
SetTitle("CurrProj " & m_MainWindowM.nProjInd.ToString & " - OmagVIEWPlus")
End If
' se non sono riuscito a caricare esco
If Not m_WaitingConfirmManualPart Then Return False
' rendo visibile la freccia rossa
Map.refUnloadingAreaVM.Table1ArrowVisibility = Visibility.Visible
' eventualmente rendo visibilie il bottone per la conferma selezione manuale
Map.refSceneHostVM.NotifyPropertyChanged("VisibilityManulaPartCommand")
' se non ho dato conferma del pezzo allora aspetto (bottone acceso)
If Map.refUnloadingAreaVM.IsChecked_Manual Then Return False
' significa che la selezione è avvenuta
m_WaitingConfirmManualPart = False
' nascondo la freccia rossa
Map.refUnloadingAreaVM.Table1ArrowVisibility = Visibility.Collapsed
' passo al posizionamento delle ventose
Return MyUpdateVacuumsForUnloading()
End Function
#End Region ' METHODS
#Region "COMMANDS"
#Region "AboutBoxCommand"
' Returns a command that manage the MainWindow_Unloaded command
Public ReadOnly Property AboutBoxCommand() As ICommand
Get
If m_cmdAboutBox Is Nothing Then
m_cmdAboutBox = New Command(AddressOf AboutBox)
End If
Return m_cmdAboutBox
End Get
End Property
' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded.
Public Sub AboutBox(ByVal param As Object)
Dim AboutBoxWindow As New AboutBoxV
AboutBoxWindow.Owner = Application.Current.MainWindow
AboutBoxWindow.ShowDialog()
End Sub
#End Region ' AboutBoxCommand
#Region "CloseApplicationCommand"
' Returns a command that manage the MainWindow_Unloaded command
Public ReadOnly Property CloseApplicationCommand() As ICommand
Get
If m_cmdCloseApplication Is Nothing Then
m_cmdCloseApplication = New Command(AddressOf CloseApplication)
End If
Return m_cmdCloseApplication
End Get
End Property
' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded.
Public Sub CloseApplication(ByVal param As Object)
' Termino il Model
m_MainWindowM.Close()
' Termino il programma
Application.Current.Shutdown()
End Sub
#End Region ' CloseApplicationCommand
#End Region ' COMMANDS
End Class