Make directories sort before files in sort order.

Change identifiers to match existing style.
This commit is contained in:
David Vierra 2015-02-25 23:32:57 -10:00
parent d8229f7ec5
commit 5c32832281

View file

@ -23,7 +23,7 @@ namespace NBTExplorer.Controllers
public class NodeTreeComparer : IComparer
{
public int orderForTag(TagType tagID)
public int OrderForTag(TagType tagID)
{
switch (tagID)
{
@ -44,6 +44,18 @@ namespace NBTExplorer.Controllers
}
}
public int OrderForNode(object node)
{
if (node is DirectoryDataNode)
{
return 0;
}
else
{
return 1;
}
}
public int Compare(object x, object y)
{
TreeNode tx = x as TreeNode;
@ -52,13 +64,21 @@ namespace NBTExplorer.Controllers
TagDataNode dy = ty.Tag as TagDataNode;
if (dx == null || dy == null)
{
int nodeOrder = this.OrderForNode(tx.Tag).CompareTo(this.OrderForNode(ty.Tag));
if (nodeOrder != 0)
{
return nodeOrder;
}
else
{
return tx.Text.CompareTo(ty.Text);
}
}
TagType idx = dx.Tag.GetTagType();
TagType idy = dy.Tag.GetTagType();
int tagOrder = this.orderForTag(idx).CompareTo(this.orderForTag(idy));
int tagOrder = this.OrderForTag(idx).CompareTo(this.OrderForTag(idy));
if (tagOrder != 0)
{
return tagOrder;