Line | |
---|
1 | using System.Data;
|
---|
2 | using System.Linq;
|
---|
3 | using System.Windows;
|
---|
4 | using System.Collections.Generic;
|
---|
5 |
|
---|
6 | namespace 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 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.