private void UpdateOperation(LinkNode node) { OpLink link = node.Link; TreeListNode parent = null; OpLink uplink = GetTreeHigher(link); if (uplink == null) { parent = virtualParent; } else if (NodeMap.ContainsKey(uplink.UserID)) { parent = NodeMap[uplink.UserID]; } else if (uplink.IsLoopRoot) { parent = CreateNode(uplink); LoadRoot((LinkNode)parent); } // else branch this link is apart of is not visible in current display // self is changing ensure it's visible if (node.Link.UserID == Core.UserID) { if (parent == null) { List <ulong> uplinks = Trust.GetUnconfirmedUplinkIDs(Core.UserID, Project); uplinks.Add(Core.UserID); ExpandPath(node, uplinks); // check nodeMap again now that highers added if (NodeMap.ContainsKey(uplink.UserID)) { parent = NodeMap[uplink.UserID]; } } if (parent != null) { parent.Expand(); } } // remember settings bool selected = node.Selected; bool expanded = node.IsExpanded; bool loadsubs = node.AddSubs; // update parent node if (node.Parent != parent) { List <ulong> visible = new List <ulong>(); // remove previous instance of node if (node.Parent != null) { if (node.IsVisible()) { visible.Add(link.UserID); } LinkNode oldParent = node.Parent as LinkNode; LinkNode unload = (oldParent != null && oldParent.Link.IsLoopRoot) ? oldParent : node; // if old parent is a loop node, the loop is made obsolete by change UnloadNode(unload, visible); unload.Remove(); } if (parent == null) { return; } // if new parent is hidden, dont bother adding till user expands LinkNode newParent = parent as LinkNode; // null if virtual parent (root) if (newParent != null && newParent.AddSubs == false) { return; } // copy node to start fresh LinkNode newNode = CreateNode(node.Link); if (newParent != null) { GuiUtils.InsertSubNode(newParent, newNode); } else { LoadRoot(newNode); } ArrangeRoots(); // arrange nodes can cause newNode to become invalid, retrieve updated copy if (!NodeMap.ContainsKey(link.UserID)) { return; } newNode = NodeMap[link.UserID]; if (loadsubs) // if previous node set to add kids { LoadNode(newNode); if (expanded) // if previous node set expanded { newNode.Expand(); } } node = newNode; // recurse to each previously visible node List <LinkNode> roots = new List <LinkNode>(); foreach (TreeListNode treeNode in Nodes) { if (treeNode.GetType() == typeof(LinkNode)) { if (((LinkNode)treeNode).Section == ProjectNode) { roots.Add(treeNode as LinkNode); } } } foreach (ulong id in visible) { List <ulong> uplinks = Trust.GetUnconfirmedUplinkIDs(id, Project); foreach (LinkNode root in roots) { VisiblePath(root, uplinks); } } // show unlinked if there's something to show if (Nodes.IndexOf(UnlinkedNode) + 1 == Nodes.Count) { UnlinkedNode.Text = ""; } else { UnlinkedNode.Text = "Untrusted"; } } node.UpdateStatus(); if (selected) { node.Selected = true; } Invalidate(); }
private void RemoveNode(LinkNode node) { UnloadNode(node, null); // unload subs NodeMap.Remove(node.Link.UserID); // remove from map node.Remove(); // remove from tree }
private void RemoveNode(LinkNode node) { UnloadNode(node, null); // unload subs NodeMap.Remove(node.Link.UserID); // remove from map node.Remove(); // remove from tree }