Start refining the UI
This commit is contained in:
@@ -37,17 +37,22 @@ public partial class ObservableCollection<TItem> :
|
|||||||
private readonly System.Collections.ObjectModel.ObservableCollection<TItem> collection = [];
|
private readonly System.Collections.ObjectModel.ObservableCollection<TItem> collection = [];
|
||||||
|
|
||||||
private readonly Queue<object> pendingEvents = [];
|
private readonly Queue<object> pendingEvents = [];
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private bool activated;
|
private bool activated;
|
||||||
|
|
||||||
private bool clearing;
|
private bool clearing;
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
private int count;
|
||||||
|
|
||||||
|
private IDispatcher dispatcher;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private bool initialized;
|
private bool initialized;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private TItem? selectedItem;
|
private TItem? selectedItem;
|
||||||
|
|
||||||
private IDispatcher dispatcher;
|
|
||||||
public ObservableCollection(IServiceProvider provider,
|
public ObservableCollection(IServiceProvider provider,
|
||||||
IServiceFactory factory,
|
IServiceFactory factory,
|
||||||
IMediator mediator,
|
IMediator mediator,
|
||||||
@@ -92,9 +97,6 @@ public partial class ObservableCollection<TItem> :
|
|||||||
public event NotifyCollectionChangedEventHandler? CollectionChanged;
|
public event NotifyCollectionChangedEventHandler? CollectionChanged;
|
||||||
|
|
||||||
public event EventHandler? DeactivateHandler;
|
public event EventHandler? DeactivateHandler;
|
||||||
|
|
||||||
public int Count => collection.Count;
|
|
||||||
|
|
||||||
public IDisposer Disposer { get; private set; }
|
public IDisposer Disposer { get; private set; }
|
||||||
|
|
||||||
public IServiceFactory Factory { get; private set; }
|
public IServiceFactory Factory { get; private set; }
|
||||||
@@ -282,22 +284,6 @@ public partial class ObservableCollection<TItem> :
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateSelection(TItem item)
|
|
||||||
{
|
|
||||||
if (item is ISelectable newSelection)
|
|
||||||
{
|
|
||||||
if (newSelection.Selected)
|
|
||||||
{
|
|
||||||
if (SelectedItem is ISelectable oldSelection)
|
|
||||||
{
|
|
||||||
oldSelection.Selected = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
dispatcher.Invoke(() => SelectedItem = item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task Handle(InsertEventArgs<TItem> args)
|
public Task Handle(InsertEventArgs<TItem> args)
|
||||||
{
|
{
|
||||||
if (Activated)
|
if (Activated)
|
||||||
@@ -564,8 +550,27 @@ public partial class ObservableCollection<TItem> :
|
|||||||
private static bool IsCompatibleObject(object? value) =>
|
private static bool IsCompatibleObject(object? value) =>
|
||||||
(value is TItem) || (value == null && default(TItem) == null);
|
(value is TItem) || (value == null && default(TItem) == null);
|
||||||
|
|
||||||
private void OnCollectionChanged(object? sender, NotifyCollectionChangedEventArgs args) =>
|
private void OnCollectionChanged(object? sender, NotifyCollectionChangedEventArgs args)
|
||||||
|
{
|
||||||
|
Count = collection.Count;
|
||||||
CollectionChanged?.Invoke(this, args);
|
CollectionChanged?.Invoke(this, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateSelection(TItem item)
|
||||||
|
{
|
||||||
|
if (item is ISelectable newSelection)
|
||||||
|
{
|
||||||
|
if (newSelection.Selected)
|
||||||
|
{
|
||||||
|
if (SelectedItem is ISelectable oldSelection)
|
||||||
|
{
|
||||||
|
oldSelection.Selected = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
dispatcher.Invoke(() => SelectedItem = item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public partial class ObservableCollection<TValue, TViewModel>(IServiceProvider provider,
|
public partial class ObservableCollection<TValue, TViewModel>(IServiceProvider provider,
|
||||||
|
|||||||
@@ -3,6 +3,4 @@
|
|||||||
namespace Toolkit.UI.Avalonia;
|
namespace Toolkit.UI.Avalonia;
|
||||||
|
|
||||||
public class ItemInvokedEventArgs :
|
public class ItemInvokedEventArgs :
|
||||||
RoutedEventArgs
|
RoutedEventArgs;
|
||||||
{
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user