Exemple #1
0
        // Refresh the tree
        //
        private void TreeRefresh(bool FullRefresh)
        {
            int     KillSwitch = 0;
            PidList Updates    = new PidList();

            Updates.GetSystemPids(true);             // Load system processes
            Updates.Remove("idle", PidFields.Name);  // Remove the Idles
            Running.Remove("idle", PidFields.Name);

            if (FullRefresh)                          // Clear the running processes
            {
                Running.Clear();                      // so the Diff will think
                PidTree.Nodes.Clear();                // everything's new

                TreeNode Root = new TreeNode("Idle"); // Add Idle process to the tree
                Root.Name = "0";
                PidTree.Nodes.Add(Root);
            }

            PidDiff Result = Running.Diff(Updates);     // Execute a Diff

            PruneBranches(Result.Removed);              // Kill Removed

            // Add nodes loop
            //
            while (Result.Added.Count != 0 && KillSwitch < 9)
            {
                Result.Added = AddBranches(Result.Added);
                KillSwitch++;
            }

            if (FullRefresh)                         // Collapse the Tree
            {
                PidTree.CollapseAll();

                TreeNode[] t = PidTree.Nodes.Find("0", true);  // Expand Idle
                t[0].Expand();
                PidTree.LastNode  = t[0];
                txtProcessID.Text = $"Idle (0)";

                // Expand Explorer
                //
                Pid tmpPid = Running.Find("explorer", PidFields.Name);  // Search for explorer
                if (tmpPid != null)
                {
                    t = PidTree.Nodes.Find(tmpPid.Id.ToString(), true); // Highlight explorer
                    t[0].Expand();

                    txtProcessID.Text    = $"{tmpPid.Name} ({tmpPid.Id})";
                    PidTree.SelectedNode = t[0];
                    PidTree.LastNode     = t[0];
                    t[0].EnsureVisible();
                }
            }

            txtProcessCount.Text = $"Processes: {Running.Count}";
        }
Exemple #2
0
        private void CreatePidList(TreeNode n)
        {
            ReturnPids.Add(Running.Find(n.Name, PidFields.Id));

            foreach (TreeNode Search in n.Nodes)
            {
                CreatePidList(Search);
            }
        }