刷新并清除 Oxyplot 模型
Refresh and Clear Oxyplot Model
我正在创建一个程序,它在 btnCalculate_Click
之后使用 oxyplot
创建一个情节。我该怎么做才能在更改文本框值并单击 btnCalculate
时刷新绘图?我也有 btnPrint
并且点击它应该清除情节?
public void btnCalculate_Click(object sender, EventArgs e)
{
Pko = float.Parse(textBox5.Text);
//Plotting Using Oxyplots
OxyPlot.WindowsForms.PlotView pv = new PlotView();
pv.Location = new Point(650, 0);
pv.Size = new Size(900, 815);
this.Controls.Add(pv);
pv.Model = new PlotModel { Title = "Program" };
pv.Model.InvalidatePlot(true);
//Pko line from surface to depth
LineSeries Pkoline = new LineSeries();
Pkoline.Color = OxyColors.Black;
Pkoline.LineStyle = LineStyle.Solid;
Pkoline.StrokeThickness = 1;
Pkoline.Points.Add(new DataPoint(Pko, 0));
Pkoline.Points.Add(new DataPoint(100, 200));
pv.Model.Series.Add()
}
private void btnClear_Click(object sender, EventArgs e)
{
}
首先,您需要为绘图定义变量,以便在不同的事件处理程序中调用它。通关剧情就是通关系列合集
private readonly PlotView _pv;
public Form1()
{
InitializeComponent();
//moved initialization from btnCalculate_Click
_pv = new PlotView();
this.Controls.Add(_pv);
_pv.Location = new Point(0, 0);
_pv.Size = new Size(500, 500);
_pv.Model = new PlotModel {Title = "Program"};
_pv.Model.InvalidatePlot(true);
}
private void btnCalculate_Click(object sender, EventArgs e)
{
// keep old code Except _pv initialization
_pv.Model.Series.Add(Pkoline);//typo in old code
}
private void clearBtn_Click(object sender, EventArgs e)
{
_pv.Model.InvalidatePlot(true);
_pv.Model.Series.Clear();
}
我正在创建一个程序,它在 btnCalculate_Click
之后使用 oxyplot
创建一个情节。我该怎么做才能在更改文本框值并单击 btnCalculate
时刷新绘图?我也有 btnPrint
并且点击它应该清除情节?
public void btnCalculate_Click(object sender, EventArgs e)
{
Pko = float.Parse(textBox5.Text);
//Plotting Using Oxyplots
OxyPlot.WindowsForms.PlotView pv = new PlotView();
pv.Location = new Point(650, 0);
pv.Size = new Size(900, 815);
this.Controls.Add(pv);
pv.Model = new PlotModel { Title = "Program" };
pv.Model.InvalidatePlot(true);
//Pko line from surface to depth
LineSeries Pkoline = new LineSeries();
Pkoline.Color = OxyColors.Black;
Pkoline.LineStyle = LineStyle.Solid;
Pkoline.StrokeThickness = 1;
Pkoline.Points.Add(new DataPoint(Pko, 0));
Pkoline.Points.Add(new DataPoint(100, 200));
pv.Model.Series.Add()
}
private void btnClear_Click(object sender, EventArgs e)
{
}
首先,您需要为绘图定义变量,以便在不同的事件处理程序中调用它。通关剧情就是通关系列合集
private readonly PlotView _pv;
public Form1()
{
InitializeComponent();
//moved initialization from btnCalculate_Click
_pv = new PlotView();
this.Controls.Add(_pv);
_pv.Location = new Point(0, 0);
_pv.Size = new Size(500, 500);
_pv.Model = new PlotModel {Title = "Program"};
_pv.Model.InvalidatePlot(true);
}
private void btnCalculate_Click(object sender, EventArgs e)
{
// keep old code Except _pv initialization
_pv.Model.Series.Add(Pkoline);//typo in old code
}
private void clearBtn_Click(object sender, EventArgs e)
{
_pv.Model.InvalidatePlot(true);
_pv.Model.Series.Clear();
}