private void HandleColumnClick(object sender, ColumnEventArgs e) { ResourcePropsColumn col = e.Column as ResourcePropsColumn; if (col != null && _listView != null) { HandeColumnClick(col); } }
private ResourceComparer CreateColumnComparer(ResourcePropsColumn col, SortSettings sortSettings) { if (col.CustomComparer != null) { return(new ResourceComparer(_resourceList, col.CustomComparer, sortSettings.SortAscending)); } else { return(new ResourceComparer(_resourceList, sortSettings, true)); } }
public void UpdateSortColumn() { if (_curSortSettings != null) { foreach (JetListViewColumn col in _listView.Columns) { ResourcePropsColumn rlvCol = col as ResourcePropsColumn; if (rlvCol != null && rlvCol.PropIdsEqual(_curSortSettings.SortProps)) { rlvCol.SortIcon = _curSortSettings.SortAscending ? SortIcon.Ascending : SortIcon.Descending; _lastSortColumn = rlvCol; _listView.GroupProvider = _lastSortColumn.GroupProvider; break; } } } }
public void ApplySortSettings(JetListView listView, SortSettings sortSettings) { if (sortSettings != null) { _curSortSettings = sortSettings; bool foundComparerColumn = false; foreach (JetListViewColumn col in listView.Columns) { ResourcePropsColumn propsCol = col as ResourcePropsColumn; if (propsCol != null && propsCol.PropIdsEqual(sortSettings.SortProps)) { _lastComparer = CreateColumnComparer(propsCol, sortSettings); propsCol.SortIcon = sortSettings.SortAscending ? SortIcon.Ascending : SortIcon.Descending; _lastSortColumn = propsCol; _listView.GroupProvider = _lastSortColumn.GroupProvider; foundComparerColumn = true; } else { col.SortIcon = SortIcon.None; } } if (!foundComparerColumn) { _lastComparer = new ResourceComparer(_resourceList, _curSortSettings, true); } if (_lastComparer != null) { _listView.NodeCollection.SetItemComparer(null, _lastComparer); if (_nodesAdded) { _listView.NodeCollection.Sort(); } } } }
public void HandeColumnClick(ResourcePropsColumn col) { ComparableArrayList propList = new ComparableArrayList(col.PropIds); if (_lastComparer != null && col == _lastSortColumn) { Guard.NullMember(_curSortSettings, "_curSortSettings"); _curSortSettings = _curSortSettings.Reverse(); _lastSortDirections [propList] = (col.SortIcon == SortIcon.Descending); // reverse } else { bool sortAscending = true; if (_lastSortDirections.ContainsKey(propList)) { sortAscending = (bool)_lastSortDirections [propList]; } _curSortSettings = new SortSettings(col.PropIds, sortAscending); if (_lastSortColumn != null) { _lastSortColumn.SortIcon = SortIcon.None; } _lastSortColumn = col; } _lastComparer = CreateColumnComparer(col, _curSortSettings); Guard.NullMember(_lastSortColumn, "_lastSortColumn"); _lastSortColumn.SortIcon = _curSortSettings.SortAscending ? SortIcon.Ascending : SortIcon.Descending; Guard.NullMember(_listView, "_listView"); _listView.NodeCollection.SetItemComparer(null, _lastComparer); _listView.NodeCollection.Sort(); _listView.GroupProvider = _lastSortColumn.GroupProvider; OnSortChanged(); }