Files
EgtDOORCreator/HardwarePart/HardwarePartVM.vb
T
Nicola Pievani cbecb11ab7 EgtDOORCreato 2.2e1:
-> scrittura messaggi nel file dei messaggi.
2020-06-05 10:50:02 +00:00

388 lines
12 KiB
VB.net

Imports System.Collections.ObjectModel
Imports System.ComponentModel
Imports System.IO
Imports EgtUILib
Imports EgtWPFLib5
Public Class HardwarePartVM
'Inherits VMBase
Implements INotifyPropertyChanged
Friend Shared bIsSettingDoor As Boolean = False
Dim m_HardwareTemp As Hardware
#Region "Property"
Friend Event m_CloseWindow(bDialogResult As Boolean)
Private m_Height As String
Public Property Height As String
Get
Return m_Height
End Get
Set(value As String)
m_Height = value
End Set
End Property
Private m_Width As String
Public Property Width As String
Get
Return m_Width
End Get
Set(value As String)
m_Width = value
End Set
End Property
Private m_Thickness As String
Public Property Thickness As String
Get
Return m_Thickness
End Get
Set(value As String)
m_Thickness = value
End Set
End Property
Private m_SwingList As List(Of String)
Public Property SwingList As List(Of String)
Get
Return m_SwingList
End Get
Set(value As List(Of String))
m_SwingList = value
End Set
End Property
Private m_SelectedItem As String
Public Property SelectedItem As String
Get
Return m_SelectedItem
End Get
Set(value As String)
m_SelectedItem = value
End Set
End Property
Private m_MaterialListIsVisble As Visibility = Visibility.Collapsed
Public ReadOnly Property MaterialListIsVisible As Visibility
Get
Return m_MaterialListIsVisble
End Get
End Property
Private m_MaterialList As ObservableCollection(Of MaterialType)
Public Property MaterialList As ObservableCollection(Of MaterialType)
Get
Return m_MaterialList
End Get
Set(value As ObservableCollection(Of MaterialType))
m_MaterialList = value
End Set
End Property
Private m_SelectedMaterial As MaterialType
Public Property SelectedMaterial As MaterialType
Get
Return m_SelectedMaterial
End Get
Set(value As MaterialType)
m_SelectedMaterial = value
End Set
End Property
Private m_LockEdgeProfile As ObservableCollection(Of EdgeType)
Public Property LockEdgeProfile As ObservableCollection(Of EdgeType)
Get
Return m_LockEdgeProfile
End Get
Set(value As ObservableCollection(Of EdgeType))
m_LockEdgeProfile = value
End Set
End Property
Private m_SelectedLockEdgeProfile As EdgeType
Public Property SelectedLockEdgeProfile As EdgeType
Get
Return m_SelectedLockEdgeProfile
End Get
Set(value As EdgeType)
m_SelectedLockEdgeProfile = value
End Set
End Property
Private m_HingeEdgeProfile As ObservableCollection(Of EdgeType)
Public Property HingeEdgeProfile As ObservableCollection(Of EdgeType)
Get
Return m_HingeEdgeProfile
End Get
Set(value As ObservableCollection(Of EdgeType))
m_HingeEdgeProfile = value
End Set
End Property
Private m_SelectedHingeEdgeProfile As EdgeType
Public Property SelectedHingeEdgeProfile As EdgeType
Get
Return m_SelectedHingeEdgeProfile
End Get
Set(value As EdgeType)
m_SelectedHingeEdgeProfile = value
End Set
End Property
Private m_TopEdgeProfile As ObservableCollection(Of EdgeType)
Public Property TopEdgeProfile As ObservableCollection(Of EdgeType)
Get
Return m_TopEdgeProfile
End Get
Set(value As ObservableCollection(Of EdgeType))
m_TopEdgeProfile = value
End Set
End Property
Private m_SelectedTopEdgeProfile As EdgeType
Public Property SelectedTopEdgeProfile As EdgeType
Get
Return m_SelectedTopEdgeProfile
End Get
Set(value As EdgeType)
m_SelectedTopEdgeProfile = value
End Set
End Property
Private m_BottomEdgeProfile As ObservableCollection(Of EdgeType)
Public Property BottomEdgeProfile As ObservableCollection(Of EdgeType)
Get
Return m_BottomEdgeProfile
End Get
Set(value As ObservableCollection(Of EdgeType))
m_BottomEdgeProfile = value
End Set
End Property
Private m_SelectedBottomEdgeProfile As EdgeType
Public Property SelectedBottomEdgeProfile As EdgeType
Get
Return m_SelectedBottomEdgeProfile
End Get
Set(value As EdgeType)
m_SelectedBottomEdgeProfile = value
End Set
End Property
#End Region ' Property
#Region "MESSAGES"
Public ReadOnly Property General As String
Get
Return EgtMsg(50040)
End Get
End Property
Public ReadOnly Property EdgeTypeMsg As String
Get
Return EgtMsg(50044)
End Get
End Property
Public ReadOnly Property Title As String
Get
' 50725=Part Dimension
Return EgtMsg(50725)
End Get
End Property
Public ReadOnly Property HeightMsg As String
Get
Return EgtMsg(50002)
End Get
End Property
Public ReadOnly Property WidthMsg As String
Get
Return EgtMsg(50001)
End Get
End Property
Public ReadOnly Property ThicknessMsg As String
Get
Return EgtMsg(50003)
End Get
End Property
Public ReadOnly Property SwingMsg As String
Get
Return EgtMsg(50004)
End Get
End Property
Public ReadOnly Property LockedgeMsg As String
Get
Return EgtMsg(50005)
End Get
End Property
Public ReadOnly Property HingeedgeMsg As String
Get
Return EgtMsg(50006)
End Get
End Property
Public ReadOnly Property TopedgeMsg As String
Get
Return EgtMsg(50007)
End Get
End Property
Public ReadOnly Property BottomedgeMsg As String
Get
Return EgtMsg(50008)
End Get
End Property
Public ReadOnly Property MaterialMsg As String
Get
' 50710=Material
Return EgtMsg(50710)
End Get
End Property
Public ReadOnly Property ApplyMsg As String
Get
' 50726=Apply
Return EgtMsg(50726)
End Get
End Property
Public ReadOnly Property CancelMsg As String
Get
' 50412=Cancel
Return EgtMsg(50412)
End Get
End Property
#End Region ' Messages
Private m_CmdApply As ICommand
Private m_cmdOk As ICommand
#Region "APPLY"
Public ReadOnly Property ApplyCommand As ICommand
Get
If m_CmdApply Is Nothing Then
m_CmdApply = New Command(AddressOf Apply)
End If
Return m_CmdApply
End Get
End Property
Public Sub Apply()
If Not IsNothing(Map.refHardwarePageVM) AndAlso
Not IsNothing(Map.refHardwarePageVM.GenericPart) Then
Map.refHardwarePageVM.GenericPart.SetHeight(m_Height)
Map.refHardwarePageVM.GenericPart.SetWidth(m_Width)
Map.refHardwarePageVM.GenericPart.SetThickness(m_Thickness)
Map.refHardwarePageVM.GenericPart.SwingTypeList = m_SwingList
Map.refHardwarePageVM.GenericPart.SetSwing(m_SelectedItem)
Map.refHardwarePageVM.GenericPart.SetLockEdgeType(m_SelectedLockEdgeProfile)
Map.refHardwarePageVM.GenericPart.SetHingeEdgeType(m_SelectedHingeEdgeProfile)
Map.refHardwarePageVM.GenericPart.SetTopType(m_SelectedTopEdgeProfile)
Map.refHardwarePageVM.GenericPart.SetBottomType(m_SelectedBottomEdgeProfile)
Map.refHardwarePageVM.GenericPart.SetMaterial(m_SelectedMaterial)
Map.refHardwarePageVM.GenericPart.NotifyPropertyChanged("GenericPart")
bIsSettingDoor = True
Map.refSceneManagerVM.RefreshBtn()
If Not IsNothing(Map.refHardwarePageVM.CurrHardware()) Then
Map.refHardwarePageVM.CurrHardware.ClearGroupChapters()
Map.refHardwarePageVM.CurrHardware.ReadChapterTemplate()
Map.refHardwarePageVM.CurrHardware.RelaoadTempCurrHardwareFile()
End If
bIsSettingDoor = False
End If
End Sub
#End Region ' Apply
#Region "OkWnd"
Public ReadOnly Property OkCommand() As ICommand
Get
If m_cmdOk Is Nothing Then
m_cmdOk = New Command(AddressOf Ok)
End If
Return m_cmdOk
End Get
End Property
Public Sub Ok()
Apply()
RaiseEvent m_CloseWindow( True)
End Sub
#End Region
Public Sub New()
If Not IsNothing(Map.refHardwarePageVM) AndAlso
Not IsNothing(Map.refHardwarePageVM.GenericPart) Then
m_Height = Map.refHardwarePageVM.GenericPart.Height
m_Width = Map.refHardwarePageVM.GenericPart.Width
m_Thickness = Map.refHardwarePageVM.GenericPart.Thickness
m_SwingList = OptionModule.m_SwingTypeList
If Not IsNothing(OptionModule.m_MaterialList) AndAlso OptionModule.m_MaterialList.Count > 0 Then
m_MaterialList = Map.refHardwarePageVM.GenericPart.MaterialsList
Dim s_LastSelectedMaterial As String = Map.refHardwarePageVM.GenericPart.SelectedMaterial.Name
If Not IsNothing(OptionModule.m_CurrMaterial) Then
s_LastSelectedMaterial = OptionModule.m_CurrMaterial.Name
End If
Try
m_SelectedMaterial = m_MaterialList.First(Function(x) x.Name = Trim(s_LastSelectedMaterial))
Catch ex As Exception
m_SelectedMaterial = m_MaterialList(0)
Map.refHardwarePageVM.GenericPart.SetMaterial(m_SelectedMaterial)
End Try
If OptionModule.m_MaterialList.Count > 1 Then
m_MaterialListIsVisble = Visibility.Visible
NotifyPropertyChanged("MaterialListIsVisible")
End If
End If
For Each Item In m_SwingList
If Trim(Item) = Trim(Map.refHardwarePageVM.GenericPart.Swing) Then
m_SelectedItem = Item
Exit For
End If
Next
m_LockEdgeProfile = Map.refHardwarePageVM.GenericPart.LockEdgeTypeList
m_HingeEdgeProfile = Map.refHardwarePageVM.GenericPart.HingeEdgeTypeList
m_TopEdgeProfile = Map.refHardwarePageVM.GenericPart.TopEdgeTypeList
m_BottomEdgeProfile = Map.refHardwarePageVM.GenericPart.BottomEdgeTypeList
For Index = 0 To m_LockEdgeProfile.Count - 1
If Trim(m_LockEdgeProfile(Index).Name) = Trim(Map.refHardwarePageVM.GenericPart.LockEdgeType.Name) Then
SelectedLockEdgeProfile = (m_LockEdgeProfile(Index))
Exit For
End If
Next
For Index = 0 To m_HingeEdgeProfile.Count - 1
If Trim(m_LockEdgeProfile(Index).Name) = Trim(Map.refHardwarePageVM.GenericPart.HingeEdgeType.Name) Then
SelectedHingeEdgeProfile = (m_HingeEdgeProfile(Index))
Exit For
End If
Next
For Index = 0 To m_TopEdgeProfile.Count - 1
If Trim(m_LockEdgeProfile(Index).Name) = Trim(Map.refHardwarePageVM.GenericPart.TopType.Name) Then
SelectedTopEdgeProfile = (m_TopEdgeProfile(Index))
Exit For
End If
Next
For Index = 0 To m_BottomEdgeProfile.Count - 1
If Trim(m_BottomEdgeProfile(Index).Name) = Trim(Map.refHardwarePageVM.GenericPart.BottomType.Name) Then
SelectedBottomEdgeProfile = (m_BottomEdgeProfile(Index))
Exit For
End If
Next
Else
' 50560=The hardware part has not been generated correctly.
MessageBox.Show(EgtMsg(50560), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error)
Ok()
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