This commit is contained in:
2024-02-23 06:53:16 -05:00
commit dbdccce727
1094 changed files with 57645 additions and 0 deletions

View File

@@ -0,0 +1,57 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Diagnostics;
using System.Windows;
using Xamarin.Forms;
namespace DataDisplay.DataSource
{
/// <summary>Base class for all sources who receive data for charting
/// from any IEnumerable of T</summary>
/// <typeparam name="T">Type of items in IEnumerable</typeparam>
public abstract class EnumerableDataSourceBase<T> : IPointDataSource {
private IEnumerable data;
/// <summary>
/// Gets or sets the data.
/// </summary>
/// <value>The data.</value>
public IEnumerable Data {
get { return data; }
set {
if (value == null)
throw new ArgumentNullException("value");
data = value;
var observableCollection = data as INotifyCollectionChanged;
if (observableCollection != null) {
observableCollection.CollectionChanged += observableCollection_CollectionChanged;
}
}
}
protected EnumerableDataSourceBase(IEnumerable<T> data) : this((IEnumerable)data) { }
protected EnumerableDataSourceBase(IEnumerable data) {
if (data == null)
throw new ArgumentNullException("data");
Data = data;
}
private void observableCollection_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) {
RaiseDataChanged();
}
public event EventHandler DataChanged;
public void RaiseDataChanged() {
if (DataChanged != null) {
DataChanged(this, EventArgs.Empty);
}
}
public abstract IPointEnumerator GetEnumerator(BindableObject context);
}
}