예제 #1
0
            public int Compare(object x, object y)
            {
                int result = 0;

                int       sortColumn = fOwner.fSortColumn;
                SortOrder sortOrder  = fOwner.fSortOrder;

                if (sortOrder != SortOrder.None && sortColumn >= 0)
                {
                    ListViewItem item1 = (ListViewItem)x;
                    ListViewItem item2 = (ListViewItem)y;

                    if (sortColumn == 0)
                    {
                        if (item1 is IComparable && item2 is IComparable)
                        {
                            IComparable eitem1 = (IComparable)x;
                            IComparable eitem2 = (IComparable)y;
                            result = eitem1.CompareTo(eitem2);
                        }
                        else
                        {
                            result = ZListView.StrCompareEx(item1.Text, item2.Text);
                        }
                    }
                    else if (sortColumn < item1.SubItems.Count && sortColumn < item2.SubItems.Count)
                    {
                        ListViewItem.ListViewSubItem subitem1 = item1.SubItems[sortColumn];
                        ListViewItem.ListViewSubItem subitem2 = item2.SubItems[sortColumn];

                        if (subitem1 is IComparable && subitem2 is IComparable)
                        {
                            IComparable sub1 = (IComparable)subitem1;
                            IComparable sub2 = (IComparable)subitem2;
                            result = sub1.CompareTo(sub2);
                        }
                        else
                        {
                            result = ZListView.StrCompareEx(subitem1.Text, subitem2.Text);
                        }
                    }

                    if (sortOrder == SortOrder.Descending)
                    {
                        result = -result;
                    }
                }

                return(result);
            }
예제 #2
0
 public LVColumnSorter(ZListView owner)
 {
     fOwner = owner;
 }