@ -19,11 +19,11 @@ using Avalonia.Utilities;
namespace Avalonia.Collections
{
public abstract class Avalonia GroupDescription : INotifyPropertyChanged
public abstract class DataGrid GroupDescription : INotifyPropertyChanged
{
public AvaloniaList < object > GroupKeys { get ; }
public Avalonia GroupDescription( )
public DataGrid GroupDescription( )
{
GroupKeys = new AvaloniaList < object > ( ) ;
GroupKeys . CollectionChanged + = ( sender , e ) = > OnPropertyChanged ( new PropertyChangedEventArgs ( nameof ( GroupKeys ) ) ) ;
@ -54,14 +54,14 @@ namespace Avalonia.Collections
return object . Equals ( groupKey , itemKey ) ;
}
}
public class PathGroupDescription : Avalonia GroupDescription
public class DataGrid PathGroupDescription : DataGrid GroupDescription
{
private string _ propertyPath ;
private Type _ propertyType ;
private IValueConverter _ valueConverter ;
private StringComparison _ stringComparison = StringComparison . Ordinal ;
public PathGroupDescription ( string propertyPath )
public DataGrid PathGroupDescription( string propertyPath )
{
_ propertyPath = propertyPath ;
}
@ -114,7 +114,7 @@ namespace Avalonia.Collections
}
}
public abstract class CollectionViewGroup : INotifyPropertyChanged
public abstract class DataGrid CollectionViewGroup : INotifyPropertyChanged
{
private int _ itemCount ;
@ -133,7 +133,7 @@ namespace Avalonia.Collections
}
}
protected CollectionViewGroup ( object key )
protected DataGrid CollectionViewGroup( object key )
{
Key = key ;
ProtectedItems = new AvaloniaList < object > ( ) ;
@ -159,24 +159,24 @@ namespace Avalonia.Collections
PropertyChanged ? . Invoke ( this , e ) ;
}
}
internal class CollectionViewGroupInternal : CollectionViewGroup
internal class DataGrid CollectionViewGroupInternal : DataGrid CollectionViewGroup
{
/// <summary>
/// GroupDescription used to define how to group the items
/// </summary>
private Avalonia GroupDescription _ groupBy ;
private DataGrid GroupDescription _ groupBy ;
/// <summary>
/// Parent group of this CollectionViewGroupInternal
/// </summary>
private readonly CollectionViewGroupInternal _ parentGroup ;
private readonly DataGrid CollectionViewGroupInternal _ parentGroup ;
/// <summary>
/// Used for detecting stale enumerators
/// </summary>
private int _ version ;
public CollectionViewGroupInternal ( object key , CollectionViewGroupInternal parent )
public DataGrid CollectionViewGroupInternal( object key , DataGrid CollectionViewGroupInternal parent )
: base ( key )
{
_ parentGroup = parent ;
@ -186,7 +186,7 @@ namespace Avalonia.Collections
internal int FullCount { get ; set ; }
internal Avalonia GroupDescription GroupBy
internal DataGrid GroupDescription GroupBy
{
get { return _ groupBy ; }
set
@ -240,7 +240,7 @@ namespace Avalonia.Collections
// look for first item, child by child
for ( int k = 0 , n = Items . Count ; k < n ; + + k )
{
if ( ! ( Items [ k ] is CollectionViewGroupInternal subgroup ) )
if ( ! ( Items [ k ] is DataGrid CollectionViewGroupInternal subgroup ) )
{
// child is an item - return it
return Items [ k ] ;
@ -267,7 +267,7 @@ namespace Avalonia.Collections
}
}
private CollectionViewGroupInternal Parent = > _ parentGroup ;
private DataGrid CollectionViewGroupInternal Parent = > _ parentGroup ;
/// <summary>
/// Adds the specified item to the collection
@ -322,7 +322,7 @@ namespace Avalonia.Collections
for ( index = low ; index < high ; + + index )
{
object seed1 = ( ProtectedItems [ index ] is CollectionViewGroupInternal subgroup ) ? subgroup . SeedItem : ProtectedItems [ index ] ;
object seed1 = ( ProtectedItems [ index ] is DataGrid CollectionViewGroupInternal subgroup ) ? subgroup . SeedItem : ProtectedItems [ index ] ;
if ( seed1 = = AvaloniaProperty . UnsetValue )
{
continue ;
@ -383,7 +383,7 @@ namespace Avalonia.Collections
{
for ( int k = 0 , n = Items . Count ; k < n ; + + k )
{
if ( Items [ k ] is CollectionViewGroupInternal subgroup )
if ( Items [ k ] is DataGrid CollectionViewGroupInternal subgroup )
{
// current item is a group - either drill in, or skip over
if ( index < subgroup . ItemCount )
@ -426,7 +426,7 @@ namespace Avalonia.Collections
int result = 0 ;
// accumulate the number of predecessors at each level
for ( CollectionViewGroupInternal group = this ;
for ( DataGrid CollectionViewGroupInternal group = this ;
group ! = null ;
item = group , group = group . Parent , index = - 1 )
{
@ -441,7 +441,7 @@ namespace Avalonia.Collections
}
// accumulate leaf count
CollectionViewGroupInternal subgroup = group . Items [ k ] as CollectionViewGroupInternal ;
DataGrid CollectionViewGroupInternal subgroup = group . Items [ k ] as DataGrid CollectionViewGroupInternal;
result + = subgroup ? . ItemCount ? ? 1 ;
}
}
@ -460,7 +460,7 @@ namespace Avalonia.Collections
int leaves = 0 ; // number of leaves we've passed over so far
for ( int k = 0 , n = Items . Count ; k < n ; + + k )
{
if ( Items [ k ] is CollectionViewGroupInternal subgroup )
if ( Items [ k ] is DataGrid CollectionViewGroupInternal subgroup )
{
int subgroupIndex = subgroup . LeafIndexOf ( item ) ;
if ( subgroupIndex < 0 )
@ -519,13 +519,13 @@ namespace Avalonia.Collections
/// Removes an empty group from the PagedCollectionView grouping
/// </summary>
/// <param name="group">Empty subgroup to remove</param>
private static void RemoveEmptyGroup ( CollectionViewGroupInternal group )
private static void RemoveEmptyGroup ( DataGrid CollectionViewGroupInternal group )
{
CollectionViewGroupInternal parent = group . Parent ;
DataGrid CollectionViewGroupInternal parent = group . Parent ;
if ( parent ! = null )
{
Avalonia GroupDescription groupBy = parent . GroupBy ;
DataGrid GroupDescription groupBy = parent . GroupBy ;
int index = parent . ProtectedItems . IndexOf ( group ) ;
// remove the subgroup unless it is one of the explicit groups
@ -544,9 +544,9 @@ namespace Avalonia.Collections
/// <param name="delta">Delta to change count by</param>
protected void ChangeCounts ( object item , int delta )
{
bool changeLeafCount = ! ( item is CollectionViewGroup ) ;
bool changeLeafCount = ! ( item is DataGrid CollectionViewGroup) ;
for ( CollectionViewGroupInternal group = this ;
for ( DataGrid CollectionViewGroupInternal group = this ;
group ! = null ;
group = group . _ parentGroup )
{
@ -576,7 +576,7 @@ namespace Avalonia.Collections
private class LeafEnumerator : IEnumerator
{
private object _ current ; // current item
private CollectionViewGroupInternal _ group ; // parent group
private DataGrid CollectionViewGroupInternal _ group ; // parent group
private int _ index ; // current index into Items
private IEnumerator _ subEnum ; // enumerator over current subgroup
private int _ version ; // parent group's version at ctor
@ -585,7 +585,7 @@ namespace Avalonia.Collections
/// Initializes a new instance of the LeafEnumerator class.
/// </summary>
/// <param name="group">CollectionViewGroupInternal that uses the enumerator</param>
public LeafEnumerator ( CollectionViewGroupInternal group )
public LeafEnumerator ( DataGrid CollectionViewGroupInternal group )
{
_ group = group ;
DoReset ( ) ; // don't call virtual Reset in ctor
@ -636,7 +636,7 @@ namespace Avalonia.Collections
return false ;
}
CollectionViewGroupInternal subgroup = _ group . Items [ _ index ] as CollectionViewGroupInternal ;
DataGrid CollectionViewGroupInternal subgroup = _ group . Items [ _ index ] as DataGrid CollectionViewGroupInternal;
if ( subgroup = = null )
{
// current item is a leaf - it's the new Current
@ -839,7 +839,7 @@ namespace Avalonia.Collections
}
internal class CollectionViewGroupRoot : CollectionViewGroupInternal , INotifyCollectionChanged
internal class CollectionViewGroupRoot : DataGrid CollectionViewGroupInternal, INotifyCollectionChanged
{
/// <summary>
/// String constant used for the Root Name
@ -854,12 +854,12 @@ namespace Avalonia.Collections
/// <summary>
/// Private accessor for the top level GroupDescription
/// </summary>
private static Avalonia GroupDescription topLevelGroupDescription ;
private static DataGrid GroupDescription topLevelGroupDescription ;
/// <summary>
/// Private accessor for an ObservableCollection containing group descriptions
/// </summary>
private readonly AvaloniaList < Avalonia GroupDescription> _ groupBy = new AvaloniaList < Avalonia GroupDescription> ( ) ;
private readonly AvaloniaList < DataGrid GroupDescription> _ groupBy = new AvaloniaList < DataGrid GroupDescription> ( ) ;
/// <summary>
/// Indicates whether the list of items (after applying the sort and filters, if any)
@ -870,7 +870,7 @@ namespace Avalonia.Collections
/// <summary>
/// Private accessor for the owning ICollectionView
/// </summary>
private readonly ICollectionView _ view ;
private readonly IDataGrid CollectionView _ view ;
/// <summary>
/// Raise this event when the (grouped) view changes
@ -887,7 +887,7 @@ namespace Avalonia.Collections
/// </summary>
/// <param name="view">CollectionView that contains this grouping</param>
/// <param name="isDataInGroupOrder">True if items are already in correct order for grouping</param>
internal CollectionViewGroupRoot ( ICollectionView view , bool isDataInGroupOrder )
internal CollectionViewGroupRoot ( IDataGrid CollectionView view , bool isDataInGroupOrder )
: base ( RootName , null )
{
_ view = view ;
@ -897,7 +897,7 @@ namespace Avalonia.Collections
/// <summary>
/// Gets the description of grouping, indexed by level.
/// </summary>
public virtual AvaloniaList < Avalonia GroupDescription> GroupDescriptions = > _ groupBy ;
public virtual AvaloniaList < DataGrid GroupDescription> GroupDescriptions = > _ groupBy ;
/// <summary>
/// Gets or sets the current IComparer being used
@ -938,7 +938,7 @@ namespace Avalonia.Collections
protected override int FindIndex ( object item , object seed , IComparer comparer , int low , int high )
{
// root group needs to adjust the bounds of the search to exclude the new item (if any)
if ( _ view is IEditableCollectionView iecv & & iecv . IsAddingNew )
if ( _ view is IDataGrid EditableCollectionView iecv & & iecv . IsAddingNew )
{
- - high ;
}
@ -1061,15 +1061,15 @@ namespace Avalonia.Collections
/// <param name="level">The level of grouping.</param>
/// <param name="key">Name of subgroup to add to</param>
/// <param name="loading">Whether we are currently loading</param>
private void AddToSubgroup ( object item , CollectionViewGroupInternal group , int level , object key , bool loading )
private void AddToSubgroup ( object item , DataGrid CollectionViewGroupInternal group , int level , object key , bool loading )
{
CollectionViewGroupInternal subgroup ;
DataGrid CollectionViewGroupInternal subgroup ;
int index = ( _ isDataInGroupOrder ) ? group . LastIndex : 0 ;
// find the desired subgroup
for ( int n = group . Items . Count ; index < n ; + + index )
{
subgroup = group . Items [ index ] as CollectionViewGroupInternal ;
subgroup = group . Items [ index ] as DataGrid CollectionViewGroupInternal;
if ( subgroup = = null )
{
continue ; // skip children that are not groups
@ -1084,7 +1084,7 @@ namespace Avalonia.Collections
}
// the item didn't match any subgroups. Create a new subgroup and add the item.
subgroup = new CollectionViewGroupInternal ( key , group ) ;
subgroup = new DataGrid CollectionViewGroupInternal( key , group ) ;
InitializeGroup ( subgroup , level + 1 , item ) ;
@ -1112,7 +1112,7 @@ namespace Avalonia.Collections
/// <param name="group">Group to add item to</param>
/// <param name="level">The level of grouping</param>
/// <param name="loading">Whether we are currently loading</param>
private void AddToSubgroups ( object item , CollectionViewGroupInternal group , int level , bool loading )
private void AddToSubgroups ( object item , DataGrid CollectionViewGroupInternal group , int level , bool loading )
{
object key = GetGroupKey ( item , group . GroupBy , level ) ;
@ -1145,7 +1145,7 @@ namespace Avalonia.Collections
}
}
public virtual Func < CollectionViewGroup , int , Avalonia GroupDescription> GroupBySelector { get ; set ; }
public virtual Func < DataGrid CollectionViewGroup, int , DataGrid GroupDescription> GroupBySelector { get ; set ; }
/// <summary>
/// Returns the description of how to divide the given group into subgroups
@ -1153,9 +1153,9 @@ namespace Avalonia.Collections
/// <param name="group">CollectionViewGroup to get group description from</param>
/// <param name="level">The level of grouping</param>
/// <returns>GroupDescription of how to divide the given group</returns>
private Avalonia GroupDescription GetGroupDescription ( CollectionViewGroup group , int level )
private DataGrid GroupDescription GetGroupDescription ( DataGrid CollectionViewGroup group , int level )
{
Avalonia GroupDescription result = null ;
DataGrid GroupDescription result = null ;
if ( group = = this )
{
group = null ;
@ -1181,7 +1181,7 @@ namespace Avalonia.Collections
/// <param name="groupDescription">GroupDescription for the group</param>
/// <param name="level">The level of grouping</param>
/// <returns>Group names for the specified item</returns>
private object GetGroupKey ( object item , Avalonia GroupDescription groupDescription , int level )
private object GetGroupKey ( object item , DataGrid GroupDescription groupDescription , int level )
{
if ( groupDescription ! = null )
{
@ -1199,10 +1199,10 @@ namespace Avalonia.Collections
/// <param name="group">Group to initialize</param>
/// <param name="level">The level of grouping</param>
/// <param name="seedItem">The seed item to compare with to see where to insert</param>
private void InitializeGroup ( CollectionViewGroupInternal group , int level , object seedItem )
private void InitializeGroup ( DataGrid CollectionViewGroupInternal group , int level , object seedItem )
{
// set the group description for dividing the group into subgroups
Avalonia GroupDescription groupDescription = GetGroupDescription ( group , level ) ;
DataGrid GroupDescription groupDescription = GetGroupDescription ( group , level ) ;
group . GroupBy = groupDescription ;
// create subgroups for each of the explicit names
@ -1211,7 +1211,7 @@ namespace Avalonia.Collections
{
for ( int k = 0 , n = keys . Count ; k < n ; + + k )
{
CollectionViewGroupInternal subgroup = new CollectionViewGroupInternal ( keys [ k ] , group ) ;
DataGrid CollectionViewGroupInternal subgroup = new DataGrid CollectionViewGroupInternal( keys [ k ] , group ) ;
InitializeGroup ( subgroup , level + 1 , seedItem ) ;
group . Add ( subgroup ) ;
}
@ -1226,7 +1226,7 @@ namespace Avalonia.Collections
/// <param name="group">Group to remove item from</param>
/// <param name="item">Item to remove</param>
/// <returns>True if item could not be removed</returns>
private bool RemoveFromGroupDirectly ( CollectionViewGroupInternal group , object item )
private bool RemoveFromGroupDirectly ( DataGrid CollectionViewGroupInternal group , object item )
{
int leafIndex = group . Remove ( item , true ) ;
if ( leafIndex > = 0 )
@ -1248,15 +1248,15 @@ namespace Avalonia.Collections
/// <param name="level">The level of grouping</param>
/// <param name="key">Name of item to remove</param>
/// <returns>Return true if the item was not in one of the subgroups it was supposed to be.</returns>
private bool RemoveFromSubgroup ( object item , CollectionViewGroupInternal group , int level , object key )
private bool RemoveFromSubgroup ( object item , DataGrid CollectionViewGroupInternal group , int level , object key )
{
bool itemIsMissing = false ;
CollectionViewGroupInternal subgroup ;
DataGrid CollectionViewGroupInternal subgroup ;
// find the desired subgroup
for ( int index = 0 , n = group . Items . Count ; index < n ; + + index )
{
subgroup = group . Items [ index ] as CollectionViewGroupInternal ;
subgroup = group . Items [ index ] as DataGrid CollectionViewGroupInternal;
if ( subgroup = = null )
{
continue ; // skip children that are not groups
@ -1284,7 +1284,7 @@ namespace Avalonia.Collections
/// <param name="group">Group to remove item from</param>
/// <param name="level">The level of grouping</param>
/// <returns>Return true if the item was not in one of the subgroups it was supposed to be.</returns>
private bool RemoveFromSubgroups ( object item , CollectionViewGroupInternal group , int level )
private bool RemoveFromSubgroups ( object item , DataGrid CollectionViewGroupInternal group , int level )
{
bool itemIsMissing = false ;
object key = GetGroupKey ( item , group . GroupBy , level ) ;
@ -1326,7 +1326,7 @@ namespace Avalonia.Collections
/// </summary>
/// <param name="group">Group to remove item from</param>
/// <param name="item">Item to remove</param>
private void RemoveItemFromSubgroupsByExhaustiveSearch ( CollectionViewGroupInternal group , object item )
private void RemoveItemFromSubgroupsByExhaustiveSearch ( DataGrid CollectionViewGroupInternal group , object item )
{
// try to remove the item from the direct children
// this function only returns true if it failed to remove from group directly
@ -1337,7 +1337,7 @@ namespace Avalonia.Collections
// (loop runs backwards in case an entire group is deleted)
for ( int k = group . Items . Count - 1 ; k > = 0 ; - - k )
{
if ( group . Items [ k ] is CollectionViewGroupInternal subgroup )
if ( group . Items [ k ] is DataGrid CollectionViewGroupInternal subgroup )
{
RemoveItemFromSubgroupsByExhaustiveSearch ( subgroup , item ) ;
}
@ -1349,7 +1349,7 @@ namespace Avalonia.Collections
/// <summary>
/// TopLevelGroupDescription class
/// </summary>
private class TopLevelGroupDescription : Avalonia GroupDescription
private class TopLevelGroupDescription : DataGrid GroupDescription
{
/// <summary>
/// Initializes a new instance of the TopLevelGroupDescription class.