/Main/src/DynamicDataDisplay/DataSources/OneDimensional/TableDataSource.cs
C# | 32 lines | 25 code | 3 blank | 4 comment | 0 complexity | c0102955f6c29f925ab061d145b270bf MD5 | raw file
Possible License(s): CC-BY-SA-3.0
1using System.Data; 2using System.Linq; 3using System.Windows; 4using System.Collections.Generic; 5 6namespace Microsoft.Research.DynamicDataDisplay.DataSources 7{ 8 /// <summary>Data source that extracts sequence of points and their attributes from DataTable</summary> 9 public class TableDataSource : EnumerableDataSource<DataRow> 10 { 11 public TableDataSource(DataTable table) 12 : base(table.Rows) 13 { 14 // Subscribe to DataTable events 15 table.TableNewRow += NewRowInsertedHandler; 16 table.RowChanged += RowChangedHandler; 17 table.RowDeleted += RowChangedHandler; 18 } 19 20 private void RowChangedHandler(object sender, DataRowChangeEventArgs e) 21 { 22 RaiseDataChanged(); 23 } 24 25 private void NewRowInsertedHandler(object sender, DataTableNewRowEventArgs e) 26 { 27 // Raise DataChanged event. ChartPlotter should redraw graph. 28 // This will be done automatically when rows are added to table. 29 RaiseDataChanged(); 30 } 31 } 32}