/[xmltv_parser]/branches/linux/xmltv_parser/xmltv_parser/ListViewSorter.cs
ViewVC logotype

Annotation of /branches/linux/xmltv_parser/xmltv_parser/ListViewSorter.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 282 - (hide annotations) (download)
Wed Jul 29 19:09:14 2015 UTC (5 years ago) by william
File size: 1361 byte(s)


1 william 61 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 william 62 public ListViewSorter() { }
12 william 61 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 william 62 string str1 = lvi1.SubItems[CurrentColumn].Text;
21 william 61 ListViewItem lvi2 = (ListViewItem)o1;
22 william 62 string str2 = lvi2.SubItems[CurrentColumn].Text;
23 william 61
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 william 62 LastColumn = CurrentColumn;
31 william 61
32     return (result);
33     }
34    
35 william 62 int _LastColumn;
36     public int LastColumn
37 william 61 {
38 william 62 get { return _LastColumn; }
39     set { _LastColumn = value; }
40     }
41 william 61
42 william 62 int _CurrentColumn = 0;
43     public int CurrentColumn
44 william 61 {
45 william 62 get { return _CurrentColumn; }
46     set { _CurrentColumn = value; }
47 william 61 }
48 william 62
49 william 61 }
50     }

  ViewVC Help
Powered by ViewVC 1.1.22