Files
EgtDOORCreator/SceneManager/DimensioningPanel/DimensioningPanelVM.vb
Nicola Pievani 40c5eb4e0b EgtDOORCreator 2.2e1:
-> aggiornamento dell'elenco dei capitoli in funzione della scelta del materiale in HardwareManager,
-> gestione delle quote in fase di avvio del programma.
2020-05-27 17:32:29 +00:00

148 lines
6.2 KiB
VB.net

Imports System.Collections.ObjectModel
Imports EgtWPFLib5
Imports EgtUILib
Public Class DimensioningPanelVM
Inherits VMBase
Public ReadOnly Property DimensionToolTip As String
Get
' Dimension
Return EgtMsg(50418)
End Get
End Property
' lista degli hardware presenti nella porta corrente
Private m_HardwareDimensionList As New ObservableCollection(Of HardwareDimension)
Public Property HardwareDimensionList As ObservableCollection(Of HardwareDimension)
Get
Return m_HardwareDimensionList
End Get
Set(value As ObservableCollection(Of HardwareDimension))
m_HardwareDimensionList = value
End Set
End Property
Private m_DimensioningPanel_Visibility As Visibility
Public ReadOnly Property DimensioningPanel_Visibility As Visibility
Get
Return m_DimensioningPanel_Visibility
End Get
End Property
Public ReadOnly Property EnableDimensionPanel As Boolean
Get
If Not IsNothing(Map.refInstrumentPanelVM) Then
Return Map.refInstrumentPanelVM.EnablePage
Else
Return True
End If
End Get
End Property
Friend Sub SetDimensioningPanel_Visibility(IsVisible As Boolean)
If IsVisible Then
m_DimensioningPanel_Visibility = Visibility.Visible
Else
m_DimensioningPanel_Visibility = Visibility.Collapsed
End If
NotifyPropertyChanged("DimensioningPanel_Visibility")
End Sub
Public Function LoadHardwareDimList() As Boolean
' Se lista vuota
If m_HardwareDimensionList.Count = 0 Then
' carico la lista
Dim LocalHardware As New HardwareDimension
LocalHardware.NameHardware = "Door"
LocalHardware.NameLayer = "DIM_DOOR"
LocalHardware.SetSelectedLayer(GetMainPrivateProfileInt("Dimensions", LocalHardware.NameHardware, 0) <> 0)
HardwareDimensionList.Add(LocalHardware)
For Each CompoType In Map.refCompoPanelHardwareVM.CompoTypeList
Dim CurrNameLayer As String = String.Empty
GetPrivateProfileLayerName(ConstCompo.S_LAYER, ConstCompo.K_LAYER_NAME, CurrNameLayer, CompoType.Path & "\" & CONFIGINI_FILE_NAME)
If Not String.IsNullOrWhiteSpace(CurrNameLayer) Then
LocalHardware = New HardwareDimension
LocalHardware.NameHardware = CompoType.Name
LocalHardware.NameHardwareDDF = CompoType.DDFName
LocalHardware.NameLayer = CurrNameLayer
LocalHardware.SetSelectedLayer(GetMainPrivateProfileInt("Dimensions", LocalHardware.NameHardware, 0) <> 0)
HardwareDimensionList.Add(LocalHardware)
End If
Next
End If
' se sono nella pagina assembalto devo leggere tutti i part
If Map.refMainWindowVM.SelectedPage = MainWindowVM.ListPageEnum.nAssemblyPage Then
For Each HardwareDimension In m_HardwareDimensionList
If HardwareDimension.NameLayer <> "DIM_DOOR" Then
HardwareDimension.IsActive = False
End If
Next
If Not IsNothing(Map.refAssemblyManagerVM.CurrProject) AndAlso
Not IsNothing(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName) AndAlso
Not IsNothing(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.SelAssembly) AndAlso
Not IsNothing(Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.SelAssembly.ListPartDoor) Then
For Each CurrPart In Map.refAssemblyManagerVM.CurrProject.SelAssemblyName.SelAssembly.ListPartDoorOfDoor
If Not IsNothing(CurrPart.Door) Then
SetHardwareDimension(CurrPart.Door)
End If
Next
Return True
End If
End If
' Abilito solo i tipi di hardware presenti nella porta corrente
Dim CurrDoor As Part = Map.refPartPageVM.CurrPart
If IsNothing(CurrDoor) Then Return False
' disattivo tutti gli hardware nella lista
For Each HardwareDimension In m_HardwareDimensionList
If HardwareDimension.NameLayer <> "DIM_DOOR" Then
HardwareDimension.IsActive = False
End If
Next
If CurrDoor.CompoList.Count < 1 Then Return False
' Ciclo sugli hardware presenti nella porta corrente
For DoorCompoIndex = 0 To CurrDoor.CompoList.Count - 1
' verifico se il tipo di hardware è diverso dal precedente
If DoorCompoIndex = 0 OrElse (Not DoorCompoIndex = 0 AndAlso CurrDoor.CompoList(DoorCompoIndex).CompoType.Name <> CurrDoor.CompoList(DoorCompoIndex - 1).CompoType.Name) Then
' lo cerco nella lista delle dimensioni dell'hardware
For Each HardwareDimension In m_HardwareDimensionList
If CurrDoor.CompoList(DoorCompoIndex).CompoType.Name = HardwareDimension.NameHardware Then
HardwareDimension.IsActive = True
Exit For
End If
Next
End If
Next
Return True
End Function
Private Function SetHardwareDimension(ByRef CurrPart As Part) As Boolean
If IsNothing(CurrPart) Then Return False
' disattivo tutti gli hardware nella lista
If CurrPart.CompoList.Count < 1 Then Return False
' Ciclo sugli hardware presenti nella porta corrente
For DoorCompoIndex = 0 To CurrPart.CompoList.Count - 1
' verifico se il tipo di hardware è diverso dal precedente
If DoorCompoIndex = 0 OrElse (Not DoorCompoIndex = 0 AndAlso
CurrPart.CompoList(DoorCompoIndex).CompoType.Name <> CurrPart.CompoList(DoorCompoIndex - 1).CompoType.Name) Then
' lo cerco nella lista delle dimensioni dell'hardware
For Each HardwareDimension In m_HardwareDimensionList
If CurrPart.CompoList(DoorCompoIndex).CompoType.Name = HardwareDimension.NameHardware Then
HardwareDimension.IsActive = True
Exit For
End If
Next
End If
Next
Return True
End Function
Sub New()
Map.SetRefDimensioningPanelVM(Me)
End Sub
End Class