efb250b4a4
- aggiunto il campo "Weight" al general del door, - aggiunta di una variabile booleana alla funzione ReadDDF nella classe Door per permettere di stampare le funzioni scritte nelle textbox, attualmente no è in uso (settata True)
246 lines
9.3 KiB
VB.net
246 lines
9.3 KiB
VB.net
Imports EgtUILib
|
|
Imports System.ComponentModel
|
|
Imports System.IO
|
|
Imports EgtWPFLib5
|
|
|
|
Public Class MainWindowViewModel
|
|
Implements INotifyPropertyChanged
|
|
' Modello del MainWindow (classe vera e propria)
|
|
Private m_MainWindowModel As New MainWindowModel
|
|
Friend m_rfSceneManagerViewModel As SceneManagerViewModel
|
|
|
|
Private m_ProjectNameMsg As String
|
|
Public Property ProjectNameMsg As String
|
|
Get
|
|
Return m_ProjectNameMsg
|
|
End Get
|
|
Set(value As String)
|
|
m_ProjectNameMsg = "EgtDOORCreator - " & SetTitle(value)
|
|
NotifyPropertyChanged("ProjectNameMsg")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_CompoPanel As CompoPanelView
|
|
Public ReadOnly Property CompoPanel As CompoPanelView
|
|
Get
|
|
If IsNothing(m_CompoPanel) Then
|
|
m_CompoPanel = New CompoPanelView
|
|
m_CompoPanel.DataContext = New CompoPanelViewModel(Me)
|
|
End If
|
|
Return m_CompoPanel
|
|
End Get
|
|
End Property
|
|
|
|
Private m_Launcher As LauncherView
|
|
Public ReadOnly Property Launcher As LauncherView
|
|
Get
|
|
If IsNothing(m_Launcher) Then
|
|
m_Launcher = New LauncherView
|
|
m_Launcher.DataContext = New LauncherViewModel(Me)
|
|
End If
|
|
Return m_Launcher
|
|
End Get
|
|
End Property
|
|
|
|
Private m_ProjectManagerViewModel As ProjectManagerViewModel
|
|
Public ReadOnly Property ProjectManagerViewModel As ProjectManagerViewModel
|
|
Get
|
|
If IsNothing(m_ProjectManagerViewModel) Then
|
|
m_ProjectManagerViewModel = New ProjectManagerViewModel(Me)
|
|
End If
|
|
Return m_ProjectManagerViewModel
|
|
End Get
|
|
End Property
|
|
|
|
Private m_DoorManager As DoorManagerView
|
|
Public ReadOnly Property DoorManager As DoorManagerView
|
|
Get
|
|
If IsNothing(m_DoorManager) Then
|
|
m_DoorManager = New DoorManagerView
|
|
m_DoorManager.DataContext = New DoorManagerViewModel(Me)
|
|
End If
|
|
Return m_DoorManager
|
|
End Get
|
|
End Property
|
|
|
|
Private m_DoorParameters As DoorParametersView
|
|
Public ReadOnly Property DoorParameters As DoorParametersView
|
|
Get
|
|
If IsNothing(m_DoorParameters) Then
|
|
m_DoorParameters = New DoorParametersView
|
|
m_DoorParameters.DataContext = New DoorParametersViewModel(Me)
|
|
End If
|
|
Return m_DoorParameters
|
|
End Get
|
|
End Property
|
|
|
|
Private m_SceneManager As SceneManagerView
|
|
Public ReadOnly Property SceneManager As SceneManagerView
|
|
Get
|
|
If IsNothing(m_SceneManager) Then
|
|
m_SceneManager = New SceneManagerView
|
|
m_SceneManager.DataContext = New SceneManagerViewModel(Me)
|
|
End If
|
|
Return m_SceneManager
|
|
End Get
|
|
|
|
End Property
|
|
|
|
Private m_AboutBox As Window
|
|
Private bFirstAboutBox As Boolean = True
|
|
Public ReadOnly Property AboutBox As Window
|
|
Get
|
|
If bFirstAboutBox Then
|
|
m_AboutBox = New AboutBoxView()
|
|
End If
|
|
Return New AboutBoxView
|
|
End Get
|
|
End Property
|
|
|
|
' MainWindow Closing Event
|
|
Private m_cmdClose As ICommand
|
|
|
|
Public Sub SetLauncher()
|
|
Select Case OptionModule.m_OptionLauncherList.IndexOf(OptionModule.m_SelectedOptionLauncher)
|
|
Case 0
|
|
' apre la finestra
|
|
Dim Launcher As New LauncherView
|
|
Launcher.Height = 200
|
|
Launcher.Width = 250
|
|
LauncherModule.InitLauncherModule()
|
|
Launcher.DataContext = New LauncherViewModel(Me)
|
|
Launcher.Owner = Application.Current.MainWindow
|
|
Launcher.ShowDialog()
|
|
Case 1
|
|
' se non trovo salvato nessun ultimo file allora apro vuoto
|
|
If GetPrivateProfileString(S_LAUNCHERWINDOW, K_LASTPROJECT, "", m_sLastProject) < 0 Then
|
|
Exit Select
|
|
Else
|
|
' apro l'ultimo progetto
|
|
Me.ProjectManagerViewModel.OpenLastProject()
|
|
End If
|
|
' non fa assolutamente nulla
|
|
End Select
|
|
End Sub
|
|
|
|
' questa funzione restituisce il nome del direttorio corrente
|
|
Friend Function SetTitle(DirectoryTitle As String) As String
|
|
If Not String.IsNullOrWhiteSpace(DirectoryTitle) Then
|
|
Dim Items() As String = DirectoryTitle.Split("\".ToCharArray)
|
|
If Items.Count = 1 Then
|
|
Items = DirectoryTitle.Split("-".ToCharArray)
|
|
End If
|
|
' restituisco il nome dell'ultimo direttorio aperto
|
|
DirectoryTitle = Items(Items.Count - 1)
|
|
End If
|
|
Return DirectoryTitle
|
|
End Function
|
|
|
|
Friend Sub ModifyTitle(bModified As Boolean)
|
|
If bModified Then
|
|
If Not m_ProjectNameMsg(m_ProjectNameMsg.Count - 1) = "*" Then
|
|
ProjectNameMsg &= "*"
|
|
End If
|
|
Else
|
|
If m_ProjectNameMsg(m_ProjectNameMsg.Count - 1) = "*" Then
|
|
ProjectNameMsg.Trim("*"c)
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Friend Sub WinPosToWindow(Window As Window, WinPos As WinPos)
|
|
Window.WindowStartupLocation = WindowStartupLocation.Manual
|
|
Window.Top = WinPos.nTop
|
|
Window.Left = WinPos.nLeft
|
|
Window.Height = WinPos.nHeight
|
|
Window.Width = WinPos.nWidth
|
|
Window.WindowState = If(WinPos.nFlag = 1, WindowState.Maximized, WindowState.Normal)
|
|
End Sub
|
|
|
|
Friend Sub WindowToWinPos(Window As Window, WinPos As WinPos)
|
|
WinPos.nTop = CInt(Window.Top)
|
|
WinPos.nLeft = CInt(Window.Left)
|
|
WinPos.nHeight = CInt(Window.Height)
|
|
WinPos.nWidth = CInt(Window.Width)
|
|
WinPos.nFlag = If(Window.WindowState = WindowState.Maximized, 1, 0)
|
|
If Window.WindowState = WindowState.Maximized Then
|
|
WinPos.nHeight = CInt(Window.RestoreBounds.Height)
|
|
WinPos.nWidth = CInt(Window.RestoreBounds.Width)
|
|
End If
|
|
End Sub
|
|
|
|
#Region "CloseApplicationCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that manage the MainWindow_Unloaded command
|
|
''' </summary>
|
|
Public ReadOnly Property CloseApplicationCommand() As ICommand
|
|
Get
|
|
If m_cmdClose Is Nothing Then
|
|
m_cmdClose = New Command(AddressOf CloseApplication)
|
|
End If
|
|
Return m_cmdClose
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded.
|
|
''' </summary>
|
|
Public Sub CloseApplication(ByVal param As Object)
|
|
'' Gestisco eventuale file corrente modificato
|
|
'Application.Msn.NotifyColleagues(Application.MANAGEMODIFIED)
|
|
'If m_allowWindowToClose Then
|
|
' Application.Msn.NotifyColleagues(Application.CLOSEAPPLICATION)
|
|
' Salvo posizione Form (se non minimizzato)
|
|
If Application.Current.MainWindow.WindowState <> WindowState.Minimized Then
|
|
Dim WinPos As New WinPos
|
|
WindowToWinPos(Application.Current.MainWindow, WinPos)
|
|
WritePrivateProfileWinPos(S_GENERAL, K_WINPLACE, WinPos.nFlag, WinPos.nLeft, WinPos.nTop, WinPos.nWidth, WinPos.nHeight)
|
|
End If
|
|
' ' Terminazione generale di EgtInterface
|
|
' EgtExit()
|
|
' ' Rilascio mutex
|
|
' m_objMutex.Close()
|
|
' ' Aggiorno istanze usate
|
|
' Dim nTmp As Integer = GetPrivateProfileInt(S_GENERAL, K_INSTANCES, 0)
|
|
' nTmp -= (1 << (m_nInstance - 1))
|
|
' WritePrivateProfileString(S_GENERAL, K_INSTANCES, nTmp.ToString())
|
|
' ' Salvo impostazione macchina corrente
|
|
' Application.Msn.NotifyColleagues(Application.SAVECURRENTMACHINE)
|
|
|
|
' aggiorno file DDF grafico (CurrDoor.ddf)
|
|
If Not IsNothing(DirectCast(Me.DoorParameters.DataContext, DoorParametersViewModel).CurrDoor) Then
|
|
DdfFile.WriteDDF(DirectCast(Me.DoorParameters.DataContext, DoorParametersViewModel).CurrDoor, IniFile.m_sTempDir & "\" & TEMP_FILE, True)
|
|
Dim SelDoor As String = DirectCast(Me.DoorManager.DataContext, DoorManagerViewModel).SelectedDoor
|
|
''If Not DdfFile.ComparisonFileDDF(IniFile.m_sTempDir & "\CurrDoor.ddf", SelDoor) Then
|
|
If Not DdfFile.SetModify(Me) Then
|
|
' se la risposta è di non salavre non faccio nulla
|
|
If MessageBox.Show("Do you want to save this file (" & Path.GetFileNameWithoutExtension(SelDoor) & ")?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Warning) = MessageBoxResult.No Then
|
|
Else
|
|
' altrimenti sovrascrivo il DDF
|
|
DdfFile.WriteDDF(DirectCast(Me.DoorParameters.DataContext, DoorParametersViewModel).CurrDoor, SelDoor, True)
|
|
End If
|
|
End If
|
|
' scrivo il nome dell'ultimo file aperto
|
|
If Not IsNothing(Me.ProjectManagerViewModel.m_CurrProject) Then
|
|
IniFile.WritePrivateProfileString(S_LAUNCHERWINDOW, K_LASTPROJECT, Me.ProjectManagerViewModel.m_CurrProject.Name)
|
|
End If
|
|
End If
|
|
|
|
EgtExit()
|
|
'' Disabilito gestore Idle
|
|
'RemoveHandler Application.Idle, AddressOf Application_Idle
|
|
Application.Current.MainWindow.Close()
|
|
'End If
|
|
End Sub
|
|
|
|
#End Region ' CloseApplicationCommand
|
|
|
|
Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
|
|
|
|
Public Sub NotifyPropertyChanged(propName As String)
|
|
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propName))
|
|
End Sub
|
|
|
|
End Class
|