forked from arsium/PegasusHVNC
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathListViewColumnSorter.cs
More file actions
38 lines (33 loc) · 909 Bytes
/
Copy pathListViewColumnSorter.cs
File metadata and controls
38 lines (33 loc) · 909 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System.Collections;
using System.Windows.Forms;
public class ListViewColumnSorter : IComparer
{
private readonly CaseInsensitiveComparer _objectCompare;
public int SortColumn { get; set; }
public SortOrder Order { get; set; }
public ListViewColumnSorter()
{
SortColumn = 0;
Order = SortOrder.None;
_objectCompare = new CaseInsensitiveComparer();
}
public int Compare(object x, object y)
{
ListViewItem listViewItem = (ListViewItem)x;
ListViewItem listViewItem2 = (ListViewItem)y;
if (listViewItem.SubItems[0].Text == ".." || listViewItem2.SubItems[0].Text == "..")
{
return 0;
}
int num = _objectCompare.Compare(listViewItem.SubItems[SortColumn].Text, listViewItem2.SubItems[SortColumn].Text);
if (Order == SortOrder.Ascending)
{
return num;
}
if (Order != SortOrder.Descending)
{
return 0;
}
return -num;
}
}