問題のあるトピックをたくさん見ました:
「オブジェクトには X の定義が含まれておらず、オブジェクト型の最初の引数を受け入れる拡張メソッド X もありません」
しかし、それらのどれも私の問題に対する解決策を持っていませんでした。
状況: 3 つの一連の DataPoint を保存したいと考えています。そのため、シリーズを保持するリストを作成しました:
List<OxyPlot.Series.DataPointSeries> filesToBeStored;
public OxyPlot.Series.DataPointSeries saveAnalyseBSITotal;
public OxyPlot.Series.DataPointSeries saveAnalyseSBSI;
public OxyPlot.Series.DataPointSeries saveAnalyseTBSI;
Form.cs で、SaveFile(...) を呼び出します。
for (int i = 0; i < plotSBSIBandsA.Model.Series.Count; i++)
{
OxyPlot.Series.DataPointSeries sA = (plotSBSIBandsA.Model.Series[i] as OxyPlot.Series.DataPointSeries);
OxyPlot.Series.DataPointSeries sB = (plotSBSIBandsB.Model.Series[i] as OxyPlot.Series.DataPointSeries);
sB.Points.Clear();
for (int j = 0; j < sA.Points.Count; j++)
{
sB.Points.Add(new OxyPlot.DataPoint(sA.Points[j].X, sA.Points[j].Y));
}
}
if(saveButtonClicked)
{this.SaveFile(sB)}
完全な保存クラスは次のとおりです。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BSIAnalyzer
{
class SaveFile
{
List<OxyPlot.Series.DataPointSeries> filesToBeStored;
public OxyPlot.Series.DataPointSeries saveAnalyseBSITotal;
public OxyPlot.Series.DataPointSeries saveAnalyseSBSI;
public OxyPlot.Series.DataPointSeries saveAnalyseTBSI;
public SaveFile(OxyPlot.Series.DataPointSeries sA)
{
for (int i = 0; i < sA.Points.Count; i++)
{
saveAnalyseBSITotal.Points.Add(new OxyPlot.DataPoint(sA.Points[i].X, sA.Points[i].Y));
}
}
public SaveFile(List<OxyPlot.Series.DataPointSeries> series)
{
filesToBeStored.Insert(0, saveAnalyseBSITotal);
filesToBeStored.Insert(1, saveAnalyseSBSI);
filesToBeStored.Insert(2, saveAnalyseTBSI);
for (int k = 0; k < series.Count; k++)
{
filesToBeStored[k].Points.Add(new OxyPlot.DataPoint(series[k].Points.X, series[k].Points.Y));
}
}
}
}
te "k" を使用した forloop でエラーが発生しました。