PageRenderTime 54ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/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
  1. using System.Data;
  2. using System.Linq;
  3. using System.Windows;
  4. using System.Collections.Generic;
  5. namespace Microsoft.Research.DynamicDataDisplay.DataSources
  6. {
  7. /// <summary>Data source that extracts sequence of points and their attributes from DataTable</summary>
  8. public class TableDataSource : EnumerableDataSource<DataRow>
  9. {
  10. public TableDataSource(DataTable table)
  11. : base(table.Rows)
  12. {
  13. // Subscribe to DataTable events
  14. table.TableNewRow += NewRowInsertedHandler;
  15. table.RowChanged += RowChangedHandler;
  16. table.RowDeleted += RowChangedHandler;
  17. }
  18. private void RowChangedHandler(object sender, DataRowChangeEventArgs e)
  19. {
  20. RaiseDataChanged();
  21. }
  22. private void NewRowInsertedHandler(object sender, DataTableNewRowEventArgs e)
  23. {
  24. // Raise DataChanged event. ChartPlotter should redraw graph.
  25. // This will be done automatically when rows are added to table.
  26. RaiseDataChanged();
  27. }
  28. }
  29. }