/[xmltv_parser]/trunk/xmltv_parser/ListViewSorter.cs
ViewVC logotype

Contents of /trunk/xmltv_parser/ListViewSorter.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 61 - (show annotations) (download)
Fri Mar 8 14:13:19 2013 UTC (7 years, 4 months ago) by william
File size: 1261 byte(s)

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 int Compare(object o1, object o2)
12 {
13 if (!(o1 is ListViewItem))
14 return (0);
15 if (!(o2 is ListViewItem))
16 return (0);
17
18 ListViewItem lvi1 = (ListViewItem)o2;
19 string str1 = lvi1.SubItems[ByColumn].Text;
20 ListViewItem lvi2 = (ListViewItem)o1;
21 string str2 = lvi2.SubItems[ByColumn].Text;
22
23 int result;
24 if (lvi1.ListView.Sorting == SortOrder.Ascending)
25 result = String.Compare(str1, str2);
26 else
27 result = String.Compare(str2, str1);
28
29 LastSort = ByColumn;
30
31 return (result);
32 }
33
34
35 public int ByColumn
36 {
37 get { return Column; }
38 set { Column = value; }
39 }
40 int Column = 0;
41
42 public int LastSort
43 {
44 get { return LastColumn; }
45 set { LastColumn = value; }
46 }
47 int LastColumn = 0;
48 }
49 }

  ViewVC Help
Powered by ViewVC 1.1.22