private void loadJewData() { dgv_searchRe.Rows.Clear(); jewDataList.Clear(); string sqlstr = "select * from JewDataTable order by ID asc "; var datalst = SqliteHelper.ExecDataTable(sqlstr); lbl_reCount.Text = "查找结果:" + datalst.Rows.Count + " 条。"; foreach (DataRow dr in datalst.Rows) { JewDataClass jewData = new Model.JewDataClass(); jewData.jewId = (int)dr["ID"]; jewData.jewName = (string)dr["Name"]; jewData.jewClass = (string)dr["JewClass"]; jewData.wavelength = ProcessArray.StringToDouble((string)dr["Wavelength"]); jewData.spectrum = ProcessArray.StringToDouble((string)dr["Spectrum"]); jewData.addTime = (string)dr["AddTime"]; jewData.creator = (string)dr["Creator"]; jewData.remark = (string)dr["Remark"]; jewDataList.Add(jewData); int index = dgv_searchRe.Rows.Add(); dgv_searchRe.Rows[index].Cells[0].Value = jewData.jewId; dgv_searchRe.Rows[index].Cells[1].Value = jewData.jewName; dgv_searchRe.Rows[index].Cells[2].Value = jewData.jewClass; dgv_searchRe.Rows[index].Cells[3].Value = jewData.addTime; dgv_searchRe.Rows[index].Cells[4].Value = jewData.creator; dgv_searchRe.Rows[index].Cells[5].Value = jewData.remark; } }
private void btn_search_Click(object sender, EventArgs e) { try { if (!processSpec.IsConn) { return; } stopGetSpec(); double[] oneWave = ProcessArray.getOneStepArrayDouble(processSpec.ShowWavelength_MinMax[0], processSpec.ShowWavelength_MinMax[1]); double[] oneSpec = ProcessArray.FixArrayY(oneWave, processSpec.wavelengths, processSpec.showY); OnAddLines(oneWave, oneSpec, false, "当前谱图");//添加待耦合的曲线。 dt_fitting = processFitting.sqlFitting(processSpec.wavelengths, processSpec.showY, processSpec.ShowWavelength_MinMax[0], processSpec.ShowWavelength_MinMax[1]); dt_show = getThresholdDataTable(dt_fitting, (int)nud_threshold.Value); dgv_fittingResult.DataSource = sortDataTable(dt_show, 10); for (int i = 0; i < dgv_fittingResult.Columns.Count; i++) { dgv_fittingResult.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable; } for (int i = 9; i > 3; i--) { dgv_fittingResult.Columns[i].Visible = false; } selectTablePage2(1); } catch (Exception ex) { MessageBox.Show("拟合失败!" + ex.Message); } }
private void dgv_fittingResult_SelectionChanged(object sender, EventArgs e) { OnAddLines(new object(), null, false, "当前谱图");//清空除了第一条线之外的谱线; foreach (DataGridViewRow dr in dgv_fittingResult.SelectedRows) { //int index = dgv_fittingResult.SelectedRows[i].Index; //DataRow dtr = dt_fitting.Rows[index]; int[] wave = ProcessArray.StringToInt((string)dr.Cells["Wavelength"].Value); double[] spec = ProcessArray.StringToDouble((string)dr.Cells["Spectrum"].Value); string remark = dr.Cells["Remark"].Value.ToString(); string name = dr.Cells["Name"].Value.ToString(); double[] realSign = new double[0], unrealSign = new double[0]; if (dr.Cells["RealSign"].Value.ToString() != "") { realSign = ProcessArray.StringToDouble((string)dr.Cells["RealSign"].Value); } if (dr.Cells["UnRealSign"].Value.ToString() != "") { unrealSign = ProcessArray.StringToDouble((string)dr.Cells["UnRealSign"].Value); } addSignToGrid(realSign, unrealSign); OnAddLines(wave, spec, true, name); setRemarks(remark); setSignEvent(wave, spec, realSign, unrealSign); } }
private void addSignFittingChart(double[] bufwave, double[] bufspec, double[] realSign, double[] unrealSign) { for (int i = axTChart1.SeriesCount - 1; i > 1; i--) { axTChart1.RemoveSeries(i); } axTChart1.Series(1).Clear(); if (realSign.Length == 0 && unrealSign.Length == 0) { return; } double[] markx = new double[realSign.Length + unrealSign.Length]; double[] marky = new double[realSign.Length + unrealSign.Length]; for (int i = 0; i < realSign.Length; i++) { //ESeriesClass lineSeries = new ESeriesClass(); int waveindex = ProcessArray.getCursorIndex(realSign[i], bufwave); double[] newserArrayY = new double[] { 0, bufspec[waveindex] }; double[] newserArrayX = new double[] { realSign[i], realSign[i] }; int index = axTChart1.AddSeries(ESeriesClass.scFastLine); axTChart1.Series(index).AddArray(2, newserArrayY, newserArrayX); axTChart1.Series(index).asFastLine.LinePen.Width = 2; axTChart1.Series(index).asFastLine.LinePen.Color = (uint)ColorTranslator.ToWin32(Color.Green); markx[i] = realSign[i]; marky[i] = bufspec[waveindex]; //int index=Chart_fitting.Tools.Add(EToolClass.tcCursor); //Chart_fitting.Tools.Items[index].asTeeCursor.Series = Chart_fitting.Series(0); //Chart_fitting.Tools.Items[index].asTeeCursor.Style = ECursorToolStyle.cssVertical; //Chart_fitting.Tools.Items[index].asTeeCursor.XVal = realSign[i]; //Chart_fitting.Tools.Items[index].asTeeCursor.Pen.Color = (uint)ColorTranslator.ToWin32(Color.Green); //Chart_fitting.Tools.Items[index].asTeeCursor.Pen.Width = 2; } for (int i = 0; i < unrealSign.Length; i++) { int waveindex = ProcessArray.getCursorIndex(unrealSign[i], bufwave); double[] newserArrayY = new double[] { 0, bufspec[waveindex] }; double[] newserArrayX = new double[] { unrealSign[i], unrealSign[i] }; int index = axTChart1.AddSeries(ESeriesClass.scFastLine); axTChart1.Series(index).AddArray(2, newserArrayY, newserArrayX); axTChart1.Series(index).asFastLine.LinePen.Width = 2; axTChart1.Series(index).asFastLine.LinePen.Color = (uint)ColorTranslator.ToWin32(Color.Red); markx[i + realSign.Length] = unrealSign[i]; marky[i + realSign.Length] = bufspec[waveindex]; } int serindex = 1; axTChart1.Series(serindex).AddArray(marky.Length, marky, markx); axTChart1.Series(serindex).asPoint.Pointer.Visible = false; axTChart1.Series(serindex).Marks.Style = EMarkStyle.smsXValue; axTChart1.Series(serindex).Marks.Symbol.Visible = false; axTChart1.Series(serindex).Marks.Show(); }
private void btn_findPeak_Click(object sender, EventArgs e) { if (!processSpec.IsConn) { return; } double[] showY = new double[processSpec.showY.Length]; Array.Copy(processSpec.showY, showY, showY.Length); List <int> peaks1 = new List <int> (), peaks2 = new List <int> (); if (processSpec.findPeakDerection == 0) { double[] backShowY = new double[processSpec.showY.Length]; for (int i = 0; i < processSpec.showY.Length; i++) { backShowY[i] = (-1) * processSpec.showY[i]; } peaks2 = ProcessArray.findPeaks(backShowY, processSpec.findPeakWidth, processSpec.findPeakSmoothWidth, processSpec.findPeakThreshold); } else if (processSpec.findPeakDerection == 1) { peaks1 = ProcessArray.findPeaks(processSpec.showY, processSpec.findPeakWidth, processSpec.findPeakSmoothWidth, processSpec.findPeakThreshold); } else if (processSpec.findPeakDerection == 2) { peaks1 = ProcessArray.findPeaks(processSpec.showY, processSpec.findPeakWidth, processSpec.findPeakSmoothWidth, processSpec.findPeakThreshold); double[] backShowY = new double[processSpec.showY.Length]; for (int i = 0; i < processSpec.showY.Length; i++) { backShowY[i] = (-1) * processSpec.showY[i]; } peaks2 = ProcessArray.findPeaks(backShowY, processSpec.findPeakWidth, processSpec.findPeakSmoothWidth, processSpec.findPeakThreshold); } peaks1.AddRange(peaks2); peaks1.Sort(); double[] peakX = new double[peaks1.Count]; double[] peakY = new double[peaks1.Count]; for (int i = 0; i < peaks1.Count; i++) { peakX[i] = processSpec.wavelengths[peaks1[i]]; peakY[i] = showY[peaks1[i]]; } if (peakX.Length > 0) { Chart_spec.Series(1).AddArray(peakX.Length, peakY, peakX); } else { Chart_spec.Series(1).Clear(); } }
private void addSignFittingChart(int[] bufwave, double[] bufspec, double [] realSign, double[] unrealSign) { for (int i = Chart_fitting.SeriesCount - 1; i > 2; i--) { Chart_fitting.RemoveSeries(i); } Chart_fitting.Series(1).Clear(); if (realSign.Length == 0 && unrealSign.Length == 0) { return; } double[] markx = new double[realSign.Length + unrealSign.Length]; double[] marky = new double[realSign.Length + unrealSign.Length]; for (int i = 0; i < realSign.Length; i++) { int waveindex = ProcessArray.getCursorIndex(realSign[i], bufwave); double[] newserArrayY = new double[] { 0, bufspec [waveindex] }; double[] newserArrayX = new double[] { realSign[i], realSign[i] }; int index = Chart_fitting.AddSeries(ESeriesClass.scFastLine); Chart_fitting.Series(index).AddArray(2, newserArrayY, newserArrayX); Chart_fitting.Series(index).asFastLine.LinePen.Width = 2; Chart_fitting.Series(index).asFastLine.LinePen.Color = (uint)ColorTranslator.ToWin32(Color.Green); markx[i] = realSign[i]; marky[i] = bufspec[waveindex]; } for (int i = 0; i < unrealSign.Length; i++) { int waveindex = ProcessArray.getCursorIndex(unrealSign[i], bufwave); double[] newserArrayY = new double[] { 0, bufspec[waveindex] }; double[] newserArrayX = new double[] { unrealSign[i], unrealSign[i] }; int index = Chart_fitting.AddSeries(ESeriesClass.scFastLine); Chart_fitting.Series(index).AddArray(2, newserArrayY, newserArrayX); Chart_fitting.Series(index).asFastLine.LinePen.Width = 2; Chart_fitting.Series(index).asFastLine.LinePen.Color = (uint)ColorTranslator.ToWin32(Color.Red); markx[i + realSign.Length] = unrealSign[i]; marky[i + realSign.Length] = bufspec[waveindex]; } int serindex = 1; Chart_fitting.Series(serindex).AddArray(marky.Length, marky, markx); Chart_fitting.Series(serindex).asPoint.Pointer.Visible = false; Chart_fitting.Series(serindex).Marks.Style = EMarkStyle.smsXValue; Chart_fitting.Series(serindex).Marks.Symbol.Visible = false; Chart_fitting.Series(serindex).Marks.Show(); }
private void 加入光谱图对比ToolStripMenuItem_Click(object sender, EventArgs e) { if (dgv_fittingResult.SelectedRows.Count > 0) { double[] wave = ProcessArray.StringToDouble((string)dgv_fittingResult.SelectedRows[0].Cells["Wavelength"].Value); double[] spec = ProcessArray.StringToDouble((string)dgv_fittingResult.SelectedRows[0].Cells["Spectrum"].Value); string remark = dgv_fittingResult.SelectedRows[0].Cells["Remark"].Value.ToString(); string name = dgv_fittingResult.SelectedRows[0].Cells["Name"].Value.ToString(); addSpecLine(spec, wave, name); //OnAddLines(wave, spec, true, name); //setRemarks(remark); } }
private void 导出谱图ToolStripMenuItem_Click(object sender, EventArgs e) { int index; if (int.TryParse(dgv_searchRe.SelectedRows[0].Cells[0].Value.ToString(), out index)) { string sqlstr = "select Name,Wavelength,Spectrum from JewDataTable WHERE ID = " + index; var datalst = SqliteHelper.ExecDataTable(sqlstr); string name = (string)datalst.Rows[0]["Name"]; double[] wave = ProcessArray.StringToDouble((string)datalst.Rows[0]["Wavelength"]); double[] spec = ProcessArray.StringToDouble((string)datalst.Rows[0]["Spectrum"]); ProcessFile.saveCurrentTwoArray(name, wave, spec); } }
private void 修改谱图ToolStripMenuItem_Click(object sender, EventArgs e) { int index; if (int.TryParse(dgv_searchRe.SelectedRows[0].Cells[0].Value.ToString(), out index)) { string sqlstr = "select * from JewDataTable WHERE ID = " + index; var datalst = SqliteHelper.ExecDataTable(sqlstr); string name = (string)datalst.Rows[0]["Name"]; double[] wave = ProcessArray.StringToDouble((string)datalst.Rows[0]["Wavelength"]); double[] spec = ProcessArray.StringToDouble((string)datalst.Rows[0]["Spectrum"]); Form_updateSql updateSql = new Form_updateSql(index); updateSql.Show(); } }
private void 导出当前数据ToolStripMenuItem_Click(object sender, EventArgs e) { int length = (int)processSpec.ShowWavelength_MinMax[1] - (int)processSpec.ShowWavelength_MinMax[0] + 1; if (length <= 0) { return; } double[] one_nmWave = new double[length]; for (int i = 0; i < one_nmWave.Length; i++) { one_nmWave[i] = i + (int)processSpec.ShowWavelength_MinMax[0]; } double[] newy = ProcessArray.FixArrayY(one_nmWave, processSpec.showX, processSpec.showY); ProcessFile.saveCurrentTwoArray(DateTime.Now.ToFileTime().ToString(), one_nmWave, newy); }
private void btn_addJewData_Click(object sender, EventArgs e) { if (!processSpec.IsConn) { return; } try { List <double> realSign = new List <double>(); List <double> unRealSign = new List <double>(); for (int i = 0; i < dgv_sign.Rows.Count; i++) { double real, unReal; if (double.TryParse(dgv_sign.Rows[i].Cells [0].Value.ToString(), out real)) { realSign.Add(real); } if (double.TryParse(dgv_sign.Rows [i].Cells [1].Value.ToString(), out unReal)) { unRealSign.Add(unReal); } } JewDataClass jewSample = new JewDataClass(); jewSample.jewId = processSpec.JewID; jewSample.jewName = txt_name.Text.Trim(); jewSample.jewClass = cbx_class.SelectedItem.ToString(); jewSample.wavelength = ProcessArray.getOneStepArrayDouble(processSpec.ShowWavelength_MinMax[0], processSpec.ShowWavelength_MinMax[1]); jewSample.spectrum = ProcessArray.FixArrayY(jewSample.wavelength, processSpec.wavelengths, processSpec.showY); jewSample.creator = cbx_people.SelectedItem.ToString(); jewSample.remark = rtb_remark.Text.Trim(); jewSample.addTime = DateTime.Now.ToString(); jewSample.realSign = realSign; jewSample.unRealSign = unRealSign; SqliteHelper.SaveJewData(jewSample); processSpec.JewID = processSpec.JewID + 1; MessageBox.Show("保存成功!"); } catch (Exception ex) { MessageBox.Show("保存失败!" + ex.Message); } }
private void btn_zoomIn_Click(object sender, EventArgs e) { if (processSpec.IsConn) { if (double.IsNegativeInfinity(Chart_spec.Axis.Left.Minimum) && double.IsPositiveInfinity(Chart_spec.Axis.Left.Maximum)) { return; } int minIndex = ProcessArray.getCursorIndex(Chart_spec.Axis.Bottom.Minimum, processSpec.wavelengths); int maxIndex = ProcessArray.getCursorIndex(Chart_spec.Axis.Bottom.Maximum, processSpec.wavelengths); double maxValue = processSpec.showY[maxIndex]; double minValue = processSpec.showY[minIndex]; for (int i = minIndex; i < maxIndex; i++) { if (processSpec.showY[i] < minValue) { minValue = processSpec.showY[i]; } if (processSpec.showY[i] > maxValue) { maxValue = processSpec.showY[i]; } } Chart_spec.Axis.Left.Automatic = false; double max = maxValue + (maxValue - minValue) * 0.1; double min = minValue - (maxValue - minValue) * 0.1; if (max < Chart_spec.Axis.Left.Minimum) { Chart_spec.Axis.Left.Minimum = min; Chart_spec.Axis.Left.Maximum = max; } else { Chart_spec.Axis.Left.Maximum = max; Chart_spec.Axis.Left.Minimum = min; } } }
private void toolStripMenuItem3_Click(object sender, EventArgs e) { int index; string creator = dgv_searchRe.SelectedRows[0].Cells[4].Value.ToString(); if (creator == "法宝技术") { MessageBox.Show("无法导出厂家数据!"); return; } if (int.TryParse(dgv_searchRe.SelectedRows[0].Cells[0].Value.ToString(), out index)) { string sqlstr = "select Name,Wavelength,Spectrum from JewDataTable WHERE ID = " + index; var datalst = SqliteHelper.ExecDataTable(sqlstr); string name = (string)datalst.Rows[0]["Name"]; double[] wave = ProcessArray.StringToDoubleEncryption((string)datalst.Rows[0]["Wavelength"]); double[] spec = ProcessArray.StringToDoubleEncryption((string)datalst.Rows[0]["Spectrum"]); ProcessFile.saveCurrentTwoArray(name, wave, spec); } }
private void btn_search_Click(object sender, EventArgs e) { dgv_searchRe.Rows.Clear(); string key = txt_key.Text.Trim(); string className = cbx_class.SelectedItem.ToString(); string creatorName = cbx_creator.SelectedItem.ToString(); string sqlstr; jewDataList.Clear(); if (key == string.Empty) { // sqlstr = "select * from JewDataTable order by ID asc "; if (cbx_class.SelectedIndex == 0 && cbx_creator.SelectedIndex == 0) { sqlstr = "select * from JewDataTable order by ID asc "; } else if (cbx_class.SelectedIndex != 0 && cbx_creator.SelectedIndex != 0) { sqlstr = "select * from JewDataTable WHERE JewClass like '" + className + "' AND Creator like '" + creatorName + "' order by ID asc "; } else if (cbx_class.SelectedIndex != 0 && cbx_creator.SelectedIndex == 0) { sqlstr = "select * from JewDataTable WHERE JewClass like '" + className + "' order by ID asc "; } else { sqlstr = "select * from JewDataTable WHERE Creator like '" + creatorName + "' order by ID asc "; } } else { if (cbx_class.SelectedIndex == 0 && cbx_creator.SelectedIndex == 0) { sqlstr = "select * from JewDataTable WHERE Name like '%" + key + "%' order by ID asc "; } else if (cbx_class.SelectedIndex != 0 && cbx_creator.SelectedIndex != 0) { sqlstr = "select * from JewDataTable WHERE Name like '%" + key + "%' AND JewClass like '" + className + "' AND Creator like '" + creatorName + "' order by ID asc "; } else if (cbx_class.SelectedIndex != 0 && cbx_creator.SelectedIndex == 0) { sqlstr = "select * from JewDataTable WHERE Name like '%" + key + "%' AND JewClass like '" + className + "' order by ID asc "; } else { sqlstr = "select * from JewDataTable WHERE Name like '%" + key + "%' AND Creator like '" + creatorName + "' order by ID asc "; } } var datalst = SqliteHelper.ExecDataTable(sqlstr); lbl_reCount.Text = "查找结果:" + datalst.Rows.Count + " 条。"; foreach (DataRow dr in datalst.Rows) { JewDataClass jewData = new Model.JewDataClass(); jewData.jewId = (int)dr["ID"]; jewData.jewName = (string)dr["Name"]; jewData.jewClass = (string)dr["JewClass"]; jewData.wavelength = ProcessArray.StringToDoubleEncryption((string)dr["Wavelength"]); jewData.spectrum = ProcessArray.StringToDoubleEncryption((string)dr["Spectrum"]); jewData.addTime = (string)dr["AddTime"]; jewData.creator = (string)dr["Creator"]; jewData.remark = (string)dr["Remark"]; if (dr["RealSign"].ToString() != "") { jewData.realSign = ProcessArray.StringToDouble((string)dr["RealSign"]).ToList(); } if (dr["UnRealSign"].ToString() != "") { jewData.unRealSign = ProcessArray.StringToDouble((string)dr["UnRealSign"]).ToList(); } //jewData.factoryState = (string)dr["Factory"]; jewDataList.Add(jewData); int index = dgv_searchRe.Rows.Add(); dgv_searchRe.Rows[index].Cells[0].Value = jewData.jewId; dgv_searchRe.Rows[index].Cells[1].Value = jewData.jewName; dgv_searchRe.Rows[index].Cells[2].Value = jewData.jewClass; dgv_searchRe.Rows[index].Cells[3].Value = jewData.addTime; dgv_searchRe.Rows[index].Cells[4].Value = jewData.creator; dgv_searchRe.Rows[index].Cells[5].Value = jewData.remark; } }
public static float MakeAction(this float[] array, ProcessArray action) => action.Invoke(array);
public IGenericProcess GetGenericProcess(ProcessType processType) { IGenericProcess genericProcess = null; switch (processType) { case ProcessType.Buffer: genericProcess = new ProcessBuffer(); break; case ProcessType.CircularBuffer: genericProcess = new ProcessCircularBuffer(); break; case ProcessType.Array: genericProcess = new ProcessArray(); break; case ProcessType.List: genericProcess = new ProcessList(); break; case ProcessType.Queue: genericProcess = new ProcessQueue(); break; case ProcessType.Stack: genericProcess = new ProcessStack(); break; case ProcessType.HashSet: genericProcess = new ProcessHashSet(); break; case ProcessType.LinkedList: genericProcess = new ProcessLinkedList(); break; case ProcessType.Dictionary: genericProcess = new ProcessDictionary(); break; case ProcessType.Sort: genericProcess = new ProcessSort(); break; case ProcessType.ComparingEmployees: genericProcess = new ProcessComparingEmployees(); break; case ProcessType.Delegates: genericProcess = new ProcessDelegates(); break; case ProcessType.Constraints: genericProcess = new ProcessConstraints(); break; case ProcessType.GenericMethods: genericProcess = new ProcessGenericMethods(); break; case ProcessType.IocContainer: genericProcess = new ProcessIocContainer(); break; case ProcessType.GenericEnum: genericProcess = new ProcessGenericEnum(); break; case ProcessType.BaseTypes: genericProcess = new ProcessBaseTypes(); break; case ProcessType.GenericStatics: genericProcess = new ProcessGenericStatics(); break; default: break; } return(genericProcess); }