Work in progress

This commit is contained in:
watsonb8
2019-12-18 20:23:59 -05:00
parent 555eb07ec1
commit 93dc9ae8c9
9 changed files with 166 additions and 112 deletions

View File

@ -2,8 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using Xamarin.Forms;
using System.ComponentModel;
using System.Collections.Specialized;
namespace Aurora.Design.Components.Library
{
@ -33,51 +31,9 @@ namespace Aurora.Design.Components.Library
propertyChanged: (BindableObject bindable, object oldValue, object newValue) =>
{
Library control = bindable as Library;
var libraryDataGrid = control.LibraryDataGrid;
libraryDataGrid.ItemsSource = newValue as IEnumerable<object>;
if (newValue is INotifyPropertyChanged)
{
var collection = newValue as INotifyCollectionChanged;
collection.CollectionChanged += (object sender, NotifyCollectionChangedEventArgs eventArgs) =>
OnItemSourceCollectionChanged(sender, eventArgs, bindable);
}
if (oldValue is INotifyPropertyChanged)
{
var collection = newValue as INotifyCollectionChanged;
collection.CollectionChanged -= (object sender, NotifyCollectionChangedEventArgs eventArgs) =>
OnItemSourceCollectionChanged(sender, eventArgs, bindable);
}
control.LibraryDataGrid.ItemsSource = (IEnumerable<object>)newValue;
});
private static void OnItemSourceCollectionChanged(object sender, NotifyCollectionChangedEventArgs e, BindableObject bindable)
{
if (sender is IEnumerable<object>)
{
Library control = bindable as Library;
var libraryDataGrid = control.LibraryDataGrid;
var collection = libraryDataGrid.ItemsSource as IEnumerable<object>;
if (e.NewItems != null)
{
foreach (object obj in e.NewItems)
{
collection.Concat(new[] { obj });
}
}
if (e.OldItems != null)
{
foreach (object obj in e.OldItems)
{
var list = collection.ToList();
list.Remove(obj);
collection = list;
}
}
}
}
/// <summary>
/// Backing property for the ItemsSource property.
@ -164,10 +120,10 @@ namespace Aurora.Design.Components.Library
private static void OnDoubleClickPropertyChanged(BindableObject bindable, object newValue, object oldValue)
{
Library control = bindable as Library;
var queueDataGrid = control.LibraryDataGrid;
if (queueDataGrid.GestureRecognizers.Count > 0)
var dataGrid = control.LibraryDataGrid;
if (dataGrid.GestureRecognizers.Count > 0)
{
var gestureRecognizer = queueDataGrid.GestureRecognizers.First();
var gestureRecognizer = dataGrid.GestureRecognizers.First();
if (gestureRecognizer is TapGestureRecognizer)
{