using ErrorAnalysis.Service.Model; using OxyPlot.Axes; using OxyPlot.Legends; using OxyPlot.Series; using OxyPlot.WindowsForms; using OxyPlot; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace ErrorAnalysis.UI { public partial class ProcessingData : Form { ProcessingDataModel _model; public ProcessingData(ProcessingDataModel model) { _model = model; InitializeComponent(); } private void Plot(ProcessingDataModel model) { pnlCO.Controls.Clear(); pnlData.Controls.Clear(); var plotModel = new PlotModel(); var xAxis = new LinearAxis { Position = AxisPosition.Bottom, Title = "Porosity(%)" }; var yAxis = new LinearAxis { Position = AxisPosition.Left, Title = "C/O" }; xAxis.MajorGridlineStyle = LineStyle.DashDashDotDot; yAxis.MajorGridlineStyle = LineStyle.DashDot; plotModel.Axes.Add(xAxis); plotModel.Axes.Add(yAxis); // 创建曲线系列 var oSeries = new LineSeries { Title = "Water Line", Color = OxyColors.MediumBlue }; var cSeries = new LineSeries { Title = "Oil Line", Color = OxyColors.DarkRed }; var oOriginSeries = new LineSeries { Title = "Water Line Origin", Color = OxyColors.MediumPurple }; var cOriginSeries = new LineSeries { Title = "Oil Line Origin", Color = OxyColors.DarkOrange }; foreach (var o in model.WaterLine) oSeries.Points.Add(new DataPoint(o[0], o[1])); foreach (var c in model.OilLine) cSeries.Points.Add(new DataPoint(c[0], c[1])); foreach (var o in model.WaterLineOrgin) oOriginSeries.Points.Add(new DataPoint(o[0], o[1])); foreach (var c in model.OilLineOrigin) cOriginSeries.Points.Add(new DataPoint(c[0], c[1])); plotModel.Legends.Add(new Legend { LegendPosition = LegendPosition.TopLeft }); // 添加曲线到图表模型 plotModel.Series.Add(oSeries); plotModel.Series.Add(cSeries); plotModel.Series.Add(cOriginSeries); plotModel.Series.Add(oOriginSeries); // 可视化代码 // 创建 Windows 窗体以显示图表 var plotView = new PlotView { Model = plotModel }; plotView.Dock = DockStyle.Fill; pnlCO.Controls.Add(plotView); pnlData.Controls.Clear(); plotModel = new PlotModel(); xAxis = new LinearAxis { Position = AxisPosition.Bottom, Title = "Track" }; xAxis.MajorGridlineStyle = LineStyle.Dash; var logYAxis = new LogarithmicAxis { Position = AxisPosition.Left, Title = "Counting" }; logYAxis.MajorGridlineStyle = LineStyle.Dash; plotModel.Axes.Add(xAxis); plotModel.Axes.Add(logYAxis); var farSeries = new LineSeries { Title = "Far Spectrum", Color = OxyColors.MediumBlue }; var nearSeries = new LineSeries { Title = "Near Spectrum", Color = OxyColors.MediumPurple }; foreach (var item in model.FarSpecData) farSeries.Points.Add(new DataPoint(item[0], item[1])); foreach (var item in model.NearSpecData) nearSeries.Points.Add(new DataPoint(item[0], item[1])); plotModel.Legends.Add(new Legend { LegendPosition = LegendPosition.TopRight }); plotModel.Series.Add(farSeries); plotModel.Series.Add(nearSeries); plotView = new PlotView { Model = plotModel }; plotView.Dock = DockStyle.Fill; pnlData.Controls.Add(plotView); } private void btnClose_Click(object sender, EventArgs e) { Close(); Dispose(); } private void ProcessingData_Load(object sender, EventArgs e) { txtNearCC.Text = _model.NearCC.ToString(); txtNearOC.Text = _model.NearOC.ToString(); txtNearCR.Text = _model.NearCR.ToString(); txtNearOR.Text = _model.NearOR.ToString(); txtFarCC.Text = _model.FarCC.ToString(); txtFarOC.Text = _model.FarOC.ToString(); txtFarCR.Text = _model.FarCR.ToString(); txtFarOR.Text = _model.FarOR.ToString(); txtNearTO.Text = _model.NearTO.ToString(); txtFarTO.Text = _model.FarTO.ToString(); txtNearPDEV.Text = _model.NearPDEV.ToString(); txtFarPDEV.Text = _model.FarPDEV.ToString(); txtMergePDEV.Text = _model.MergePDEV.ToString(); txtOilLinePoint.Text = _model.OilPoint.ToString(); txtWaterLinePoint.Text = _model.WaterPoint.ToString(); txtMergeDelta.Text = _model.MergeDelta.ToString(); txtFarTO.Text = _model.FarTO.ToString(); txtNearTO.Text = _model.NearTO.ToString(); Plot(_model); pnlCO.Focus(); } } }