Beispiel #1
0
        private void ReloadGoals()
        {
            TreeMap.Clear();
            GoalTree.Nodes.Clear();

            List <ulong> uplinks = Trust.GetUplinkIDs(View.UserID, View.ProjectID);

            uplinks.Add(View.UserID);

            // show all branches
            if (!MineOnly.Checked)
            {
                GoalNode root = CreateNode(Head);
                LoadNode(root);
                GoalTree.Nodes.Add(root);

                ExpandPath(root, uplinks);
            }

            // show only our branch
            else if (Head != null)
            {
                foreach (ulong id in uplinks)
                {
                    OpPlan plan = Plans.GetPlan(id, true);

                    if (plan != null && plan.GoalMap.ContainsKey(Head.Ident))
                    {
                        foreach (PlanGoal goal in plan.GoalMap[Head.Ident])
                        {
                            if (goal.Person == View.UserID)
                            {
                                GoalNode root = CreateNode(goal);
                                LoadNode(root);
                                InsertSubNode(GoalTree.virtualParent, root);
                                root.Expand();
                            }
                        }
                    }
                }
            }

            Reselect();
        }
Beispiel #2
0
        private void RefreshGoalCombo()
        {
            GoalComboItem prevItem = GoalCombo.SelectedItem as GoalComboItem;

            int prevSelectedID = 0;

            if (prevItem != null)
            {
                prevSelectedID = prevItem.ID;
            }

            GoalCombo.Items.Clear();

            GoalCombo.Items.Add(new GoalComboItem("None", 0));

            // go up the chain looking for goals which have been assigned to this person
            // at root goal is the title of the goal


            List <PlanGoal> rootList = new List <PlanGoal>();
            List <int>      assigned = new List <int>();

            // foreach self & higher
            List <ulong> ids = Trust.GetUplinkIDs(UserID, ProjectID);

            ids.Add(UserID);

            foreach (ulong id in ids)
            {
                OpPlan plan = Plans.GetPlan(id, true);

                if (plan == null)
                {
                    continue;
                }

                // goals we have been assigned to
                foreach (List <PlanGoal> list in plan.GoalMap.Values)
                {
                    foreach (PlanGoal goal in list)
                    {
                        if (goal.Project != ProjectID)
                        {
                            break;
                        }

                        if (goal.Person == UserID && !assigned.Contains(goal.Ident))
                        {
                            assigned.Add(goal.Ident);
                        }

                        if (goal.BranchDown == 0)
                        {
                            if (!goal.Archived)
                            {
                                rootList.Add(goal);
                            }
                        }
                    }
                }
            }

            // update combo
            GoalComboItem prevSelected = null;

            foreach (PlanGoal goal in rootList)
            {
                if (assigned.Contains(goal.Ident))
                {
                    GoalComboItem item = new GoalComboItem(goal.Title, goal.Ident);

                    if (goal.Ident == prevSelectedID)
                    {
                        prevSelected = item;
                    }

                    GoalCombo.Items.Add(item);
                }
            }

            if (prevSelected != null)
            {
                GoalCombo.SelectedItem = prevSelected;
            }
            else
            {
                GoalCombo.SelectedIndex = 0;
            }
        }