Browse Source

修改报告导出三元图,从echar截图改成图片绘制

zhangjiaxin 3 years ago
parent
commit
e3c1d9d38c

+ 14 - 0
OTSIncAReportApp/1-UI/Control_ECharts/EChart_Trianglediagram.cs

@@ -8,6 +8,7 @@ using OTSIncAReportApp.OTSSampleReportInfo;
 using System;
 using System.Collections.Generic;
 using System.Data;
+using System.Drawing;
 using System.IO;
 using System.Runtime.Serialization;
 using System.Windows.Forms;
@@ -184,6 +185,10 @@ namespace OTSIncAReportApp.Control_ECharts
                 }
                 ReportExporting = false;
                 TriangleJsonClass cl = GettriangleJsonClass(resultFile.FilePath, resultFile.anotherFileName, nameList, TemplateName,sel);
+
+
+          
+
                 m_list_trianglejsonclass.Add(cl);
             }
 
@@ -253,6 +258,13 @@ namespace OTSIncAReportApp.Control_ECharts
             return triangleJsonClass;
         }
 
+
+
+
+   
+
+
+
         //获取颗粒信息
         private DataTable GetParticles(string filepath, List<string> nameList,int sel)
         {
@@ -338,6 +350,7 @@ namespace OTSIncAReportApp.Control_ECharts
             ret_dt.Columns.Add("top");
             ret_dt.Columns.Add("left");
             ret_dt.Columns.Add("right");
+            ret_dt.Columns.Add("Color_position");
 
             for (int k = 0; k < listName.Count; k++)
             {
@@ -360,6 +373,7 @@ namespace OTSIncAReportApp.Control_ECharts
                     dr["top"] = strRet.Split(',')[0];
                     dr["left"] = strRet.Split(',')[1];
                     dr["right"] = strRet.Split(',')[2];
+                    dr["Color_position"] = k.ToString();
                     ret_dt.Rows.Add(dr);
                 }
 

+ 434 - 10
OTSIncAReportApp/1-UI/OTSTemplateDesigner/Export_ReportTemplate.cs

@@ -30,6 +30,9 @@ namespace OTSIncAReportApp.OTSTemplateDesigner
         DataTable userLibraryData;
         DataTable m_bt_DBData = new DataTable();
         List<string> TemplateList;
+        frmReportConditionChoose m_condition;
+
+        public int condition = -1;
         #endregion
 
         #region 构造函数
@@ -37,7 +40,7 @@ namespace OTSIncAReportApp.OTSTemplateDesigner
         {
             m_otsreport_export = in_export;
             TemplateList = new List<string>();
-
+            m_condition = in_export.m_ReportApp.m_conditionChoose;
             //加载三元相图各项
             string pathtpf = in_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.TrigTemplateFileFolder + "\\" + in_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.TriTempFile;// Application.StartupPath + "\\Config\\ProData\\DefaultTriTemplateFile.tpf";
             TemplateList = new List<string>();
@@ -200,7 +203,7 @@ namespace OTSIncAReportApp.OTSTemplateDesigner
             }
             data = dt;
         }
