2 Star 5 Fork 3

彭添 / SerialPlot_PT

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
MainViewModel.cs 4.23 KB
一键复制 编辑 原始数据 按行查看 历史
彭添 提交于 2015-08-13 01:36 . FirstSync
using OxyPlot;
using OxyPlot.Series;
using System.Collections.Generic;
namespace 帆板仪表盘
{
public class MainViewModel : Observable
{
public PlotModel model=new PlotModel("Waiting Connect", "");
// public List<PlotModel> models = new List<PlotModel>();
// LineSeries series1 = new LineSeries("Series 1") { MarkerType = MarkerType.Circle };
private List<DataPoint> lastDPs = new List<DataPoint>();
//public List<PlotModel> Models
//{
// get { return models; }
// set
// {
// models = value;
// RaisePropertyChanged(() => Models);
// }
//}
public MainViewModel()
{
// Create the plot model
// var tmp = new PlotModel("Simple example", "using OxyPlot");
// Create two line series (markers are hidden by default)
//Model.Series.Add(Series1);
// Series1.Points.Add(new DataPoint(30, 8));
// Series1.Points.Add(new DataPoint(40, 18));
// var series2 = new LineSeries("Series 2") { MarkerType = MarkerType.Square };
// RaisePropertyChanged(() => Model);
// Axes are created automatically if they are not defined
// Set the Model property, the INotifyPropertyChanged event will make the WPF Plot control update its content
}
public void Add(double x, double y,string tA,string tB)
{
// Model = null;
var tmp = new PlotModel(tA,tB);
var series2 = new LineSeries() { MarkerType = MarkerType.None };
series2.StrokeThickness = 1;
series2.MarkerType = MarkerType.Cross;
lastDPs.Add(new DataPoint(x, y));
if (lastDPs.Count > 200)
{
lastDPs.RemoveRange(0, lastDPs.Count - 200);
}
foreach (DataPoint item in lastDPs)
{
series2.Points.Add(item);
}
series2.Points.Add(new DataPoint(x, y));
// Model.Series.Add(series2);
tmp.Series.Add(series2);
Model = tmp;
// models.Add(Model);
// Add the series to the plot model
#region MyRegion
// var tmp = new PlotModel("Simple example", "using OxyPlot");
//// Create two line series (markers are hidden by default)
//var series1 = new LineSeries("Series 1") { MarkerType = MarkerType.Circle };
//series1.Points.Add(new DataPoint(0, 0));
//series1.Points.Add(new DataPoint(10, 18));
//series1.Points.Add(new DataPoint(20, 12));
//series1.Points.Add(new DataPoint(30, 8));
//series1.Points.Add(new DataPoint(40, 15));
//var series2 = new LineSeries("Series 2") { MarkerType = MarkerType.Square };
//series2.Points.Add(new DataPoint(0, 4));
//series2.Points.Add(new DataPoint(10, 12));
//series2.Points.Add(new DataPoint(20, 16));
//series2.Points.Add(new DataPoint(30, 25));
//series2.Points.Add(new DataPoint(40, 5));
//// Add the series to the plot model
//tmp.Series.Add(series1);
//tmp.Series.Add(series2);
//// Axes are created automatically if they are not defined
//// Set the Model property, the INotifyPropertyChanged event will make the WPF Plot control update its content
//Model = tmp;
#endregion
}
public PlotModel Model
{
get { return model; }
set
{
// bool f = ((model.Series[0]) as LineSeries)!=null?true:false;
if (model != value)
{
model = value;
RaisePropertyChanged(() => Model);
}
}
}
//public LineSeries Series1
//{
// get { return series1; }
// set {
// if (series1 != value)
// {
// series1 = value;
// RaisePropertyChanged(() => Model);
// }
// }
//}
}
}
1
https://gitee.com/pengtianabc/SerialPlot_PT.git
git@gitee.com:pengtianabc/SerialPlot_PT.git
pengtianabc
SerialPlot_PT
SerialPlot_PT
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891