using System; using System.Collections.Generic; using System.Linq; using System.Text; using Abt.Controls.SciChart.Visuals.RenderableSeries; using System.ComponentModel; using System.Windows.Media; using Abt.Controls.SciChart.Model.DataSeries; using Aitex.Core.Util; namespace Aitex.Core.UI.View.Smart { /// /// Customized line series type /// public class SmartDataLine : FastLineRenderableSeries, INotifyPropertyChanged { /// /// 自定义曲线的构造函数 /// /// /// public SmartDataLine(string displayName, Color seriesColor, string dbName, bool isVisable) { //产生一随机的GUID作为每个曲线的标志号,方便后续对曲线的查找和操作 UniqueId = Guid.NewGuid().ToString(); //if (dataSource.Datas.ContainsKey(dbName)) // Points = dataSource.Datas[dbName]; //_dataSource = dataSource; //指名x、y坐标轴,此处和xaml文件中定义需一致 XAxisId = "DefaultAxisId"; YAxisId = "DefaultAxisId"; DataSeries = new XyDataSeries(); DisplayName = displayName; DbDataName = dbName; SeriesColor = seriesColor; DefaultSeriesColor = seriesColor; NextQueryTime = DateTime.MinValue; IsVisible = isVisable; IsDefaultVisable = isVisable; } /// /// 下一次获取数据的时间点 /// public DateTime NextQueryTime { get; set; } /// /// 是否默认显示 /// public bool IsDefaultVisable { get; set; } /// /// 默认的显示颜色 /// public Color DefaultSeriesColor { get; set; } /// /// related data source /// //PostgreSqlDataSource _dataSource; /// /// Series Name /// public string DbDataName { get; private set; } /// /// series line's display name /// public string DisplayName { get { return DataSeries.SeriesName; } set { DataSeries.SeriesName = value; InvokePropertyChanged("DisplayName"); } } /// /// series line's thickness /// public double LineThickness { get { return StrokeThickness; } set { var i = Convert.ToInt32(value); if (i < 1) i = 1; if (i > 100) i = 100; StrokeThickness = i; InvokePropertyChanged("LineThickness"); } } /// /// series object's unique id /// public string UniqueId { get; private set; } /// /// raw data points /// public DataItem Points { get; set; } #region PropertyChanged public event PropertyChangedEventHandler PropertyChanged; public void InvokePropertyChanged(string propertyName) { PropertyChangedEventArgs eventArgs = new PropertyChangedEventArgs(propertyName); PropertyChangedEventHandler changed = PropertyChanged; if (changed != null) { changed(this, eventArgs); } } public void InvokePropertyChanged() { Type t = this.GetType(); var ps = t.GetProperties(); foreach (var p in ps) { InvokePropertyChanged(p.Name); } } #endregion } }