コード例 #1
0
 /// <summary>
 /// Called to update the branches of the tree once the root nodes
 /// have been added. This method is meant to be called recursively.
 /// </summary>
 /// <param name="root">Root node</param>
 /// <param name="child">Current Child</param>
 /// <param name="branchRoot">Original root of this branch</param>
 private void BuildAssignmentTree(AssignmentTreeViewItem root,
                                  ejsAssignment child, AssignmentTreeViewItem branchRoot)
 {
     if (root.Assignment.ExternalAssignmentId == child.ParentAssignmentId)
     {
         CommentedAssignmentTreeViewItem cat = new CommentedAssignmentTreeViewItem(child);
         cat.BranchRoot = branchRoot;
         if (child.IsAvailable)
         {
             cat.DefaultImage  = new BitmapImage(new Uri("pack://application:,,,/Stages/imgData/caTvS.png"));
             cat.SelectedImage = new BitmapImage(new Uri("pack://application:,,,/Stages/imgData/caTvD.png"));
         }
         else
         {
             cat.DefaultImage  = new BitmapImage(new Uri("pack://application:,,,/Stages/imgData/aNA.png"));
             cat.SelectedImage = new BitmapImage(new Uri("pack://application:,,,/Stages/imgData/aNA.png"));
         }
         root.Items.Add(cat);
         //Add up the total number of comments in this branch..
         branchRoot.Assignment.CommentCount += child.CommentCount;
     }
     else
     {
         foreach (AssignmentTreeViewItem childItem in root.Items)
         {
             this.BuildAssignmentTree(childItem, child, branchRoot);
         }
     }
 }
コード例 #2
0
        private void OnHideCurrentItem(object sender, RoutedEventArgs e)
        {
            if (this._tv_Assignments.SelectedItem == null)
            {
                return;
            }

            if (this._tv_Assignments.SelectedItem is CourseTreeViewItem)
            {
                return;
            }

            AssignmentTreeViewItem assignment =
                this._tv_Assignments.SelectedItem as AssignmentTreeViewItem;

            this.HideAssignment(assignment.Assignment);
        }
コード例 #3
0
        private void OnDeleteCurrentItem(object sender, RoutedEventArgs e)
        {
            if (this._tv_Assignments.SelectedItem == null)
            {
                return;
            }

            if (this._tv_Assignments.SelectedItem is CourseTreeViewItem)
            {
                return;
            }

            if (this.GetDeleteConfirmation() == true)
            {
                AssignmentTreeViewItem assignment =
                    this._tv_Assignments.SelectedItem as AssignmentTreeViewItem;

                this.DeleteAssignment(assignment.Assignment);
            }
        }
コード例 #4
0
        private void OrganizeAssignments(ObservableAssignmentList assignments)
        {
            this._tv_Assignments.Items.Clear();

            ObservableCourseList clist =
                App.Current.Resources["CompleteCoursesList"] as ObservableCourseList;

            foreach (ejsCourse course in clist)
            {
                CourseTreeViewItem c = new CourseTreeViewItem(course);
                this._tv_Assignments.Items.Add(c);
            }

            List <AssignmentTreeViewItem> topAssignments =
                new List <AssignmentTreeViewItem>();

            foreach (ejsAssignment assignment in assignments)
            {
                //1 = Commented Assignment
                if (assignment.AssignmentContentType == 1)
                {
                    continue;                     //We only add the 'real' assignments first
                }
                AssignmentTreeViewItem t = new AssignmentTreeViewItem(assignment);
                if (assignment.IsAvailable)
                {
                    t.DefaultImage  = new BitmapImage(new Uri("pack://application:,,,/Stages/imgData/aTvS.png"));
                    t.SelectedImage = new BitmapImage(new Uri("pack://application:,,,/Stages/imgData/aTvD.png"));
                }
                else
                {
                    t.DefaultImage  = new BitmapImage(new Uri("pack://application:,,,/Stages/imgData/aNA.png"));
                    t.SelectedImage = new BitmapImage(new Uri("pack://application:,,,/Stages/imgData/aNA.png"));
                }

                foreach (CourseTreeViewItem cItem in this._tv_Assignments.Items)
                {
                    if (cItem.Course._id == assignment.CourseId)
                    {
                        cItem.Items.Add(t);
                    }
                }

                topAssignments.Add(t);
            }

            //Second run to add all the children
            foreach (ejsAssignment assignment in assignments)
            {
                //0 = Normal Assignment
                if (assignment.AssignmentContentType == 0)
                {
                    continue;                     //We're only adding the Commented Assignments
                }
                if (assignment.CourseId == -1)    //-1 = commented assignments do not belong to courses
                {
                    foreach (AssignmentTreeViewItem ParentAssignment in topAssignments)
                    {
                        this.BuildAssignmentTree(ParentAssignment, assignment, ParentAssignment);
                    }
                }
            }

            foreach (AssignmentTreeViewItem ParentAssignment in topAssignments)
            {
                ParentAssignment.TextDetails.Text +=
                    " Comments: " + ParentAssignment.Assignment.CommentCount.ToString();
            }
        }