我有几个数组来从postgreSQL查询中收集数据。数据来自现场部署的RF接收器。当用户建立查询的频率和时间范围时,数据显示在网格视图上并从那里传递到由I值指示的阵列和与包含RF接收器的纬度的列中的单元编号匹配的I +值。此数据用于绘制表示(频率,幅度),(频率,带宽)等的xy散点图。我想创建一个列表和对象,而不是使用数组。
private void button11_Click(object sender, EventArgs e)
dataGridView1.SelectAll();
numCells = dataGridView1.SelectedCells.Count;
for (i = 14; i < (numCells); i += 14)
{
if (i < numCells)
{
if (Convert.ToDouble(dataGridView1.SelectedCells[i + 11].Value.ToString()== 28.464258839)
{
UCS1size += 1;
}
else if (Convert.ToDouble(dataGridView1.SelectedCells[i + 11].Value.ToStrin()) == 28.42859146)
{
MOCsize += 1;
}
else if (Convert.ToDouble(dataGridView1.SelectedCells[i + 11].Value.ToStrin()) == 28.490616471)
{
AMsize += 1;
}
else if (Convert.ToDouble(dataGridView1.SelectedCells[i + 11].Value.ToStrin()) == 28.525409911)
{
UCS2size += 1;
}
else if (Convert.ToDouble(dataGridView1.SelectedCells[i + 11].Value.ToStrin()) == 28.560529988)
{
LC40size += 1;
}
}
else
{
MessageBox.Show("exiting for loop. numcells: " + numCells);
}
}
double[] freqLC40 = new double[LC40size];
double[] ampMaxLC40 = new double[LC40size];
double[] freqMOC = new double[MOCsize];
double[] ampMaxMOC = new double[MOCsize];
double[] freqUCS1 = new double[UCS1size];
double[] ampMaxUCS1 = new double[UCS1size];
double[] freqUCS2 = new double[UCS2size];
double[] ampMaxUCS2 = new double[UCS2size];
double[] freqAM = new double[AMsize];
double[] ampMaxAM = new double[AMsize];
int LC40idx = 0;
int MOCidx = 0;
int UCS1idx = 0;
int UCS2idx = 0;
int AMsidx = 0;
for (i = 14; i < (numCells); i += 14)
{
if (i < numCells)
{
if (Convert.ToDouble(dataGridView1.SelectedCells[i + 11].Value.ToString())== 28.464258839)
{
freqUCS1[UCS1idx] = Convert.ToDouble(dataGridView1.SelectedCell[i].Value.ToString());
ampMaxUCS1[UCS1idx] = Convert.ToDouble(dataGridView1.SelectedCells[i +9].Value.ToString());
UCS1idx += 1;
}
else if (Convert.ToDouble(dataGridView1.SelectedCells[i +11].Value.ToString()) == 28.42859146)
{
freqMOC[MOCidx] = Convert.ToDouble(dataGridView1.SelectedCells[i].Value.ToString());
ampMaxMOC[MOCidx] = Convert.ToDouble(dataGridView1.SelectedCells[i +9].Value.ToString());
MOCidx += 1;
}
else if (Convert.ToDouble(dataGridView1.SelectedCells[i + 11].Value.ToString()) == 28.490616471)
{
freqAM[AMsidx] = Convert.ToDouble(dataGridView1.SelectedCells[i].Value.ToString());
ampMaxAM[AMsidx] = Convert.ToDouble(dataGridView1.SelectedCells[i + 9].Value.ToString());
AMsidx += 1;
}
else if (Convert.ToDouble(dataGridView1.SelectedCells[i + 11].Value.ToString()) == 28.525409911)
{
freqUCS2[UCS2idx] = Convert.ToDouble(dataGridView1.SelectedCells[i].Value.ToString());
ampMaxUCS2[UCS2idx] = Convert.ToDouble(dataGridView1.SelectedCells[i +9].Value.ToString());
UCS2idx += 1;
}
else if (Convert.ToDouble(dataGridView1.SelectedCells[i + 11].Value.ToString()) == 28.560529988)
{
freqLC40[LC40idx] = Convert.ToDouble(dataGridView1.SelectedCells[i].Value.ToString());
ampMaxLC40[LC40idx] = Convert.ToDouble(dataGridView1.SelectedCells[i+9].Value.ToString());
LC40idx += 1;
}
}
else
{
MessageBox.Show("exiting for loop. numcells: " + numCells);
}
}
//get XY form LC40
xyForm = new XYplotForm();
xyForm.Plot(freqLC40, ampMaxLC40, "LC-40 Max Amplitude");
xyForm.Show();