406 lines
13 KiB
VB.net
406 lines
13 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports System.ComponentModel
|
|
Imports System.IO
|
|
Imports EgtUILib
|
|
Imports System.Text.RegularExpressions
|
|
Imports EgtWPFLib5
|
|
|
|
Public Class HardwarePageVM
|
|
Implements INotifyPropertyChanged
|
|
'Inherits VMBase
|
|
|
|
Friend m_GeomtryWindowIsOpen As Boolean = False
|
|
|
|
Private m_GenericPart As Part
|
|
Public Property GenericPart As Part
|
|
Get
|
|
Return m_GenericPart
|
|
End Get
|
|
Set(value As Part)
|
|
m_GenericPart = value
|
|
NotifyPropertyChanged("GenericPart")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_Door As Part
|
|
Public Property Door As Part
|
|
Get
|
|
Return m_Door
|
|
End Get
|
|
Set(value As Part)
|
|
m_Door = value
|
|
NotifyPropertyChanged("Door")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_Jamb As Part
|
|
Public Property Jamb As Part
|
|
Get
|
|
Return m_Jamb
|
|
End Get
|
|
Set(value As Part)
|
|
m_Jamb = value
|
|
NotifyPropertyChanged("Jamb")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_CurrHardware As Hardware
|
|
Public Property CurrHardware As Hardware
|
|
Get
|
|
Return m_CurrHardware
|
|
End Get
|
|
Set(value As Hardware)
|
|
m_CurrHardware = value
|
|
NotifyPropertyChanged("CurrHardware")
|
|
End Set
|
|
End Property
|
|
|
|
' l'elenco dei bottoni
|
|
Private m_CompoPanelPart As ContentControl
|
|
Public Property CompoPanelControl As ContentControl
|
|
Get
|
|
Return m_CompoPanelPart
|
|
End Get
|
|
Set(value As ContentControl)
|
|
m_CompoPanelPart = value
|
|
End Set
|
|
End Property
|
|
|
|
' mostra la visibilità del general della pagina
|
|
Private m_VisibilityGeneral As Visibility = Visibility.Collapsed
|
|
Public Property VisibilityGeneral As Visibility
|
|
Get
|
|
Return m_VisibilityGeneral
|
|
End Get
|
|
Set(value As Visibility)
|
|
m_VisibilityGeneral = value
|
|
NotifyPropertyChanged("VisibilityGeneral")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_EnablePageHardware As Boolean
|
|
Sub SetStatusPage()
|
|
NotifyPropertyChanged("EnablePageHardware")
|
|
End Sub
|
|
Public ReadOnly Property EnablePageHardware As Boolean
|
|
Get
|
|
Map.refProjectManagerHardwareVM.NotifyPropertyChanged("EnableProjectManagerHardware")
|
|
If Not IsNothing(Map.refInstrumentPanelVM) Then
|
|
Return Map.refInstrumentPanelVM.EnablePage
|
|
Else
|
|
Return True
|
|
End If
|
|
End Get
|
|
End Property
|
|
|
|
#Region "DISPOSITION SCREEN"
|
|
|
|
Public ReadOnly Property WidthColumn1 As String
|
|
Get
|
|
If OptionModule.m_nDispostionScreen = 0 Or OptionModule.m_nDispostionScreen = 1 Then
|
|
Return "1*"
|
|
Else
|
|
Return "5*"
|
|
End If
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property WidthColumn2 As String
|
|
Get
|
|
If OptionModule.m_nDispostionScreen = 0 Or OptionModule.m_nDispostionScreen = 1 Then
|
|
Return "5*"
|
|
Else
|
|
Return "1*"
|
|
End If
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property GridGeneralDiposition As String
|
|
Get
|
|
If OptionModule.m_nDispostionScreen = 0 Or OptionModule.m_nDispostionScreen = 1 Then
|
|
Return "1"
|
|
Else
|
|
Return "0"
|
|
End If
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property CompoPanelDiposition As String
|
|
Get
|
|
If OptionModule.m_nDispostionScreen = 0 Or OptionModule.m_nDispostionScreen = 1 Then
|
|
Return "0"
|
|
Else
|
|
Return "1"
|
|
End If
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' Disposition Screen
|
|
|
|
#Region "MESSAGES"
|
|
|
|
Public ReadOnly Property GeneralMsg As String
|
|
Get
|
|
' General
|
|
Return EgtMsg(50040)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property TemplateMsg As String
|
|
Get
|
|
' Template
|
|
Return EgtMsg(50031)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property TypeMsg As String
|
|
Get
|
|
' Type
|
|
Return EgtMsg(50009)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property BrandMsg As String
|
|
Get
|
|
' Brand
|
|
Return EgtMsg(50052)
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' Messages
|
|
|
|
' definizione comando
|
|
Private m_EnterRefreshCmd As ICommand
|
|
Private m_F1GuideCmd As ICommand
|
|
Private m_GeometryConfig As ICommand
|
|
Private m_ImportGeometryCmd As ICommand
|
|
Private m_DeleteNgeGeometryCmd As ICommand
|
|
Private m_ImportLuaCmd As ICommand
|
|
|
|
#Region "COMMANDS"
|
|
|
|
Public ReadOnly Property RefreshCmd As ICommand
|
|
Get
|
|
If m_EnterRefreshCmd Is Nothing Then
|
|
m_EnterRefreshCmd = New Command(AddressOf EnterRefresh)
|
|
End If
|
|
Return m_EnterRefreshCmd
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub EnterRefresh()
|
|
Map.refSceneManagerVM.RefreshBtn()
|
|
End Sub
|
|
|
|
' Comando Guida
|
|
Public ReadOnly Property GuideCmd As ICommand
|
|
Get
|
|
If m_F1GuideCmd Is Nothing Then
|
|
m_F1GuideCmd = New Command(AddressOf F1Guide)
|
|
End If
|
|
Return m_F1GuideCmd
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub F1Guide()
|
|
Dim rfGuideVM As New GuideVM
|
|
If String.IsNullOrEmpty(GuideVM.m_AddressGuide) Then
|
|
GuideVM.m_AddressGuide = GUIDE_FILE
|
|
End If
|
|
Map.refProjectManagerVM.Guide()
|
|
End Sub
|
|
|
|
' GeometryConfig
|
|
Public ReadOnly Property GeometryConfigCmd As ICommand
|
|
Get
|
|
If m_GeometryConfig Is Nothing Then
|
|
m_GeometryConfig = New Command(AddressOf GeometryConfig)
|
|
End If
|
|
Return m_GeometryConfig
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub GeometryConfig(param As Object)
|
|
Dim NameParameter As String = CStr(param)
|
|
Dim ref_GeometryListConfigVM As New GeometryListConfigVM(NameParameter)
|
|
Dim GeometryConfigWnd As New GeometryListConfigV(Application.Current.MainWindow, ref_GeometryListConfigVM)
|
|
m_GeomtryWindowIsOpen = True
|
|
GeometryConfigWnd.ShowDialog()
|
|
ref_GeometryListConfigVM = Nothing
|
|
m_GeomtryWindowIsOpen = False
|
|
End Sub
|
|
|
|
' ImportGeometry
|
|
Public ReadOnly Property ImportGeometryCmd As ICommand
|
|
Get
|
|
If m_ImportGeometryCmd Is Nothing Then
|
|
m_ImportGeometryCmd = New Command(AddressOf ImportGeometry)
|
|
End If
|
|
Return m_ImportGeometryCmd
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub ImportGeometry()
|
|
Dim sFilePath As String = String.Empty
|
|
|
|
Dim FolderBrowserDialog As New System.Windows.Forms.OpenFileDialog()
|
|
' 50559=Open File Dialog
|
|
FolderBrowserDialog.Title = EgtMsg(50559)
|
|
FolderBrowserDialog.InitialDirectory = Path.GetDirectoryName(CurrHardware.CurrPath)
|
|
FolderBrowserDialog.Filter = "File (*.nge)|*.nge|All (*.*)|*.*"
|
|
If FolderBrowserDialog.ShowDialog <> Forms.DialogResult.OK Then
|
|
' se la risposta è diversa da OK esce
|
|
Return
|
|
End If
|
|
sFilePath = FolderBrowserDialog.FileName
|
|
Dim DestFile As String = Path.Combine(FolderBrowserDialog.InitialDirectory, Path.GetFileNameWithoutExtension(CurrHardware.CurrPath) & "_" & Path.GetFileName(sFilePath))
|
|
Try
|
|
File.Copy(sFilePath, DestFile, True)
|
|
Catch ex As System.IO.IOException
|
|
' Error in copying: {0}
|
|
MessageBox.Show(String.Format(EgtMsg(50189), ex.Message))
|
|
Return
|
|
End Try
|
|
CurrHardware.SetGeometryName(Path.GetFileName(DestFile))
|
|
SetModified()
|
|
EnterRefresh()
|
|
|
|
'------------------------------------------------------------------------------------------------------------------------
|
|
' Dim FolderBrowserDialog As New Microsoft.Win32.OpenFileDialog
|
|
' FolderBrowserDialog.Filter = "File (*.nge)|*.nge|All (*.*)|*.*"
|
|
' If FolderBrowserDialog.ShowDialog() Then
|
|
' sFilePath = FolderBrowserDialog.FileName
|
|
' Dim CurrFolder As String = Path.GetDirectoryName(CurrHardware.CurrPath)
|
|
' Dim DestFile As String = Path.Combine(CurrFolder, Path.GetFileNameWithoutExtension(CurrHardware.CurrPath) & "_" & Path.GetFileName(sFilePath))
|
|
' Try
|
|
' File.Copy(sFilePath, DestFile, True)
|
|
' Catch ex As System.IO.IOException
|
|
' ' Error in copying: {0}
|
|
' MessageBox.Show(String.Format(EgtMsg(50189), ex.Message))
|
|
' Return
|
|
' End Try
|
|
' CurrHardware.SetGeometryName(Path.GetFileName(DestFile))
|
|
' SetModified()
|
|
' EnterRefresh()
|
|
' End If
|
|
End Sub
|
|
|
|
' DeleteGeometry
|
|
Public ReadOnly Property DeleteGeometryCmd As ICommand
|
|
Get
|
|
If m_DeleteNgeGeometryCmd Is Nothing Then
|
|
m_DeleteNgeGeometryCmd = New Command(AddressOf DeleteGeometry)
|
|
End If
|
|
Return m_DeleteNgeGeometryCmd
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub DeleteGeometry()
|
|
Dim FileNgeName As String = CurrHardware.GetGeometryName()
|
|
If String.IsNullOrEmpty(FileNgeName) Then Return
|
|
FileNgeName = Path.GetDirectoryName(CurrHardware.CurrPath) & "\" & FileNgeName
|
|
If Not Path.HasExtension(FileNgeName) Then
|
|
FileNgeName = FileNgeName & NGE_EXTENSION
|
|
End If
|
|
If File.Exists(FileNgeName) Then
|
|
Try
|
|
File.Delete(FileNgeName)
|
|
Catch ex As System.IO.IOException
|
|
' 50557=Error in deleting file: {0}
|
|
MessageBox.Show(String.Format(EgtMsg(50557), ex.Message))
|
|
Return
|
|
End Try
|
|
End If
|
|
CurrHardware.SetGeometryName("")
|
|
SetModified()
|
|
EnterRefresh()
|
|
Return
|
|
End Sub
|
|
|
|
' ImportLua
|
|
Public ReadOnly Property ImportLuaCmd As ICommand
|
|
Get
|
|
If m_ImportLuaCmd Is Nothing Then
|
|
m_ImportLuaCmd = New Command(AddressOf ImportLua)
|
|
End If
|
|
Return m_ImportLuaCmd
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub ImportLua(param As Object)
|
|
Dim sDDFName As String = CStr(param)
|
|
Dim sFilePath As String = String.Empty
|
|
Dim FileDialog As New Microsoft.Win32.OpenFileDialog
|
|
FileDialog.Filter = "File (*.lua)|*.lua|All (*.*)|*.*"
|
|
FileDialog.InitialDirectory = CurrHardware.HardwareGeneral.Path
|
|
If FileDialog.ShowDialog() Then
|
|
sFilePath = FileDialog.FileName
|
|
If String.Compare(sFilePath, 0, FileDialog.InitialDirectory, 0, FileDialog.InitialDirectory.Length(), True) <> 0 Then
|
|
' 50558=Impossible to import a different hardware!
|
|
MessageBox.Show(EgtMsg(50558), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error)
|
|
Return
|
|
End If
|
|
Dim CurrFolder As String = Path.GetDirectoryName(CurrHardware.CurrPath)
|
|
Dim DestFile As String = Path.Combine(CurrFolder, Path.GetFileNameWithoutExtension(CurrHardware.CurrPath) & "_" & Path.GetFileName(sFilePath))
|
|
Try
|
|
File.Copy(sFilePath, DestFile, True)
|
|
Catch ex As System.IO.IOException
|
|
' Error in copying: {0}
|
|
MessageBox.Show(String.Format(EgtMsg(50189), ex.Message))
|
|
Return
|
|
End Try
|
|
CurrHardware.SetLuaFileInAggregate(Path.GetFileName(DestFile), sDDFName)
|
|
SetModified()
|
|
EnterRefresh()
|
|
End If
|
|
End Sub
|
|
|
|
|
|
#End Region ' Command
|
|
|
|
' creo un'anta
|
|
Public Function CreateDoor() As Boolean
|
|
Dim Hardware As String = String.Empty
|
|
' questa stringa serve solo per costruire un overload della sub New!
|
|
Dim ref_Door As New Part(Hardware)
|
|
Door = ref_Door
|
|
Dim sTempFile As String = IniFile.m_sTempDir & "\" & TEMP_FILE
|
|
DdfFile.WriteDDFPartForTestHardware(Door, sTempFile, False, False)
|
|
GenericPart = Door
|
|
'ExecDoors(Map.refSceneManagerVM.ProjectScene, sTempFile)
|
|
Return True
|
|
End Function
|
|
|
|
' creo un jamb
|
|
Public Function CreateJamb() As Boolean
|
|
Dim HardwareJamb As String = "Jamb"
|
|
Dim ref_Jamb As New Part(HardwareJamb)
|
|
Jamb = ref_Jamb
|
|
Dim sTempFile As String = IniFile.m_sTempDir & "\" & TEMP_FILE
|
|
DdfFile.WriteDDFPartForTestHardware(Jamb, sTempFile, False, False)
|
|
'ExecDoors(Map.refSceneManagerVM.ProjectScene, sTempFile)
|
|
Return True
|
|
End Function
|
|
|
|
Sub New()
|
|
Map.SetRefHardwarePageVM(Me)
|
|
' se non esiste la lista dei componenti per l'HardwareManager viene creata nuova
|
|
If IsNothing(Map.refCompoPanelHardwareVM) Then Map.SetRefCompoPaneHardwarelVM(New CompoPanelVM("HardwarePage"))
|
|
' se il ContentControl è vuoto allora viene creato nuovo
|
|
If IsNothing(m_CompoPanelPart) Then m_CompoPanelPart = New CompoPanelHardwareV
|
|
m_CompoPanelPart.DataContext = Map.refCompoPanelHardwareVM
|
|
End Sub
|
|
|
|
Sub PrepareEvent()
|
|
If Not IsNothing(Map.refInstrumentPanelVM) Then
|
|
AddHandler Map.refInstrumentPanelVM.EnableCurrentPage, AddressOf Me.SetStatusPage
|
|
End If
|
|
End Sub
|
|
|
|
Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
|
|
|
|
Public Sub NotifyPropertyChanged(propName As String)
|
|
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propName))
|
|
End Sub
|
|
|
|
End Class
|
|
|
|
|