Text that appears in grid header. Tracks sorting order and displays the appropriate sort order glyph.
Inheritance: TextVisual
Example #1
0
 /// <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;
     }
 }
Example #2
0
 private void ResetSortToPrimary(HeaderTextVisual primary)
 {
     foreach (var viz in _visualChildren)
     {
         var v = viz as HeaderTextVisual;
         if (v != null && v != primary)
         {
             v.SortOrder = SortOrderType.None;
         }
     }
 }
Example #3
0
        /// <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;
            }
        }
Example #4
0
 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);
 }
Example #5
0
        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);
                });
            }
        }
Example #6
0
 /// <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));
 }
Example #7
0
 private void ResetSortToPrimary(HeaderTextVisual primary) {
     foreach (var viz in _visualChildren) {
         var v = viz as HeaderTextVisual;
         if (v != null && v != primary) {
             v.SortOrder = SortOrderType.None;
         }
     }
 }
Example #8
0
 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);
 }
Example #9
0
 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;
             });
     }
 }
Example #10
0
 /// <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));
 }