コード例 #1
0
        private int TryCompareByType(BaseViewItemHomeworkExam other)
        {
            if (this.GetType() == other.GetType())
            {
                return(0);
            }

            if (this is ViewItemExam)
            {
                // Exams go ahead of everything
                return(-1);
            }
            else if (other is ViewItemExam)
            {
                return(1);
            }

            if (this is ViewItemHomework)
            {
                return(-1);
            }
            else if (other is ViewItemHomework)
            {
                return(1);
            }

            // Only remaining type is Event. Both items, by definition, must be events.
            // Therefore this code shouldn't even get hit.
            return(0);
        }
コード例 #2
0
        private int TryCompareWithDateTimeOtherwiseUseDateCreated(BaseViewItemHomeworkExam other)
        {
            int compare = this.Date.CompareTo(other.Date);

            if (compare != 0)
            {
                return(compare);
            }

            return(this.DateCreated.CompareTo(other.DateCreated));
        }
コード例 #3
0
        private int TryCompareByCompletionStatus(BaseViewItemHomeworkExam other)
        {
            var thisIsComplete  = this.IsComplete();
            var otherIsComplete = other.IsComplete();

            // If other is complete and this isn't, we send this to front
            if (otherIsComplete && !thisIsComplete)
            {
                return(-1);
            }

            // If this is complete and other isn't, we send this to back
            if (thisIsComplete && !otherIsComplete)
            {
                return(1);
            }

            // Otherwise, continue to use normal sorting behavior
            return(0);
        }
コード例 #4
0
 private void _dayPagerControl_ItemClick(object sender, PowerPlannerAppDataLibrary.ViewItems.BaseViewItems.BaseViewItemHomeworkExam e)
 {
     ViewModel.ShowItem(e);
 }
コード例 #5
0
        public int CompareTo(BaseViewItemHomeworkExam other)
        {
            // Desired sort order:
            //
            // - Anything on a different day obviously goes earlier/later
            //
            // - Within the same day, items that are completed drop to the bottom
            //
            // - Items that have times (or class times) should go first and appear in chronological order
            //
            // - After the items with times, everything else should appear afterwards
            //
            // - Anything that collides at the same time (or at the bottom, or don't have times) are sorted in the following order
            //   - Exam
            //   - Homework
            //   - Task
            //   - Event

            // If earlier date, goes first
            if (this.Date.Date < other.Date.Date)
            {
                return(-1);
            }

            // If later date, goes last
            if (this.Date.Date > other.Date.Date)
            {
                return(1);
            }

            // Otherwise, same date, so need to sort based on specific behaviors...

            // Within same day, items that are complete drop to bottom
            int comp = this.TryCompareByCompletionStatus(other);

            if (comp != 0)
            {
                return(comp);
            }

            // Place items in chronological order
            comp = this.GetDueDateWithTime().CompareTo(other.GetDueDateWithTime());
            if (comp != 0)
            {
                return(comp);
            }

            // Otherwise, items collide at same time (or didn't have time)

            // Compare by type
            comp = this.TryCompareByType(other);
            if (comp != 0)
            {
                return(comp);
            }

            // Otherwise, compare by class if present
            var class1 = GetClassOrNull();
            var class2 = GetClassOrNull();

            if (class1 != null && class2 != null)
            {
                comp = class1.CompareTo(class2);
                if (comp != 0)
                {
                    return(comp);
                }
            }

            // Otherwise, compare by date created
            return(this.DateCreated.CompareTo(other.DateCreated));
        }