87 lines
1.9 KiB
C#
87 lines
1.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using VEPROMS.CSLA.Library;
|
|
using Csla;
|
|
using System.Windows.Forms;
|
|
|
|
namespace WinApp
|
|
{
|
|
public class FolderTreeNode : TreeNode
|
|
{
|
|
FolderTreeNode(string s) : base(s)
|
|
{
|
|
this.Name="ID:" + s;
|
|
}
|
|
FolderTreeNode(FolderInfo folderinfo)
|
|
: base(folderinfo.Name)
|
|
{
|
|
_folderinfo = folderinfo;
|
|
this.Name = "ID:" + folderinfo.FolderID.ToString();
|
|
}
|
|
private FolderInfo _folderinfo;
|
|
public FolderInfo FolderInfo
|
|
{
|
|
get { return _folderinfo; }
|
|
set
|
|
{
|
|
_folderinfo = value;
|
|
}
|
|
}
|
|
private Dictionary<int, FolderTreeNode> _findTree = null;
|
|
private Dictionary<int, FolderTreeNode> FindTree
|
|
{
|
|
get { return _findTree; }
|
|
set { _findTree = value; }
|
|
}
|
|
public FolderTreeNode FindTreeNode(int folderID)
|
|
{
|
|
if (_findTree != null) return _findTree[folderID];
|
|
return null;
|
|
}
|
|
public static FolderTreeNode BuildTreeList()
|
|
{
|
|
FolderTreeNode root = null;
|
|
FolderInfoList fil = FolderInfoList.Get();
|
|
Dictionary<int, FolderTreeNode> dicMissing = new Dictionary<int, FolderTreeNode>();
|
|
Dictionary<int, FolderTreeNode> dicExists = new Dictionary<int, FolderTreeNode>();
|
|
foreach (FolderInfo fi in fil)
|
|
{
|
|
FolderTreeNode ftp = null;
|
|
if (dicExists.ContainsKey(fi.ParentID))
|
|
{
|
|
ftp = dicExists[fi.ParentID];
|
|
}
|
|
else
|
|
{
|
|
if (fi.ParentID != 0)
|
|
{
|
|
ftp = new FolderTreeNode(fi.ParentID.ToString());
|
|
dicMissing.Add(fi.ParentID, ftp);
|
|
dicExists.Add(fi.ParentID, ftp);
|
|
}
|
|
}
|
|
FolderTreeNode ft = null;
|
|
if (dicMissing.ContainsKey(fi.FolderID))
|
|
{
|
|
ft = dicMissing[fi.FolderID];
|
|
ft.FolderInfo = fi;
|
|
dicMissing.Remove(fi.FolderID);
|
|
}
|
|
else
|
|
{
|
|
ft = new FolderTreeNode(fi);
|
|
dicExists.Add(fi.FolderID, ft);
|
|
}
|
|
if (fi.ParentID == 0)
|
|
root = ft;
|
|
else
|
|
ftp.Nodes.Add(ft);
|
|
}
|
|
root.FindTree = dicExists;
|
|
return root;
|
|
}
|
|
}
|
|
}
|
|
|