vbAccelerator - Contents of code file: cVBProjectGroup.cls

VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "cVBProjectGroup"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit

Private m_bFakeGroup As Boolean
Private m_cVBP() As cVBProject
Private m_iCount As Long
Private m_sPath As String
Private m_sFile As String
Private m_bFixPaths As Boolean

Public Property Get FixPaths() As Boolean
   FixPaths = m_bFixPaths
End Property
Public Property Let FixPaths(ByVal bState As Boolean)
   m_bFixPaths = bState
End Property

Public Sub Zip(ByRef cZ As cZip)
Dim i As Long
   If Not m_bFakeGroup Then
      cZ.AddFileSpec NormalizePath(m_sPath) & m_sFile
   End If
   For i = 1 To m_iCount
      Project(i).Zip cZ
   Next i
End Sub

Public Property Get FakeGroup() As Boolean
   FakeGroup = m_bFakeGroup
End Property
Public Property Get Path() As String
   Path = m_sPath
End Property
Public Property Get FileName() As String
   FileName = m_sFile
End Property

Public Property Get Count() As Long
   Count = m_iCount
End Property
Public Property Get Project(ByVal nIndex As Long) As cVBProject
   Set Project = m_cVBP(nIndex)
End Property

Public Sub Show( _
      lstThis As ListBox, _
      cODList As cSimpleODListBox, _
      cSysILS As cVBALSysImageList, _
      ByVal bShowFolders As Boolean _
   )
Dim lIndent As Long
Dim i As Long
   lstThis.Clear
   If Not m_bFakeGroup Then
      cODList.AddItem lstThis, m_sFile & vbTab & "<ProjectGroup><FileName>" &
       m_sFile & "</Name></ProjectGroup>", cSysILS.ItemIndex("C:\Junk.VBG"), 0
      lIndent = 1
   End If
   For i = 1 To m_iCount
      m_cVBP(i).Show lstThis, cODList, cSysILS, lIndent, bShowFolders
   Next i
End Sub

Public Sub Load(ByVal sCmd As String)
Dim iPos As Long
Dim sText As String
Dim sThis As String
Dim sType As String
Dim sItem As String
Dim sLine As String
Dim bStartup As Boolean

   sCmd = ReplaceSection(sCmd, """", "")

   iPos = InstrRev(sCmd, "\")
   If iPos > 0 Then
      m_sPath = Left$(sCmd, iPos - 1)
      m_sFile = Mid$(sCmd, iPos + 1)
   Else
      m_sPath = App.Path
      m_sFile = sCmd
   End If
   If UCase$(Right$(sCmd, 3)) = "VBG" Then
      m_bFakeGroup = False
      If ReadFileText(sCmd, sText) Then
         Dim cS As New cSplitString
         cS.Splitter(1) = vbCrLf
         cS.Splitter(2) = "="
         cS.TheString = sText
         sText = ""
         
         Do
            sThis = cS.NextItem
            If cS.SplitItem = 2 Then
               sType = sThis
            Else
               If sType = "StartupProject" Then
                  bStartup = True
                  sItem = sThis
               ElseIf sType = "Project" Then
                  bStartup = False
                  sItem = sThis
               Else
                  sItem = ""
               End If
               
               If Not sItem = "" Then
                  ' Fix up dumb paths:
                  sItem = RelativePath(m_sPath, AddFileToPath(m_sPath, sItem))
               
                  m_iCount = m_iCount + 1
                  ReDim Preserve m_cVBP(1 To m_iCount) As cVBProject
                  Set m_cVBP(m_iCount) = New cVBProject
                  m_cVBP(m_iCount).FixPaths = m_bFixPaths
                  m_cVBP(m_iCount).Load m_sPath, sItem, bStartup
                  sThis = sItem
               End If

            End If
                        
            sText = sText & sThis
            If cS.SplitItem = 2 Then
               sText = sText & "="
            Else
               sText = sText & vbCrLf
            End If
            
         Loop While cS.More
         If m_bFixPaths Then
            ReplaceFileText sCmd, sText
         End If
            
      End If
   Else
      m_bFakeGroup = True
      m_iCount = 1
      ReDim m_cVBP(1 To 1) As cVBProject
      Set m_cVBP(1) = New cVBProject
      m_cVBP(1).FixPaths = m_bFixPaths
      m_cVBP(1).Load m_sPath, m_sFile, True
   End If
End Sub