e4aaac1c46
-> bloccaggio dei progetti in fase di lettura, -> correzione nell'intestazione della pagina DOORCreator (nome progetto corrente), -> correzione della lettura degli swing nell'HardwareManager, -> se si crea per la prima volta una componente questa viene salvata nella radice (a meno che non sia stata definita almeno una cartella)
272 lines
8.5 KiB
VB.net
272 lines
8.5 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports System.ComponentModel
|
|
Imports System.IO
|
|
Imports EgtUILib
|
|
Imports System.Text.RegularExpressions
|
|
Imports EgtWPFLib5
|
|
|
|
Public Class HardwarePageVM
|
|
Inherits VMBase
|
|
|
|
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
|
|
|
|
#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_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)
|
|
GeometryConfigWnd.ShowDialog()
|
|
ref_GeometryListConfigVM = Nothing
|
|
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 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
|
|
|
|
' 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
|
|
MessageBox.Show("Impossible to import a different hardware!", 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
|
|
|
|
End Class
|
|
|
|
|