file scoped namespaces (#565)
This commit is contained in:
@@ -3,47 +3,46 @@ using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
|
||||
namespace Wino.MenuFlyouts
|
||||
namespace Wino.MenuFlyouts;
|
||||
|
||||
public partial class WinoOperationFlyout<TActionType> : MenuFlyout, IDisposable where TActionType : class
|
||||
{
|
||||
public partial class WinoOperationFlyout<TActionType> : MenuFlyout, IDisposable where TActionType : class
|
||||
public TActionType ClickedOperation { get; set; }
|
||||
|
||||
protected readonly IEnumerable<TActionType> AvailableActions;
|
||||
|
||||
private readonly TaskCompletionSource<TActionType> _completionSource;
|
||||
|
||||
public WinoOperationFlyout(IEnumerable<TActionType> availableActions, TaskCompletionSource<TActionType> completionSource)
|
||||
{
|
||||
public TActionType ClickedOperation { get; set; }
|
||||
_completionSource = completionSource;
|
||||
|
||||
protected readonly IEnumerable<TActionType> AvailableActions;
|
||||
AvailableActions = availableActions;
|
||||
|
||||
private readonly TaskCompletionSource<TActionType> _completionSource;
|
||||
Closing += FlyoutClosing;
|
||||
}
|
||||
|
||||
public WinoOperationFlyout(IEnumerable<TActionType> availableActions, TaskCompletionSource<TActionType> completionSource)
|
||||
private void FlyoutClosing(Windows.UI.Xaml.Controls.Primitives.FlyoutBase sender, Windows.UI.Xaml.Controls.Primitives.FlyoutBaseClosingEventArgs args)
|
||||
{
|
||||
Closing -= FlyoutClosing;
|
||||
|
||||
_completionSource.TrySetResult(ClickedOperation);
|
||||
}
|
||||
|
||||
protected void MenuItemClicked(TActionType operation)
|
||||
{
|
||||
ClickedOperation = operation;
|
||||
|
||||
Hide();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
foreach (var item in Items)
|
||||
{
|
||||
_completionSource = completionSource;
|
||||
|
||||
AvailableActions = availableActions;
|
||||
|
||||
Closing += FlyoutClosing;
|
||||
}
|
||||
|
||||
private void FlyoutClosing(Windows.UI.Xaml.Controls.Primitives.FlyoutBase sender, Windows.UI.Xaml.Controls.Primitives.FlyoutBaseClosingEventArgs args)
|
||||
{
|
||||
Closing -= FlyoutClosing;
|
||||
|
||||
_completionSource.TrySetResult(ClickedOperation);
|
||||
}
|
||||
|
||||
protected void MenuItemClicked(TActionType operation)
|
||||
{
|
||||
ClickedOperation = operation;
|
||||
|
||||
Hide();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
foreach (var item in Items)
|
||||
if (item is IDisposable disposableItem)
|
||||
{
|
||||
if (item is IDisposable disposableItem)
|
||||
{
|
||||
disposableItem.Dispose();
|
||||
}
|
||||
disposableItem.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user