public void UpdateMapObjectLayer(MapObject target) { if (target == null) { return; } TreeNode objectNode = TreeViewUtil.FindNodeByTag(rootNode, target); if (objectNode == null) { return; } TreeNode layerNode = target.EditorLayer == null? rootNode : TreeViewUtil.FindNodeByTag(rootNode, target.EditorLayer); if (layerNode != null) { objectNode.Remove(); layerNode.Nodes.Add(objectNode); TreeViewUtil.ExpandTo(objectNode); } }
private void UpdateData(string currentPath) { this.treeView.BeginUpdate(); this.treeView.Nodes.Clear(); while (this.imageListTreeView.Images.Count > 2) { this.imageListTreeView.Images.RemoveAt(2); } foreach (ResourceType current in ResourceTypeManager.Instance.Types) { Image icon = current.Icon; if (icon != null) { int count = this.imageListTreeView.Images.Count; this.imageListTreeView.Images.Add(icon); icon.Tag = count; } } this.rootNode = new TreeNode("Data", 0, 0); this.treeView.Nodes.Add(rootNode); this.UpdateDataDirectory("", rootNode); this.treeView.TreeViewNodeSorter = new NodeComparer(); this.treeView.Sort(); this.rootNode.Expand(); if (this.rootNode.Nodes.Count == 1) { this.rootNode.Nodes[0].Expand(); } bool flag = false; if (!string.IsNullOrEmpty(currentPath)) { TreeNode nodeByPath = this.GetNodeByPath(currentPath); if (nodeByPath != null) { TreeViewUtil.ExpandTo(nodeByPath); this.treeView.SelectedNode = nodeByPath; flag = true; } } if (!flag && string.IsNullOrEmpty(currentPath) && !string.IsNullOrEmpty(currentHelperDirectoryName)) { TreeNode nodeByPath2 = GetNodeByPath(currentHelperDirectoryName); if (nodeByPath2 != null) { TreeViewUtil.ExpandTo(nodeByPath2); treeView.SelectedNode = nodeByPath2; flag = true; } } if (this.allowChooseNull) { this.nullValueNode = new TreeNode(ToolsLocalization.Translate("ChooseResourceForm", "(Null)"), 1, 1); this.nullValueNode.Name = nullValueNode.Text; this.treeView.Nodes.Add(nullValueNode); if (string.IsNullOrEmpty(currentPath) && !flag) { this.treeView.SelectedNode = nullValueNode; flag = true; } } if (!flag && treeView.Nodes.Count != 0) { this.treeView.SelectedNode = treeView.Nodes[0]; } this.treeView.EndUpdate(); }