private void button2_Click(object sender, EventArgs e) { int i; int j; int k = 0; filesave.muserchannel.Clear(); for (i = 0; i < this.uListEditor1.dataGridView1.Rows.Count; i++) { CComLibrary.userchannelitem muserchannelitem = new CComLibrary.userchannelitem(); muserchannelitem.channelname = uListEditor1.dataGridView1.Rows[i].Cells[0].Value.ToString(); muserchannelitem.channelvalue = uListEditor1.dataGridView1.Rows[i].Tag as string; muserchannelitem.channelunit = uListEditor1.dataGridView1.Rows[i].Cells[2].Value.ToString(); DataGridViewComboBoxCell dcc = (DataGridViewComboBoxCell)uListEditor1.dataGridView1[3, i]; muserchannelitem.channel_dimensionkind = dcc.Items.IndexOf(dcc.Value); if (filesave.muserchannel.Count == 0) { filesave.muserchannel.Add(muserchannelitem); } else { Boolean mb = false; for (j = 0; j < filesave.muserchannel.Count; j++) { if (muserchannelitem.channelname == filesave.muserchannel[j].channelname) { mb = true; } } if (mb == false) { filesave.muserchannel.Add(muserchannelitem); } else { MessageBox.Show("自定义通道定义重复,请重新定义"); return; } } } CComLibrary.GlobeVal.formulakind = 0; k = this.uListEditor1.dataGridView1.SelectedCells[0].RowIndex; if (k >= 0) { } else { MessageBox.Show("请选择要编辑的公式"); return; } double[,] t = new double[20, 100]; for (i = 0; i < 20; i++) { for (j = 0; j < 100; j++) { t[i, j] = j + i; } } string s; s = ""; for (i = 0; i < cboitem.Items.Count; i++) { s = s + cboitem.Items[i] + " "; } s = s.Trim(); CComLibrary.GlobeVal.filesave = filesave; CComLibrary.GlobeVal.gcalc.Initialize(); CComLibrary.GlobeVal.gcalc.setarrayvalueold(t, 100, 2); CComLibrary.GlobeVal.gcalc.initarray(s, 100); CComLibrary.GlobeVal.filesave = filesave; CComLibrary.GlobeVal._programname = this.uListEditor1.dataGridView1.Rows[k].Cells[0].Value.ToString(); CComLibrary.GlobeVal._programstring = filesave.muserchannel[k].channelvalue; FormCalc f = new FormCalc(); f.kind = 0; f.num = k; f.ShowDialog(); uListEditor1.dataGridView1.Rows[k].Tag = CComLibrary.GlobeVal._programstring; }
private void button1_Click(object sender, EventArgs e) { int i; int j; int k = 0; CComLibrary.GlobeVal.formulakind = 1; filesave.moutput.Clear(); for (i = 0; i < listEditor2.List.Count; i++) { CComLibrary.outputitem moutput = new CComLibrary.outputitem(); moutput.formulaname = (listEditor2.List[i] as SampleProject.Extensions.ChartBarDefine).公式名称; moutput.formulavalue = (listEditor2.List[i] as SampleProject.Extensions.ChartBarDefine).value; moutput.formulaunit = (listEditor2.List[i] as SampleProject.Extensions.ChartBarDefine).公式单位; moutput.show = (listEditor2.List[i] as SampleProject.Extensions.ChartBarDefine).曲线显示; moutput.check = (listEditor2.List[i] as SampleProject.Extensions.ChartBarDefine).是否计算; moutput.formulaexplain = (listEditor2.List[i] as SampleProject.Extensions.ChartBarDefine).公式说明; for (j = 0; j < ClsStaticStation.m_Global.mycls.SignalsNames.Length; j++) { if (ClsStaticStation.m_Global.mycls.SignalsNames[j] == listEditor2.grid[i + 1, listEditor2.grid.ColumnsCount - 1].Value.ToString()) // if (ClsStaticStation.m_Global.mycls.SignalsNames[j] == ClsStaticStation.m_Global.mycls.SignalsNames[(listEditor2.List[i] as SampleProject.Extensions.ChartBarDefine).量纲]) { moutput.dimsel = j; break; } } if (moutput.myitemsignal == null) { moutput.myitemsignal = ClsStaticStation.m_Global.mycls.signalskindlist[moutput.dimsel].Clone() as ItemSignal; moutput.myitemsignal.cUnitsel = 0; } else if (moutput.myitemsignal.cName != ClsStaticStation.m_Global.mycls.signalskindlist[moutput.dimsel].cName) { moutput.myitemsignal = ClsStaticStation.m_Global.mycls.signalskindlist[moutput.dimsel].Clone() as ItemSignal; moutput.myitemsignal.cUnitsel = 0; } if (filesave.moutput.Count == 0) { filesave.moutput.Add(moutput); } else { Boolean mb = false; for (j = 0; j < filesave.moutput.Count; j++) { if (moutput.formulaname == filesave.moutput[j].formulaname) { mb = true; } } if (mb == false) { filesave.moutput.Add(moutput); } else { MessageBox.Show("自定义公式定义重复,请重新定义"); return; } } } /* * filesave.moutput.Clear(); * * for (i = 0; i < listEditor2.List.Count; i++) * { * CComLibrary.outputitem moutput = new CComLibrary.outputitem(); * moutput.formulaname = (listEditor2.List[i] as SampleProject.Extensions.ChartBarDefine).公式名称; * moutput.formulavalue = (listEditor2.List[i] as SampleProject.Extensions.ChartBarDefine).value; * moutput.formulaunit = (listEditor2.List[i] as SampleProject.Extensions.ChartBarDefine).公式单位; * moutput.check = (listEditor2.List[i] as SampleProject.Extensions.ChartBarDefine).是否计算; * * * if (filesave.moutput.Count == 0) * { * filesave.moutput.Add(moutput); * * } * * else * { * * Boolean mb = false; * for (j = 0; j < filesave.moutput.Count ; j++) * { * * if (moutput.formulaname== filesave.moutput[j].formulaname ) * { * mb = true; * * } * * } * * if (mb == false) * { * filesave.moutput.Add(moutput); * * } * else * { * MessageBox.Show("自定义公式定义重复,请重新定义"); * * return; * } * } * * } */ k = listEditor2.row - 1; if (k >= 0) { } else { MessageBox.Show("请选择要编辑的公式"); return; } double[,] t = new double[20, 100]; for (i = 0; i < 20; i++) { for (j = 0; j < 100; j++) { t[i, j] = j + i; } } string s; s = ""; for (i = 0; i < cboitem.Items.Count; i++) { s = s + cboitem.Items[i] + " "; } s = s.Trim(); CComLibrary.GlobeVal.filesave = filesave; CComLibrary.GlobeVal.gcalc.Initialize(); CComLibrary.GlobeVal.gcalc.setarrayvalueold(t, 100, 2); CComLibrary.GlobeVal.gcalc.initarray(s, 100); CComLibrary.GlobeVal.filesave = filesave; CComLibrary.GlobeVal._programname = (listEditor2.List[k] as SampleProject.Extensions.ChartBarDefine).公式名称; CComLibrary.GlobeVal._programstring = (listEditor2.List[k] as SampleProject.Extensions.ChartBarDefine).value; FormCalc f = new FormCalc(); f.kind = 1; f.ShowDialog(); if (CComLibrary.GlobeVal._programstring == null) { (listEditor2.List[k] as SampleProject.Extensions.ChartBarDefine).公式内容 = "无"; } else { (listEditor2.List[k] as SampleProject.Extensions.ChartBarDefine).公式内容 = "有"; } (listEditor2.List[k] as SampleProject.Extensions.ChartBarDefine).value = CComLibrary.GlobeVal._programstring; // listEditor2.LoadList(); }