Browse Source

Add prefixes and correct references from PageCollectionView to DataGridCollectionView.

pull/2109/head
Jumar Macato 8 years ago
parent
commit
d5399091b6
No known key found for this signature in database GPG Key ID: B19884DAC3A5BF3F
  1. 6
      samples/ControlCatalog/Pages/DataGridPage.xaml.cs
  2. 34
      src/Avalonia.Controls.DataGrid/Collections/DataGridCollectionView.cs
  3. 10
      src/Avalonia.Controls.DataGrid/DataGridDataConnection.cs

6
samples/ControlCatalog/Pages/DataGridPage.xaml.cs

@ -14,7 +14,7 @@ namespace ControlCatalog.Pages
var dg1 = this.FindControl<DataGrid>("dataGrid1"); var dg1 = this.FindControl<DataGrid>("dataGrid1");
dg1.IsReadOnly = true; dg1.IsReadOnly = true;
var collectionView1 = new CollectionViewBase(Countries.All); var collectionView1 = new DataGridCollectionView(Countries.All);
//collectionView.GroupDescriptions.Add(new PathGroupDescription("Region")); //collectionView.GroupDescriptions.Add(new PathGroupDescription("Region"));
dg1.Items = collectionView1; dg1.Items = collectionView1;
@ -22,7 +22,7 @@ namespace ControlCatalog.Pages
var dg2 = this.FindControl<DataGrid>("dataGridGrouping"); var dg2 = this.FindControl<DataGrid>("dataGridGrouping");
dg2.IsReadOnly = true; dg2.IsReadOnly = true;
var collectionView2 = new CollectionViewBase(Countries.All); var collectionView2 = new DataGridCollectionView(Countries.All);
collectionView2.GroupDescriptions.Add(new DataGridPathGroupDescription("Region")); collectionView2.GroupDescriptions.Add(new DataGridPathGroupDescription("Region"));
dg2.Items = collectionView2; dg2.Items = collectionView2;
@ -36,7 +36,7 @@ namespace ControlCatalog.Pages
new Person { FirstName = "Elizabeth", LastName = "Thomas" }, new Person { FirstName = "Elizabeth", LastName = "Thomas" },
new Person { FirstName = "Zack", LastName = "Ward" } new Person { FirstName = "Zack", LastName = "Ward" }
}; };
var collectionView3 = new CollectionViewBase(items); var collectionView3 = new DataGridCollectionView(items);
dg3.Items = collectionView3; dg3.Items = collectionView3;

34
src/Avalonia.Controls.DataGrid/Collections/DataGridCollectionView.cs

