7494e86397
- modifiche per libreria EgtSTONELib rinominata in EgtPHOTOLib.
214 lines
7.9 KiB
VB.net
214 lines
7.9 KiB
VB.net
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
Imports EgtPHOTOLib
|
|
Imports System.IO
|
|
|
|
Public Class MainWindowVM
|
|
Inherits VMBase
|
|
|
|
' Riferimento al Model della MainWindow
|
|
Private m_MainWindowM As MainWindowM
|
|
Friend ReadOnly Property MainWindowM As MainWindowM
|
|
Get
|
|
Return m_MainWindowM
|
|
End Get
|
|
End Property
|
|
|
|
' 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
|
|
|
|
' Finestra per VeinMatching
|
|
Private m_VeinMatchingWnd As VeinMatchingWindow = Nothing
|
|
Friend ReadOnly Property VeinMatchingWnd As VeinMatchingWindow
|
|
Get
|
|
Return m_VeinMatchingWnd
|
|
End Get
|
|
End Property
|
|
|
|
' definizione comandi
|
|
Private m_cmdAboutBox As ICommand
|
|
Private m_cmdCloseApplication As ICommand
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
' Avvio l'inizializzazione della mappa passandogli il riferimento al MainWindowVM
|
|
OmagOFFICEMap.BeginInit(Me)
|
|
' Creo Model della MainWindow
|
|
m_MainWindowM = New MainWindowM
|
|
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 OmagOFFICEMap.EndInit() Then
|
|
m_bInitStatus = True
|
|
AddHandler OmagOFFICEMap.refSceneHostVM.MainController.OnSavedProject, AddressOf OmagOFFICEMap.refMainWindowVM.SetProjectSaved
|
|
' altrimenti chiudo il programma
|
|
Else
|
|
m_bInitStatus = False
|
|
End If
|
|
' Inizializzo gestore CSV
|
|
InitCsvM()
|
|
' Verifico abilitazione VeinMatching
|
|
Dim bVmOn As Boolean = MainWindowM.GetKeyOption(KEY_OPT.VM_MULTI) And
|
|
GetMainPrivateProfileInt(S_VEINMATCHING, K_VEINMA_ENABLE, 0) <> 0
|
|
OmagOFFICEMap.refVeinMatchPanelVM.VeinMatchIsEnabled = bVmOn
|
|
' Se abilitato e richiesto carico finestra per VeinMatching
|
|
If bVmOn And IsNothing(m_VeinMatchingWnd) Then
|
|
m_VeinMatchingWnd = New VeinMatchingWindow
|
|
m_VeinMatchingWnd.Owner = Application.Current.MainWindow
|
|
m_VeinMatchingWnd.Show()
|
|
m_VeinMatchingWnd.Hide()
|
|
VeinMatching.m_nVeinCtx = m_VeinMatchingWnd.VeinMatchingScene.GetCtx()
|
|
EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx())
|
|
m_VeinMatchingWnd.AdjustPosition()
|
|
' Leggo dimensioni immagini esportate
|
|
Dim nImgWidth = GetMainPrivateProfileInt(S_VEINMATCHING, K_VEINMA_IMGWIDTH, 1600)
|
|
Dim nImgHeight = GetMainPrivateProfileInt(S_VEINMATCHING, K_VEINMA_IMGHEIGHT, 1200)
|
|
VeinMatching.SetExportImageDim(nImgWidth, nImgHeight)
|
|
End If
|
|
' Aggiorno visualizzazione unità di misura
|
|
OmagOFFICEMap.refStatusBarVM.SetMeasureUnit(If(EgtUiUnitsAreMM(), MeasureUnitOpt.MM, MeasureUnitOpt.INCH))
|
|
' Se istanza oltre la prima, chiedo cosa aprire
|
|
If Not m_MainWindowM.bFirstInstance Then
|
|
OmagOFFICEMap.refTopCommandBarVM.Open()
|
|
' altrimenti verifico se richiesto ultimo progetto
|
|
ElseIf GetMainPrivateProfileInt(S_GENERAL, K_AUTOLOADLASTPROJ, 0) = 1 Then
|
|
Dim sLastProjectPath As String = String.Empty
|
|
GetMainPrivateProfileString(S_GENERAL, K_LASTPROJ, String.Empty, sLastProjectPath)
|
|
If Not String.IsNullOrWhiteSpace(sLastProjectPath) AndAlso File.Exists(sLastProjectPath) Then
|
|
OmagOFFICEMap.refTopCommandBarVM.OpenProject(sLastProjectPath)
|
|
Else
|
|
OmagOFFICEMap.refTopCommandBarVM.NewCmd()
|
|
End If
|
|
' altrimenti nuovo progetto
|
|
Else
|
|
OmagOFFICEMap.refTopCommandBarVM.NewCmd()
|
|
End If
|
|
End Sub
|
|
|
|
Private ProjectSaved As Boolean = False
|
|
Private Sub SetProjectSaved()
|
|
If OmagOFFICEMap.refMainWindowVM.MainWindowM.m_SlabDB Then
|
|
' quando salvo un progetto la lista corrente dievnta la lista origine
|
|
OmagOFFICEMap.refMachGroupPanelVM.SlabNameListOrig.Clear()
|
|
For Each CurrSlab In OmagOFFICEMap.refMachGroupPanelVM.SlabNameListCurr
|
|
OmagOFFICEMap.refMachGroupPanelVM.SlabNameListOrig.Add(CurrSlab)
|
|
Next
|
|
' recupero il nome del progetto corrente
|
|
Dim sFileProject As String = String.Empty
|
|
EgtGetCurrFilePath(sFileProject)
|
|
PhotoMap.refOptionPanelVM.sProjectAssigned = sFileProject
|
|
For Each OrigSlab In OmagOFFICEMap.refMachGroupPanelVM.SlabNameListOrig
|
|
PhotoMap.refOptionPanelVM.SetAssignedSlab(OrigSlab)
|
|
Next
|
|
End If
|
|
ProjectSaved = True
|
|
End Sub
|
|
|
|
#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)
|
|
If OmagOFFICEMap.refOptionPanelVM.SelItem = OptionPanelVM.Tabs.SIMUL Then
|
|
OmagOFFICEMap.refSimulTabVM.ResetSimulation()
|
|
End If
|
|
|
|
ProjectSaved = False
|
|
|
|
' Imposto contesto principale
|
|
EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx())
|
|
' Gestisco eventuale file corrente modificato
|
|
Dim bAllowClose As Boolean = OmagOFFICEMap.refSceneHostVM.MainController.ManageModified()
|
|
' Se non confermata chiusura, esco
|
|
If Not bAllowClose Then Return
|
|
|
|
If OmagOFFICEMap.refMainWindowVM.MainWindowM.m_SlabDB AndAlso Not ProjectSaved Then
|
|
For Each CurrSlab In OmagOFFICEMap.refMachGroupPanelVM.SlabNameListCurr
|
|
PhotoMap.refOptionPanelVM.SetAvailableSlab(CurrSlab)
|
|
Next
|
|
' recupero il nome del progetto corrente
|
|
Dim sFileProject As String = String.Empty
|
|
EgtGetCurrFilePath(sFileProject)
|
|
PhotoMap.refOptionPanelVM.sProjectAssigned = sFileProject
|
|
For Each OrigSlab In OmagOFFICEMap.refMachGroupPanelVM.SlabNameListOrig
|
|
PhotoMap.refOptionPanelVM.SetAssignedSlab(OrigSlab)
|
|
Next
|
|
End If
|
|
|
|
' Salvo nome ultimo file (per gestire bene multi istanza)
|
|
Dim sFilePath As String = String.Empty
|
|
If EgtGetCurrFilePath(sFilePath) Then WriteMainPrivateProfileString(S_GENERAL, K_LASTPROJ, sFilePath)
|
|
' Termino il Model
|
|
m_MainWindowM.Close()
|
|
' Termino il programma
|
|
Application.Current.Shutdown()
|
|
End Sub
|
|
|
|
#End Region ' CloseApplicationCommand
|
|
|
|
#End Region ' COMMANDS
|
|
|
|
End Class
|