private PackageExportTreeView.EnabledState GetFolderChildrenEnabledState(PackageExportTreeView.PackageExportTreeViewItem folder) { if (!folder.isFolder) { Debug.LogError((object)"Should be a folder item!"); } if (!folder.hasChildren) { return(PackageExportTreeView.EnabledState.None); } PackageExportTreeView.EnabledState enabledState1 = PackageExportTreeView.EnabledState.NotSet; PackageExportTreeView.EnabledState enabledState2 = (folder.children[0] as PackageExportTreeView.PackageExportTreeViewItem).enabledState; for (int index = 1; index < folder.children.Count; ++index) { PackageExportTreeView.PackageExportTreeViewItem child = folder.children[index] as PackageExportTreeView.PackageExportTreeViewItem; if (enabledState2 != child.enabledState) { enabledState1 = PackageExportTreeView.EnabledState.Mixed; break; } } if (enabledState1 == PackageExportTreeView.EnabledState.NotSet) { enabledState1 = enabledState2 != PackageExportTreeView.EnabledState.All ? PackageExportTreeView.EnabledState.None : PackageExportTreeView.EnabledState.All; } return(enabledState1); }
private PackageExportTreeView.EnabledState GetFolderChildrenEnabledState(PackageExportTreeView.PackageExportTreeViewItem folder) { ExportPackageItem item = folder.item; if (item != null && !item.isFolder) { Debug.LogError("Should be a folder item!"); } if (!folder.hasChildren) { return(PackageExportTreeView.EnabledState.None); } PackageExportTreeView.EnabledState enabledState = PackageExportTreeView.EnabledState.NotSet; PackageExportTreeView.PackageExportTreeViewItem packageExportTreeViewItem = folder.children[0] as PackageExportTreeView.PackageExportTreeViewItem; ExportPackageItem item2 = packageExportTreeViewItem.item; int num = (item2 != null) ? item2.enabledStatus : 1; for (int i = 1; i < folder.children.Count; i++) { item2 = (folder.children[i] as PackageExportTreeView.PackageExportTreeViewItem).item; if (num != item2.enabledStatus) { enabledState = PackageExportTreeView.EnabledState.Mixed; break; } } if (enabledState == PackageExportTreeView.EnabledState.NotSet) { enabledState = ((num != 1) ? PackageExportTreeView.EnabledState.None : PackageExportTreeView.EnabledState.All); } return(enabledState); }
private PackageExportTreeView.EnabledState GetFolderChildrenEnabledState(PackageExportTreeView.PackageExportTreeViewItem folder) { if (!folder.isFolder) { Debug.LogError("Should be a folder item!"); } PackageExportTreeView.EnabledState result; if (!folder.hasChildren) { result = PackageExportTreeView.EnabledState.None; } else { PackageExportTreeView.EnabledState enabledState = PackageExportTreeView.EnabledState.NotSet; PackageExportTreeView.PackageExportTreeViewItem packageExportTreeViewItem = folder.children[0] as PackageExportTreeView.PackageExportTreeViewItem; PackageExportTreeView.EnabledState enabledState2 = packageExportTreeViewItem.enabledState; for (int i = 1; i < folder.children.Count; i++) { PackageExportTreeView.PackageExportTreeViewItem packageExportTreeViewItem2 = folder.children[i] as PackageExportTreeView.PackageExportTreeViewItem; if (enabledState2 != packageExportTreeViewItem2.enabledState) { enabledState = PackageExportTreeView.EnabledState.Mixed; break; } } if (enabledState == PackageExportTreeView.EnabledState.NotSet) { enabledState = ((enabledState2 != PackageExportTreeView.EnabledState.All) ? PackageExportTreeView.EnabledState.None : PackageExportTreeView.EnabledState.All); } result = enabledState; } return(result); }
private TreeViewItem EnsureFolderPath(string folderPath, Dictionary <string, PackageExportTreeView.PackageExportTreeViewItem> treeViewFolders, bool initExpandedState) { TreeViewItem result; if (folderPath == "") { result = this.m_RootItem; } else { int hashCode = folderPath.GetHashCode(); TreeViewItem treeViewItem = TreeViewUtility.FindItem(hashCode, this.m_RootItem); if (treeViewItem != null) { result = treeViewItem; } else { string[] array = folderPath.Split(new char[] { '/' }); string text = ""; TreeViewItem treeViewItem2 = this.m_RootItem; int num = -1; for (int i = 0; i < array.Length; i++) { string text2 = array[i]; if (text != "") { text += '/'; } text += text2; if (i != 0 || !(text == "Assets")) { num++; hashCode = text.GetHashCode(); PackageExportTreeView.PackageExportTreeViewItem packageExportTreeViewItem; if (treeViewFolders.TryGetValue(text, out packageExportTreeViewItem)) { treeViewItem2 = packageExportTreeViewItem; } else { PackageExportTreeView.PackageExportTreeViewItem packageExportTreeViewItem2 = new PackageExportTreeView.PackageExportTreeViewItem(null, hashCode, num, treeViewItem2, text2); treeViewItem2.AddChild(packageExportTreeViewItem2); treeViewItem2 = packageExportTreeViewItem2; if (initExpandedState) { this.m_TreeView.state.expandedIDs.Add(hashCode); } treeViewFolders[text] = packageExportTreeViewItem2; } } } result = treeViewItem2; } } return(result); }
private void RecursiveComputeEnabledStateForFolders(PackageExportTreeView.PackageExportTreeViewItem pitem, HashSet <PackageExportTreeView.PackageExportTreeViewItem> done) { if (pitem.isFolder) { if (pitem.hasChildren) { foreach (TreeViewItem current in pitem.children) { this.RecursiveComputeEnabledStateForFolders(current as PackageExportTreeView.PackageExportTreeViewItem, done); } } if (!done.Contains(pitem)) { PackageExportTreeView.EnabledState folderChildrenEnabledState = this.GetFolderChildrenEnabledState(pitem); pitem.enabledState = folderChildrenEnabledState; if (folderChildrenEnabledState == PackageExportTreeView.EnabledState.Mixed) { done.Add(pitem); for (PackageExportTreeView.PackageExportTreeViewItem packageExportTreeViewItem = pitem.parent as PackageExportTreeView.PackageExportTreeViewItem; packageExportTreeViewItem != null; packageExportTreeViewItem = (packageExportTreeViewItem.parent as PackageExportTreeView.PackageExportTreeViewItem)) { if (!done.Contains(packageExportTreeViewItem)) { packageExportTreeViewItem.enabledState = PackageExportTreeView.EnabledState.Mixed; done.Add(packageExportTreeViewItem); } } } } } }
private void ComputeEnabledStateForFolders() { PackageExportTreeView.PackageExportTreeViewItem root = this.m_TreeView.data.root as PackageExportTreeView.PackageExportTreeViewItem; this.RecursiveComputeEnabledStateForFolders(root, new HashSet <PackageExportTreeView.PackageExportTreeViewItem>() { root }); }
private void EnableChildrenRecursive(TreeViewItem parentItem, PackageExportTreeView.EnabledState enabled) { if (parentItem.hasChildren) { foreach (TreeViewItem current in parentItem.children) { PackageExportTreeView.PackageExportTreeViewItem packageExportTreeViewItem = current as PackageExportTreeView.PackageExportTreeViewItem; packageExportTreeViewItem.enabledState = enabled; this.EnableChildrenRecursive(packageExportTreeViewItem, enabled); } } }
private void DoIconAndText(PackageExportTreeView.PackageExportTreeViewItem item, Rect contentRect, bool selected, bool focused) { EditorGUIUtility.SetIconSize(new Vector2(this.k_IconWidth, this.k_IconWidth)); GUIStyle lineStyle = TreeViewGUI.s_Styles.lineStyle; lineStyle.padding.left = 0; if (Event.current.type == EventType.Repaint) { lineStyle.Draw(contentRect, GUIContent.Temp(item.displayName, this.GetIconForNode((TreeViewItem)item)), false, false, selected, focused); } EditorGUIUtility.SetIconSize(Vector2.zero); }
private TreeViewItem EnsureFolderPath(string folderPath, Dictionary <string, PackageExportTreeView.PackageExportTreeViewItem> treeViewFolders, bool initExpandedState) { if (folderPath == "") { return(base.m_RootItem); } TreeViewItem item2 = TreeViewUtility.FindItem(folderPath.GetHashCode(), base.m_RootItem); if (item2 != null) { return(item2); } char[] separator = new char[] { '/' }; string[] strArray = folderPath.Split(separator); string key = ""; TreeViewItem rootItem = base.m_RootItem; int depth = -1; for (int i = 0; i < strArray.Length; i++) { string displayName = strArray[i]; if (key != "") { key = key + '/'; } key = key + displayName; if ((i != 0) || (key != "Assets")) { PackageExportTreeView.PackageExportTreeViewItem item4; depth++; int hashCode = key.GetHashCode(); if (treeViewFolders.TryGetValue(key, out item4)) { rootItem = item4; } else { PackageExportTreeView.PackageExportTreeViewItem child = new PackageExportTreeView.PackageExportTreeViewItem(null, hashCode, depth, rootItem, displayName); rootItem.AddChild(child); rootItem = child; if (initExpandedState) { base.m_TreeView.state.expandedIDs.Add(hashCode); } treeViewFolders[key] = child; } } } return(rootItem); }
private TreeViewItem EnsureFolderPath(string folderPath, Dictionary <string, PackageExportTreeView.PackageExportTreeViewItem> treeViewFolders, bool initExpandedState) { if (folderPath == string.Empty) { return(this.m_RootItem); } TreeViewItem treeViewItem = TreeViewUtility.FindItem(folderPath.GetHashCode(), this.m_RootItem); if (treeViewItem != null) { return(treeViewItem); } string[] strArray = folderPath.Split('/'); string empty = string.Empty; TreeViewItem parent = this.m_RootItem; int depth = -1; for (int index = 0; index < strArray.Length; ++index) { string displayName = strArray[index]; if (empty != string.Empty) { empty += (string)(object)'/'; } empty += displayName; if (index != 0 || !(empty == "Assets")) { ++depth; int hashCode = empty.GetHashCode(); PackageExportTreeView.PackageExportTreeViewItem exportTreeViewItem1; if (treeViewFolders.TryGetValue(empty, out exportTreeViewItem1)) { parent = (TreeViewItem)exportTreeViewItem1; } else { PackageExportTreeView.PackageExportTreeViewItem exportTreeViewItem2 = new PackageExportTreeView.PackageExportTreeViewItem((ExportPackageItem)null, hashCode, depth, parent, displayName); parent.AddChild((TreeViewItem)exportTreeViewItem2); parent = (TreeViewItem)exportTreeViewItem2; if (initExpandedState) { this.m_TreeView.state.expandedIDs.Add(hashCode); } treeViewFolders[empty] = exportTreeViewItem2; } } } return(parent); }
private void ItemWasToggled(PackageExportTreeView.PackageExportTreeViewItem pitem) { if (this.m_Selection.Count <= 1) { this.EnableChildrenRecursive(pitem, pitem.enabledState); } else { foreach (PackageExportTreeView.PackageExportTreeViewItem current in this.m_Selection) { current.enabledState = pitem.enabledState; } } this.ComputeEnabledStateForFolders(); }
private void EnableChildrenRecursive(TreeViewItem parentItem, PackageExportTreeView.EnabledState enabled) { if (!parentItem.hasChildren) { return; } using (List <TreeViewItem> .Enumerator enumerator = parentItem.children.GetEnumerator()) { while (enumerator.MoveNext()) { PackageExportTreeView.PackageExportTreeViewItem current = enumerator.Current as PackageExportTreeView.PackageExportTreeViewItem; current.enabledState = enabled; this.EnableChildrenRecursive((TreeViewItem)current, enabled); } } }
private static void Toggle(ExportPackageItem[] items, PackageExportTreeView.PackageExportTreeViewItem pitem, Rect toggleRect) { bool flag = pitem.enabledState > PackageExportTreeView.EnabledState.None; GUIStyle toggle = EditorStyles.toggle; if (pitem.isFolder && (pitem.enabledState == PackageExportTreeView.EnabledState.Mixed)) { toggle = EditorStyles.toggleMixed; } bool flag3 = GUI.Toggle(toggleRect, flag, GUIContent.none, toggle); if (flag3 != flag) { pitem.enabledState = !flag3 ? PackageExportTreeView.EnabledState.None : PackageExportTreeView.EnabledState.All; } }
private void SelectionChanged(int[] selectedIDs) { this.m_Selection = new List <PackageExportTreeView.PackageExportTreeViewItem>(); IList <TreeViewItem> rows = this.m_TreeView.data.GetRows(); foreach (TreeViewItem current in rows) { if (selectedIDs.Contains(current.id)) { PackageExportTreeView.PackageExportTreeViewItem packageExportTreeViewItem = current as PackageExportTreeView.PackageExportTreeViewItem; if (packageExportTreeViewItem != null) { this.m_Selection.Add(packageExportTreeViewItem); } } } }
private void EnableChildrenRecursive(TreeViewItem parentItem, int enabled) { if (!parentItem.hasChildren) { return; } foreach (TreeViewItem current in parentItem.children) { PackageExportTreeView.PackageExportTreeViewItem packageExportTreeViewItem = current as PackageExportTreeView.PackageExportTreeViewItem; ExportPackageItem item = packageExportTreeViewItem.item; if (item != null) { item.enabledStatus = enabled; } this.EnableChildrenRecursive(packageExportTreeViewItem, enabled); } }
protected override Texture GetIconForItem(TreeViewItem tItem) { PackageExportTreeView.PackageExportTreeViewItem item = tItem as PackageExportTreeView.PackageExportTreeViewItem; ExportPackageItem item2 = item.item; if ((item2 == null) || item2.isFolder) { return(Constants.folderIcon); } Texture cachedIcon = AssetDatabase.GetCachedIcon(item2.assetPath); if (cachedIcon != null) { return(cachedIcon); } return(InternalEditorUtility.GetIconForFile(item2.assetPath)); }
private static void Toggle(ExportPackageItem[] items, PackageExportTreeView.PackageExportTreeViewItem pitem, Rect toggleRect) { bool flag1 = pitem.enabledState > PackageExportTreeView.EnabledState.None; GUIStyle style = EditorStyles.toggle; if (pitem.isFolder && pitem.enabledState == PackageExportTreeView.EnabledState.Mixed) { style = EditorStyles.toggleMixed; } bool flag2 = GUI.Toggle(toggleRect, flag1, GUIContent.none, style); if (flag2 == flag1) { return; } pitem.enabledState = !flag2 ? PackageExportTreeView.EnabledState.None : PackageExportTreeView.EnabledState.All; }
private void ItemWasToggled(PackageExportTreeView.PackageExportTreeViewItem pitem) { if (this.m_Selection.Count <= 1) { this.EnableChildrenRecursive((TreeViewItem)pitem, pitem.enabledState); } else { using (List <PackageExportTreeView.PackageExportTreeViewItem> .Enumerator enumerator = this.m_Selection.GetEnumerator()) { while (enumerator.MoveNext()) { enumerator.Current.enabledState = pitem.enabledState; } } } this.ComputeEnabledStateForFolders(); }
public override void FetchData() { int depth = -1; this.m_RootItem = new PackageExportTreeView.PackageExportTreeViewItem(null, "Assets".GetHashCode(), depth, null, "InvisibleAssetsFolder"); bool flag = true; if (flag) { this.m_TreeView.state.expandedIDs.Add(this.m_RootItem.id); } ExportPackageItem[] items = this.m_PackageExportView.items; Dictionary <string, PackageExportTreeView.PackageExportTreeViewItem> dictionary = new Dictionary <string, PackageExportTreeView.PackageExportTreeViewItem>(); for (int i = 0; i < items.Length; i++) { ExportPackageItem exportPackageItem = items[i]; if (!PackageImport.HasInvalidCharInFilePath(exportPackageItem.assetPath)) { string fileName = Path.GetFileName(exportPackageItem.assetPath); string directoryName = Path.GetDirectoryName(exportPackageItem.assetPath); TreeViewItem treeViewItem = this.EnsureFolderPath(directoryName, dictionary, flag); if (treeViewItem != null) { int hashCode = exportPackageItem.assetPath.GetHashCode(); PackageExportTreeView.PackageExportTreeViewItem packageExportTreeViewItem = new PackageExportTreeView.PackageExportTreeViewItem(exportPackageItem, hashCode, treeViewItem.depth + 1, treeViewItem, fileName); treeViewItem.AddChild(packageExportTreeViewItem); if (flag) { this.m_TreeView.state.expandedIDs.Add(hashCode); } if (exportPackageItem.isFolder) { dictionary[exportPackageItem.assetPath] = packageExportTreeViewItem; } } } } if (flag) { this.m_TreeView.state.expandedIDs.Sort(); } }
private void SelectionChanged(int[] selectedIDs) { this.m_Selection = new List <PackageExportTreeView.PackageExportTreeViewItem>(); using (List <TreeViewItem> .Enumerator enumerator = this.m_TreeView.data.GetRows().GetEnumerator()) { while (enumerator.MoveNext()) { TreeViewItem current = enumerator.Current; if (((IEnumerable <int>)selectedIDs).Contains <int>(current.id)) { PackageExportTreeView.PackageExportTreeViewItem exportTreeViewItem = current as PackageExportTreeView.PackageExportTreeViewItem; if (exportTreeViewItem != null) { this.m_Selection.Add(exportTreeViewItem); } } } } }
private static void Toggle(ExportPackageItem[] items, PackageExportTreeView.PackageExportTreeViewItem pitem, Rect toggleRect) { ExportPackageItem item = pitem.item; if (item != null) { bool flag = item.enabledStatus > 0; GUIStyle toggle = EditorStyles.toggle; if (item.isFolder && (item.enabledStatus == 2)) { toggle = EditorStyles.toggleMixed; } bool flag3 = GUI.Toggle(toggleRect, flag, GUIContent.none, toggle); if (flag3 != flag) { item.enabledStatus = !flag3 ? 0 : 1; } } }
private void DoToggle(PackageExportTreeView.PackageExportTreeViewItem pitem, Rect toggleRect) { EditorGUI.BeginChangeCheck(); Toggle(this.m_PackageExportView.items, pitem, toggleRect); if (EditorGUI.EndChangeCheck()) { if ((base.m_TreeView.GetSelection().Length <= 1) || !base.m_TreeView.GetSelection().Contains <int>(pitem.id)) { int[] selectedIDs = new int[] { pitem.id }; base.m_TreeView.SetSelection(selectedIDs, false); base.m_TreeView.NotifyListenersThatSelectionChanged(); } if (this.itemWasToggled != null) { this.itemWasToggled(pitem); } Event.current.Use(); } }
public override void FetchData() { int depth = -1; base.m_RootItem = new PackageExportTreeView.PackageExportTreeViewItem(null, "Assets".GetHashCode(), depth, null, "InvisibleAssetsFolder"); bool initExpandedState = true; if (initExpandedState) { base.m_TreeView.state.expandedIDs.Add(base.m_RootItem.id); } ExportPackageItem[] items = this.m_PackageExportView.items; Dictionary <string, PackageExportTreeView.PackageExportTreeViewItem> treeViewFolders = new Dictionary <string, PackageExportTreeView.PackageExportTreeViewItem>(); for (int i = 0; i < items.Length; i++) { ExportPackageItem itemIn = items[i]; if (!PackageImport.HasInvalidCharInFilePath(itemIn.assetPath)) { string fileName = Path.GetFileName(itemIn.assetPath); string directoryName = Path.GetDirectoryName(itemIn.assetPath); TreeViewItem parent = this.EnsureFolderPath(directoryName, treeViewFolders, initExpandedState); if (parent != null) { int hashCode = itemIn.assetPath.GetHashCode(); PackageExportTreeView.PackageExportTreeViewItem child = new PackageExportTreeView.PackageExportTreeViewItem(itemIn, hashCode, parent.depth + 1, parent, fileName); parent.AddChild(child); if (initExpandedState) { base.m_TreeView.state.expandedIDs.Add(hashCode); } if (itemIn.isFolder) { treeViewFolders[itemIn.assetPath] = child; } } } } if (initExpandedState) { base.m_TreeView.state.expandedIDs.Sort(); } }
public override void FetchData() { this.m_RootItem = (TreeViewItem) new PackageExportTreeView.PackageExportTreeViewItem((ExportPackageItem)null, "Assets".GetHashCode(), -1, (TreeViewItem)null, "InvisibleAssetsFolder"); bool initExpandedState = true; if (initExpandedState) { this.m_TreeView.state.expandedIDs.Add(this.m_RootItem.id); } ExportPackageItem[] items = this.m_PackageExportView.items; Dictionary <string, PackageExportTreeView.PackageExportTreeViewItem> treeViewFolders = new Dictionary <string, PackageExportTreeView.PackageExportTreeViewItem>(); for (int index = 0; index < items.Length; ++index) { ExportPackageItem itemIn = items[index]; if (!PackageImport.HasInvalidCharInFilePath(itemIn.assetPath)) { string fileName = Path.GetFileName(itemIn.assetPath); TreeViewItem parent = this.EnsureFolderPath(Path.GetDirectoryName(itemIn.assetPath), treeViewFolders, initExpandedState); if (parent != null) { int hashCode = itemIn.assetPath.GetHashCode(); PackageExportTreeView.PackageExportTreeViewItem exportTreeViewItem = new PackageExportTreeView.PackageExportTreeViewItem(itemIn, hashCode, parent.depth + 1, parent, fileName); parent.AddChild((TreeViewItem)exportTreeViewItem); if (initExpandedState) { this.m_TreeView.state.expandedIDs.Add(hashCode); } if (itemIn.isFolder) { treeViewFolders[itemIn.assetPath] = exportTreeViewItem; } } } } if (!initExpandedState) { return; } this.m_TreeView.state.expandedIDs.Sort(); }
private void DoToggle(PackageExportTreeView.PackageExportTreeViewItem pitem, Rect toggleRect) { EditorGUI.BeginChangeCheck(); PackageExportTreeView.PackageExportTreeViewGUI.Toggle(this.m_PackageExportView.items, pitem, toggleRect); if (!EditorGUI.EndChangeCheck()) { return; } if (this.m_TreeView.GetSelection().Length <= 1 || !((IEnumerable <int>) this.m_TreeView.GetSelection()).Contains <int>(pitem.id)) { this.m_TreeView.SetSelection(new int[1] { pitem.id }, 0 != 0); this.m_TreeView.NotifyListenersThatSelectionChanged(); } if (this.itemWasToggled != null) { this.itemWasToggled(pitem); } Event.current.Use(); }
private void ItemWasToggled(PackageExportTreeView.PackageExportTreeViewItem pitem) { ExportPackageItem item = pitem.item; if (item != null) { if (this.m_Selection.Count <= 1) { this.EnableChildrenRecursive(pitem, item.enabledStatus); } else { foreach (PackageExportTreeView.PackageExportTreeViewItem current in this.m_Selection) { ExportPackageItem item2 = current.item; item2.enabledStatus = item.enabledStatus; } } this.ComputeEnabledStateForFolders(); } }
public override void OnRowGUI(Rect rowRect, TreeViewItem tvItem, int row, bool selected, bool focused) { base.k_IndentWidth = 18f; base.k_FoldoutWidth = 18f; PackageExportTreeView.PackageExportTreeViewItem pitem = tvItem as PackageExportTreeView.PackageExportTreeViewItem; bool flag = Event.current.type == EventType.Repaint; if (selected && flag) { TreeViewGUI.s_Styles.selectionStyle.Draw(rowRect, false, false, true, focused); } if (base.m_TreeView.data.IsExpandable(tvItem)) { this.DoFoldout(rowRect, tvItem, row); } Rect toggleRect = new Rect((base.k_BaseIndent + (tvItem.depth * base.indentWidth)) + base.k_FoldoutWidth, rowRect.y, 18f, rowRect.height); this.DoToggle(pitem, toggleRect); Rect contentRect = new Rect(toggleRect.xMax, rowRect.y, rowRect.width, rowRect.height); this.DoIconAndText(tvItem, contentRect, selected, focused); }
protected override Texture GetIconForItem(TreeViewItem tItem) { PackageExportTreeView.PackageExportTreeViewItem packageExportTreeViewItem = tItem as PackageExportTreeView.PackageExportTreeViewItem; ExportPackageItem item = packageExportTreeViewItem.item; Texture result; if (item == null || item.isFolder) { result = PackageExportTreeView.PackageExportTreeViewGUI.Constants.folderIcon; } else { Texture cachedIcon = AssetDatabase.GetCachedIcon(item.assetPath); if (cachedIcon != null) { result = cachedIcon; } else { result = InternalEditorUtility.GetIconForFile(item.assetPath); } } return(result); }
private void RecursiveComputeEnabledStateForFolders(PackageExportTreeView.PackageExportTreeViewItem pitem, HashSet <PackageExportTreeView.PackageExportTreeViewItem> done) { if (!pitem.isFolder) { return; } if (pitem.hasChildren) { using (List <TreeViewItem> .Enumerator enumerator = pitem.children.GetEnumerator()) { while (enumerator.MoveNext()) { this.RecursiveComputeEnabledStateForFolders(enumerator.Current as PackageExportTreeView.PackageExportTreeViewItem, done); } } } if (done.Contains(pitem)) { return; } PackageExportTreeView.EnabledState childrenEnabledState = this.GetFolderChildrenEnabledState(pitem); pitem.enabledState = childrenEnabledState; if (childrenEnabledState != PackageExportTreeView.EnabledState.Mixed) { return; } done.Add(pitem); for (PackageExportTreeView.PackageExportTreeViewItem parent = pitem.parent as PackageExportTreeView.PackageExportTreeViewItem; parent != null; parent = parent.parent as PackageExportTreeView.PackageExportTreeViewItem) { if (!done.Contains(parent)) { parent.enabledState = PackageExportTreeView.EnabledState.Mixed; done.Add(parent); } } }
private TreeViewItem EnsureFolderPath(string folderPath, Dictionary<string, PackageExportTreeView.PackageExportTreeViewItem> treeViewFolders, bool initExpandedState) { if (folderPath == string.Empty) return this.m_RootItem; TreeViewItem treeViewItem = TreeViewUtility.FindItem(folderPath.GetHashCode(), this.m_RootItem); if (treeViewItem != null) return treeViewItem; string[] strArray = folderPath.Split('/'); string empty = string.Empty; TreeViewItem parent = this.m_RootItem; int depth = -1; for (int index = 0; index < strArray.Length; ++index) { string displayName = strArray[index]; if (empty != string.Empty) empty += (string) (object) '/'; empty += displayName; if (index != 0 || !(empty == "Assets")) { ++depth; int hashCode = empty.GetHashCode(); PackageExportTreeView.PackageExportTreeViewItem exportTreeViewItem1; if (treeViewFolders.TryGetValue(empty, out exportTreeViewItem1)) { parent = (TreeViewItem) exportTreeViewItem1; } else { PackageExportTreeView.PackageExportTreeViewItem exportTreeViewItem2 = new PackageExportTreeView.PackageExportTreeViewItem((ExportPackageItem) null, hashCode, depth, parent, displayName); parent.AddChild((TreeViewItem) exportTreeViewItem2); parent = (TreeViewItem) exportTreeViewItem2; if (initExpandedState) this.m_TreeView.state.expandedIDs.Add(hashCode); treeViewFolders[empty] = exportTreeViewItem2; } } } return parent; }
public override void FetchData() { this.m_RootItem = (TreeViewItem) new PackageExportTreeView.PackageExportTreeViewItem((ExportPackageItem) null, "Assets".GetHashCode(), -1, (TreeViewItem) null, "InvisibleAssetsFolder"); bool initExpandedState = true; if (initExpandedState) this.m_TreeView.state.expandedIDs.Add(this.m_RootItem.id); ExportPackageItem[] items = this.m_PackageExportView.items; Dictionary<string, PackageExportTreeView.PackageExportTreeViewItem> treeViewFolders = new Dictionary<string, PackageExportTreeView.PackageExportTreeViewItem>(); for (int index = 0; index < items.Length; ++index) { ExportPackageItem itemIn = items[index]; if (!PackageImport.HasInvalidCharInFilePath(itemIn.assetPath)) { string fileName = Path.GetFileName(itemIn.assetPath); TreeViewItem parent = this.EnsureFolderPath(Path.GetDirectoryName(itemIn.assetPath), treeViewFolders, initExpandedState); if (parent != null) { int hashCode = itemIn.assetPath.GetHashCode(); PackageExportTreeView.PackageExportTreeViewItem exportTreeViewItem = new PackageExportTreeView.PackageExportTreeViewItem(itemIn, hashCode, parent.depth + 1, parent, fileName); parent.AddChild((TreeViewItem) exportTreeViewItem); if (initExpandedState) this.m_TreeView.state.expandedIDs.Add(hashCode); if (itemIn.isFolder) treeViewFolders[itemIn.assetPath] = exportTreeViewItem; } } } if (!initExpandedState) return; this.m_TreeView.state.expandedIDs.Sort(); }
public override void FetchData() { int depth = -1; base.m_RootItem = new PackageExportTreeView.PackageExportTreeViewItem(null, "Assets".GetHashCode(), depth, null, "InvisibleAssetsFolder"); bool initExpandedState = true; if (initExpandedState) { base.m_TreeView.state.expandedIDs.Add(base.m_RootItem.id); } ExportPackageItem[] items = this.m_PackageExportView.items; Dictionary<string, PackageExportTreeView.PackageExportTreeViewItem> treeViewFolders = new Dictionary<string, PackageExportTreeView.PackageExportTreeViewItem>(); for (int i = 0; i < items.Length; i++) { ExportPackageItem itemIn = items[i]; if (!PackageImport.HasInvalidCharInFilePath(itemIn.assetPath)) { string fileName = Path.GetFileName(itemIn.assetPath); string directoryName = Path.GetDirectoryName(itemIn.assetPath); TreeViewItem parent = this.EnsureFolderPath(directoryName, treeViewFolders, initExpandedState); if (parent != null) { int hashCode = itemIn.assetPath.GetHashCode(); PackageExportTreeView.PackageExportTreeViewItem child = new PackageExportTreeView.PackageExportTreeViewItem(itemIn, hashCode, parent.depth + 1, parent, fileName); parent.AddChild(child); if (initExpandedState) { base.m_TreeView.state.expandedIDs.Add(hashCode); } if (itemIn.isFolder) { treeViewFolders[itemIn.assetPath] = child; } } } } if (initExpandedState) { base.m_TreeView.state.expandedIDs.Sort(); } }
private TreeViewItem EnsureFolderPath(string folderPath, Dictionary<string, PackageExportTreeView.PackageExportTreeViewItem> treeViewFolders, bool initExpandedState) { if (folderPath == "") { return base.m_RootItem; } TreeViewItem item2 = TreeViewUtility.FindItem(folderPath.GetHashCode(), base.m_RootItem); if (item2 != null) { return item2; } char[] separator = new char[] { '/' }; string[] strArray = folderPath.Split(separator); string key = ""; TreeViewItem rootItem = base.m_RootItem; int depth = -1; for (int i = 0; i < strArray.Length; i++) { string displayName = strArray[i]; if (key != "") { key = key + '/'; } key = key + displayName; if ((i != 0) || (key != "Assets")) { PackageExportTreeView.PackageExportTreeViewItem item4; depth++; int hashCode = key.GetHashCode(); if (treeViewFolders.TryGetValue(key, out item4)) { rootItem = item4; } else { PackageExportTreeView.PackageExportTreeViewItem child = new PackageExportTreeView.PackageExportTreeViewItem(null, hashCode, depth, rootItem, displayName); rootItem.AddChild(child); rootItem = child; if (initExpandedState) { base.m_TreeView.state.expandedIDs.Add(hashCode); } treeViewFolders[key] = child; } } } return rootItem; }