Imports System.Collections.ObjectModel Imports System.IO Imports EgtUILib Imports EgtWPFLib5 Public Class HardwarePartVM Inherits VMBase 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_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 Title As String Get Return "Part Dimension" 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 OkMsg As String Get Return "Ok" End Get End Property Public ReadOnly Property CancelMsg As String Get Return "Cancel" 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.NotifyPropertyChanged("GenericPart") Map.refSceneManagerVM.RefreshBtn() 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 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 MessageBox.Show("The current part has not been generated correctly.", EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Error) Ok() End If End Sub End Class