-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
407 additions
and
238 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
|
||
namespace Sungaila.SUBSTitute.Extensions; | ||
|
||
/// <summary> | ||
/// A collection view implementation that supports filtering, grouping, sorting and incremental loading | ||
/// </summary> | ||
public partial class HackedCollectionView | ||
{ | ||
/// <summary> | ||
/// Stops refreshing until it is disposed | ||
/// </summary> | ||
/// <returns>An disposable object</returns> | ||
public IDisposable DeferRefresh() | ||
{ | ||
return new NotificationDeferrer(this); | ||
} | ||
|
||
/// <summary> | ||
/// Notification deferrer helper class | ||
/// </summary> | ||
#pragma warning disable CA1063 // Implement IDisposable Correctly | ||
public partial class NotificationDeferrer : IDisposable | ||
#pragma warning restore CA1063 // Implement IDisposable Correctly | ||
{ | ||
private readonly HackedCollectionView _acvs; | ||
private readonly object _currentItem; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="NotificationDeferrer"/> class. | ||
/// </summary> | ||
/// <param name="acvs">Source ACVS</param> | ||
public NotificationDeferrer(HackedCollectionView acvs) | ||
{ | ||
_acvs = acvs; | ||
_currentItem = _acvs.CurrentItem; | ||
_acvs._deferCounter++; | ||
} | ||
|
||
/// <summary> | ||
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. | ||
/// </summary> | ||
/// <filterpriority>2</filterpriority> | ||
#pragma warning disable CA1063 // Implement IDisposable Correctly | ||
public void Dispose() | ||
#pragma warning restore CA1063 // Implement IDisposable Correctly | ||
{ | ||
_acvs.MoveCurrentTo(_currentItem); | ||
_acvs._deferCounter--; | ||
_acvs.Refresh(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using Microsoft.UI.Xaml.Data; | ||
using Windows.Foundation.Collections; | ||
|
||
namespace Sungaila.SUBSTitute.Extensions; | ||
|
||
/// <summary> | ||
/// A collection view implementation that supports filtering, grouping, sorting and incremental loading | ||
/// </summary> | ||
public partial class HackedCollectionView | ||
{ | ||
/// <summary> | ||
/// Currently selected item changing event | ||
/// </summary> | ||
/// <param name="e">event args</param> | ||
private void OnCurrentChanging(CurrentChangingEventArgs e) | ||
{ | ||
if (_deferCounter > 0) | ||
{ | ||
return; | ||
} | ||
|
||
CurrentChanging?.Invoke(this, e); | ||
} | ||
|
||
/// <summary> | ||
/// Currently selected item changed event | ||
/// </summary> | ||
/// <param name="e">event args</param> | ||
private void OnCurrentChanged(object e) | ||
{ | ||
if (_deferCounter > 0) | ||
{ | ||
return; | ||
} | ||
|
||
CurrentChanged?.Invoke(this, e); | ||
|
||
// ReSharper disable once ExplicitCallerInfoArgument | ||
OnPropertyChanged(nameof(CurrentItem)); | ||
} | ||
|
||
/// <summary> | ||
/// Vector changed event | ||
/// </summary> | ||
/// <param name="e">event args</param> | ||
private void OnVectorChanged(IVectorChangedEventArgs e) | ||
{ | ||
if (_deferCounter > 0) | ||
{ | ||
return; | ||
} | ||
|
||
VectorChanged?.Invoke(this, e); | ||
|
||
// ReSharper disable once ExplicitCallerInfoArgument | ||
OnPropertyChanged(nameof(Count)); | ||
} | ||
} |
Oops, something went wrong.