ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/xmltv_parser/branches/linux/xmltv_parser/xmltv_parser/ListViewSorter.cs
Revision: 62
Committed: Fri Mar 8 14:24:17 2013 UTC (10 years, 2 months ago) by william
Original Path: trunk/xmltv_parser/ListViewSorter.cs
File size: 1361 byte(s)
Log Message:

File Contents

# Content
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Windows.Forms;
6
7 namespace xmltv_parser
8 {
9 public class ListViewSorter : System.Collections.IComparer
10 {
11 public ListViewSorter() { }
12 public int Compare(object o1, object o2)
13 {
14 if (!(o1 is ListViewItem))
15 return (0);
16 if (!(o2 is ListViewItem))
17 return (0);
18
19 ListViewItem lvi1 = (ListViewItem)o2;
20 string str1 = lvi1.SubItems[CurrentColumn].Text;
21 ListViewItem lvi2 = (ListViewItem)o1;
22 string str2 = lvi2.SubItems[CurrentColumn].Text;
23
24 int result;
25 if (lvi1.ListView.Sorting == SortOrder.Ascending)
26 result = String.Compare(str1, str2);
27 else
28 result = String.Compare(str2, str1);
29
30 LastColumn = CurrentColumn;
31
32 return (result);
33 }
34
35 int _LastColumn;
36 public int LastColumn
37 {
38 get { return _LastColumn; }
39 set { _LastColumn = value; }
40 }
41
42 int _CurrentColumn = 0;
43 public int CurrentColumn
44 {
45 get { return _CurrentColumn; }
46 set { _CurrentColumn = value; }
47 }
48
49 }
50 }