/// <summary> /// Adds column to the sorting order. Typically called when user /// Shift+Click on the column header adding it to the set. /// If the column is already in the set, the call does nothing. /// </summary> /// <param name="v"></param> public void Add(HeaderTextVisual v) { var existing = _sortOrderList.FirstOrDefault(x => x.ColumnIndex == v.ColumnIndex); if (existing == null) { _sortOrderList.Add(new ColumnSortOrder(v.ColumnIndex, v.SortOrder == SortOrderType.Descending)); } else { existing.Descending = v.SortOrder == SortOrderType.Descending; } }
private void ResetSortToPrimary(HeaderTextVisual primary) { foreach (var viz in _visualChildren) { var v = viz as HeaderTextVisual; if (v != null && v != primary) { v.SortOrder = SortOrderType.None; } } }
/// <summary> /// Adds column to the sorting order. Typically called when user /// Shift+Click on the column header adding it to the set. /// If the column is already in the set, the call does nothing. /// </summary> /// <param name="v"></param> public void Add(HeaderTextVisual v) { var existing = _sortOrderList.FirstOrDefault(x => x.ColumnIndex == v.ColumnIndex); if (existing == null) { _sortOrderList.Add(new ColumnSortOrder(v.ColumnIndex, v.SortOrder == SortOrderType.Descending)); } else { existing.Descending = v.SortOrder == SortOrderType.Descending; } }
public void ToggleSort(HeaderTextVisual v, bool add) { // Order: None -> Ascending -> Descending -> Ascending -> Descending -> ... v.ToggleSortOrder(); if (add) { // Shift+Click adds column to the sorting set. _sortOrder.Add(v); } else { // Clear all column sorts except the one that was clicked on. ResetSortToPrimary(v); _sortOrder.ResetTo(v); } SortOrderChanged?.Invoke(this, EventArgs.Empty); }
private void CreateGrid(GridRange newViewport, IGrid <string> data, GridUpdateType updateType) { var orgGrid = _visualGrid; if (Header) { _visualGrid = new Grid <TextVisual>( newViewport, (r, c) => { if (updateType == GridUpdateType.Sort) { return(orgGrid[r, c]); } if (updateType != GridUpdateType.Refresh && _dataViewport.Contains(r, c)) { return(orgGrid[r, c]); } var visual = new HeaderTextVisual(c); InitVisual(r, c, data, visual); return(visual); }); } else { _visualGrid = new Grid <TextVisual>( newViewport, (r, c) => { if (updateType != GridUpdateType.Refresh && _dataViewport.Contains(r, c)) { return(orgGrid[r, c]); } var visual = new TextVisual(); InitVisual(r, c, data, visual); return(visual); }); } }
/// <summary> /// Resets sort to one column assuming default (ascending) order. /// Typically called as a result of click on one of the column /// headers which clears current sort across all columns and sets /// the clicked column as primary with the default sorting order. /// </summary> /// <param name="v"></param> public void ResetTo(HeaderTextVisual v) { _sortOrderList.Clear(); _sortOrderList.Add(new ColumnSortOrder(v.ColumnIndex, v.SortOrder == SortOrderType.Descending)); }
private void ResetSortToPrimary(HeaderTextVisual primary) { foreach (var viz in _visualChildren) { var v = viz as HeaderTextVisual; if (v != null && v != primary) { v.SortOrder = SortOrderType.None; } } }
public void ToggleSort(HeaderTextVisual v, bool add) { // Order: None -> Ascending -> Descending -> Ascending -> Descending -> ... v.ToggleSortOrder(); if (add) { // Shift+Click adds column to the sorting set. _sortOrder.Add(v); } else { // Clear all column sorts except the one that was clicked on. ResetSortToPrimary(v); _sortOrder.ResetTo(v); } SortOrderChanged?.Invoke(this, EventArgs.Empty); }
private void CreateGrid(GridRange newViewport, IGrid<string> data, GridUpdateType updateType) { var orgGrid = _visualGrid; if (Header) { _visualGrid = new Grid<TextVisual>( newViewport, (r, c) => { if (updateType == GridUpdateType.Sort) { return orgGrid[r, c]; } if (updateType != GridUpdateType.Refresh && _dataViewport.Contains(r, c)) { return orgGrid[r, c]; } var visual = new HeaderTextVisual(c); InitVisual(r, c, data, visual); return visual; }); } else { _visualGrid = new Grid<TextVisual>( newViewport, (r, c) => { if (updateType != GridUpdateType.Refresh && _dataViewport.Contains(r, c)) { return orgGrid[r, c]; } var visual = new TextVisual(); InitVisual(r, c, data, visual); return visual; }); } }
/// <summary> /// Resets sort to one column assuming default (ascending) order. /// Typically called as a result of click on one of the column /// headers which clears current sort across all columns and sets /// the clicked column as primary with the default sorting order. /// </summary> /// <param name="v"></param> public void ResetTo(HeaderTextVisual v) { _sortOrderList.Clear(); _sortOrderList.Add(new ColumnSortOrder(v.ColumnIndex, v.SortOrder == SortOrderType.Descending)); }