Created
May 2, 2016 15:18
-
-
Save xximjasonxx/187abb12fa23345d10a84beabb592287 to your computer and use it in GitHub Desktop.
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
public ObservableCollection<TemperatureReading> ChartDataSource | |
{ | |
get { return _datasource; } | |
set | |
{ | |
if (value != null) | |
{ | |
if (value.Count == 0) | |
{ | |
_datasource = value; | |
_datasource.CollectionChanged += Datasource_CollectionChanged; | |
} | |
else if (value.Count > 0) | |
{ | |
// we are reentering | |
var item = value.ElementAt(0);; | |
InitializeChart(item.SensorData.Keys.Count); | |
InitializeChartPalette(); | |
} | |
} | |
if (HorizontalAxis == null) | |
InitializeHorizontalAxis(); | |
if (VerticalAxis == null) | |
InitializeVerticalAxis(); | |
} | |
} | |
void Datasource_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) | |
{ | |
if (e.NewItems != null && e.NewItems.Count > 0) | |
{ | |
if (_temperatureChartValueCollection == null) | |
{ | |
var item = ChartDataSource.ElementAt(0); // need to determine how many sensors are coming in | |
_temperatureChartValueCollection = new Com.Telerik.Android.Common.ObservableCollection(); | |
InitializeChart(item.SensorData.Keys.Count); | |
InitializeChartPalette(); | |
} | |
_temperatureChartValueCollection.Add(new TemperatureReadingChartValue((TemperatureReading)e.NewItems[0])); | |
} | |
if (e.Action == NotifyCollectionChangedAction.Remove) | |
{ | |
// at this stage the first index is the one that is always being removed | |
_temperatureChartValueCollection.Remove(0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment