90db656549
- Aggiunti componenti parametrici con anche componenti interni.
247 lines
8.2 KiB
VB.net
247 lines
8.2 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
|
|
Public Class CompoListPageVM
|
|
Inherits VMBase
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
Private m_CompoList As New ObservableCollection(Of CompoItem)
|
|
Public ReadOnly Property CompoList As ObservableCollection(Of CompoItem)
|
|
Get
|
|
Return m_CompoList
|
|
End Get
|
|
End Property
|
|
|
|
Private m_CompoManagerControl As CompoManagerV
|
|
Public Property CompoManagerControl As CompoManagerV
|
|
Get
|
|
Return m_CompoManagerControl
|
|
End Get
|
|
Set(value As CompoManagerV)
|
|
m_CompoManagerControl = value
|
|
NotifyPropertyChanged("CompoManagerControl")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_BackVisibility As Visibility
|
|
Public ReadOnly Property BackVisibility As Visibility
|
|
Get
|
|
Return m_BackVisibility
|
|
End Get
|
|
End Property
|
|
|
|
' definizione comandi
|
|
Private m_cmdCompoBtn As ICommand
|
|
Private m_cmdBack As ICommand
|
|
|
|
#End Region ' FIELDS & PROPERTIES
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
' Creo riferimento a questa classe in CompoWindowMap
|
|
CompoWindowMap.SetRefCompoListPageVM(Me)
|
|
End Sub
|
|
|
|
#End Region ' CONSTRUCTOR
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Sub InitCompoListPage()
|
|
RefreshCompoList()
|
|
' porto in CompoParam il CompoManager
|
|
If IsNothing(CompoWindowMap.refCompoWindowVM.m_SelCompo) Then
|
|
CompoWindowMap.refCompoParamPageVM.CompoManagerControl = Nothing
|
|
CompoManagerControl = Nothing
|
|
Else
|
|
CompoWindowMap.refCompoParamPageVM.CompoManagerControl = Nothing
|
|
CompoManagerControl = CompoWindowMap.refCompoWindowVM.CompoManagerV
|
|
End If
|
|
' lancio inizializzazione CompoManager
|
|
CompoWindowMap.refCompoManagerVM.InitCompoManager()
|
|
End Sub
|
|
|
|
Private Sub RefreshCompoList()
|
|
m_CompoList.Clear()
|
|
If IsNothing(CompoWindowMap.refCompoWindowVM.m_SelCompoFamily) Then
|
|
LoadMainCompoList()
|
|
m_BackVisibility = Visibility.Collapsed
|
|
ElseIf IsNothing(CompoWindowMap.refCompoWindowVM.m_SelCompo) Then
|
|
LoadSelCompoList()
|
|
m_BackVisibility = Visibility.Visible
|
|
Else
|
|
LoadInternalCompoList()
|
|
m_BackVisibility = Visibility.Visible
|
|
End If
|
|
NotifyPropertyChanged("BackVisibility")
|
|
End Sub
|
|
|
|
Private Sub LoadMainCompoList()
|
|
Dim CompoNumber As Integer = GetMainPrivateProfileInt("Compo", "Count", 0)
|
|
Dim sCompoImage As String = String.Empty
|
|
For CompoIndex = 1 To CompoNumber
|
|
Dim nCompoName As Integer = GetMainPrivateProfileInt("Compo" & CompoIndex, "Name", 0)
|
|
GetMainPrivateProfileString("Compo" & CompoIndex, "Image", "", sCompoImage)
|
|
If GetMainPrivateProfileInt("Compo" & CompoIndex, "Count", 1) = 1 Then
|
|
' Recupero path del Lua
|
|
Dim sLuaPath As String = GetPrivateProfileCompo("Compo" & CompoIndex, "Compo1").LuaPath
|
|
m_CompoList.Add(New CompoItem(CompoIndex, nCompoName, sLuaPath, sCompoImage))
|
|
Else
|
|
m_CompoList.Add(New CompoItem(CompoIndex, nCompoName, sCompoImage))
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
Private Sub LoadSelCompoList()
|
|
Dim SelCompoIndex As Integer = CompoWindowMap.refCompoWindowVM.m_SelCompoFamily.Index
|
|
Dim CompoNumber As Integer = GetMainPrivateProfileInt("Compo" & SelCompoIndex, "Count", 0)
|
|
For CompoIndex = 1 To CompoNumber
|
|
m_CompoList.Add(GetPrivateProfileCompo("Compo" & SelCompoIndex, "Compo" & CompoIndex))
|
|
Next
|
|
End Sub
|
|
|
|
Private Sub LoadInternalCompoList()
|
|
Dim CompoNumber As Integer = GetMainPrivateProfileInt("InternalCompo", "Count", 0)
|
|
For CompoIndex = 1 To CompoNumber
|
|
m_CompoList.Add(GetPrivateProfileCompo("InternalCompo" & CompoIndex, "InternalCompo" & CompoIndex))
|
|
Next
|
|
End Sub
|
|
|
|
Public Function GetPrivateProfileCompo(
|
|
ByVal lpAppName As String,
|
|
ByVal lpKeyName As String) As CompoItem
|
|
Dim sVal As String = String.Empty
|
|
GetMainPrivateProfileString(lpAppName, lpKeyName, "", sVal)
|
|
Dim sItems() As String = sVal.Split(",".ToCharArray)
|
|
If sItems.Count() >= 2 Then
|
|
Dim nName As Integer = 0
|
|
StringToInt(sItems(0), nName)
|
|
Dim sImagePath As String = String.Empty
|
|
If sItems.Count() >= 3 Then
|
|
sImagePath = sItems(2)
|
|
End If
|
|
Return New CompoItem(nName, sItems(1), sImagePath)
|
|
End If
|
|
Return Nothing
|
|
End Function
|
|
|
|
#End Region ' METHODS
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "CompoBtnCommand"
|
|
|
|
' Returns a command that manage the MainWindow_Unloaded command
|
|
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
|
|
|
|
' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded.
|
|
Public Sub CompoBtn(ByVal param As Object)
|
|
If IsNothing(CompoWindowMap.refCompoWindowVM.m_SelCompoFamily) Then
|
|
CompoWindowMap.refCompoWindowVM.m_SelCompoFamily = DirectCast(param, CompoItem)
|
|
Dim SubCompoCount As Integer = GetMainPrivateProfileInt("Compo" & CompoWindowMap.refCompoWindowVM.m_SelCompoFamily.Index, "Count", 1)
|
|
If SubCompoCount = 1 Then
|
|
CompoWindowMap.refCompoWindowVM.m_SelCompo = CompoWindowMap.refCompoWindowVM.m_SelCompoFamily
|
|
CompoWindowMap.refCompoWindowVM.CompoPage = CompoWindowVM.CompoPageOpt.PARAM
|
|
Else
|
|
RefreshCompoList()
|
|
End If
|
|
ElseIf IsNothing(CompoWindowMap.refCompoWindowVM.m_SelCompo) Then
|
|
CompoWindowMap.refCompoWindowVM.m_SelCompo = DirectCast(param, CompoItem)
|
|
CompoWindowMap.refCompoWindowVM.CompoPage = CompoWindowVM.CompoPageOpt.PARAM
|
|
Else
|
|
CompoWindowMap.refCompoWindowVM.m_SelInternalCompo = DirectCast(param, CompoItem)
|
|
CompoWindowMap.refCompoWindowVM.CompoPage = CompoWindowVM.CompoPageOpt.PARAM
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' CompoBtnCommand
|
|
|
|
#Region "BackCommand"
|
|
|
|
' Returns a command that manage the MainWindow_Unloaded command
|
|
Public ReadOnly Property BackCommand() As ICommand
|
|
Get
|
|
If m_cmdBack Is Nothing Then
|
|
m_cmdBack = New Command(AddressOf Back)
|
|
End If
|
|
Return m_cmdBack
|
|
End Get
|
|
End Property
|
|
|
|
' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded.
|
|
Public Sub Back(ByVal param As Object)
|
|
If IsNothing(CompoWindowMap.refCompoWindowVM.m_SelCompo) Then
|
|
CompoWindowMap.refCompoWindowVM.m_SelCompoFamily = Nothing
|
|
InitCompoListPage()
|
|
Else
|
|
CompoWindowMap.refCompoWindowVM.m_SelCompo = Nothing
|
|
InitCompoListPage()
|
|
EgtNewFile()
|
|
EgtDraw()
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' BackCommand
|
|
|
|
#End Region ' COMMANDS
|
|
|
|
End Class
|
|
|
|
Public Class CompoItem
|
|
|
|
Private m_nIndex As Integer
|
|
Friend ReadOnly Property Index As Integer
|
|
Get
|
|
Return m_nIndex
|
|
End Get
|
|
End Property
|
|
Private m_sName As String
|
|
Public ReadOnly Property Name As String
|
|
Get
|
|
Return m_sName
|
|
End Get
|
|
End Property
|
|
|
|
Private m_sLuaPath As String
|
|
Public ReadOnly Property LuaPath As String
|
|
Get
|
|
Return m_sLuaPath
|
|
End Get
|
|
End Property
|
|
|
|
Private m_sImagePath As String
|
|
Public ReadOnly Property ImagePath As String
|
|
Get
|
|
Return m_sImagePath
|
|
End Get
|
|
End Property
|
|
|
|
Sub New(nIndex As Integer, nName As Integer, sImagePath As String)
|
|
m_nIndex = nIndex
|
|
m_sName = EgtMsg(MSG_COMPONENTPAGEUC + nName)
|
|
m_sImagePath = sImagePath
|
|
End Sub
|
|
|
|
Sub New(nIndex As Integer, nName As Integer, sLuaPath As String, sImagePath As String)
|
|
m_nIndex = nIndex
|
|
m_sName = EgtMsg(MSG_COMPONENTPAGEUC + nName)
|
|
m_sLuaPath = sLuaPath
|
|
m_sImagePath = sImagePath
|
|
End Sub
|
|
|
|
Sub New(nName As Integer, sLuaPath As String, sImagePath As String)
|
|
m_sName = EgtMsg(MSG_COMPONENTPAGEUC + nName)
|
|
m_sLuaPath = sLuaPath
|
|
m_sImagePath = sImagePath
|
|
End Sub
|
|
|
|
End Class |