代码拉取完成,页面将自动刷新
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);
// }
// }
//}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。