-        public bool GetDBData(MBSZClass m_mbszclass)
+        public bool GetDBData(c_TemplateClass m_mbszclass)
         {
             //GetSTL();
             
@@ -925,7 +928,7 @@ namespace OTSIncAReportApp.OTSTemplateDesigner
         /// </summary>
         /// <param name="m_mbszclass"></param>
         /// <returns></returns>
-        public DataTable Get_dev_kllb_data(MBSZClass m_mbszclass)
+        public DataTable Get_dev_kllb_data(c_TemplateClass m_mbszclass)
         {
             int serialNumber = 1;
             //------------------加载模块,获取数据-------------------------------------------------
@@ -1140,7 +1143,7 @@ namespace OTSIncAReportApp.OTSTemplateDesigner
             return DT_Largest20;
         }
 
-        public void Get_dev_kllb_data_frame(MBSZClass m_mbszclass, out DataTable file_pic, out List<DataTable> list_dt)
+        public void Get_dev_kllb_data_frame(c_TemplateClass m_mbszclass, out DataTable file_pic, out List<DataTable> list_dt)
         {
 
             //------------------加载模块,获取数据-------------------------------------------------
@@ -1231,7 +1234,7 @@ namespace OTSIncAReportApp.OTSTemplateDesigner
             list_dt = listData;
         }
 
-        private void FrameGraphParticleTableDatat(DataTable dt_ParticlesGridDevidePage, ParticleData fielddata, DataTable DT_field_dt, MBSZClass m_mbszclass, out DataTable data_A)
+        private void FrameGraphParticleTableDatat(DataTable dt_ParticlesGridDevidePage, ParticleData fielddata, DataTable DT_field_dt, c_TemplateClass m_mbszclass, out DataTable data_A)
         {
             //将颗粒大小排序(从大到小)
             DataView dv = dt_ParticlesGridDevidePage.DefaultView;
@@ -1355,7 +1358,7 @@ namespace OTSIncAReportApp.OTSTemplateDesigner
 
         }
 
-        public void ParticleSizeTable(MBSZClass m_mbszclass, out DataTable surface_dt, out DataTable partsize_dt, out DataTable class_dt, out DataTable subdivide_dt)
+        public void ParticleSizeTable(c_TemplateClass m_mbszclass, out DataTable surface_dt, out DataTable partsize_dt, out DataTable class_dt, out DataTable subdivide_dt)
         {
             //全部大类
             DataTable dt_addCalss = new DataTable();
@@ -1535,7 +1538,7 @@ namespace OTSIncAReportApp.OTSTemplateDesigner
 
         }
 
-        public bool InsertReportTemplateTable_ElementAvgGrid(MBSZClass m_mbszclass, out DataTable dt1, out DataTable dt2)
+        public bool InsertReportTemplateTable_ElementAvgGrid(c_TemplateClass m_mbszclass, out DataTable dt1, out DataTable dt2)
         {
             if (m_bt_DBData.Columns.Count == 0)
             {
@@ -1676,7 +1679,9 @@ namespace OTSIncAReportApp.OTSTemplateDesigner
             return true;
         }
 
-        public Bitmap GetByte_InsertReportChart_Trianglediagram(int selectindex, MBSZClass m_mbszclass)
+        #region 三元图
+        //截取Echar的三元图
+        public Bitmap GetByte_InsertReportChart_Trianglediagram(int selectindex, c_TemplateClass m_mbszclass)
         {
             //加载模块
             EChart_Trianglediagram eChart_Trianglediagram = new EChart_Trianglediagram(m_otsreport_export.m_ReportApp, TemplateList[selectindex]);
@@ -1705,12 +1710,431 @@ namespace OTSIncAReportApp.OTSTemplateDesigner
 
             return btmap_pic;
         }
+        //手动绘制的三元图
+        public Bitmap DrawATernaryPicture(int selectindex, c_TemplateClass m_mbszclass, List<Color> Color_list)
+        {
+            int sel = 0;
+            if (m_mbszclass.M_SY.int_xzkl == 0)
+            {
+                sel = 0;
+            }
+            else
+            {
+                sel = 1;
+            }
+
+            ResultFile resultFile = m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()];
+
+            string template = TemplateList[selectindex];
+            if (template == "")
+            { //三元相图模板
+                template = m_condition.m_SourceGridData.GetPropItemDisplayValueByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.TRIO_CHART_TYPE).ToString();
+            }
+            //获取粒级表
+            string pathtpf = Application.StartupPath + "\\Config\\ProData\\DefaultTriTemplateFile.tpf";
+            List<string> nameList = new List<string>();
+            DataSet ds = XMLoperate.GetXmlData(pathtpf, "XMLData");
+            DataTable dt = ds.Tables["Member"];
+            string TemplateName = "";
+            //遍历第一层节点
+            foreach (DataRow element in dt.Rows)
+            {
+                TemplateName = element["TemplateName"].ToString();
+
+                if (TemplateName == template)
+                {
+                    string Element = element["Element"].ToString();
+                    nameList.Add(Element.Split('.')[0]);
+                    nameList.Add(Element.Split('.')[1]);
+                    nameList.Add(Element.Split('.')[2]);
+                    break;
+                }
+            }
+
+
+            
+            DataTable dt_point_sort = new DataTable();
+            dt_point_sort.Columns.Add("X", typeof(double));
+            dt_point_sort.Columns.Add("Y", typeof(double));
+            dt_point_sort.Columns.Add("Color_position");
+            DataTable particles = GetParticles(resultFile.FilePath, nameList, sel);
+            foreach (DataRow item in particles.Rows)
+            {
+                if (item["particleLocation"].ToString() == "0,0,0")
+                {
+                    continue;
+                }
+
+                double top = Convert.ToDouble(item["top"]);
+                double left = Convert.ToDouble(item["left"]);
+                double right = Convert.ToDouble(item["right"]);
+                //x=right+top/2,y=(√3/2)*top
+                double Y = 0.866 * top * 500;
+                double X = (right + top / 2) * 500;
+                double[] point_ = { Math.Round(X, 2), Math.Round(Y) };
+                DataRow dr = dt_point_sort.NewRow();
+                dr["X"] = Math.Round(X, 2);
+                dr["Y"] = Math.Round(Y);
+                dr["Color_position"] = item["Color_position"];
+                dt_point_sort.Rows.Add(dr);
+
+            }
+
+            #region 图形
+            int Line = 500;
+            Bitmap map = new Bitmap(530, 530);
+            Graphics g = Graphics.FromImage(map);
+
+            SolidBrush sbrush_White = new SolidBrush(Color.White);
+            g.FillRectangle(sbrush_White, 0, 0, 530, 530);
+
+            Pen mypen = new Pen(Color.Black, 2);
+            g.DrawImage(map, 0, 0, map.Width, map.Height);
+            g.DrawLine(mypen, new Point(Line + 10, Line), new Point(Line / 2 + 10, Convert.ToInt32(Line - (Line / 2 * 1.732))));//"\"
+            g.DrawLine(mypen, new Point(Line / 2 + 10, Convert.ToInt32(Line - (Line / 2 * 1.732))), new Point(0 + 10, Line));//"/"
+            g.DrawLine(mypen, new Point(0 + 10, Line), new Point(Line + 10, Line));//"_"
+
+
+            mypen.DashStyle = System.Drawing.Drawing2D.DashStyle.Custom;
+            mypen.DashPattern = new float[] { 2, 2 };
+            mypen = new Pen(Color.FromArgb(212, 212, 212), 1);
+
+
+            int point = Line / 10;
+            for (int i = 1; i < 10; i++)
+            {
+                //"\"
+                int x1_a = point / 2 + ((point / 2) * (i - 1));
+                int x2_a = Line - (43 * i);
+                int y1_a = point * i;
+                g.DrawLine(mypen, new Point(x1_a + 10, x2_a), new Point(y1_a + 10, Line));
+
+                //"/"
+                int x1_b = Line - (point / 2 + ((point / 2) * (i - 1)));
+                int x2_b = Line - (43 * i);
+                int y1_b = Line - (point * i);
+                g.DrawLine(mypen, new Point(x1_b + 10, x2_b), new Point(y1_b + 10, Line));
+
+                //"_"
+                int x1_c = point / 2 + ((point / 2) * (i - 1));
+                int x2_c = Line - (43 * i);
+
+                int y1_c = Line - (point / 2 + ((point / 2) * (i - 1)));
+                int y2_c = Line - (43 * i);
+
+                g.DrawLine(mypen, new Point(x1_c + 10, x2_c), new Point(y1_c + 10, y2_c));
+            }
+
+            for (int i = 0; i < dt_point_sort.Rows.Count; i++)
+            {
+                mypen = new Pen(Color.Black, 1);
+                SolidBrush mysbrush = new SolidBrush(Color_list[Convert.ToInt32(dt_point_sort.Rows[i]["Color_position"])]);
+
+                g.FillRectangle(mysbrush, Convert.ToInt32(dt_point_sort.Rows[i]["X"]) + 8, 500 - Convert.ToInt32(dt_point_sort.Rows[i]["Y"]) - 2, 4, 5);
+                g.DrawRectangle(mypen, Convert.ToInt32(dt_point_sort.Rows[i]["X"]) + 7, 500 - Convert.ToInt32(dt_point_sort.Rows[i]["Y"]) - 2, 5, 5);
+            }
+            Font myFont = new Font("宋体", 13, FontStyle.Bold);
+
+            Font Font_features = new Font("宋体", 10, FontStyle.Bold);
+            SolidBrush sbrush = new SolidBrush(Color.Black);
+            g.DrawString("features:" + dt_point_sort.Rows.Count.ToString(), Font_features, sbrush, 350, 200);
+
+
+
+            g.DrawString(TemplateName, myFont, sbrush, 265 - (TemplateName.Length * 10 / 2), 10);
+
+            g.DrawString(TemplateName.Split('.')[0].ToString(), myFont, sbrush, 265 - (TemplateName.Split('.')[0].ToString().Length * 10 / 2), 45);//顶点名字
+            g.DrawString(TemplateName.Split('.')[1].ToString(), myFont, sbrush, 0, 510);//左侧名字
+            g.DrawString(TemplateName.Split('.')[2].ToString(), myFont, sbrush, 500 - (TemplateName.Split('.')[0].ToString().Length * 10), 510);//左侧名字
+                                                                                                                                                // map.Save("D:\\1.bmp");
+            #endregion
+
+            return map;
+        }
+        //绘制图例
+        public Bitmap DrawATernaryDiagramLegend(List<Color> Color_list)
+        {
+            Bitmap map = new Bitmap(450, 115);
+            Graphics g = Graphics.FromImage(map);
+            SolidBrush sbrush_White = new SolidBrush(Color.White);
+            SolidBrush sbrush = new SolidBrush(Color.Black);
+            g.FillRectangle(sbrush_White, 0, 0, 450, 115);
+            Font myFont = new Font("宋体", 10, FontStyle.Bold);
+            g.DrawString("legend(length,microns)", myFont, sbrush, 140, 3);
+            //legend(length,microns)
+            Pen mypen = new Pen(Color.Black, 1);
+            g.DrawLine(mypen, 100, 19, 350, 19);
+
+
+            //设置标签名称
+            List<string> listName = new List<string>();
+            //获取粒级表
+            string pathe = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder + m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFile;
+            DataSet ds = XMLoperate.GetXml(pathe);
+            string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
+
+            for (int i = 0; i < sizestr.Split(',').Length - 1; i++)
+            {
+                if (sizestr.Split(',')[i].Length > 0)
+                {
+                    double d1 = Convert.ToDouble(sizestr.Split(',')[i]);
+                    double d2 = Convert.ToDouble(sizestr.Split(',')[i + 1]);
+                    listName.Add(d1.ToString() + "~" + d2.ToString());
+                }
+            }
+            double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
+            listName.Add(d.ToString() + "~MAX");
+            int PositionJeight = 27;
+            string str_unit = " microns";
+            for (int i=0;i< listName.Count;i=i+3)
+            {
+                if (i< listName.Count)
+                {
+                    SolidBrush sbrush_Color = new SolidBrush(Color_list[i]);
+                    g.DrawRectangle(mypen, 26, PositionJeight, 8, 8);
+                    g.FillRectangle(sbrush_Color, 27, PositionJeight + 1, 7, 7);
+                    g.DrawString(listName[i].ToString()+ str_unit, myFont, sbrush, 38, PositionJeight-2);
+                }
+                if (i+1 < listName.Count)
+                {
+                    SolidBrush sbrush_Color = new SolidBrush(Color_list[i+1]);
+                    g.DrawRectangle(mypen, 170, PositionJeight, 8, 8);
+                    g.FillRectangle(sbrush_Color, 171, PositionJeight + 1, 7, 7);
+                    g.DrawString(listName[i+1].ToString()+ str_unit, myFont, sbrush, 182, PositionJeight - 2);
+                }
+                if (i + 2 < listName.Count)
+                {
+                    SolidBrush sbrush_Color = new SolidBrush(Color_list[i + 2]);
+                    g.DrawRectangle(mypen, 314, PositionJeight, 8, 8);
+                    g.FillRectangle(sbrush_Color, 315, PositionJeight + 1, 7, 7);
+                    g.DrawString(listName[i + 2].ToString()+ str_unit, myFont, sbrush, 326, PositionJeight - 2);
+                }
+
+                PositionJeight = PositionJeight + 15;
+            }
+
+
+            //g.DrawRectangle(mypen, 26, 27, 8, 8);
+            //g.DrawString("50-100 microns", myFont, sbrush, 38, 25);
+
+            //g.DrawRectangle(mypen, 170, 27, 8, 8);
+            //g.DrawString("50-100 microns", myFont, sbrush, 182, 25);
+
+            //g.DrawRectangle(mypen, 314, 27, 8, 8);
+            //g.DrawString("50-100 microns", myFont, sbrush, 326, 25);
+            //map.Save("D://2.bmp");
+            return map;
+        }
+
+        private DataTable GetParticles(string filepath, List<string> nameList, int sel)
+        {
+            ParticleData particledata = new ParticleData(filepath);
+            //设置标签名称
+            List<string> listName = new List<string>();
+            //获取粒级表
+            string pathe = m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder + m_otsreport_export.m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFile;
+            DataSet ds = XMLoperate.GetXml(pathe);
+            string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
+
+            for (int i = 0; i < sizestr.Split(',').Length - 1; i++)
+            {
+                if (sizestr.Split(',')[i].Length > 0)
+                {
+                    double d1 = Convert.ToDouble(sizestr.Split(',')[i]);
+                    double d2 = Convert.ToDouble(sizestr.Split(',')[i + 1]);
+                    listName.Add(d1.ToString() + "~" + d2.ToString());
+                }
+            }
+            double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
+            listName.Add(d.ToString() + "~MAX");
+
+            string filedAndParticl = "";
+            if (sel == 1)
+            {
+                List<Particle> selectParticles = m_otsreport_export.m_ReportApp.GetSelectedParticles();
+                foreach (var item in selectParticles)
+                {
+                    filedAndParticl = filedAndParticl + "," + (item.FieldId.ToString() + "-" + item.ParticleId.ToString());
+                }
+                if (filedAndParticl != "")
+                {
+                    filedAndParticl = filedAndParticl + ",";
+                }
+            }
+            string po = "";
+            string con = "";
+            int row = m_condition.m_SourceGridData.ConditionItemList.Count;
+            if (condition != -1)
+            {
+                List<string> li = new List<string>() { "DMAX", "DMIN", "Area", "FERET" };
+                con = li[condition];
+            }
+            else
+            {
+                if (row < 4)
+                {
+                    con = "DMAX";
+                }
+                else
+                {
+                    con = m_condition.m_SourceGridData.GetPropItemDisplayValueByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.SIZE_CAL_METHOD_TYPE).ToString();
+                }
+            }
+
+
+
+            switch (con)
+            {
+                case "DMAX":
+                    po = "DMAX";
+                    break;
+                case "DMIN":
+                    po = "DMIN";
+                    break;
+                case "CIRCLE":
+                    po = "Area";
+                    break;
+                case "FERET":
+                    po = "DFERET";
+                    break;
+            }
+
+            DataTable dtp = particledata.GetParticleHaveXray(filedAndParticl);
+            //创建一个临时表
+            DataTable ret_dt = new DataTable();
+            //然后额外存放三列,用于存放拆分后三个顶点的值
+            ret_dt.Columns.Add("sizeLevel");
+            ret_dt.Columns.Add("particleLocation");
+            ret_dt.Columns.Add("top");
+            ret_dt.Columns.Add("left");
+            ret_dt.Columns.Add("right");
+            ret_dt.Columns.Add("Color_position");
+
+            for (int k = 0; k < listName.Count; k++)
+            {
+                string str = listName[k];
+                string d1 = str.Split('~')[0];
+                string d2 = str.Split('~')[1];
+                if (d2 == "MAX")
+                {
+                    d2 = "999";
+                }
+
+                DataRow[] datas = dtp.Select(getWhere(d2, d1, po));
+                foreach (var item in datas)
+                {
+                    DataRow dr = ret_dt.NewRow();
+                    dr["sizeLevel"] = str;
+                    string element = item["Element"].ToString();
+                    string strRet = getStrRet(nameList, element);
+                    dr["particleLocation"] = strRet;
+                    dr["top"] = strRet.Split(',')[0];
+                    dr["left"] = strRet.Split(',')[1];
+                    dr["right"] = strRet.Split(',')[2];
+                    dr["Color_position"] = k.ToString();
+                    ret_dt.Rows.Add(dr);
+                }
+
+            }
+
+            return ret_dt;
+        }
+        private string getWhere(string max, string min, string col)
+        {
+            return col + ">=" + min + " and " + col + "<=" + max;
+        }
+
+        private string getStrRet(List<string> template, string element)
+        {
+            List<string> name = new List<string>()
+    { "h","he",
+        "li","be","b","c","n","o","f","ne",
+        "na","mg","al","si","p","s","cl","ar",
+        "k","ca","sc","ti","v","cr","mn","fe","co","ni","cu","zn","ga","ge","as","se","br","kr",
+        "rb","sr","y","zr","nb","mo","tc","ru","rh","pd","ag","cd","in","sn","sb","te","i","xe",
+        "cs","ba","la",
+        "ce","pr","nd","pm","sm","eu","gd","tb","dy","ho","er","tm","yb","lu",
+        "hf","ta","w","re","os","ir","pt","au","hg","tl","pb","bi","po","at","rn",
+        "fr","ra","ac",
+        "th","pa","u","np","pu","am","cm","bk","cf","es","fm","md","no","lr"
+    };
+            List<double> value = new List<double>()
+    { 1.008,4.003,
+        6.941,9.012,10.811,12.011,14.007,15.999,18.998,20.180,
+        22.990,24.305,26.982,28.086,30.974,32.066,35.453,39.948,
+        39.098,40.08,44.956,47.88,50.942,51.996,54.938,55.847,58.933,58.70,63.546,65.39,69.72,72.61,74.922,78.96,79.904,83.80,
+        85.468,87.62,88.906,91.22,92.906,95.94,98.00,101.07,102.906,106.42,107.868,112.41,114.82,118.71,121.76,127.60,126.905,131.29,
+        132.905,137.33,138.906,
+        140.12,140.908,144.24,145.0,150.36,151.97,157.25,158.925,162.50,64.93,167.26,168.934,173.04,174.967,
+        178.49,180.948,183.85,186.207,190.20,192.22,195.08,196.967,200.59,204.38,207.2,208.980,209.00,210.00,222.00,
+        223.00,226.025,227.028,
+        232.038,231.036,238.029,237.048,244.00,243.00,247.00,247.00,251.00,252.00,257.00,258.00,259.00,260.00
+    };
+            double d_ASum = 0;
+            double d_BSum = 0;
+            double d_CSum = 0;
+            string aElements = template[0];
+            string bElements = template[1];
+            string cElements = template[2];
+            foreach (var item in element.Split(';'))
+            {
+                if (item.Contains(aElements + "-"))
+                {
+                    if (aElements != "")
+                    {
+                        d_ASum = Convert.ToDouble(item.Split('-')[1]) / value[name.IndexOf(aElements.ToLower())];
+                    }
+
+                }
+                for (int i = 0; i < bElements.Split(',').Length; i++)
+                {
+                    string e = bElements.Split(',')[i];
+                    if (item.Contains(e + "-"))
+                    {
+                        d_BSum = d_BSum + Convert.ToDouble(item.Split('-')[1]) / value[name.IndexOf(e.ToLower())];
+                    }
+                }
+
+                if (item.Contains(cElements + "-"))
+                {
+                    if (cElements != "")
+                        d_CSum = Convert.ToDouble(item.Split('-')[1]) / value[name.IndexOf(cElements.ToLower())];
+                }
+            }
+            double allNums = d_ASum + d_BSum + d_CSum;
+            string strRet = "";
+            if ((allNums) == 0)
+            {
+                strRet = "0,0,0";
+            }
+            else
+            {
+                double aPercent = 0, bPercent = 0, cPercent = 0;
+                if (d_ASum != 0)
+                {
+                    aPercent = d_ASum / allNums;
+                }
+                if (d_BSum != 0)
+                {
+                    bPercent = d_BSum / allNums;
+                }
+                if (d_CSum != 0)
+                {
+                    cPercent = d_CSum / allNums;
+                }
+                strRet = aPercent.ToString() + "," + bPercent.ToString() + "," + cPercent.ToString();
+            }
+            return strRet;
+        }
+        #endregion
+
+
         /// <summary>
         /// 大分类数据
         /// </summary>
         /// <param name="m_mbszclass"></param>
         /// <returns></returns>
