| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252 | using OTSIncAReportApp.Control_ECharts;using OTSIncAReportApp.DataOperation.DataAccess;using OTSIncAReportApp.DataOperation.Model;using OTSIncAReportGraph.Controls;using OTSIncAReportGrids;using OTSPeriodicTable;using System;using System.Collections.Generic;using System.Data;using System.Drawing;using System.IO;using System.Linq;using System.Windows.Forms;namespace OTSIncAReportApp.OTSTemplateDesigner{    public class Export_ReportTemplate    {        #region 全局变量        public List<DataTable> m_list_dt;                   //导出的各模块数据,合集        public OTSReport_Export m_otsreport_export;        List<string> TemplateList;        #endregion        #region 构造函数        public Export_ReportTemplate(OTSReport_Export in_export)        {            m_otsreport_export = in_export;            TemplateList = new List<string>();            //加载三元相图各项            string pathtpf = in_export.m_ReportApp.m_RptConfigFile.FileFolderTrigTemp + "\\" + in_export.m_ReportApp.m_RptConfigFile.TriTempFile;// Application.StartupPath + "\\Config\\ProData\\DefaultTriTemplateFile.tpf";            TemplateList = new List<string>();            DataSet ds = DataOperation.DataAccess.XMLoperate.GetXmlData(pathtpf, "XMLData");            DataTable dt = ds.Tables["Member"];            foreach (DataRow item in dt.Rows)            {                if (item["TemplateName"].ToString() != "")                {                    TemplateList.Add(item["TemplateName"].ToString());                }            }            m_list_dt = new List<DataTable>();        }        #endregion        #region 插入测量结果Grid表格        /// <summary>        /// 向 模板设计器 中插入测量结果Grid表格        /// </summary>        /// <returns></returns>        public bool InsertReportTemplateTable_ResultGrid()        {            try            {                //------------------加载模块,获取数据-------------------------------------------------                ResultGrid ls_resultgrid = new ResultGrid(m_otsreport_export.m_ReportApp);                Dictionary<string, string> keyValues_ResultGrid = ls_resultgrid.GetData_ResultGrid();                //------------------加载模块,获取数据结束----------------------------------------------                Dictionary<string, string>.Enumerator en = keyValues_ResultGrid.GetEnumerator();                string str_CLJGMC = "";                string str_YXSJ = "";                string str_SCZS = "";                string str_FLFA = "";                string str_YJCTZ = "";                string str_SCMJ = "";                string str_CKBZ = "GB/130834-2014";                keyValues_ResultGrid.TryGetValue(ls_resultgrid.table["col1"].ToString(), out str_CLJGMC);//测量结果名称                keyValues_ResultGrid.TryGetValue(ls_resultgrid.table["col4"].ToString(), out str_YXSJ);//运行时间                keyValues_ResultGrid.TryGetValue(ls_resultgrid.table["col5"].ToString(), out str_SCZS);//视场总数                keyValues_ResultGrid.TryGetValue(ls_resultgrid.table["col6"].ToString(), out str_FLFA);//分类方案                keyValues_ResultGrid.TryGetValue(ls_resultgrid.table["col7"].ToString(), out str_YJCTZ);//已检测特征                keyValues_ResultGrid.TryGetValue(ls_resultgrid.table["col8"].ToString(), out str_SCMJ);//视场面积                //将获取到的数据转换成报告模板能接收的格式。                DataTable ls_new_dt = new DataTable();                ls_new_dt.TableName = "ResultGrid";                ls_new_dt.Columns.Add("CLJGMC"); //测量结果名称                ls_new_dt.Columns.Add("YXSJ");      //运行时间                ls_new_dt.Columns.Add("SCZS");      //视场总数                ls_new_dt.Columns.Add("FLFA");      //分类方案                ls_new_dt.Columns.Add("YJCTZ");     //已检测特征                ls_new_dt.Columns.Add("SCMJ");      //视场面积                ls_new_dt.Columns.Add("CKBZ");      //参考标准                //行转列,这里不会发生改变,所以这样写                DataRow dr = ls_new_dt.NewRow();                dr["CLJGMC"] = str_CLJGMC;                dr["YXSJ"] = str_YXSJ;                dr["SCZS"] = str_SCZS;                dr["FLFA"] = str_FLFA;                dr["YJCTZ"] = str_YJCTZ;                dr["SCMJ"] = str_SCMJ;                dr["CKBZ"] = str_CKBZ;                ls_new_dt.Rows.Add(dr);                m_list_dt.Add(ls_new_dt);                return true;            }            catch (Exception ee)            {                string str = ee.ToString();                return false;            }        }        #endregion        #region 插入颗粒列表并带有帧图        /// <summary>        /// 颗粒列表中插入帧图,并带上颗粒分组信息        /// </summary>        /// <returns></returns>        public bool InsertReportTemplateTable_ParticlesGridDevidePage()        {            //------------------加载模块,获取数据-------------------------------------------------            m_otsreport_export.m_ReportApp.im_ParticlesGridDevidePage = new ParticlesGridDevidePage(m_otsreport_export.m_ReportApp);            //DataGridView gv_dt_ParticlesGridDevidePage_element = new DataGridView();            //DataTable dt_ParticlesGridDevidePage_element = new DataTable();            //m_otsreport_export.m_ReportApp.m_CTablesWindow.Controls.Add(m_otsreport_export.m_ReportApp.im_ParticlesGridDevidePage);            //m_otsreport_export.m_ReportApp.im_ParticlesGridDevidePage.GetDataTableAndGridView(out dt_ParticlesGridDevidePage_element, out gv_dt_ParticlesGridDevidePage_element);                        //根据sql条件,查询获取颗粒信息数据            DataTable dt_ParticlesGridDevidePage = new DataTable();            ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.resultFilesList[m_otsreport_export.m_ReportApp.WorkingResult].FilePath);            dt_ParticlesGridDevidePage = fielddata.GetInfoForPartucleDevidePage(0, 200, "fieldid,particleid", "");            string str_resultPath = m_otsreport_export.m_ReportApp.resultFilesList[m_otsreport_export.m_ReportApp.WorkingResult].FilePath;            //------------------加载模块,获取数据结束----------------------------------------------            #region 创建要插入数据库表结构            //插入模板需父子表,结构            //表名field_dt表:(父表)           帧图表            DataTable DT_field_dt = new DataTable();            DT_field_dt = new DataTable();            DT_field_dt.TableName = "field_dt";            DataColumn colpictid2 = new DataColumn("FieldId");            colpictid2.DataType = typeof(int);            DT_field_dt.Columns.Add(colpictid2);            //图像列            DataColumn colpict2 = new DataColumn("FieldImg");            colpict2.DataType = System.Type.GetType("System.Byte[]");            DT_field_dt.Columns.Add(colpict2);            //表名Largest_frame表:(子表)       显示20条颗粒除外的部份颗粒信息            DataTable DT_Largest_frame = new DataTable();            DT_Largest_frame.TableName = "Largest_frame";            DT_Largest_frame.Columns.Add("pid");            DT_Largest_frame.Columns.Add("Size");            DT_Largest_frame.Columns.Add("Width");            DT_Largest_frame.Columns.Add("Class");            DT_Largest_frame.Columns.Add("ColName1");            DT_Largest_frame.Columns.Add("ColName2");            DT_Largest_frame.Columns.Add("ColName3");            DT_Largest_frame.Columns.Add("ColName4");            DT_Largest_frame.Columns.Add("ColName5");            DT_Largest_frame.Columns.Add("ColName6");            DT_Largest_frame.Columns.Add("ColVal1");            DT_Largest_frame.Columns.Add("ColVal2");            DT_Largest_frame.Columns.Add("ColVal3");            DT_Largest_frame.Columns.Add("ColVal4");            DT_Largest_frame.Columns.Add("ColVal5");            DT_Largest_frame.Columns.Add("ColVal6");            DataColumn colpictid = new DataColumn("FieldId");            colpictid.DataType = typeof(int);            DT_Largest_frame.Columns.Add(colpictid);            //图像列            DataColumn colpict = new DataColumn("p1");            colpict.DataType = System.Type.GetType("System.Byte[]");            DT_Largest_frame.Columns.Add(colpict);            //largest20表:(无关系表)       需要显示前20条带有显示能谱图像的颗粒表            DataTable DT_Largest20 = new DataTable();            DT_Largest20.TableName = "Largest20";            DT_Largest20.Columns.Add("pid");            DT_Largest20.Columns.Add("Size");            DT_Largest20.Columns.Add("Width");            DT_Largest20.Columns.Add("Class");            DT_Largest20.Columns.Add("ColName1");            DT_Largest20.Columns.Add("ColName2");            DT_Largest20.Columns.Add("ColName3");            DT_Largest20.Columns.Add("ColName4");            DT_Largest20.Columns.Add("ColName5");            DT_Largest20.Columns.Add("ColName6");            DT_Largest20.Columns.Add("ColVal1");            DT_Largest20.Columns.Add("ColVal2");            DT_Largest20.Columns.Add("ColVal3");            DT_Largest20.Columns.Add("ColVal4");            DT_Largest20.Columns.Add("ColVal5");            DT_Largest20.Columns.Add("ColVal6");            // 图像列            DataColumn colpict_20ago = new DataColumn("p1");            colpict_20ago.DataType = System.Type.GetType("System.Byte[]");            DT_Largest20.Columns.Add(colpict_20ago);            DataColumn colpict2_20ago = new DataColumn("p2");            colpict2_20ago.DataType = System.Type.GetType("System.Byte[]");            DT_Largest20.Columns.Add(colpict2_20ago);            DataColumn colpict3_20ago = new DataColumn("p3");            colpict3_20ago.DataType = System.Type.GetType("System.Byte[]");            DT_Largest20.Columns.Add(colpict3_20ago);            #endregion            #region 插入-前20颗粒部份            for (int i_row = 0; i_row < 20; i_row++)            {                if (i_row < dt_ParticlesGridDevidePage.Rows.Count)                {                    //获取颗粒的fieldid,和particleid                    string str_fieldid = dt_ParticlesGridDevidePage.Rows[i_row]["fieldid"].ToString();                    string str_particleid = dt_ParticlesGridDevidePage.Rows[i_row]["particleid"].ToString();                    string str_subparticles = dt_ParticlesGridDevidePage.Rows[i_row]["SubParticles"].ToString();                    string str_typeid = dt_ParticlesGridDevidePage.Rows[i_row]["TypeId"].ToString();                    string str_typename = dt_ParticlesGridDevidePage.Rows[i_row]["TypeName"].ToString();                    string str_element = dt_ParticlesGridDevidePage.Rows[i_row]["Element"].ToString();                    //获取原始颗粒图像                    Bitmap bp_particle = new Bitmap(1, 1);                    string str_path = str_resultPath + "\\FIELD_FILES\\";                    string str_imagePath = str_path + "Field" + str_fieldid.ToString() + ".bmp";                    if (str_fieldid == "-1")                        continue;                    if (str_subparticles != null && str_subparticles != "")                    {                        //合并大颗粒                        double ScanFieldSize = 1142;                        Bitmap tempbit = fielddata.ReadImageFile(str_imagePath);                        int pixw = tempbit.Width;                        double xs = pixw / ScanFieldSize;                        bp_particle = fielddata.GetBitmapForBig(str_subparticles, xs, str_resultPath);                    }                    else                    {                        //正常颗粒                        Rectangle rectangle = new Rectangle() { X = Convert.ToInt32(dt_ParticlesGridDevidePage.Rows[i_row]["RectLeft"]), Y = Convert.ToInt32(dt_ParticlesGridDevidePage.Rows[i_row]["RectTop"]), Width = Convert.ToInt32(dt_ParticlesGridDevidePage.Rows[i_row]["RectWidth"]), Height = Convert.ToInt32(dt_ParticlesGridDevidePage.Rows[i_row]["RectHeight"]) };                        Bitmap bp_field = fielddata.ReadImageFile(str_imagePath);                        bp_particle = fielddata.GetBitmapByParticle(bp_field, rectangle);                        bp_particle.Tag = new List<string>() { dt_ParticlesGridDevidePage.Rows[i_row]["FieldId"].ToString(), dt_ParticlesGridDevidePage.Rows[i_row]["ParticleId"].ToString(), dt_ParticlesGridDevidePage.Rows[i_row]["TypeId"].ToString() };                    }                    //获取该颗粒的xray能谱图像                    System.Drawing.Bitmap bp_xraybp = ExportXRayBitmap(str_fieldid,                        str_particleid, Convert.ToInt32(str_typeid), str_typename, fielddata);                    Bitmap ls_xraybpnew = new Bitmap(1, 1);                    ls_xraybpnew = OTSIncAReportGraph.Class.DrawFuncation.KiResizeImage(bp_xraybp, 700, 115);//能谱图处理                    //获取该颗粒的二次放大处理图像                    Bitmap ls_processbitmap = new Bitmap(1, 1);                    ls_processbitmap = OTSIncAReportGraph.Class.DrawFuncation.GetReZoomBitmap(bp_particle);// (Bitmap)bp_particle.Clone();//待完善                    //再将图像转成二进制流-------------------------------------------------------------------                    //原图                    MemoryStream newms_p1 = new MemoryStream();                    bp_particle.Save(newms_p1, System.Drawing.Imaging.ImageFormat.Bmp);                    newms_p1.Seek(0, SeekOrigin.Begin);                    byte[] newarr_p1 = new byte[newms_p1.Length];                    newms_p1.Read(newarr_p1, 0, newarr_p1.Length);                    //二次放大图                    MemoryStream newms_p2 = new MemoryStream();                    ls_processbitmap.Save(newms_p2, System.Drawing.Imaging.ImageFormat.Bmp);                    newms_p2.Seek(0, SeekOrigin.Begin);                    byte[] newarr_p2 = new byte[newms_p2.Length];                    newms_p2.Read(newarr_p2, 0, newarr_p2.Length);                    //能谱图                    MemoryStream newms_p3 = new MemoryStream();                    ls_xraybpnew.Save(newms_p3, System.Drawing.Imaging.ImageFormat.Bmp);                    newms_p3.Seek(0, SeekOrigin.Begin);                    byte[] newarr_p3 = new byte[newms_p3.Length];                    newms_p3.Read(newarr_p3, 0, newarr_p3.Length);                    //---------------------------------------------------------------------------------------                                      DataRow dr = DT_Largest20.NewRow();                    dr["p1"] = newarr_p1;                    dr["p2"] = newarr_p2;                    dr["p3"] = newarr_p3;                    newms_p1.Dispose();                    newms_p2.Dispose();                    newms_p3.Dispose();                    dr["pid"] = str_fieldid + dt_ParticlesGridDevidePage.Rows[i_row]["particleid"].ToString();                    dr["Size"] = Convert.ToDouble(dt_ParticlesGridDevidePage.Rows[i_row]["area"]).ToString("#0.00"); //可以需要选择切换,计算方式                    dr["Width"] = dt_ParticlesGridDevidePage.Rows[i_row]["rectwidth"].ToString();                    dr["Class"] = dt_ParticlesGridDevidePage.Rows[i_row]["typename"].ToString();                    List<string> list_max_elementname = new List<string>();                    List<double> list_max_elementvale = new List<double>();                    GetMaxElementFromDataTable(dt_ParticlesGridDevidePage, i_row, out list_max_elementname, out list_max_elementvale);                    //元素1                    dr["ColName1"] = list_max_elementname[0];                    dr["ColVal1"] = list_max_elementvale[0].ToString();                    //元素2                    dr["ColName2"] = list_max_elementname[1];                    dr["ColVal2"] = list_max_elementvale[1].ToString();                    //元素3                    dr["ColName3"] = list_max_elementname[2];                    dr["ColVal3"] = list_max_elementvale[2].ToString();                    //元素4                    dr["ColName4"] = list_max_elementname[3];                    dr["ColVal4"] = list_max_elementvale[3].ToString();                    //元素5                    dr["ColName5"] = list_max_elementname[4];                    dr["ColVal5"] = list_max_elementvale[4].ToString();                    //元素6                    dr["ColName6"] = list_max_elementname[5];                    dr["ColVal6"] = list_max_elementvale[5].ToString();                                       DT_Largest20.Rows.Add(dr);                }            }            #endregion            #region 插入-帧图图像部份            //首先生成标记颗粒的帧图图像文件            m_otsreport_export.m_ReportApp.im_ParticlesGridDevidePage.SaveMarkParticleRectangleOnFieldFile();            string str_path_FIELD_FILES_MARK = str_resultPath + "\\FIELD_FILES_MARK\\";            DirectoryInfo theFolder = new DirectoryInfo(str_path_FIELD_FILES_MARK);            if (theFolder.Exists)            {                foreach (FileInfo nextifile in theFolder.GetFiles())                {                    if (nextifile.Name.Contains(".bmp") == true || nextifile.Name.Contains(".BMP") == true)                    {                        //确认对应的帧图名                        string str_fieldid = Path.GetFileNameWithoutExtension(nextifile.Name);                        //在数据表中有颗粒在该帧图中的话,则对该帧图标记图像进行读取存入数据库                        DataRow[] datarowlist = dt_ParticlesGridDevidePage.Select(" fieldid = " + str_fieldid);                        if (datarowlist.Count() > 0)                        {                            Bitmap ls_bp_fieldmark = new Bitmap(nextifile.FullName);                            DataRow dr = DT_field_dt.NewRow();                            MemoryStream newms_bp_fieldmark = new MemoryStream();                            ls_bp_fieldmark.Save(newms_bp_fieldmark, System.Drawing.Imaging.ImageFormat.Bmp);                            newms_bp_fieldmark.Seek(0, SeekOrigin.Begin);                            byte[] newarr_fieldmark = new byte[newms_bp_fieldmark.Length];                            newms_bp_fieldmark.Read(newarr_fieldmark, 0, newarr_fieldmark.Length);                            dr["FieldImg"] = newarr_fieldmark;                            dr["FieldId"] = str_fieldid;                            ls_bp_fieldmark.Dispose();                            DT_field_dt.Rows.Add(dr);                        }                    }                }            }            #endregion            #region 插入-前20颗粒外的颗粒            for (int i_row = 20; i_row < dt_ParticlesGridDevidePage.Rows.Count; i_row++)            {                //获取颗粒的fieldid,和particleid                string str_fieldid = dt_ParticlesGridDevidePage.Rows[i_row]["fieldid"].ToString();                string str_particleid = dt_ParticlesGridDevidePage.Rows[i_row]["particleid"].ToString();                string str_subparticles = dt_ParticlesGridDevidePage.Rows[i_row]["SubParticles"].ToString();                string str_typeid = dt_ParticlesGridDevidePage.Rows[i_row]["TypeId"].ToString();                string str_typename = dt_ParticlesGridDevidePage.Rows[i_row]["TypeName"].ToString();                string str_element = dt_ParticlesGridDevidePage.Rows[i_row]["Element"].ToString();                //获取原始颗粒图像                Bitmap bp_particle = new Bitmap(1, 1);                string str_path = str_resultPath + "\\FIELD_FILES\\";                string str_imagePath = str_path + "Field" + str_fieldid.ToString() + ".bmp";                if (str_subparticles != null && str_subparticles != "")                {                    //合并大颗粒                    double ScanFieldSize = 1142;                    Bitmap tempbit = fielddata.ReadImageFile(str_imagePath);                    int pixw = tempbit.Width;                    double xs = pixw / ScanFieldSize;                    bp_particle = fielddata.GetBitmapForBig(str_subparticles, xs, str_resultPath);                }                else                {                    //正常颗粒                    Rectangle rectangle = new Rectangle() { X = Convert.ToInt32(dt_ParticlesGridDevidePage.Rows[i_row]["RectLeft"]), Y = Convert.ToInt32(dt_ParticlesGridDevidePage.Rows[i_row]["RectTop"]), Width = Convert.ToInt32(dt_ParticlesGridDevidePage.Rows[i_row]["RectWidth"]), Height = Convert.ToInt32(dt_ParticlesGridDevidePage.Rows[i_row]["RectHeight"]) };                    Bitmap bp_field = fielddata.ReadImageFile(str_imagePath);                    bp_particle = fielddata.GetBitmapByParticle(bp_field, rectangle);                    bp_particle.Tag = new List<string>() { dt_ParticlesGridDevidePage.Rows[i_row]["FieldId"].ToString(), dt_ParticlesGridDevidePage.Rows[i_row]["ParticleId"].ToString(), dt_ParticlesGridDevidePage.Rows[i_row]["TypeId"].ToString() };                }                //获取该颗粒的xray能谱图像                System.Drawing.Bitmap bp_xraybp = ExportXRayBitmap(str_fieldid,                    str_particleid, Convert.ToInt32(str_typeid), str_typename, fielddata);                //获取该颗粒的二次放大处理图像                Bitmap ls_processbitmap = new Bitmap(1, 1);                ls_processbitmap = (Bitmap)bp_particle.Clone();//待完善                //再将图像转成二进制流-------------------------------------------------------------------                //原图                MemoryStream newms_p1 = new MemoryStream();                bp_particle.Save(newms_p1, System.Drawing.Imaging.ImageFormat.Bmp);                newms_p1.Seek(0, SeekOrigin.Begin);                byte[] newarr_p1 = new byte[newms_p1.Length];                newms_p1.Read(newarr_p1, 0, newarr_p1.Length);                //---------------------------------------------------------------------------------------                                  DataRow dr = DT_Largest_frame.NewRow();                dr["p1"] = newarr_p1;                newms_p1.Dispose();                dr["pid"] = str_fieldid + dt_ParticlesGridDevidePage.Rows[i_row]["particleid"].ToString();                dr["Size"] = Convert.ToDouble(dt_ParticlesGridDevidePage.Rows[i_row]["area"]).ToString("#0.00");  //可以需要选择切换,计算方式                dr["Width"] = dt_ParticlesGridDevidePage.Rows[i_row]["rectwidth"].ToString();                dr["Class"] = dt_ParticlesGridDevidePage.Rows[i_row]["typename"].ToString();                dr["fieldid"] = str_fieldid;                List<string> list_max_elementname = new List<string>();                List<double> list_max_elementvale = new List<double>();                GetMaxElementFromDataTable(dt_ParticlesGridDevidePage, i_row, out list_max_elementname, out list_max_elementvale);                //元素1                dr["ColName1"] = list_max_elementname[0];                dr["ColVal1"] = list_max_elementvale[0].ToString();                //元素2                dr["ColName2"] = list_max_elementname[1];                dr["ColVal2"] = list_max_elementvale[1].ToString();                //元素3                dr["ColName3"] = list_max_elementname[2];                dr["ColVal3"] = list_max_elementvale[2].ToString();                //元素4                dr["ColName4"] = list_max_elementname[3];                dr["ColVal4"] = list_max_elementvale[3].ToString();                //元素5                dr["ColName5"] = list_max_elementname[4];                dr["ColVal5"] = list_max_elementvale[4].ToString();                //元素6                dr["ColName6"] = list_max_elementname[5];                dr["ColVal6"] = list_max_elementvale[5].ToString();                               DT_Largest_frame.Rows.Add(dr);            }            #endregion            m_list_dt.Add(DT_field_dt);            m_list_dt.Add(DT_Largest_frame);            m_list_dt.Add(DT_Largest20);            return true;        }        #endregion        #region 插入颗粒尺寸表        /// <summary>        /// 向 模板设计器 中插入 颗粒尺寸表        /// </summary>        /// <returns></returns>        public bool InsertReportTemplateTable_ParticleSizeGrid()        {            try            {                //加载模块                ParticlesSizeGrid ls_particlesizegrid = new ParticlesSizeGrid(m_otsreport_export.m_ReportApp);                List<string> vs = new List<string>() { "DMAX", "DMIN", "Area", "FERET" };                ls_particlesizegrid.condition = vs[m_otsreport_export.m_mbszclass.M_KLFXJG.index_cb_klcc_jsfs];                m_otsreport_export.panel_container.Controls.Clear();                m_otsreport_export.panel_container.Controls.Add(ls_particlesizegrid);                DataGridView ls_gv = new DataGridView();                DataTable ls_dt = new DataTable();                ls_particlesizegrid.GetDataTableAndGridView(out ls_dt, out ls_gv);                //------------------------------------------------                DataTable ls_partsize_dt = new DataTable();                ls_partsize_dt.TableName = "PartSize";                ls_partsize_dt.Columns.Add("c1");                ls_partsize_dt.Columns.Add("c2");                ls_partsize_dt.Columns.Add("c3");                ls_partsize_dt.Columns.Add("c4");                ls_partsize_dt.Columns.Add("c5");                ls_partsize_dt.Columns.Add("c6");                ls_partsize_dt.Columns.Add("c7");                ls_partsize_dt.Columns.Add("c8");                ls_partsize_dt.Columns.Add("c9");                DataRow dr = ls_partsize_dt.NewRow();                //从2开始,固定的                int col = 6;                for (int i = 1; i < 11; i++)                {                    if (ls_gv.Columns.Count > col)                        if (i<10)                            dr["c" + i.ToString()] = ls_gv.Columns[col++].Name;                                        }                ls_partsize_dt.Rows.Add(dr);                DataTable ls_Particel_dt = new DataTable();                ls_Particel_dt.TableName = "Particel";                ls_Particel_dt.Columns.Add("c1");                ls_Particel_dt.Columns.Add("c2");                ls_Particel_dt.Columns.Add("c3");                ls_Particel_dt.Columns.Add("c4");                ls_Particel_dt.Columns.Add("c5");                ls_Particel_dt.Columns.Add("c6");                ls_Particel_dt.Columns.Add("c7");                ls_Particel_dt.Columns.Add("c8");                ls_Particel_dt.Columns.Add("c9");                ls_Particel_dt.Columns.Add("SName");                ls_Particel_dt.Columns.Add("total");                ls_Particel_dt.Columns.Add("Largest");                ls_Particel_dt.Columns.Add("Hardness");                ls_Particel_dt.Columns.Add("Density");                ls_Particel_dt.Columns.Add("Conductivity");                for (int i = 0; i < ls_gv.Rows.Count; i++)                {                    DataRow dr2 = ls_Particel_dt.NewRow();                    dr2["SName"] = ls_gv.Rows[i].Cells[1].Value.ToString();                    dr2["Largest"] = ls_gv.Rows[i].Cells[4].Value.ToString();                    dr2["Hardness"] = ls_gv.Rows[i].Cells[6].Value.ToString();                    dr2["Density"] = ls_gv.Rows[i].Cells[7].Value.ToString();                    dr2["Conductivity"] = ls_gv.Rows[i].Cells[8].Value.ToString();                    int col2 = 6;                    for (int j = 1; j < 11; j++)                    {                        if (ls_gv.Columns.Count > col2)                            if(j<10)                                dr2["c" + j.ToString()] = ls_gv.Rows[i].Cells[col2++].Value.ToString();                    }                    //total,不为空行,和不能是总计行                    if (dr2["SName"].ToString() != "" && dr2["SName"].ToString().IndexOf("个数") < 0)                    {                        dr2["total"] = "0"; //求合                        double d_total = 0;                        int col3 = 6;                        for (int j = 1; j < 11; j++)                        {                            if (ls_gv.Columns.Count > col3)                                d_total = d_total + Convert.ToInt64(ls_gv.Rows[i].Cells[col3++].Value.ToString());                        }                        dr2["total"] = d_total.ToString();                    }                    ls_Particel_dt.Rows.Add(dr2);                }                m_list_dt.Add(ls_partsize_dt);                m_list_dt.Add(ls_Particel_dt);                return true;            }            catch (Exception ee)            {                m_otsreport_export.WriteRictBox(ee.ToString());                return false;            }        }        #endregion        #region 插入平均元素含量表        /// <summary>        /// 向 模板设计器 中插入 平均元素含量表        /// </summary>        /// <returns></returns>        public bool InsertReportTemplateTable_ElementCompositionAvgGrid()        {            try            {                //加载模块                ElementCompositionAvgGrid ls_elementcompositionavggrid = new ElementCompositionAvgGrid(m_otsreport_export.m_ReportApp);                //List<string> vs = new List<string>() { "DMAX", "DMIN", "Area", "FERET" };                //ls_elementcompositionavggrid.condition = vs[m_otsreport_export.m_mbszclass.M_YSFXJG.index_cb_yxfx_jsfs];                m_otsreport_export.panel_container.Controls.Clear();                m_otsreport_export.panel_container.Controls.Add(ls_elementcompositionavggrid);                DataGridView ls_gv = new DataGridView();                DataTable ls_dt = new DataTable();                ls_elementcompositionavggrid.GetDataTableAndGridView(out ls_dt, out ls_gv);                //------------------------------------------------                DataTable ls_elementname_dt = new DataTable();                ls_elementname_dt.TableName = "ElementName";                ls_elementname_dt.Columns.Add("e1");                ls_elementname_dt.Columns.Add("e2");                ls_elementname_dt.Columns.Add("e3");                ls_elementname_dt.Columns.Add("e4");                ls_elementname_dt.Columns.Add("e5");                ls_elementname_dt.Columns.Add("e6");                ls_elementname_dt.Columns.Add("e7");                ls_elementname_dt.Columns.Add("e8");                ls_elementname_dt.Columns.Add("e9");                DataRow dr = ls_elementname_dt.NewRow();                int col = 5;                for (int i = 1; i < 10; i++)                {                    if (ls_gv.Columns.Count > col)                        dr["e" + i.ToString()] = ls_gv.Columns[col++].Name;                }                ls_elementname_dt.Rows.Add(dr);                DataTable ls_element_dt = new DataTable();                ls_element_dt.TableName = "ElementValue";                ls_element_dt.Columns.Add("e1");                ls_element_dt.Columns.Add("e2");                ls_element_dt.Columns.Add("e3");                ls_element_dt.Columns.Add("e4");                ls_element_dt.Columns.Add("e5");                ls_element_dt.Columns.Add("e6");                ls_element_dt.Columns.Add("e7");                ls_element_dt.Columns.Add("e8");                ls_element_dt.Columns.Add("e9");                ls_element_dt.Columns.Add("PName");                ls_element_dt.Columns.Add("Count");                for (int i = 0; i < ls_gv.Rows.Count; i++)                {                    DataRow dr2 = ls_element_dt.NewRow();                    dr2["PName"] = ls_gv.Rows[i].Cells[1].Value.ToString();                    dr2["Count"] = ls_gv.Rows[i].Cells[2].Value.ToString();                    int colq = 5;                    for (int j = 1; j < 10; j++)                    {                        if (ls_gv.Columns.Count > colq)                            dr2["e" + j.ToString()] = ls_gv.Rows[i].Cells[colq++].Tag.ToString();                    }                    ls_element_dt.Rows.Add(dr2);                }                m_list_dt.Add(ls_elementname_dt);                m_list_dt.Add(ls_element_dt);                return true;            }            catch (Exception ee)            {                m_otsreport_export.WriteRictBox(ee.ToString());                return false;            }        }        #endregion        #region 插入颗粒图chart        /// <summary>        /// 用于颗粒图chart        /// </summary>        /// <returns></returns>        private DataTable GetPicDataTable_PicKL()        {            if (m_list_dt.Where(aa => aa.TableName.Contains("PicKL")).ToList().Count == 0)            {                //创建二进制列的数据表                DataTable ls_dt = new DataTable();                ls_dt.TableName = "PicKL";                DataColumn colpict = new DataColumn("pict");                colpict.DataType = System.Type.GetType("System.Byte[]");                ls_dt.Columns.Add(colpict);                m_list_dt.Add(ls_dt);                return ls_dt;            }            else            {                return m_list_dt.Where(aa => aa.TableName.Contains("PicKL")).ToList()[0];            }        }        #endregion        #region 插入元素图chart        /// <summary>        /// 用于元素图chart        /// </summary>        /// <returns></returns>        private DataTable GetPicDataTable_PicYS()        {            if (m_list_dt.Where(aa => aa.TableName.Contains("PicYS")).ToList().Count == 0)            {                //创建二进制列的数据表                DataTable ls_dt = new DataTable();                ls_dt.TableName = "PicYS";                DataColumn colpict = new DataColumn("pict");                colpict.DataType = System.Type.GetType("System.Byte[]");                ls_dt.Columns.Add(colpict);                m_list_dt.Add(ls_dt);                return ls_dt;            }            else            {                return m_list_dt.Where(aa => aa.TableName.Contains("PicYS")).ToList()[0];            }        }        #endregion        #region 插入颗粒成份图        /// <summary>        /// 向 模板设计器 中插入 颗粒成份图        /// </summary>        /// <returns></returns>        public bool InsertReportTemplateChart_ParticlesCompositionChart(string a_GraphicStyle)        {            try            {                //-----------------------------------颗粒成份图-----------------------------------------------------------------------------------------------                //加载模块                m_otsreport_export.m_ReportApp.im_EChart_ParticlesComposition = new EChart_ParticlesComposition(m_otsreport_export.m_ReportApp, "PComponent");                m_otsreport_export.m_ReportApp.m_reportname = "InclusionClassification";                m_otsreport_export.m_ReportApp.type = a_GraphicStyle;                m_otsreport_export.m_ReportApp.timerKG = true;                m_otsreport_export.m_ReportApp.m_CChartsWindow.Controls.Add(m_otsreport_export.m_ReportApp.im_EChart_ParticlesComposition);                //弹出加载图片窗体                OTSReport_GetEChartImage og = new OTSReport_GetEChartImage();                //将EChart委托事件注册给加载图片窗体的方法                m_otsreport_export.m_ReportApp.im_EChart_ParticlesComposition.butclic += og.get_ParticalesCompositionChart;                og.ShowDialog();                //获取图片数据                string str = og.PicStr;                //将Base64String转为图片并保存                byte[] arr = Convert.FromBase64String(str.Substring(str.IndexOf(',') + 1));                MemoryStream ms = new MemoryStream(arr);                System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(ms);                //再将图转成流,流再转二进制-------------------------------------------                MemoryStream newms = new MemoryStream();                bmp.Save(newms, System.Drawing.Imaging.ImageFormat.Bmp);                newms.Seek(0, SeekOrigin.Begin);                byte[] newarr = new byte[newms.Length];                newms.Read(newarr, 0, newarr.Length);                newms.Dispose();                //创建二进制列的数据表                DataTable ls_dt = GetPicDataTable_PicKL();                DataRow dr = ls_dt.NewRow();                dr["pict"] = newarr;//图像二进制                ls_dt.Rows.Add(dr);                return true;            }            catch (Exception ee)            {                m_otsreport_export.WriteRictBox(ee.ToString());                return false;            }        }        #endregion        #region 插入元素成份图        /// <summary>        /// 向 模板设计器 中插入 元素成份图        /// </summary>        /// <returns></returns>        public bool InsertReportTemplateChart_ElementCompositionChart(string a_GraphicStyle)        {            try            {                //-----------------------------------元素成份图-----------------------------------------------------------------------------------------------                //加载模块                m_otsreport_export.m_ReportApp.im_EChart_ParticlesComposition = new EChart_ParticlesComposition(m_otsreport_export.m_ReportApp, "EComponent");                m_otsreport_export.m_ReportApp.m_reportname = "ElementComposition";                m_otsreport_export.m_ReportApp.type = a_GraphicStyle;                m_otsreport_export.m_ReportApp.timerKG = true;                m_otsreport_export.m_ReportApp.m_CChartsWindow.Controls.Add(m_otsreport_export.m_ReportApp.im_EChart_ParticlesComposition);                //弹出加载图片窗体                OTSReport_GetEChartImage og = new OTSReport_GetEChartImage();                //将EChart委托事件注册给加载图片窗体的方法                m_otsreport_export.m_ReportApp.im_EChart_ParticlesComposition.butclic += og.get_ParticalesCompositionChart;                og.ShowDialog();                //获取图片数据                string str = og.PicStr;                //将Base64String转为图片并保存                byte[] arr = Convert.FromBase64String(str.Substring(str.IndexOf(',') + 1));                MemoryStream ms = new MemoryStream(arr);                System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(ms);                //再将图转成流,流再转二进制-------------------------------------------                MemoryStream newms = new MemoryStream();                bmp.Save(newms, System.Drawing.Imaging.ImageFormat.Bmp);                newms.Seek(0, SeekOrigin.Begin);                byte[] newarr = new byte[newms.Length];                newms.Read(newarr, 0, newarr.Length);                newms.Dispose();                //创建二进制列的数据表                DataTable ls_dt = GetPicDataTable_PicYS();                DataRow dr = ls_dt.NewRow();                dr["pict"] = newarr;//图像二进制                ls_dt.Rows.Add(dr);                return true;            }            catch (Exception ee)            {                m_otsreport_export.WriteRictBox(ee.ToString());                return false;            }        }        #endregion        #region 插入三元相图        /// <summary>        /// 获取或创建pic表格,用于三元相图        /// </summary>        /// <returns></returns>        private DataTable GetPicDataTable_PicSYXT2T()        {            if (m_list_dt.Where(aa => aa.TableName.Contains("PicSYXT2T")).ToList().Count == 0)            {                //创建二进制列的数据表                DataTable ls_dt = new DataTable();                ls_dt.TableName = "PicSYXT2T";                DataColumn colpict = new DataColumn("pict");                colpict.DataType = System.Type.GetType("System.Byte[]");                ls_dt.Columns.Add(colpict);                DataColumn colpict2 = new DataColumn("pict2");                colpict2.DataType = System.Type.GetType("System.Byte[]");                ls_dt.Columns.Add(colpict2);                m_list_dt.Add(ls_dt);                return ls_dt;            }            else            {                return m_list_dt.Where(aa => aa.TableName.Contains("PicSYXT2T")).ToList()[0];            }        }        /// <summary>        /// 获取或创建pic表格,用于三元相图,3个列的        /// </summary>        /// <returns></returns>        private DataTable GetPicDataTable_PicSYXT3T()        {            if (m_list_dt.Where(aa => aa.TableName.Contains("PicSYXT3T")).ToList().Count == 0)            {                //创建二进制列的数据表                DataTable ls_dt = new DataTable();                ls_dt.TableName = "PicSYXT3T";                DataColumn colpict = new DataColumn("pict");                colpict.DataType = System.Type.GetType("System.Byte[]");                ls_dt.Columns.Add(colpict);                DataColumn colpict2 = new DataColumn("pict2");                colpict2.DataType = System.Type.GetType("System.Byte[]");                ls_dt.Columns.Add(colpict2);                DataColumn colpict3 = new DataColumn("pict3");                colpict3.DataType = System.Type.GetType("System.Byte[]");                ls_dt.Columns.Add(colpict3);                m_list_dt.Add(ls_dt);                return ls_dt;            }            else            {                return m_list_dt.Where(aa => aa.TableName.Contains("PicSYXT")).ToList()[0];            }        }        /// <summary>        /// 获取三元相图二进制数据        /// </summary>        /// <param name="selectindex"></param>        /// <returns></returns>        private byte[] GetByte_InsertReportTemplateChart_Trianglediagram(int selectindex)        {            byte[] newarr = new byte[0];            //加载模块            m_otsreport_export.m_ReportApp.im_EChart_Trianglediagram = new EChart_Trianglediagram(m_otsreport_export.m_ReportApp, TemplateList[selectindex]);            m_otsreport_export.m_ReportApp.timerKG = true;            m_otsreport_export.m_ReportApp.im_EChart_Trianglediagram.condition = m_otsreport_export.m_mbszclass.M_SYXT.index_cb_syxt_jsfs;            m_otsreport_export.m_ReportApp.m_CChartsWindow.Controls.Add(m_otsreport_export.m_ReportApp.im_EChart_Trianglediagram);            //ls_echart_trianglediagram.            //弹出加载图片窗体            OTSReport_GetEChartImage og = new OTSReport_GetEChartImage();            //将EChart委托事件注册给加载图片窗体的方法            m_otsreport_export.m_ReportApp.im_EChart_Trianglediagram.butclic += og.get_ParticalesCompositionChart;            og.ShowDialog();            //获取图片数据            string str = og.PicStr;            //将Base64String转为图片并保存            byte[] arr = Convert.FromBase64String(str.Substring(str.IndexOf(',') + 1));            MemoryStream ms = new MemoryStream(arr);            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(ms);            //再将图转成流,流再转二进制-------------------------------------------            MemoryStream newms = new MemoryStream();            bmp.Save(newms, System.Drawing.Imaging.ImageFormat.Bmp);            newms.Seek(0, SeekOrigin.Begin);            newarr = new byte[newms.Length];            newms.Read(newarr, 0, newarr.Length);            newms.Dispose();            return newarr;        }        /// <summary>        /// 向 模板设计器 中插入 三元相图        /// </summary>        /// <returns></returns>        public bool InsertReportTemplateChart_Trianglediagram()        {            try            {                //创建二进制列的数据表,循环插入三元选择的模板                DataTable ls_dt = GetPicDataTable_PicSYXT2T();                DataTable ls_dt3t = GetPicDataTable_PicSYXT3T();                //这里要校验一下,总数必须要是2的整倍数,不可有余数                if (m_otsreport_export.m_mbszclass.M_SYXT.str_cb_syxt_mhxssl == "2" && m_otsreport_export.m_mbszclass.M_SYXT.list_lbv_syxt_mblb_index.Count % 2 == 0)                {                    for (int i = 0; i < m_otsreport_export.m_mbszclass.M_SYXT.list_lbv_syxt_mblb_index.Count; i = i + 2)                    {                        byte[] newarr, newarr2;                        newarr = GetByte_InsertReportTemplateChart_Trianglediagram(m_otsreport_export.m_mbszclass.M_SYXT.list_lbv_syxt_mblb_index[i]);                        newarr2 = GetByte_InsertReportTemplateChart_Trianglediagram(m_otsreport_export.m_mbszclass.M_SYXT.list_lbv_syxt_mblb_index[i + 1]);                        DataRow dr = ls_dt.NewRow();                        dr["pict"] = newarr;//图像二进制                        dr["pict2"] = newarr2;//图像二进制                        ls_dt.Rows.Add(dr);                    }                }                else                {                    DataRow dr = ls_dt.NewRow();                    dr["pict"] = null;//图像二进制                    dr["pict2"] = null;//图像二进制                    ls_dt.Rows.Add(dr);                }                if (m_otsreport_export.m_mbszclass.M_SYXT.str_cb_syxt_mhxssl == "3" && m_otsreport_export.m_mbszclass.M_SYXT.list_lbv_syxt_mblb_index.Count % 3 == 0)                {                    for (int i = 0; i < m_otsreport_export.m_mbszclass.M_SYXT.list_lbv_syxt_mblb_index.Count; i = i + 3)                    {                        byte[] newarr, newarr2, newarr3;                        newarr = GetByte_InsertReportTemplateChart_Trianglediagram(m_otsreport_export.m_mbszclass.M_SYXT.list_lbv_syxt_mblb_index[i]);                        newarr2 = GetByte_InsertReportTemplateChart_Trianglediagram(m_otsreport_export.m_mbszclass.M_SYXT.list_lbv_syxt_mblb_index[i + 1]);                        newarr3 = GetByte_InsertReportTemplateChart_Trianglediagram(m_otsreport_export.m_mbszclass.M_SYXT.list_lbv_syxt_mblb_index[i + 2]);                        DataRow dr = ls_dt3t.NewRow();                        dr["pict"] = newarr;//图像二进制                        dr["pict2"] = newarr2;//图像二进制                        dr["pict3"] = newarr3;//图像二进制                        ls_dt3t.Rows.Add(dr);                    }                }                else                {                    DataRow dr = ls_dt3t.NewRow();                    dr["pict"] = null;//图像二进制                    dr["pict2"] = null;//图像二进制                    dr["pict3"] = null;//图像二进制                    ls_dt3t.Rows.Add(dr);                }                return true;            }            catch (Exception ee)            {                m_otsreport_export.WriteRictBox(ee.ToString());                return false;            }        }        #endregion        #region 其它部份        ///// <summary>        ///// 获取夹杂物总数量,报告中暂时固定导出100数量,如果需要导出全部颗粒,到颗粒列表中导出Excel使用        ///// </summary>        ///// <returns></returns>        //public int GetReportTemplateTable_ParticlesNumber()        //{        //    return 100;        //}        /// <summary>        /// 输入颗粒的所在帧图id,颗粒id,颗粒类型id,获取对应的XRay能谱数据图        /// </summary>        /// <returns></returns>        public Bitmap ExportXRayBitmap(string in_fieldid, string in_particleid, int in_stdtypeid, string TypeName, ParticleData particleData)        {            Bitmap ret_bp;            //显示xray相关信息            uint[] Search_xray = new uint[2000];            uint[] Analysis_xray = new uint[2000];            //            int i_xray_id = 0;            List<Element> list_celementchemistryclr = new List<Element>();            //获取Xray数据            list_celementchemistryclr = new List<Element>();            Particle list = particleData.GetParticleByFidAndPid(in_fieldid, in_particleid);            if (list == null)            {                return null;            }            Particle particle = list;            if (particle.XrayId > -1)            {                for (int i = 0; i < 2000; i++)                {                    Analysis_xray[i] = BitConverter.ToUInt32(particle.XRayData, i * 4);                }                Search_xray = Analysis_xray;                i_xray_id = particle.XrayId;                list_celementchemistryclr = particle.ElementList;            }            //get CElementChemistryClr list            List<ShowElementInfo> list_showelementinfo = new List<ShowElementInfo>();            for (int i = 0; i < list_celementchemistryclr.Count; i++)            {                ShowElementInfo ls_sei = new ShowElementInfo();                ls_sei.ElementName = list_celementchemistryclr[i].Name;                ls_sei.Percentage = list_celementchemistryclr[i].Percentage;                ls_sei.dKF = Convert.ToDouble(CListPeriodic.GetPeriodicByYsm(CListPeriodic.GetListPeriodic(), ls_sei.ElementName).SX1);                list_showelementinfo.Add(ls_sei);            }            //获取使用标准库的名称            string str_stdname = "";            string str_IncALibName = "";            if (in_stdtypeid < 1000)            {                //小于1000,使用系统默认分类                str_IncALibName = TypeName;                str_stdname = "Default standard library";            }            else if (in_stdtypeid >= 1000 && in_stdtypeid < 10000)            {                //大于等于1000,并且小于10000时,使用系统数据库中夹杂物来分析                str_IncALibName = TypeName;                str_stdname = "User defined standard library";            }            else if (in_stdtypeid > 10000)            {                //大于10000时,使用用户标准库来分析夹杂物名称                str_IncALibName = TypeName;                str_stdname = "System standard library";            }            //获取数据后,需要对xraytable设置            OTSIncAReportGraph.Controls.Control_XRayTable control_XRayTable1 = new Control_XRayTable();            control_XRayTable1.SetXRayShowLineValue(Search_xray, Analysis_xray, list_showelementinfo);            //颗粒国标信息            //control_XRayTable1.GBInfoStr = in_dparticle.GBContent;            control_XRayTable1.GoodName = str_IncALibName;//杂夹物            control_XRayTable1.STDName = str_stdname;//标准库            control_XRayTable1.List_ShowElementInfo = list_showelementinfo;            control_XRayTable1.Visible = true;            control_XRayTable1.Invalidate();            control_XRayTable1.Refresh();            ret_bp = control_XRayTable1.ExportXRayImage();            return ret_bp;        }        /// <summary>        /// 导出二次放大图像        /// </summary>        /// <param name="str_srcPathName"></param>        /// <param name="str_outPathName"></param>        public void ParticleReZoom(string str_srcPathName, string str_outPathName)        {            //m_COTSReportProjFileMgrClr.ReZoom(str_srcPathName, str_outPathName);        }        /// <summary>        /// 传入DataTable,和行号,返回该Row行中,返回6个靠前的元素,不足6个返回空        /// </summary>        /// <param name="in_dt"></param>        /// <param name="row_index"></param>        /// <returns></returns>        private void GetMaxElementFromDataTable(DataTable in_dt, int row_index, out List<string> out_list_elementname, out List<double> out_list_elementvalue)        {            out_list_elementname = new List<string>();            out_list_elementvalue = new List<double>();            //分别排出元素名,元素值列表            List<string> list_elementname = new List<string>();            List<double> list_elementvalue = new List<double>();            string str_element = in_dt.Rows[row_index]["Element"].ToString();            //防止取出的元素信息为空            if (str_element != "")            {                string[] strcbo = str_element.Split(';');                for (int i = 0; i < strcbo.Length; i++)                {                    string[] str = strcbo[i].Split('-');                    list_elementname.Add(str[0]);                    list_elementvalue.Add(Math.Round(Convert.ToDouble(str[1]), 2));                }            }            //循环6次,得到最大的6个元素信息            for (int geti = 0; geti < 6; geti++)            {                double max_elementvalue = -1;                string max_elementname = "";                int max_index = -1;                if (list_elementvalue.Count > 1)                {                    for (int i = 0; i < list_elementvalue.Count; i++)                    {                        if (list_elementvalue[i] > max_elementvalue)                        {                            max_elementvalue = list_elementvalue[i];                            max_elementname = list_elementname[i];                            max_index = i;                        }                    }                    //移除掉最大的元素                    list_elementname.RemoveAt(max_index);                    list_elementvalue.RemoveAt(max_index);                    //将最大的元素添加到list中                    if (max_elementvalue > 0)                    {                        out_list_elementname.Add(max_elementname);                        out_list_elementvalue.Add(max_elementvalue);                    }                    else                    {                        out_list_elementname.Add(" ");                        out_list_elementvalue.Add(0);                    }                }                else                {                    //如果元素数量已经不够,则添加空                    out_list_elementname.Add(" ");                    out_list_elementvalue.Add(0);                }            }        }        /// <summary>        /// 传入DataTable和想要找到的列名,返回对应列的索引        /// </summary>        /// <param name="in_dt"></param>        /// <param name="in_str"></param>        /// <returns></returns>        private int GetDataTableColumnsIndexByName(DataTable in_dt, string in_str)        {            int i_ret = -1;            for (int i = 0; i < in_dt.Columns.Count; i++)            {                if (in_dt.Columns[i].ColumnName.IndexOf(in_str) > -1)                {                    //找到                    i_ret = i;                    break;                }            }            return i_ret;        }        /// <summary>        /// 传入DataTable和想要的元素第几个排列,返回对应的列的索引        /// </summary>        /// <param name="in_dt"></param>        /// <param name="in_str"></param>        /// <returns></returns>        private int GetDataTableColumnsIndexByElementNumber(DataTable in_dt, int in_elementorder)        {            int i_ret = -1;            int i_findcount = 0;//第几次找到的记数            //首先遍历所有的datatable中的元素            for (int i = 0; i < in_dt.Columns.Count; i++)            {                //然后遍历该列是否是元素名,要显示的元素名                for (int k = 0; k < m_otsreport_export.m_mbszclass.M_KLLBXX.list_str_tb_lllb_sxys.Count; k++)                {                    if (in_dt.Columns[i].ColumnName.ToString().ToUpper() == m_otsreport_export.m_mbszclass.M_KLLBXX.list_str_tb_lllb_sxys[k].ToUpper())                    {                        //找到了                        if (i_findcount == in_elementorder)                        {                            //并且达到了想找的第几个序列,返回对应的列的索引                            i_ret = i;                            return i_ret;                        }                        else                        {                            //否则,找到的索引号增长                            i_findcount++;                        }                    }                }            }            return i_ret;        }        #endregion    }}
 |