SmartDataLine.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using SciChart.Charting.Visuals.RenderableSeries;
  6. using System.ComponentModel;
  7. using System.Windows.Media;
  8. using SciChart.Charting.Model.DataSeries;
  9. using Aitex.Core.Util;
  10. namespace Aitex.Core.UI.View.Smart
  11. {
  12. /// <summary>
  13. /// Customized line series type
  14. /// </summary>
  15. public class SmartDataLine : FastLineRenderableSeries, INotifyPropertyChanged
  16. {
  17. public SmartDataLine(string displayName, Color seriesColor, string dbName, bool isVisable)
  18. {
  19. UniqueId = Guid.NewGuid().ToString();
  20. XAxisId = "DefaultAxisId";
  21. YAxisId = "DefaultAxisId";
  22. DataSeries = new XyDataSeries<DateTime, float>();
  23. DisplayName = displayName;
  24. DbDataName = dbName;
  25. Stroke = seriesColor;
  26. DefaultSeriesColor = seriesColor;
  27. NextQueryTime = DateTime.MinValue;
  28. IsVisible = isVisable;
  29. IsDefaultVisable = isVisable;
  30. }
  31. public DateTime NextQueryTime { get; set; }
  32. public bool IsDefaultVisable { get; set; }
  33. public Color DefaultSeriesColor { get; set; }
  34. public string DbDataName { get; private set; }
  35. public string DisplayName
  36. {
  37. get
  38. {
  39. return DataSeries.SeriesName;
  40. }
  41. set
  42. {
  43. DataSeries.SeriesName = value;
  44. InvokePropertyChanged("DisplayName");
  45. }
  46. }
  47. /// <summary>
  48. /// series line's thickness
  49. /// </summary>
  50. public double LineThickness
  51. {
  52. get
  53. {
  54. return StrokeThickness;
  55. }
  56. set
  57. {
  58. var i = Convert.ToInt32(value);
  59. if (i < 1) i = 1;
  60. if (i > 100) i = 100;
  61. StrokeThickness = i;
  62. InvokePropertyChanged("LineThickness");
  63. }
  64. }
  65. /// <summary>
  66. /// series object's unique id
  67. /// </summary>
  68. public string UniqueId { get; private set; }
  69. /// <summary>
  70. /// raw data points
  71. /// </summary>
  72. public DataItem Points { get; set; }
  73. #region PropertyChanged
  74. public event PropertyChangedEventHandler PropertyChanged;
  75. public void InvokePropertyChanged(string propertyName)
  76. {
  77. PropertyChangedEventArgs eventArgs = new PropertyChangedEventArgs(propertyName);
  78. PropertyChangedEventHandler changed = PropertyChanged;
  79. if (changed != null)
  80. {
  81. changed(this, eventArgs);
  82. }
  83. }
  84. public void InvokePropertyChanged()
  85. {
  86. Type t = this.GetType();
  87. var ps = t.GetProperties();
  88. foreach (var p in ps)
  89. {
  90. InvokePropertyChanged(p.Name);
  91. }
  92. }
  93. #endregion
  94. }
  95. }