-        public DataTable ClassificationIntegration(MBSZClass m_mbszclass,string str)
+        public DataTable ClassificationIntegration(c_TemplateClass m_mbszclass,string str)
         {
             ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath);
             DataTable data = new DataTable();
@@ -1896,7 +2320,7 @@ namespace OTSIncAReportApp.OTSTemplateDesigner
         /// </summary>
         /// <param name="m_mbszclass"></param>
         /// <returns></returns>
-        public DataTable subdivisionIntegration(MBSZClass m_mbszclass)
+        public DataTable subdivisionIntegration(c_TemplateClass m_mbszclass)
         {
             ParticleData fielddata = new ParticleData(m_otsreport_export.m_ReportApp.m_rstDataMgr.ResultFilesList[m_otsreport_export.m_ReportApp.m_rstDataMgr.getSelectedIndex()].FilePath);
 

+ 4 - 4
OTSIncAReportApp/1-UI/OTSTemplateDesigner/OTSReport_Export.cs

@@ -43,7 +43,7 @@ namespace OTSIncAReportApp
         public string strPath2;
         public XmlConfigUtil xmlutil;
         public XmlConfigUtil xmlutil2;
-        public MBSZClass m_mbszclass = null;
+        public c_TemplateClass m_mbszclass = null;
         OTS_DEVReport DEVReport;
         GBReport GB_Report;
         /*public bool ReportExporting = false;*///判断报告是不在是在导出的过程中
@@ -78,7 +78,7 @@ namespace OTSIncAReportApp
         /// <summary>
         /// 模板设置类
         /// </summary>
-        public class MBSZClass
+        public class c_TemplateClass
         {
             public DZ M_DZ { get; set; }
 
@@ -120,7 +120,7 @@ namespace OTSIncAReportApp
             #endregion
 
             #region 构造函数
-            public MBSZClass()
+            public c_TemplateClass()
             {
                 M_SY = new SY();
                 M_YMYJ = new YMYJ();
@@ -588,7 +588,7 @@ namespace OTSIncAReportApp
             //初始化xml类
             xmlutil = new XmlConfigUtil(strPath);
 
-            m_mbszclass = new MBSZClass();
+            m_mbszclass = new c_TemplateClass();
 
             //读取配置文件中的模板
             LoadMBSZClass();

+ 1 - 1
OTSIncAReportApp/ReportTemplate/GBReport.cs

@@ -273,7 +273,7 @@ namespace OTSIncAReportApp.ReportTemplate
         /// 首页部分数据插入
         /// </summary>
         /// <param name="m_mbszclass"></param>
-        public void setResultGrid(MBSZClass m_mbszclass)
+        public void setResultGrid(c_TemplateClass m_mbszclass)
         {
             #region 从Grid表中读取样品数据
             //------------------加载模块,获取数据-------------------------------------------------

+ 70 - 1
OTSIncAReportApp/ReportTemplate/OTS_DEVReport.Designer.cs

@@ -172,6 +172,12 @@ namespace OTSIncAReportApp._1_UI.OTSTemplateDesigner
             this.dev_fbt = new DevExpress.XtraReports.UI.XRLabel();
             this.dev_zbt = new DevExpress.XtraReports.UI.XRLabel();
             this.xrPictureBox2 = new DevExpress.XtraReports.UI.XRPictureBox();
+            this.xrPageBreak6 = new DevExpress.XtraReports.UI.XRPageBreak();
+            this.xrPictureBox4 = new DevExpress.XtraReports.UI.XRPictureBox();
+            this.xrPictureBox5 = new DevExpress.XtraReports.UI.XRPictureBox();
+            this.xrPictureBox6 = new DevExpress.XtraReports.UI.XRPictureBox();
+            this.xrPictureBox7 = new DevExpress.XtraReports.UI.XRPictureBox();
+            this.xrPictureBox3 = new DevExpress.XtraReports.UI.XRPictureBox();
             ((System.ComponentModel.ISupportInitialize)(this.xrTable2)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.xrTable_kllb_surface)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.xrChart_incaSubdivision)).BeginInit();
@@ -245,6 +251,10 @@ namespace OTSIncAReportApp._1_UI.OTSTemplateDesigner
             // Detail
             // 
             this.Detail.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] {
+            this.xrPictureBox6,
+            this.xrPictureBox7,
+            this.xrPictureBox5,
+            this.xrPageBreak6,
             this.xrTable2,
             this.xrTable_kllb_surface,
             this.xrLabel_inca_pic_subdivision,
@@ -274,7 +284,9 @@ namespace OTSIncAReportApp._1_UI.OTSTemplateDesigner
             this.dev_ypbh_up,
             this.dev_fbt,
             this.dev_zbt,
-            this.xrPictureBox2});
+            this.xrPictureBox2,
+            this.xrPictureBox3,
+            this.xrPictureBox4});
             this.Detail.HeightF = 10000F;
             this.Detail.Name = "Detail";
             // 