@ -44,7 +44,7 @@ namespace Avalonia.Collections
} }
/// <summary>Defines a method that enables a collection to provide a custom view for specialized sorting, filtering, grouping, and currency.</summary> /// <summary>Defines a method that enables a collection to provide a custom view for specialized sorting, filtering, grouping, and currency.</summary>
internal interface ICollectionViewFactory internal interface IDataGridCollectionViewFactory
{ {
/// <summary>Returns a custom view for specialized sorting, filtering, grouping, and currency.</summary> /// <summary>Returns a custom view for specialized sorting, filtering, grouping, and currency.</summary>
/// <returns>A custom view for specialized sorting, filtering, grouping, and currency.</returns> /// <returns>A custom view for specialized sorting, filtering, grouping, and currency.</returns>
@ -52,9 +52,9 @@ namespace Avalonia.Collections
} }
/// <summary> /// <summary>
/// PagedCollectionView view over an IEnumerable. /// DataGrid-readable view over an IEnumerable.
/// </summary> /// </summary>
public sealed class CollectionViewBase : IDataGridCollectionView, IDataGridEditableCollectionView, INotifyPropertyChanged //IPagedCollectionView, public sealed class DataGridCollectionView : IDataGridCollectionView, IDataGridEditableCollectionView, INotifyPropertyChanged
{ {
/// <summary> /// <summary>
/// Since there's nothing in the un-cancelable event args that is mutable, /// Since there's nothing in the un-cancelable event args that is mutable,
@ -75,7 +75,7 @@ namespace Avalonia.Collections
private int _cachedPageSize; private int _cachedPageSize;
/// <summary> /// <summary>
/// CultureInfo used in this PagedCollectionView /// CultureInfo used in this DataGridCollectionView
/// </summary> /// </summary>
private CultureInfo _culture; private CultureInfo _culture;
@ -198,18 +198,18 @@ namespace Avalonia.Collections
/// Helper constructor that sets default values for isDataSorted and isDataInGroupOrder. /// Helper constructor that sets default values for isDataSorted and isDataInGroupOrder.
/// </summary> /// </summary>
/// <param name="source">The source for the collection</param> /// <param name="source">The source for the collection</param>
public CollectionViewBase(IEnumerable source) public DataGridCollectionView(IEnumerable source)
: this(source, false /*isDataSorted*/, false /*isDataInGroupOrder*/) : this(source, false /*isDataSorted*/, false /*isDataInGroupOrder*/)
{ {
} }
/// <summary> /// <summary>
/// Initializes a new instance of the PagedCollectionView class. /// Initializes a new instance of the DataGridCollectionView class.
/// </summary> /// </summary>
/// <param name="source">The source for the collection</param> /// <param name="source">The source for the collection</param>
/// <param name="isDataSorted">Determines whether the source is already sorted</param> /// <param name="isDataSorted">Determines whether the source is already sorted</param>
/// <param name="isDataInGroupOrder">Whether the source is already in the correct order for grouping</param> /// <param name="isDataInGroupOrder">Whether the source is already in the correct order for grouping</param>
public CollectionViewBase(IEnumerable source, bool isDataSorted, bool isDataInGroupOrder) public DataGridCollectionView(IEnumerable source, bool isDataSorted, bool isDataInGroupOrder)
{ {
_sourceCollection = source ?? throw new ArgumentNullException(nameof(source)); _sourceCollection = source ?? throw new ArgumentNullException(nameof(source));
@ -1938,7 +1938,7 @@ namespace Avalonia.Collections
} }
/// <summary> /// <summary>
/// Retrieve item at the given zero-based index in this PagedCollectionView, after the source collection /// Retrieve item at the given zero-based index in this DataGridCollectionView, after the source collection
/// is filtered, sorted, and paged. /// is filtered, sorted, and paged.
/// </summary> /// </summary>
/// <exception cref="ArgumentOutOfRangeException"> /// <exception cref="ArgumentOutOfRangeException">
@ -3890,7 +3890,7 @@ namespace Avalonia.Collections
} }
/// <summary> /// <summary>
/// SortDescription was added/removed, refresh PagedCollectionView /// SortDescription was added/removed, refresh DataGridCollectionView
/// </summary> /// </summary>
/// <param name="sender">Sender that triggered this handler</param> /// <param name="sender">Sender that triggered this handler</param>
/// <param name="e">NotifyCollectionChangedEventArgs for this change</param> /// <param name="e">NotifyCollectionChangedEventArgs for this change</param>
@ -3959,7 +3959,7 @@ namespace Avalonia.Collections
private void VerifyRefreshNotDeferred() private void VerifyRefreshNotDeferred()
{ {
// If the Refresh is being deferred to change filtering or sorting of the // If the Refresh is being deferred to change filtering or sorting of the
// data by this PagedCollectionView, then PagedCollectionView will not reflect the correct // data by this DataGridCollectionView, then DataGridCollectionView will not reflect the correct
// state of the underlying data. // state of the underlying data.
if (IsRefreshDeferred) if (IsRefreshDeferred)
{ {
@ -4026,7 +4026,7 @@ namespace Avalonia.Collections
} }
/// <summary> /// <summary>
/// Used to keep track of Defer calls on the PagedCollectionView, which /// Used to keep track of Defer calls on the DataGridCollectionView, which
/// will prevent the user from calling Refresh() on the view. In order /// will prevent the user from calling Refresh() on the view. In order
/// to allow refreshes again, the user will have to call IDisposable.Dispose, /// to allow refreshes again, the user will have to call IDisposable.Dispose,
/// to end the Defer operation. /// to end the Defer operation.
@ -4036,13 +4036,13 @@ namespace Avalonia.Collections
/// <summary> /// <summary>
/// Private reference to the CollectionView that created this DeferHelper /// Private reference to the CollectionView that created this DeferHelper
/// </summary> /// </summary>
private CollectionViewBase collectionView; private DataGridCollectionView collectionView;
/// <summary> /// <summary>
/// Initializes a new instance of the DeferHelper class /// Initializes a new instance of the DeferHelper class
/// </summary> /// </summary>
/// <param name="collectionView">CollectionView that created this DeferHelper</param> /// <param name="collectionView">CollectionView that created this DeferHelper</param>
public DeferHelper(CollectionViewBase collectionView) public DeferHelper(DataGridCollectionView collectionView)
{ {
this.collectionView = collectionView; this.collectionView = collectionView;
} }
@ -4130,10 +4130,10 @@ namespace Avalonia.Collections
/// <summary> /// <summary>
/// Initializes a new instance of the NewItemAwareEnumerator class. /// Initializes a new instance of the NewItemAwareEnumerator class.
/// </summary> /// </summary>
/// <param name="collectionView">The PagedCollectionView we are creating the enumerator for</param> /// <param name="collectionView">The DataGridCollectionView we are creating the enumerator for</param>
/// <param name="baseEnumerator">The baseEnumerator that we pass in</param> /// <param name="baseEnumerator">The baseEnumerator that we pass in</param>
/// <param name="newItem">The new item we are adding to the collection</param> /// <param name="newItem">The new item we are adding to the collection</param>
public NewItemAwareEnumerator(CollectionViewBase collectionView, IEnumerator baseEnumerator, object newItem) public NewItemAwareEnumerator(DataGridCollectionView collectionView, IEnumerator baseEnumerator, object newItem)
{ {
_collectionView = collectionView; _collectionView = collectionView;
_timestamp = collectionView.Timestamp; _timestamp = collectionView.Timestamp;
@ -4204,7 +4204,7 @@ namespace Avalonia.Collections
/// <summary> /// <summary>
/// CollectionView that we are creating the enumerator for /// CollectionView that we are creating the enumerator for
/// </summary> /// </summary>
private CollectionViewBase _collectionView; private DataGridCollectionView _collectionView;
/// <summary> /// <summary>
/// The Base Enumerator that we are passing in /// The Base Enumerator that we are passing in
@ -4235,7 +4235,7 @@ namespace Avalonia.Collections
{ {
_comparers = MakeComparerArray(coll); _comparers = MakeComparerArray(coll);
} }
public MergedComparer(CollectionViewBase collectionView) public MergedComparer(DataGridCollectionView collectionView)
: this(collectionView.SortDescriptions) : this(collectionView.SortDescriptions)
{ } { }

10
src/Avalonia.Controls.DataGrid/DataGridDataConnection.cs

@ -87,7 +87,7 @@ namespace Avalonia.Controls
return list.Count; return list.Count;
} }
if(DataSource is CollectionViewBase cv) if(DataSource is DataGridCollectionView cv)
{ {
return cv.Count; return cv.Count;
} }
@ -342,7 +342,7 @@ namespace Avalonia.Controls
return (index < list.Count) ? list[index] : null; return (index < list.Count) ? list[index] : null;
} }
if (DataSource is CollectionViewBase collectionView) if (DataSource is DataGridCollectionView collectionView)
{ {
return (index < collectionView.Count) ? collectionView.GetItemAt(index) : null; return (index < collectionView.Count) ? collectionView.GetItemAt(index) : null;
} }
@ -413,7 +413,7 @@ namespace Avalonia.Controls
return list.IndexOf(dataItem); return list.IndexOf(dataItem);
} }
if (DataSource is CollectionViewBase cv) if (DataSource is DataGridCollectionView cv)
{ {
return cv.IndexOf(dataItem); return cv.IndexOf(dataItem);
} }
@ -453,7 +453,7 @@ namespace Avalonia.Controls
IDataGridCollectionView collectionView = null; IDataGridCollectionView collectionView = null;
if (source is ICollectionViewFactory collectionViewFactory) if (source is IDataGridCollectionViewFactory collectionViewFactory)
{ {
// If the source is a collection view factory, give it a chance to produce a custom collection view. // If the source is a collection view factory, give it a chance to produce a custom collection view.
collectionView = collectionViewFactory.CreateView(); collectionView = collectionViewFactory.CreateView();
@ -462,7 +462,7 @@ namespace Avalonia.Controls
if (collectionView == null) if (collectionView == null)
{ {
// If we still do not have a collection view, default to a PagedCollectionView. // If we still do not have a collection view, default to a PagedCollectionView.
collectionView = new CollectionViewBase(source); collectionView = new DataGridCollectionView(source);
} }
return collectionView; return collectionView;
} }

Loading…
Cancel
Save