public NewUIPage() { this.InitializeComponent(); TreeViewNode workFolder = new TreeViewNode() { Data = "Work Documents" }; workFolder.IsExpanded = true; workFolder.Add(new TreeViewNode() { Data = "Feature Schedule" }); workFolder.Add(new TreeViewNode() { Data = "Overall Project Plan" }); workFolder.Add(new TreeViewNode() { Data = "Feature Rsource Allocation" }); TreeViewNode remodelFolder = new TreeViewNode() { Data = "Home Remodel" }; remodelFolder.IsExpanded = true; remodelFolder.Add(new TreeViewNode() { Data = "Contractor Contact Info" }); remodelFolder.Add(new TreeViewNode() { Data = "Paint Color Scheme" }); remodelFolder.Add(new TreeViewNode() { Data = "Flooring woodgrain type" }); remodelFolder.Add(new TreeViewNode() { Data = "Kitchen cabinet style" }); TreeViewNode personalFolder = new TreeViewNode() { Data = "Personal Documents" }; personalFolder.IsExpanded = true; personalFolder.Add(remodelFolder); workFolder.Add(personalFolder); simpleTreeView.RootNode = workFolder; }
public TreeViewPage() { this.InitializeComponent(); TreeViewNode workFolder = new TreeViewNode() { Data = "Folder1" }; workFolder.Add(new TreeViewNode() { Data = "1.1" }); workFolder.Add(new TreeViewNode() { Data = "1.2" }); workFolder.Add(new TreeViewNode() { Data = "1.3" }); TreeViewNode remodelFolder = new TreeViewNode() { Data = "Folder2" }; remodelFolder.Add(new TreeViewNode() { Data = "2.1" }); remodelFolder.Add(new TreeViewNode() { Data = "2.2" }); remodelFolder.Add(new TreeViewNode() { Data = "2.3" }); personalFolder = new TreeViewNode() { Data = "TopLevel", IsExpanded = true }; personalFolder.Add(workFolder); personalFolder.Add(remodelFolder); sampleTreeView.RootNode.Add(personalFolder); }
static void _BuildReferencedTreeView(TreeViewCtrl referencedTreeView, TreeViewNode parent, List <U3DAssetInfo> assets) { if (assets.Count == 0) { return; } foreach (var a in assets) { TreeViewNode newNode = referencedTreeView.CreateNode(Path.GetFileName(a.path)); newNode.image = a.icon; newNode.tooptip = a.path; newNode.state.IsExpand = false; if (parent == null) { referencedTreeView.Roots.Add(newNode); } else { parent.Add(newNode); } List <U3DAssetInfo> nextLevelAssets = new List <U3DAssetInfo>(); ResourceManageToolModel.GetInstance().GetAssetReferenced(a.guid, out nextLevelAssets); _BuildReferencedTreeView(referencedTreeView, newNode, nextLevelAssets); } }
static void _BuildResourceRefTreeView(TreeViewCtrl resRefTreeView, TreeViewNode parent, List <U3DAssetInfo> deps) { if (deps.Count == 0) { return; } foreach (var asset in deps) { TreeViewNode newNode = resRefTreeView.CreateNode(Path.GetFileName(asset.path)); newNode.image = asset.icon; newNode.tooptip = asset.path; newNode.state.IsExpand = false; if (parent == null) { resRefTreeView.Roots.Add(newNode); } else { parent.Add(newNode); } //只构建第一层直接引用 //List<U3DAssetInfo> nextLevelDeps = new List<U3DAssetInfo>(); //ResourceManageToolModel.GetInstance().GetAssetDependencies(asset.guid, out nextLevelDeps); //_BuildResourceRefTreeView(resRefTreeView, newNode, nextLevelDeps); } }
static TreeViewNode CreateNodeChild(Transform part) { TreeViewNode node = new TreeViewNode(); node.context = part; node.content = part.name; int c = part.childCount; for (int i = 0; i < c; i++) { node.Add(CreateNodeChild(part.GetChild(i))); } return(node); }
static void AddAssetToResourceTreeView(string path) { TreeViewCtrl treeView = s_root.FindControl("_MainTreeView") as TreeViewCtrl; if (treeView == null) { return; } string totalPath = path; string currPath = path; List <TreeViewNode> currLevelNodeList = treeView.Roots; TreeViewNode parentNode = null; int len = 0; while (currPath != "") { int i = currPath.IndexOf('/'); if (i < 0) { i = currPath.Length; } len += i + 1; string pathNodeName = currPath.Substring(0, i); string currNodeFullPath = totalPath.Substring(0, len - 1); if (i + 1 < currPath.Length) { currPath = currPath.Substring(i + 1); } else { currPath = ""; } bool findNode = false; foreach (var treeNode in currLevelNodeList) { if (treeNode.name == pathNodeName) { findNode = true; parentNode = treeNode; currLevelNodeList = treeNode.children; break; } } if (!findNode) { TreeViewNode newNode = new TreeViewNode(); newNode.name = pathNodeName; newNode.image = ResourceManageToolUtility.GetCachedIcon(path); if (string.Equals(pathNodeName.ToLower(), "assets")) { newNode.state.IsExpand = true; } else { newNode.state.IsExpand = false; } TreeViewNodeUserParam userParam = new TreeViewNodeUserParam(); bool toggleState = false; //Modify by liteng for 发布工具改善 foreach (string p in PackageExportToolModel.GetInstance().GetPackageInfo().ExportAssets) { if (p.Equals(currNodeFullPath)) { toggleState = true; } } userParam.param = toggleState; newNode.state.userParams.Add(userParam); if (parentNode == null) {//说明需要作为根节点插入树视图中 currLevelNodeList.Add(newNode); } else { parentNode.Add(newNode); //Add by liteng for 发布工具改善 start if (true == toggleState) { parentNode.state.IsExpand = true; } //Add by liteng for 发布工具改善 end } parentNode = newNode; currLevelNodeList = newNode.children; } } }
static void AddAssetToResourceTreeView(U3DAssetInfo assetInfo) { TreeViewCtrl resTreeList = s_root.FindControl("_ResTreeList") as TreeViewCtrl; if (resTreeList == null) { return; } bool expandTreeNode = false; if ((ResourceManageToolModel.GetInstance().CurrFilter as NullTypeFilter) == null) {//非过滤器为全部文件则节点都展开 expandTreeNode = true; } string assetPath = assetInfo.path; string currPath = assetPath; List <TreeViewNode> currLevelNodeList = resTreeList.Roots; TreeViewNode parentNode = null; int len = 0; while (currPath != "") { int i = currPath.IndexOf('/'); if (i < 0) { i = currPath.Length; } len += i + 1; string pathNodeName = currPath.Substring(0, i); string currNodeFullPath = assetPath.Substring(0, len - 1); if (i + 1 < currPath.Length) { currPath = currPath.Substring(i + 1); } else { currPath = ""; } bool findNode = false; foreach (var treeNode in currLevelNodeList) { if (treeNode.name == pathNodeName) { findNode = true; parentNode = treeNode; currLevelNodeList = treeNode.children; break; } } if (!findNode) { U3DAssetInfo info = null; TreeViewNode newNode = new TreeViewNode(); newNode.name = pathNodeName; ResourceManageToolModel.GetInstance().Find(currNodeFullPath, out info); newNode.image = info.icon; newNode.userObject = info.guid; newNode.state.IsExpand = expandTreeNode; if (parentNode == null) {//说明需要作为根节点插入树视图中 currLevelNodeList.Add(newNode); } else { parentNode.Add(newNode); } parentNode = newNode; currLevelNodeList = newNode.children; } } }