@@ -1573,6 +1585,57 @@ namespace OTSIncAReportApp._1_UI.OTSTemplateDesigner
             this.xrPictureBox2.Sizing = DevExpress.XtraPrinting.ImageSizeMode.Squeeze;
             this.xrPictureBox2.Visible = false;
             // 
+            // xrPageBreak6
+            // 
+            this.xrPageBreak6.LocationFloat = new DevExpress.Utils.PointFloat(0F, 4070.75F);
+            this.xrPageBreak6.Name = "xrPageBreak6";
+            this.xrPageBreak6.Visible = false;
+            // 
+            // xrPictureBox4
+            // 
+            this.xrPictureBox4.ImageSource = new DevExpress.XtraPrinting.Drawing.ImageSource("img", resources.GetString("xrPictureBox4.ImageSource"));
+            this.xrPictureBox4.LocationFloat = new DevExpress.Utils.PointFloat(10.0001F, 4220.75F);
+            this.xrPictureBox4.Name = "xrPictureBox4";
+            this.xrPictureBox4.SizeF = new System.Drawing.SizeF(321.0803F, 330.2085F);
+            this.xrPictureBox4.Sizing = DevExpress.XtraPrinting.ImageSizeMode.ZoomImage;
+            this.xrPictureBox4.Visible = false;
+            // 
+            // xrPictureBox5
+            // 
+            this.xrPictureBox5.ImageSource = new DevExpress.XtraPrinting.Drawing.ImageSource("img", resources.GetString("xrPictureBox5.ImageSource"));
+            this.xrPictureBox5.LocationFloat = new DevExpress.Utils.PointFloat(342.8782F, 4220.75F);
+            this.xrPictureBox5.Name = "xrPictureBox5";
+            this.xrPictureBox5.SizeF = new System.Drawing.SizeF(335.1217F, 330.2085F);
+            this.xrPictureBox5.Sizing = DevExpress.XtraPrinting.ImageSizeMode.ZoomImage;
+            this.xrPictureBox5.Visible = false;
+            // 
+            // xrPictureBox6
+            // 
+            this.xrPictureBox6.ImageSource = new DevExpress.XtraPrinting.Drawing.ImageSource("img", resources.GetString("xrPictureBox6.ImageSource"));
+            this.xrPictureBox6.LocationFloat = new DevExpress.Utils.PointFloat(10.0001F, 4562F);
+            this.xrPictureBox6.Name = "xrPictureBox6";
+            this.xrPictureBox6.SizeF = new System.Drawing.SizeF(321.0803F, 330.2085F);
+            this.xrPictureBox6.Sizing = DevExpress.XtraPrinting.ImageSizeMode.ZoomImage;
+            this.xrPictureBox6.Visible = false;
+            // 
+            // xrPictureBox7
+            // 
+            this.xrPictureBox7.ImageSource = new DevExpress.XtraPrinting.Drawing.ImageSource("img", resources.GetString("xrPictureBox7.ImageSource"));
+            this.xrPictureBox7.LocationFloat = new DevExpress.Utils.PointFloat(342.8782F, 4562F);
+            this.xrPictureBox7.Name = "xrPictureBox7";
+            this.xrPictureBox7.SizeF = new System.Drawing.SizeF(335.1217F, 330.2085F);
+            this.xrPictureBox7.Sizing = DevExpress.XtraPrinting.ImageSizeMode.ZoomImage;
+            this.xrPictureBox7.Visible = false;
+            // 
+            // xrPictureBox3
+            // 
+            this.xrPictureBox3.ImageSource = new DevExpress.XtraPrinting.Drawing.ImageSource("img", resources.GetString("xrPictureBox3.ImageSource"));
+            this.xrPictureBox3.LocationFloat = new DevExpress.Utils.PointFloat(94.6256F, 4091.578F);
+            this.xrPictureBox3.Name = "xrPictureBox3";
+            this.xrPictureBox3.SizeF = new System.Drawing.SizeF(503.9998F, 120.8501F);
+            this.xrPictureBox3.Sizing = DevExpress.XtraPrinting.ImageSizeMode.ZoomImage;
+            this.xrPictureBox3.Visible = false;
+            // 
             // OTS_DEVReport
             // 
             this.Bands.AddRange(new DevExpress.XtraReports.UI.Band[] {
@@ -1740,5 +1803,11 @@ namespace OTSIncAReportApp._1_UI.OTSTemplateDesigner
         private DevExpress.XtraReports.UI.XRTableCell xrTableCell27;
         private DevExpress.XtraReports.UI.XRTableCell xrTableCell28;
         private DevExpress.XtraReports.UI.XRTableCell xrTableCell29;
+        private DevExpress.XtraReports.UI.XRPictureBox xrPictureBox6;
+        private DevExpress.XtraReports.UI.XRPictureBox xrPictureBox7;
+        private DevExpress.XtraReports.UI.XRPictureBox xrPictureBox5;
+        private DevExpress.XtraReports.UI.XRPageBreak xrPageBreak6;
+        private DevExpress.XtraReports.UI.XRPictureBox xrPictureBox4;
+        private DevExpress.XtraReports.UI.XRPictureBox xrPictureBox3;
     }
 }

