Esempio n. 1
0
        private void DiscardButton_Click(object sender, EventArgs e)
        {
            SaveButton.Visible     = false;
            DiscardButton.Visible  = false;
            splitContainer1.Height = Height - toolStrip1.Height;

            Plans.LoadPlan(Core.UserID);
            Plans_Update(Plans.LocalPlan);
        }
Esempio n. 2
0
        private void DiscardButton_Click(object sender, EventArgs e)
        {
            SaveButton.Visible    = false;
            DiscardButton.Visible = false;

            PlanStructure.Height = MainSplit.Panel1.Height - PlanStructure.Top;

            Plans.LoadPlan(Core.UserID);
            Plans_Update(Plans.LocalPlan);
        }
Esempio n. 3
0
        public void PlanUpdate(OpPlan plan)
        {
            if (Head == null)
            {
                return;
            }


            if (!plan.Loaded)
            {
                Plans.LoadPlan(plan.UserID);
            }

            // update progress of high levels for updated plan not in tree map because it is hidden
            if (plan.GoalMap.ContainsKey(Head.Ident) || plan.ItemMap.ContainsKey(Head.Ident))
            {
                List <ulong> uplinks = Trust.GetUplinkIDs(plan.UserID, View.ProjectID);
                uplinks.Add(plan.UserID);

                if (uplinks.Contains(Head.Person))
                {
                    foreach (ulong id in uplinks)
                    {
                        if (TreeMap.ContainsKey(id))
                        {
                            foreach (GoalNode node in TreeMap[id])
                            {
                                node.RefreshProgress();
                            }
                        }
                    }
                }
            }

            if (!TreeMap.ContainsKey(plan.UserID))
            {
                return;
            }

            if (MineOnly.Checked)
            {
                List <ulong> myUplinks = Trust.GetUplinkIDs(View.UserID, View.ProjectID);
                myUplinks.Add(View.UserID);

                if (myUplinks.Contains(plan.UserID))
                {
                    ReloadGoals();
                    return;
                }
            }


            List <PlanGoal> updated = new List <PlanGoal>();

            if (plan.GoalMap.ContainsKey(Head.Ident))
            {
                updated = plan.GoalMap[Head.Ident];
            }


            List <ulong> visible = new List <ulong>();

            foreach (GoalNode oldNode in TreeMap[plan.UserID])
            {
                // if root
                if (oldNode.Goal.BranchDown == 0)
                {
                    foreach (PlanGoal updatedGoal in updated)
                    {
                        if (updatedGoal.BranchDown == 0)
                        {
                            oldNode.Update(updatedGoal);
                            RefreshParents(oldNode);
                            break;
                        }
                    }
                }


                // go through displayed goals, if doesn't exist in update, remove
                List <GoalNode> removeList = new List <GoalNode>();

                foreach (GoalNode original in oldNode.Nodes)
                {
                    bool remove = true;

                    foreach (PlanGoal updatedGoal in updated)
                    {
                        if (oldNode.Goal.BranchDown == updatedGoal.BranchUp &&
                            original.Goal.BranchDown == updatedGoal.BranchDown)
                        {
                            remove = false;
                            original.Update(updatedGoal);
                            RefreshParents(original);
                        }
                    }

                    if (remove)
                    {
                        removeList.Add(original);
                    }
                }

                foreach (GoalNode node in removeList)
                {
                    RemoveNode(node, visible);
                }

                // go through updated goals, if isn't shown in display, add
                foreach (PlanGoal updatedGoal in updated)
                {
                    bool add = true; // if not in subs, add

                    if (updatedGoal.BranchDown == 0)
                    {
                        continue;
                    }

                    if (oldNode.Goal.BranchDown != updatedGoal.BranchUp)
                    {
                        continue;
                    }

                    foreach (GoalNode original in oldNode.Nodes)
                    {
                        if (oldNode.Goal.BranchDown == updatedGoal.BranchUp &&
                            original.Goal.BranchDown == updatedGoal.BranchDown)
                        {
                            add = false;
                        }
                    }
                    //crit check this is hit

                    if (add && oldNode.AddSubs && CheckGoal(plan.UserID, updatedGoal))
                    {
                        GoalNode node = CreateNode(updatedGoal);

                        InsertSubNode(oldNode, node);
                        RefreshParents(node);

                        if (oldNode.IsExpanded)
                        {
                            LoadNode(node);
                        }
                    }
                }
            }


            Reselect();
        }