Exemple #1
0
        private void RedrawNodes()
        {
            var nodes = state.nodeList.AsEnumerable();

            if (!state.showEmptyLevels)
            {
                nodes = nodes.Where(n => n.ChildrenNodes.Count > 0);
            }

            m_searchText = searchBox.Text.Replace("\r\n", "\n").Trim();

            int totalMarked = 0, totalNodes = 0;

            treeView1.Nodes.Clear();
            treeView1.BeginUpdate();

            foreach (var n in nodes)
            {
                totalMarked += n.ChildrenNodes.AsEnumerable().Where(n => n.NPC.Headers.ContainsKey("MARKED")).Count();
                totalNodes  += n.ChildrenNodes.Count;

                RedrawLevelNode(n);
                if (n.Nodes.Count > 0)
                {
                    treeView1.Nodes.Add(n);
                }
            }

            treeView1.EndUpdate();
            toolStripStatusLabel2.Text = string.Format("NPCs: {0} / {1} completed", totalMarked, totalNodes);

            // Try to preserve the current position in the treeview
            if (activeNode != null && activeNode.Parent != null)
            {
                if (activeNode.Parent.LastNode != null)
                {
                    activeNode.Parent.LastNode.EnsureVisible();
                }
                else
                {
                    activeNode.Parent.EnsureVisible();
                }
                activeNode.EnsureVisible();
            }
            else if (activeLevelNode != null)
            {
                // Kind of a fix for when the npc gets marked as completed and
                // is no longer displaying in the treeview, we hop to the parent node
                activeLevelNode.EnsureVisible();
            }
        }