+ 55 - 20
OTSIncAReportApp/ReportTemplate/OTS_DEVReport.cs

@@ -19,7 +19,9 @@ namespace OTSIncAReportApp._1_UI.OTSTemplateDesigner
         string dataFont = "Arial Unicode MS";
         List<string> TemplateList;
         Export_ReportTemplate export_ReportTemplate;
-        SizeF syx_Size = new SizeF(668f, 660.54f);
+        //SizeF syx_Size = new SizeF(668f, 660.54f);
+        SizeF syx_Size = new SizeF(668f, 616.67f);
+        
         float LowPlace = 3120f;
         ElementSubscript subscript=new ElementSubscript();
 
@@ -100,7 +102,7 @@ namespace OTSIncAReportApp._1_UI.OTSTemplateDesigner
         /// 首页部分数据插入
         /// </summary>
         /// <param name="m_mbszclass"></param>
-        public void setResultGrid(MBSZClass m_mbszclass)
+        public void setResultGrid(c_TemplateClass m_mbszclass)
         {
             #region 从Grid表中读取样品数据
             //------------------加载模块,获取数据-------------------------------------------------
@@ -145,7 +147,7 @@ namespace OTSIncAReportApp._1_UI.OTSTemplateDesigner
         /// 颗粒尺寸分析表
         /// </summary>
         /// <param name="m_mbszclass"></param>
-        public void setParticleSizeTable(MBSZClass m_mbszclass)
+        public void setParticleSizeTable(c_TemplateClass m_mbszclass)
         {
             //ElementSubscript subscript = new ElementSubscript();
             //    Export_ReportTemplate export_ReportTemplate = new Export_ReportTemplate(m_otsreport_export);
@@ -266,7 +268,7 @@ namespace OTSIncAReportApp._1_UI.OTSTemplateDesigner
         /// 设置插入元素分析表数据
         /// </summary>
         /// <param name="m_mbszclass"></param>
-        public void setElementAvgGrid(MBSZClass m_mbszclass)
+        public void setElementAvgGrid(c_TemplateClass m_mbszclass)
         {
             xrTb_ElementAnalysisTable.Visible = true;
 
@@ -327,7 +329,7 @@ namespace OTSIncAReportApp._1_UI.OTSTemplateDesigner
         /// 设置插入夹杂物面积比表数据
         /// </summary>
         /// <param name="m_mbszclass"></param>
-        public void setINCAtable(MBSZClass m_mbszclass)
+        public void setINCAtable(c_TemplateClass m_mbszclass)
         {
             //ElementSubscript subscript = new ElementSubscript();
             export_ReportTemplate.GenerateINCAtable(dev_scmj_text.Text, out DataTable dt);
@@ -358,7 +360,7 @@ namespace OTSIncAReportApp._1_UI.OTSTemplateDesigner
         /// 设置插入夹杂物面积比图像
         /// </summary>
         /// <param name="m_mbszclass"></param>
-        public void set_incaPIC_classify(MBSZClass m_mbszclass)
+        public void set_incaPIC_classify(c_TemplateClass m_mbszclass)
         {
             xrChart_incaClass.Visible = true;
             xrLabel_inca_pic_class.Visible = true;
@@ -391,7 +393,7 @@ namespace OTSIncAReportApp._1_UI.OTSTemplateDesigner
             this.xrChart_incaClass.Legend.Border.Color = Color.Red;//红色边框
 
         }
-        public void set_incaPIC_subdivision(MBSZClass m_mbszclass)
+        public void set_incaPIC_subdivision(c_TemplateClass m_mbszclass)
         {
             xrChart_incaSubdivision.Visible = true;
             xrLabel_inca_pic_subdivision.Visible = true;
@@ -429,18 +431,39 @@ namespace OTSIncAReportApp._1_UI.OTSTemplateDesigner
         /// 三元图
         /// </summary>
         /// <param name="m_mbszclass"></param>
-        public void InsertReportTemplateChart_Trianglediagram(MBSZClass m_mbszclass)
+        public void InsertReportTemplateChart_Trianglediagram(c_TemplateClass m_mbszclass)
         {
+            List<Color> Color_list = new List<Color>();
+            Color_list.Add(Color.FromArgb(238, 175, 14));
+            Color_list.Add(Color.FromArgb(0, 0, 238));
+            Color_list.Add(Color.FromArgb(0, 205, 0));
+            Color_list.Add(Color.FromArgb(238, 0, 0));
+            Color_list.Add(Color.FromArgb(153, 50, 204));
+            Color_list.Add(Color.FromArgb(255, 102, 153));
+            Color_list.Add(Color.FromArgb(160, 82, 45));
+            Color_list.Add(Color.FromArgb(181, 181, 181));
+            Color_list.Add(Color.FromArgb(250, 235, 215));
+            Color_list.Add(Color.FromArgb(238, 130, 238));
+            Color_list.Add(Color.FromArgb(174, 238, 238));
+            Color_list.Add(Color.FromArgb(247, 172, 189));
+            Color_list.Add(Color.FromArgb(202, 134, 135));
+            Color_list.Add(Color.FromArgb(34, 90, 31));
             for (int i = 0; i < m_mbszclass.M_SYXT.list_lbv_syxt_mblb_index.Count; i++)
             {
-                set_syt_pic("xrPictureBox_syt_" + i.ToString(), "syt_Page_" + i.ToString(), m_mbszclass, m_mbszclass.M_SYXT.list_lbv_syxt_mblb_index[i]);
+                //set_syt_pic("xrPictureBox_syt_" + i.ToString(), "syt_Page_" + i.ToString(), m_mbszclass, m_mbszclass.M_SYXT.list_lbv_syxt_mblb_index[i]);
+                set_syt_pic_legend(Color_list);
+                set_syt_pic( m_mbszclass, m_mbszclass.M_SYXT.list_lbv_syxt_mblb_index[i], Color_list);
+
+                XRPageBreak xRPage = new XRPageBreak();
+                xRPage.LocationF = new PointF(0, LowPlace + 2);
+                this.Detail.Controls.Add(xRPage);
             }
         }
         /// <summary>
         /// 颗粒列表
         /// </summary>
         /// <param name="m_mbszclass"></param>
-        public void set_kllb_data(MBSZClass m_mbszclass)
+        public void set_kllb_data(c_TemplateClass m_mbszclass)
         {
             XRPageBreak xRPage = new XRPageBreak();
             xRPage.Name = "kllb_Page";
@@ -470,7 +493,7 @@ namespace OTSIncAReportApp._1_UI.OTSTemplateDesigner
         /// 颗粒列表 帧图
         /// </summary>
         /// <param name="m_mbszclass"></param>
-        public void set_kllb_data_frame(MBSZClass m_mbszclass)
+        public void set_kllb_data_frame(c_TemplateClass m_mbszclass)
         {
             //   Export_ReportTemplate export_ReportTemplate = new Export_ReportTemplate(m_otsreport_export);
             export_ReportTemplate.Get_dev_kllb_data_frame(m_mbszclass, out DataTable dt_pic, out List<DataTable> listData);
@@ -715,26 +738,38 @@ namespace OTSIncAReportApp._1_UI.OTSTemplateDesigner
         /// <param name="syt_Page_name"></param>
         /// <param name="m_mbszclass"></param>
         /// <param name="index"></param>
-        private void set_syt_pic(string syt_pic_name, string syt_Page_name, MBSZClass m_mbszclass, int index)
+        private void set_syt_pic(c_TemplateClass m_mbszclass, int index, List<Color> Color_list)
         {
+            
+
             XRPictureBox xRPicture = new XRPictureBox();
-            xRPicture.Name = syt_pic_name;
+ 
             xRPicture.LocationF = new PointF(10f, LowPlace);
             xRPicture.SizeF = syx_Size;
 
-            ImageSource imageSource = new ImageSource(export_ReportTemplate.GetByte_InsertReportChart_Trianglediagram(index, m_mbszclass));
+            ImageSource imageSource = new ImageSource(export_ReportTemplate.DrawATernaryPicture(index, m_mbszclass,Color_list));
             xRPicture.ImageSource = imageSource;
-            xRPicture.Sizing = DevExpress.XtraPrinting.ImageSizeMode.StretchImage;
+            xRPicture.Sizing = DevExpress.XtraPrinting.ImageSizeMode.ZoomImage;
             xRPicture.Visible = true;
             this.Detail.Controls.Add(xRPicture);
 
-            XRPageBreak xRPage = new XRPageBreak();
-            xRPage.Name = syt_Page_name;
-            xRPage.LocationF = new PointF(0, xRPicture.LocationF.Y + 2);
-            this.Detail.Controls.Add(xRPage);
 
             LowPlace = syx_Size.Height + LowPlace + 10;
         }
+
+
+        private void set_syt_pic_legend(List<Color> Color_list)
+        {
+            XRPictureBox xRPicture_legend = new XRPictureBox();
+         
+            xRPicture_legend.LocationF = new PointF(95f, LowPlace);
+            xRPicture_legend.SizeF = new SizeF(504f, 120.85f);
+            xRPicture_legend.Sizing = DevExpress.XtraPrinting.ImageSizeMode.ZoomImage;
+            ImageSource imageSource_legend = new ImageSource(export_ReportTemplate.DrawATernaryDiagramLegend(Color_list));
+            xRPicture_legend.ImageSource = imageSource_legend;
+            LowPlace = LowPlace + xRPicture_legend.SizeF.Height;
+            this.Detail.Controls.Add(xRPicture_legend);
+        }
         #endregion
         #region 颗粒列表
         private XRTable add_XRTable()
@@ -897,7 +932,7 @@ namespace OTSIncAReportApp._1_UI.OTSTemplateDesigner
 
             return Template;
         }
-        private void add_kllb(MBSZClass m_mbszclass, DataTable dataTable, int position, XRTable xRTable)
+        private void add_kllb(c_TemplateClass m_mbszclass, DataTable dataTable, int position, XRTable xRTable)
         {
             XRTable table = new XRTable();
             table = xRTable;

File diff suppressed because it is too large
+ 0 - 0
OTSIncAReportApp/ReportTemplate/OTS_DEVReport.resx


Some files were not shown because too many files changed in this diff