Exemplo n.º 1
0
        private void LoadNode(GoalNode node)
        {
            // check if already loaded
            if (node.AddSubs)
            {
                return;
            }

            node.AddSubs = true;

            // load that person specified by the node
            OpPlan plan = Plans.GetPlan(node.Goal.Person, true);

            if (plan == null)
            {
                Plans.Research(node.Goal.Person);
                return;
            }

            if (!plan.GoalMap.ContainsKey(Head.Ident))
            {
                return;
            }

            // read the person's goals
            foreach (PlanGoal goal in plan.GoalMap[Head.Ident])
            {
                // if the upbranch matches the node's down branch, add
                if (goal.BranchDown == 0 || goal.BranchUp != node.Goal.BranchDown)
                {
                    continue;
                }

                if (CheckGoal(plan.UserID, goal))
                {
                    InsertSubNode(node, CreateNode(goal));
                }
            }
        }
Exemplo n.º 2
0
        public override void Init()
        {
            Trust.GuiUpdate  += new LinkGuiUpdateHandler(Trust_Update);
            Plans.PlanUpdate += new PlanUpdateHandler(Plans_Update);

            Core.KeepDataGui += new KeepDataHandler(Core_KeepData);


            splitContainer1.Height = Height - toolStrip1.Height;

            MainPanel.Init(this);


            // research highers for assignments
            List <ulong> ids = Trust.GetUplinkIDs(UserID, ProjectID);

            foreach (ulong id in ids)
            {
                Plans.Research(id);
            }


            RefreshAssigned();
        }
Exemplo n.º 3
0
        private void RefreshStructure()
        {
            PlanStructure.BeginUpdate();


            // save selected
            PlanNode selected = GetSelected();

            // save visible while unloading
            List <ulong> visible = new List <ulong>();

            foreach (TreeListNode node in PlanStructure.Nodes)
            {
                if (node.GetType() == typeof(PlanNode))
                {
                    UnloadNode((PlanNode)node, visible);
                }
            }


            NodeMap.Clear();
            PlanStructure.Nodes.Clear();


            // nodes
            ThreadedList <OpLink> roots = null;

            if (Trust.ProjectRoots.SafeTryGetValue(ProjectID, out roots))
            {
                roots.LockReading(delegate()
                {
                    foreach (OpLink root in roots)
                    {
                        if (Uplinks.Contains(root.UserID))
                        {
                            PlanNode node = CreateNode(root);

                            Plans.Research(root.UserID);

                            LoadNode(node);

                            GuiUtils.InsertSubNode(PlanStructure.virtualParent, node);

                            ExpandPath(node, Uplinks);
                        }

                        if (root.IsLoopRoot &&
                            root.Downlinks.Count > 0 &&
                            Uplinks.Contains(root.Downlinks[0].UserID))
                        {
                            foreach (OpLink downlink in root.Downlinks)
                            {
                                if (!root.IsLoopedTo(downlink))
                                {
                                    PlanNode node = CreateNode(downlink);

                                    Plans.Research(downlink.UserID);

                                    LoadNode(node);

                                    GuiUtils.InsertSubNode(PlanStructure.virtualParent, node);

                                    ExpandPath(node, Uplinks);
                                }
                            }
                        }
                    }
                });
            }

            // restore visible
            foreach (ulong id in visible)
            {
                foreach (TreeListNode node in PlanStructure.Nodes)
                {
                    if (node.GetType() == typeof(PlanNode))
                    {
                        List <ulong> uplinks = Trust.GetUnconfirmedUplinkIDs(id, ProjectID);
                        uplinks.Add(id);
                        VisiblePath((PlanNode)node, uplinks);
                    }
                }
            }

            // restore selected
            if (selected != null)
            {
                if (NodeMap.ContainsKey(selected.Link.UserID))
                {
                    PlanStructure.Select(NodeMap[selected.Link.UserID]);
                }
            }


            PlanStructure.EndUpdate();
        }