Sort the projects consistantly. Class -> Due Date -> Save Date

This commit is contained in:
Tim Young 2017-08-11 14:56:40 -05:00
parent f478221169
commit db6cdff653
3 changed files with 19 additions and 1 deletions

View File

@ -512,7 +512,8 @@ namespace EduNetworkBuilder
public TreeNode WorkTree(TreeNode theTop=null, bool ForTeacher = false)
{
//Sort by due date, and within the due dates, sort by save date
Projects.Sort((q, p) => p.DueDate == q.DueDate ? p.SaveDate.CompareTo(q.SaveDate) : p.DueDate.CompareTo(q.DueDate));
//Projects.Sort((q, p) => p.DueDate == q.DueDate ? p.SaveDate.CompareTo(q.SaveDate) : p.DueDate.CompareTo(q.DueDate));
Projects.Sort((q, p) => p.Compare(q));
List<SchoolworkClass> DrawFrom = new List<SchoolworkClass>();
List<SchoolworkClass> MasterList = new List<SchoolworkClass>();

View File

@ -292,6 +292,7 @@ namespace EduNetworkBuilder
Node.Tag = "Class"; //Do not translate this
TreeNode Top = Node;
tvClasswork.Nodes.Add(Node);
CurrentUser.Projects.Sort((q, p) => p.Compare(q));
foreach (SchoolworkClass SWC in CurrentUser.Projects)
{
Node = new TreeNode(SWC.Name);

View File

@ -90,6 +90,22 @@ namespace EduNetworkBuilder
dest.IsGraded = source.IsGraded;
}
/// <summary>
/// Basically for sorting. First by class name, then due date, and then save date
/// </summary>
/// <param name="WhatTo"></param>
/// <returns></returns>
public int Compare(SchoolworkClass WhatTo)
{
int diff = Class.CompareTo(WhatTo.Class);
if (diff != 0) return diff;
diff = DueDate.CompareTo(WhatTo.DueDate);
if (diff != 0) return diff;
return SaveDate.CompareTo(WhatTo.SaveDate);
}
#region Load and Save
//Load and save functions
public void Load(string filename)