当前位置: 网学 > 编程文档 > ASP > 正文

asp下生成目录树结构的类

来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 13/06/16
InitChildList()

Set CreateChild = New TreeNode
CreateChild.Value = szValue
CreateChild.ExpandImage = ExpandImage
CreateChild.CollapseImage = CollapseImage
CreateChild.LeafImage = LeafImage

mcolChildren.Add mcolChildren.Count + 1, CreateChild

End Function

Public Sub Draw()

LoadState()

Response.Write "<table border=""0"">" & vbCrLf
Response.Write "<tr><td>" & vbCrLf

If Expanded Then
Response.Write "<a href=""javascript:collapseNode(''" & mszName & "'')""><img src=""" & CollapseImage & """ border=""0""></a>" & vbCrLf
ElseIf Not mbChildrenInitialized Then
Response.Write "<img src=""" & LeafImage & """ border=0>" & vbCrLf
Else
Response.Write "<a href=""javascript:expandNode(''" & mszName & "'')""><img src=""" & ExpandImage & """ border=""0""></a>" & vbCrLf
End If

Response.Write "</td>" & vbCrLf
Response.Write "<td>" & Value & "</td></tr>" & vbCrLf

If Expanded Then
Response.Write "<input type=""hidden"" name=""" & mszName & """ value=""1"">" & vbCrLf

If mbChildrenInitialized Then
Response.Write "<tr><td> </td>" & vbCrLf
Response.Write "<td>" & vbCrLf

For Each ChildNode In mcolChildren.Items
ChildNode.Draw()
Next

Response.Write "</td>" & vbCrLf
Response.Write "</tr>" & vbCrLf
End If
End If

Response.Write "</table>" & vbCrLf

End Sub

End Class


Class Tree

Public Top
Public Left
Public ExpandImage
Public CollapseImage
Public LeafImage
Private mszPosition
Private mcolChildren

Public Property Let Absolute(bData)
If bData Then mszPosition = "absolute" Else mszPosition = "relative"
End Property

Public Property Get Absolute()
Absolute = CBool(mszPosition = "absolute")
End Property

Private Sub Class_Initialize()
Set mcolChildren = Server.CreateObject("Scripting.Dictionary")
mnTop = 0
mnLeft = 0
mszPosition = "absolute"
End Sub

Private Sub Class_Terminate()
mcolChildren.RemoveAll()
Set mcolChildren = Nothing
End Sub

Public Function CreateChild(szValue)

Set CreateChild = New TreeNode

CreateChild.Value = szValue
CreateChild.ExpandImage = ExpandImage
CreateChild.CollapseImage = CollapseImage
CreateChild.LeafImage = LeafImage

mcolChildren.Add mcolChildren.Count + 1, CreateChild

End Function

Public Sub LoadTemplate(szFileName)
Dim objWorkingNode
Dim colNodeStack
Dim fsObj, tsObj
Dim szLine
Dim nCurrDepth, nNextDepth

Set colNodeStack = Server.CreateObject("Scripting.Dictionary")
Set fsObj = CreateObject("Scripting.FileSystemObject")
Set tsObj = fsObj.OpenTextFile(szFileName, 1)

nCurrDepth = 0
While Not tsObj.AtEndOfLine
nNextDepth = 1
szLine = tsObj.ReadLine()

If nCurrDepth = 0 Then
Set objWorkingNode = CreateChild(Trim(szLine))
nCurrDepth = 1
Else
While Mid(szLine,nNextDepth,1) = vbTab Or Mid(szLine,nNextDepth,1) = " "
nNextDepth = nNextDepth + 1
WEnd

If nNextDepth > 1 Then szLine = Trim(Mid(szLine,nNextDepth))

If szLine <> "" Then
If nNextDepth > nCurrDepth Then
If colNodeStack.Exists(nCurrDepth) Then
Set colNodeStack.Item(nC

网学推荐

免费论文

原创论文

浏览:
设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved
湘ICP备09003080号