public static DragDropHandler GetDragDropHandlerForNode(Outliner.TreeView tree, OutlinerNode node) { if (node is OutlinerObject) { OutlinerObject obj = (OutlinerObject)node; if (obj.IsGroupHead || obj.IsGroupMember) return new GroupDragDropHandler(tree, obj); if (obj.Class == OutlinerScene.ContainerType) return new ContainerDragDropHandler(tree, obj); if (obj.SuperClass == OutlinerScene.SpacewarpType) return new SpaceWarpDragDropHandler(tree, obj); return new ObjectDragDropHandler(tree, obj); } else if (node is OutlinerMaterial) return new MaterialDragDropHandler(tree, (OutlinerMaterial)node); else if (node is OutlinerLayer) return new LayerDragDropHandler(tree, (OutlinerLayer)node); return new DragDropHandler(tree, node); }
private TreeNode CreateTreeNodeForOutlinerNode(OutlinerNode n) { TreeNode tn = new TreeNode(n.DisplayName); n.DragDropHandler = DragDropHandler.GetDragDropHandlerForNode(this, n); tn.Tag = n; Style.SetNodeColor(tn, NodeColor.Default); return tn; }
private void getChildHandles_intern(OutlinerNode n, OutlinerNode[] nodes, ref List<Int32> handles) { foreach (OutlinerNode cn in n.ChildNodes) { if (cn is OutlinerObject && !arrayContains(nodes, cn)) handles.Add(((OutlinerObject)cn).Handle); getChildHandles_intern(cn, nodes, ref handles); } }
private Color GetNodeForeColor(OutlinerNode node) { if (node is IDisplayable && ((IDisplayable)node).IsHidden) return HiddenForeColor; else if (node is IDisplayable && ((IDisplayable)node).IsFrozen) return FrozenForeColor; else if (node is OutlinerObject && ((OutlinerObject)node).Class == OutlinerScene.XrefObjectType) return XrefForeColor; else return NodeForeColor; }
protected virtual Boolean IsDroppableNode(OutlinerNode o) { return false; }
internal List<Int32> getChildNodeHandlesRecursive(OutlinerNode node) { List<Int32> childHandles = new List<Int32>(); foreach (OutlinerNode cn in node.ChildNodes) { childHandles.Add(cn.Handle); childHandles.AddRange(getChildNodeHandlesRecursive(cn)); } return childHandles; }
protected override bool IsDroppableNode(OutlinerNode o) { if (Tree.ListMode == OutlinerListMode.Hierarchy || Tree.ListMode == OutlinerListMode.Material) return (o is OutlinerObject); else if (Tree.ListMode == OutlinerListMode.Layer) return (o is OutlinerLayer); else return false; }
internal void FreezeNode(OutlinerNode n, Boolean frozen) { if (n is IDisplayable && ((IDisplayable)n).IsFrozen != frozen) { ((IDisplayable)n).IsFrozen = frozen; ApplyFilter(n, ListMode == OutlinerListMode.Hierarchy, ListMode == OutlinerListMode.Layer, ListMode == OutlinerListMode.Material); } }
internal void FreezeNodeRecursive(OutlinerNode n, Boolean frozen) { FreezeNode(n, frozen); foreach (OutlinerNode cn in n.ChildNodes) FreezeNodeRecursive(cn, frozen); }
internal void HideNode(OutlinerNode n, Boolean hidden) { if (n is IDisplayable && ((IDisplayable)n).IsHidden != hidden) { ((IDisplayable)n).IsHidden = hidden; ApplyFilter(n, ListMode == OutlinerListMode.Hierarchy, ListMode == OutlinerListMode.Layer, ListMode == OutlinerListMode.Material); if (_treeViewNodeSorter is Outliner.NodeSorters.VisibilitySorter) BeginTimedSort(); } }
internal void HideNodeRecursive(OutlinerNode n, Boolean hidden) { HideNode(n, hidden); foreach (OutlinerNode cn in n.ChildNodes) { HideNodeRecursive(cn, hidden); } }
private void RecursiveRemoveTreeNodeIntern(OutlinerNode n, TreeNode tn, Boolean removeReferences) { // n.MarkedForDelete = true; if (removeReferences) { this._expandedNodeHandles.Remove(n.Handle); _selectedNodes.Remove(n); } RemoveParentHighlights(n); _treeNodes.Remove(n); foreach (TreeNode cn in tn.Nodes) RecursiveRemoveTreeNodeIntern((OutlinerNode)cn.Tag, cn, removeReferences); }
private void RecursiveRemoveTreeNode(OutlinerNode n, TreeNode tn, Boolean removeReferences) { RecursiveRemoveTreeNodeIntern(n, tn, removeReferences); tn.Remove(); }
internal void RemoveNodeFromTree(OutlinerNode n, Boolean removeReferences) { if (n == null) return; // n.MarkedForDelete = true; if (ListMode == OutlinerListMode.Hierarchy) n = GetHighestParentToRemove(n); TreeNode tn; if (_treeNodes.TryGetValue(n, out tn)) RecursiveRemoveTreeNode(n, tn, removeReferences); }
private OutlinerNode GetHighestParentToAdd(OutlinerNode o) { if (ListMode == OutlinerListMode.Layer) return o; else { // Keeping prevParentNode reference (previous parentNode inspected) to avoid having to do dictionary lookup twice for each iteration. OutlinerNode parentNode = o; OutlinerNode prevParentNode = o; while (parentNode != null && !_treeNodes.ContainsKey(parentNode)) { prevParentNode = parentNode; parentNode = parentNode.Parent; } return prevParentNode; } }
internal void ApplyFilter(OutlinerNode n, Boolean recurseObjects, Boolean recurseLayers, Boolean recurseMaterials) { Boolean showNode = this.Filter.ShowNode(n); TreeNode tn; _treeNodes.TryGetValue(n, out tn); if (tn != null) { if (showNode) { Style.SetNodeColorAuto(tn); InvalidateTreeNode(tn); } else RemoveNodeFromTree(n, true); } else { if (showNode) { if (n is OutlinerObject && (ListMode != OutlinerListMode.Layer || !HideGroupMembersLayerMode || !((OutlinerObject)n).IsGroupMember)) AddObjectToTree((OutlinerObject)n); else if (n is OutlinerLayer && ListMode == OutlinerListMode.Layer) AddLayerToTree((OutlinerLayer)n); } } if ((recurseObjects && n is OutlinerObject) || (recurseLayers && n is OutlinerLayer) || (recurseMaterials && n is OutlinerMaterial)) { foreach (OutlinerNode c in n.ChildNodes) ApplyFilter(c, recurseObjects, recurseLayers, recurseMaterials); } }
private OutlinerNode GetHighestParentToRemove(OutlinerNode o) { if (ListMode == OutlinerListMode.Layer) return o; else { // Keeping prevParentNode reference (previous parentNode inspected) to avoid having to do dictionary lookup twice for each iteration. OutlinerNode parentNode = o.Parent; OutlinerNode prevParentNode = o; while (parentNode != null && !this.Filter.ShowNode(parentNode)) { prevParentNode = parentNode; parentNode = parentNode.Parent; } return prevParentNode; } }
internal void SetBoxModeNode(OutlinerNode n, Boolean boxMode) { if (n is IDisplayable) { ((IDisplayable)n).BoxMode = boxMode; TreeNode tn; if (_treeNodes.TryGetValue(n, out tn)) InvalidateTreeNode(tn); } }
protected override Boolean IsDroppableNode(OutlinerNode o) { return (o is OutlinerObject); }
internal void SetBoxModeNodeRecursive(OutlinerNode n, Boolean boxMode) { SetBoxModeNode(n, boxMode); foreach (OutlinerNode cn in n.ChildNodes) SetBoxModeNodeRecursive(cn, boxMode); }
private String GetImageKey(OutlinerNode node) { String imgKey = "unknown"; if (node is OutlinerObject) imgKey = GetObjectImageKey((OutlinerObject)node); else if (node is OutlinerLayer) imgKey = GetLayerImageKey((OutlinerLayer)node); else if (node is OutlinerMaterial) imgKey = GetMaterialImageKey((OutlinerMaterial)node); return imgKey; }
private void RestoreSelection(OutlinerNode[] selection) { _selectedNodes.Clear(); foreach (OutlinerNode n in selection) { SelectNode(n, true); } BeginTimedEnsureSelectionVisible(EnsureSelectionVisibleAction.SelectionChanged); _selectionChanged = false; }
protected override bool IsDroppableNode(OutlinerNode o) { return (o is OutlinerObject || o is OutlinerLayer); }
private void addChildLayerHandlesRecursive(OutlinerNode layer, ref List<Int32> handles) { foreach (OutlinerNode n in layer.ChildNodes) { if (n is OutlinerLayer) { handles.Add(n.Handle); addChildLayerHandlesRecursive(n, ref handles); } } }
private Boolean arrayContains(OutlinerNode[] nodes, OutlinerNode n) { EqualityComparer<OutlinerNode> comparer = EqualityComparer<OutlinerNode>.Default; for (int i = 0; i < nodes.Length; i++) { if (comparer.Equals(nodes[i], n)) { return true; } } return false; }
internal Boolean IsNodeSelected(OutlinerNode n) { if (n == null) return false; return _selectedNodes.Contains(n); }
public DragDropHandler(Outliner.TreeView tree, OutlinerNode data) { Tree = tree; Data = data; }
internal Boolean IsChildOfSelectedNode(OutlinerNode n) { if (n == null) return false; TreeNode tn; if (_treeNodes.TryGetValue(n, out tn)) return IsChildOfSelectedNode(tn); else return false; }
protected Int32[] getChildHandles(OutlinerNode[] nodes) { List<Int32> handles = new List<Int32>(); foreach (OutlinerNode n in nodes) { getChildHandles_intern(n, nodes, ref handles); } return handles.ToArray(); }
internal void RemoveParentHighlights(OutlinerNode n) { if ((ListMode != OutlinerListMode.Hierarchy && ListMode != OutlinerListMode.Layer) || n == null) return; TreeNode tn; if (_treeNodes.TryGetValue(n, out tn)) { tn = tn.Parent; while (tn != null && !IsNodeSelected(tn) && !IsParentOfSelectedNode(tn, true)) { Style.SetNodeColor(tn, NodeColor.Default); tn = tn.Parent; } } }