Files
EgtDOORCreator/CompoPanel/CompoPanelVM.vb
T
Dario Sassi cc05b56b56 EgtDOORCreator :
- correzioni varie
- icone per tipo vista in assemblato e per errore.
2017-12-14 17:57:54 +00:00

177 lines
5.6 KiB
VB.net

Imports System.ComponentModel
Imports System.Collections.ObjectModel
Imports EgtUILib
Imports System.IO
Public Class CompoPanelVM
Implements INotifyPropertyChanged
Public ReadOnly Property GoToAssembly As String
Get
Return "GoToAssembly"
End Get
End Property
Private Shared m_CompoTypeList As New ObservableCollection(Of CompoType)
Public Shared ReadOnly Property CompoTypeList As ObservableCollection(Of CompoType)
Get
Return m_CompoTypeList
End Get
End Property
Private m_IsVisible As Visibility
Public Property IsVisible As Visibility
Get
Return m_IsVisible
End Get
Set(value As Visibility)
m_IsVisible = value
NotifyPropertyChanged("IsVisible")
End Set
End Property
Private m_GoBackVisibility As Visibility = Visibility.Visible
Public Property GoBackVisibility As Visibility
Get
Return m_GoBackVisibility
End Get
Set(value As Visibility)
m_GoBackVisibility = value
NotifyPropertyChanged("GoBackVisibility")
End Set
End Property
' Definizione comando
Private m_CmdCompoBtn As ICommand
Private m_CmdGoToAssemblyBtn As ICommand
' definizione comando
Private m_EnterRefreshCmd As ICommand
Sub New()
Map.SetRefCompoPanelVM(Me)
Dim IndexCompoOrder = 0
Dim CompoPanelList As List(Of String) = OptionModule.m_CompoPaneOrder
' Lettura file ini per generare bottoni
Dim Index As Integer = 1
Dim CompoName As String = String.Empty
Dim CompoNameDDF As String = String.Empty
Dim Side As String = String.Empty
' Carico un vettore con il nome delle Path delle componenti
If Not Directory.Exists(IniFile.m_CompoDir) Then
EgtOutLog("CompoDir not found : " & IniFile.m_CompoDir)
Return
End If
Dim CompoArray() As String = Directory.GetDirectories(IniFile.m_CompoDir)
' carico i valori dei bottoni con un preciso ordine
For IndexCompoOrder = 0 To DdfFile.CompoListOrder.Count - 1
For Index = 0 To CompoArray.Count - 1
' apro ogni directory e cerco un file di testo di nome Config.ini
Dim CurrCompoPath As String = CompoArray(Index) & "\" & ConstCompo.CONFIGINI_FILE_NAME
If File.Exists(CurrCompoPath) Then
GetPrivateProfileCompoName(ConstCompo.S_COMPO, ConstCompo.K_NAME, CompoNameDDF, CompoName, CurrCompoPath)
GetPrivateProfileJambSide("PositionSide", "Side", Side, CurrCompoPath)
If CompoPanelList(IndexCompoOrder) = CompoNameDDF Then
m_CompoTypeList.Add(New CompoType(CompoName, CompoNameDDF, CompoArray(Index), Side))
Exit For
End If
End If
Next
Next
End Sub
#Region "COMMANDS"
#Region "CompoBtnCommand"
''' <summary>
''' Returns a command that do Exec.
''' </summary>
Public ReadOnly Property CompoBtnCommand As ICommand
Get
If m_CmdCompoBtn Is Nothing Then
m_CmdCompoBtn = New Command(AddressOf CompoBtn)
End If
Return m_CmdCompoBtn
End Get
End Property
''' <summary>
''' Execute the Exec. This method is invoked by the ExecCommand.
''' </summary>
'''
Public Sub CompoBtn(param As Object)
Dim m_CurrCompoType As CompoType = DirectCast(param, CompoType)
If Not IsNothing(Map.refPartPageVM.CurrPart) Then
Dim NewCompo As Compo = Map.refPartPageVM.CurrPart.AddNewCompo(m_CurrCompoType)
' appena aggiungo una componente nuova calcolo le sue componenti correttamente modificate
If Not IsNothing(NewCompo.refJambCompo) Then
If Not LoadCompoParam(NewCompo) Then Return
Map.refAssemblyPageVM.CurrAssembly.UpDateCurrCompoJamb(NewCompo)
ResetCompoParam()
End If
Map.refSceneManagerVM.RefreshBtn()
Else
MessageBox.Show(EgtMsg(50108), EgtMsg(50101), MessageBoxButton.OK, MessageBoxImage.Exclamation)
End If
End Sub
#End Region ' CompoBtnCommand
#Region "GoToAssemblyBtnCommand"
''' <summary>
''' Returns a command that do Exec.
''' </summary>
Public ReadOnly Property GoToAssemblyBtnCommand As ICommand
Get
If m_CmdGoToAssemblyBtn Is Nothing Then
m_CmdGoToAssemblyBtn = New Command(AddressOf GoToAssemblyBtn)
End If
Return m_CmdGoToAssemblyBtn
End Get
End Property
''' <summary>
''' Execute the Exec. This method is invoked by the ExecCommand.
''' </summary>
'''
Public Sub GoToAssemblyBtn(param As Object)
Map.refMainWindowVM.SelectedPage = MainWindowVM.ListPageEnum.nAssemblyPage
Map.refSceneManagerVM.RefreshBtn()
End Sub
#End Region ' GoToAssemblyBtnCommand
#Region "ENTERREFRESH"
''' <summary>
''' Returns a command that do Refresh.
''' </summary>
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
#End Region ' EnterRefresh
#End Region 'Commands
Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
Public Sub NotifyPropertyChanged(propName As String)
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propName))
End Sub
End Class