1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333 |
- using CefSharp;
- using CefSharp.WinForms;
- using Newtonsoft.Json;
- using OTSIncAReportApp.DataOperation.DataAccess;
- using OTSCommon.Model;
- using OTSIncAReportApp.OTSDataMgrFunction;
- using OTSIncAReportApp.OTSSampleReportInfo;
- using OTSIncAReportApp.OTSTemplateDesigner;
- using OTSIncAReportApp.SysMgrTools;
- using OTSIncAReportGrids;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Data;
- using System.IO;
- using System.Linq;
- using System.Windows.Forms;
- namespace OTSIncAReportApp.Control_ECharts
- {
- /// <summary>
- /// 各图char相关模块
- /// </summary>
- public partial class EChart_ParticlesComposition : UserControl
- {
- Hashtable table;
- #region 图表相关变量
- //y轴名称
- public string m_str_AxisY { get; set; }
- //定义图片
- //JsEvent js;
- //定义图片base64
- public string pic { get; set; }
- //定义图形类型
- public string type { get; set; }
- //图形数据
- public string data { get; set; }
- string url = "CefSharp\\Resources\\HTML\\charts.html";
- //数据图类型:常用夹杂物分类CommonlyUsedClassify ,颗粒成分PComponent,元素成分EComponent,颗粒尺寸分布PSize
- string ComSel { get; set; }
- public bool Report { get; set; }
- frmReportApp m_ReportApp;
- List<int> FLID = new List<int>() { 0, 1, 2, 4, 6, 7, 8, 9 };
- List<string> NameList = new List<string>() { "过小颗粒", "过大颗粒", "亮度不在分析范围内的颗粒", "低计数率颗粒", "不含分析元素的颗粒", "非夹杂物颗粒SiC", "非夹杂物颗粒FeO", "未识别颗粒" };
- private frmReportConditionChoose m_conditionChoose;
- private ResultDataMgr m_DataMgr;
- #endregion
- #region 窗体加载及构造函数
- public EChart_ParticlesComposition(frmReportApp ReportApp, string comsel)
- {
- ComSel = comsel;
- m_ReportApp = ReportApp;
- m_conditionChoose = ReportApp.m_conditionChoose;
- m_DataMgr = ReportApp.m_rstDataMgr;
- InitializeComponent();
- //国际化
- Language lan = new Language();
- table = lan.GetNameTable("CompositionDistributionGrid");
- //m_export_reporttemplate = new GBData();
- }
-
- private void EChart_ParticlesComposition_Load(object sender, EventArgs e)
- {
- string sou = "";
- int sel = 0;//选择颗粒范围(0为全部颗粒1为选择颗粒)
- NameList = new List<string>() { table["partcletype0"].ToString(), table["partcletype1"].ToString(), table["partcletype2"].ToString(), table["partcletype4"].ToString(), table["partcletype6"].ToString(), table["partcletype7"].ToString(), table["partcletype8"].ToString(), table["partcletype9"].ToString() };
- //int idx = m_ReportApp.m_DataMgrFun.GetPropIndexByPropItemName(m_ReportApp.SourceGridData.ConditionItemList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE);
- //string sou = m_ReportApp.SourceGridData.ConditionItemList[idx].itemVal.ToString();
- if (Report)
- {
- sou = m_DataMgr.ResultFilesList[m_DataMgr.getSelectedIndex()].anotherFileName.ToString();
- sel = 0;
- }
- else
- {
- sou = m_conditionChoose.m_conditionData.GetPropItemDisplayValueByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE).ToString();
- sel = m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListIndexByItemName(OTSIncAReportApp.OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
- }
- Report = false;
- if (sou.Contains("+"))
- {
- if (m_ReportApp.more)
- {
- m_ReportApp.trans = false;
- }
- else
- {
- m_ReportApp.trans = true;
- }
- m_ReportApp.more = true;
- //获取到List,json的字符串
- ChartdateMore list_json_str = GetListJsonStr();
- url = "CefSharp\\Resources/HTML/chartsMore.html";
- m_ReportApp.data = JsonConvert.SerializeObject(list_json_str);
- }
- else
- {
- if (!m_ReportApp.more)
- {
- m_ReportApp.trans = false;
- }
- else
- {
- m_ReportApp.trans = true;
- }
- m_ReportApp.more = false;
- //获取到List,json的字符串
-
- for (int i=0;i< m_conditionChoose.m_conditionData.ConditionItemList.Count;i++)
- {
- if (m_conditionChoose.m_conditionData.ConditionItemList[i].itemDisplayVal.ToString()== sou)
- {
- m_DataMgr.SetWorkingResultId((int)m_conditionChoose.m_conditionData.ConditionItemList[i].itemVal);
- }
- }
-
- List<Chartdate> list_json_str = GetListJsonStrByChartStruct(sel);
- url = "CefSharp\\Resources/HTML/charts.html";
- m_ReportApp.data = JsonConvert.SerializeObject(list_json_str[0]);
- if (ComSel == "PSize")
- {
- ComSel = "PSizeCombin";
- m_ReportApp.dataCombin = JsonConvert.SerializeObject(GetListJsonStrByChartStruct(sel)[0]);
- }
- else
- {
- m_ReportApp.dataCombin = "";
- }
- }
- InitBrowser();
- }
- #endregion
- #region 获取单数据源
- private Chartdate GetCommonlyUsedClassifyData(string path)
- {
- string spinel = table["str20"].ToString();
- string oxide = table["str21"].ToString();
- string SulfurOxide = table["str22"].ToString();
- string nitrides = table["str23"].ToString();
- string sulfide = table["str24"].ToString();
- DataOperation.DataAccess.ParticleData particledata = new DataOperation.DataAccess.ParticleData(path);
- //创建新的图形数据源
- Chartdate chart = new Chartdate();
- chart.Title = m_ReportApp.m_reportname;
- chart.YName = m_str_AxisY;
- //int idx = m_ReportApp.m_DataMgrFun.GetPropIndexByPropItemName(m_ReportApp.SourceGridData.ConditionItemList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
- //int sel = m_ReportApp.SourceGridData.ConditionItemList[idx].comboDownList.IndexOf(m_ReportApp.SourceGridData.ConditionItemList[idx].itemVal.ToString());
- //int sel = m_conditionChoose.m_SourceGridData.GetPropIndexByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
- int sel = m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListIndexByItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
- DataTable dt = new DataTable();
- dt = particledata.GetCommonlyUsedClassifyData();
- //DataTable dt = dataTable;
- //设置标签名称
- List<string> listName = new List<string>();
- listName.Add(spinel);
- listName.Add(oxide);
- listName.Add(SulfurOxide);
- listName.Add(nitrides);
- listName.Add(sulfide);
- chart.ListName = listName;
- //设置数据
- List<Item> listData = new List<Item>();
- //ListData
- for (int k = 0; k < dt.Rows.Count; k++)
- {
- try
- {
- Item item_SPINEL = new Item()
- {
- value = decimal.Round(decimal.Parse(dt.Rows[k]["SPINEL"].ToString()), 2).ToString(),
- name = spinel
- };
- listData.Add(item_SPINEL);
- Item item_OXIDE = new Item()
- {
- value = decimal.Round(decimal.Parse(dt.Rows[k]["OXIDE"].ToString()), 2).ToString(),
- name = oxide
- };
- listData.Add(item_OXIDE);
- Item item_SULFIDE_OXIDE = new Item()
- {
- value = decimal.Round(decimal.Parse(dt.Rows[k]["SULFIDE_OXIDE"].ToString()), 2).ToString(),
- name = SulfurOxide
- };
- listData.Add(item_SULFIDE_OXIDE);
- Item item_NITRIDE = new Item()
- {
- value = decimal.Round(decimal.Parse(dt.Rows[k]["NITRIDE"].ToString()), 2).ToString(),
- name = nitrides
- };
- listData.Add(item_NITRIDE);
- Item item_SULFIDE = new Item()
- {
- value = decimal.Round(decimal.Parse(dt.Rows[k]["SULFIDE"].ToString()), 2).ToString(),
- name = sulfide
- };
- listData.Add(item_SULFIDE);
- }
- catch
- {
- Item item = new Item()
- {
- value = "",
- name = ""
- };
- listData.Add(item);
- }
- }
- chart.ListData = listData;
- return chart;
- }
- private Chartdate GetInclusionAreaRatioData(string path,int sel)
- {
- DataOperation.DataAccess.ParticleData particledata = new DataOperation.DataAccess.ParticleData(path);
- //创建新的图形数据源
- Chartdate chart = new Chartdate();
- chart.Title = m_ReportApp.m_reportname;
- chart.YName = m_str_AxisY;
- //int sel = m_ReportApp.m_conditionChoose.m_SourceGridData.GetComboDownListIndexByItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
- DataTable data = new DataTable();
- data = particledata.GetAreaByAllIncA("");//获取所有分类面积和数量信息
- //DataTable data = particledata.GetAreaByAllIncA("");
- DataTable dt = ConSolidateInvalid(data);
- //设置标签名称
- List<string> listName = new List<string>();
- //ListName
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- if (Convert.ToInt32(dt.Rows[i]["TypeId"]) < 100)
- {
- continue;
- }
- listName.Add(dt.Rows[i]["TypeName"].ToString());
- }
-
- chart.ListName = listName;
- //设置数据
- List<Item> listData = new List<Item>();
- //ListData
- for (int k = 0; k < dt.Rows.Count; k++)
- {
- string str = dt.Rows[k]["ar"].ToString();
- string name = dt.Rows[k]["TypeName"].ToString();
- if (Convert.ToInt32(dt.Rows[k]["TypeId"]) < 100)
- {
- continue;
- }
- Item item = new Item()
- {
- value =Convert.ToInt32(dt.Rows[k]["ar"]).ToString(),
- name = name
- };
- listData.Add(item);
- }
- chart.ListData = listData;
- return chart;
- }
- private Chartdate GetInclusionAreaRatioClassData(string path,int sel)
- {
-
- //创建新的图形数据源
- Chartdate chart = new Chartdate();
- chart.Title = m_ReportApp.m_reportname;
- chart.YName = m_str_AxisY;
- //计算分类整个表的数据
- DataTable dt= ClassificationIntegration(path,sel);
- List<string> listName = new List<string>();
- //ListName
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- listName.Add(dt.Rows[i]["e1"].ToString());
- }
- chart.ListName = listName;
- //DataTable dt
- //设置数据
- List<Item> listData = new List<Item>();
- //ListData
- for (int k = 0; k < dt.Rows.Count; k++)
- {
- string str = dt.Rows[k]["Cunt"].ToString();
- string name = dt.Rows[k]["e1"].ToString();
-
- Item item = new Item()
- {
- value = decimal.Round(decimal.Parse(dt.Rows[k]["Cunt"].ToString()), 2).ToString(),
- name = name
- };
- listData.Add(item);
- }
- chart.ListData = listData;
- return chart;
- }
- private DataTable ClassificationIntegration(string path ,int sel)
- {
- //------------------加载模块,获取数据-------------------------------------------------
- ResultGrid ls_resultgrid = new ResultGrid(m_ReportApp);
- Dictionary<string, string> keyValues_ResultGrid = ls_resultgrid.GetData_ResultGrid_Report();
- //------------------加载模块,获取数据结束----------------------------------------------
- Dictionary<string, string>.Enumerator en = keyValues_ResultGrid.GetEnumerator();
-
- string str_SCZS = "";
-
- keyValues_ResultGrid.TryGetValue(ls_resultgrid.table["col5"].ToString(), out str_SCZS);//视场总数
- DataOperation.DataAccess.ParticleData particledata = new DataOperation.DataAccess.ParticleData(path);
- DataTable data = new DataTable();
- data = particledata.GetAreaByAllIncA("");//获取所有分类面积和数量信息
- if(data.Rows.Count==0)
- {
- return data;
- }
-
- DataTable AreaInformationOfAllElements = ConSolidateInvalid(data);
- DataTable AllAnalysisDetails = new DataTable();
- AllAnalysisDetails.Columns.Add("Name");
- AllAnalysisDetails.Columns.Add("TypeId");
- AllAnalysisDetails.Columns.Add("Area", typeof(double));
- AllAnalysisDetails.Columns.Add("Class");
- AllAnalysisDetails.Columns.Add("Cunt", typeof(double));
- for (int i = 0; i < AreaInformationOfAllElements.Rows.Count; i++)
- {
- DataRow dr2 = AllAnalysisDetails.NewRow();
- dr2["Name"] = AreaInformationOfAllElements.Rows[i]["TypeName"].ToString();
- dr2["Area"] = Convert.ToDouble(AreaInformationOfAllElements.Rows[i]["ar"]);
- dr2["TypeId"] = AreaInformationOfAllElements.Rows[i]["TypeId"].ToString();
- dr2["Cunt"] = Convert.ToDouble(AreaInformationOfAllElements.Rows[i]["con"]);
- dr2["Class"] = AreaInformationOfAllElements.Rows[i]["GroupName"].ToString();
- AllAnalysisDetails.Rows.Add(dr2);
- }
- //按照list列表进行物质类排序,物质类中的元素分类按照面积的大小进行排序
- List<string> ClassName = new List<string>();
- DataTable getClass_dt = particledata.GetAllClass();
- for (int i = 0; i < getClass_dt.Rows.Count; i++)
- {
- ClassName.Add(getClass_dt.Rows[i]["GroupName"].ToString());
- }
- DataTable AreaRatio = new DataTable();
- AreaRatio.TableName = "InclusionAreaRatio";
- AreaRatio.Columns.Add("e1");
- AreaRatio.Columns.Add("e2");
- AreaRatio.Columns.Add("e3", typeof(double));
- AreaRatio.Columns.Add("e4");
- AreaRatio.Columns.Add("e5");
- AreaRatio.Columns.Add("Cunt", typeof(int));
- //获取夹杂物的总面积用于计算夹杂物类别的占比(gridview最后一个固定是未识别颗粒,要排除未识别颗粒所以for循环至grid view长度减一)
- double totalInclusionArea = 0;
- totalInclusionArea = Convert.ToDouble(decimal.Parse(AllAnalysisDetails.Compute("sum(Area)", "").ToString()));
- for (int i = 0; i < AllAnalysisDetails.Rows.Count; i++)
- {
- DataRow dr2 = AreaRatio.NewRow();
- dr2["e1"] = AllAnalysisDetails.Rows[i]["Class"].ToString();
- dr2["e2"] = AllAnalysisDetails.Rows[i]["Name"].ToString();
- dr2["e3"] = Convert.ToDouble(AllAnalysisDetails.Rows[i]["Area"]);
- dr2["e4"] = Math.Round((Convert.ToDouble(AllAnalysisDetails.Rows[i]["Area"]) / totalInclusionArea) * 100, 2);
- dr2["e5"] = Math.Round((Convert.ToDouble(AllAnalysisDetails.Rows[i]["Area"]) / Convert.ToDouble(str_SCZS)) * 100, 4);
- dr2["Cunt"]= AllAnalysisDetails.Rows[i]["Cunt"].ToString();
- AreaRatio.Rows.Add(dr2);
- }
- DataTable AreaRatio_dt = AreaRatio.Copy();
- AreaRatio_dt.Clear();
- for (int i = 0; i < ClassName.Count(); i++)
- {
- DataTable dt = AreaRatio.Copy();
- dt.Clear();
- for (int a = 0; a < AreaRatio.Rows.Count; a++)
- {
- if (AreaRatio.Rows[a]["e1"].ToString() == ClassName[i].ToString())
- {
- dt.Rows.Add(AreaRatio.Rows[a].ItemArray);
- }
- }
- DataView dv = dt.DefaultView;
- dv.Sort = "e3 DESC";
- DataTable dt_Element = dv.ToTable();
- for (int a = 0; a < dt_Element.Rows.Count; a++)
- {
- AreaRatio_dt.Rows.Add(dt_Element.Rows[a].ItemArray);
- }
- }
- DataTable AllAnalysisDetails1 = AreaRatio_dt.Copy();
- AllAnalysisDetails1.Clear();
- for (int i = 0; i < ClassName.Count; i++)
- {
- DataTable dt = AreaRatio_dt.Copy();
- dt.Clear();
- for (int a = 0; a < AreaRatio_dt.Rows.Count; a++)
- {
- if (AreaRatio_dt.Rows[a]["e1"].ToString() == ClassName[i].ToString())
- {
- dt.Rows.Add(AreaRatio_dt.Rows[a].ItemArray);
- }
- }
- if (dt.Rows.Count > 0)
- {
- double totalInclusionArea2 = Convert.ToDouble(decimal.Parse(AreaRatio_dt.Compute("sum(e3)", "").ToString()));
- double Area = Convert.ToDouble(decimal.Parse(dt.Compute("sum(e3)", "").ToString()));
- int cunt= Convert.ToInt32(decimal.Parse(dt.Compute("sum(Cunt)", "").ToString()));
- DataRow dr3 = AllAnalysisDetails1.NewRow();
- dr3["e1"] = ClassName[i].ToString();
- dr3["e3"] = Math.Round(Area, 2);
- //Convert.ToDouble(decimal.Parse(dt.Compute("sum(e3)", "").ToString()));
- dr3["e4"] = Math.Round((Convert.ToDouble(dt.Rows[0]["e3"]) / totalInclusionArea2) * 100, 2);
- dr3["e5"] = Math.Round((Convert.ToDouble(dt.Rows[0]["e3"]) / Convert.ToDouble(str_SCZS)) * 100, 4);
- dr3["Cunt"] = cunt;
- AllAnalysisDetails1.Rows.Add(dr3);
- }
- }
- return AllAnalysisDetails1;
- }
- private DataTable GetParticleListForParticlSize(DataTable data, DataTable table)
- {
- DataTable dt_Partick = new DataTable();
- dt_Partick.Columns.Add("TypeId");
- dt_Partick.Columns.Add("TypeName");
- dt_Partick.Columns.Add("TypeColor");
- dt_Partick.Columns.Add("con");
- dt_Partick.Columns.Add("av");
- dt_Partick.Columns.Add("max");
- dt_Partick.Columns.Add("ar", typeof(double));
- dt_Partick.Columns.Add("GroupName");
- List<string> typeName = new List<string>();
- for (int i = 0; i < data.Rows.Count; i++)
- {
- typeName.Add(data.Rows[i]["TypeId"].ToString());
- }
- typeName = typeName.Distinct().ToList();
- for (int i = 0; i < typeName.Count; i++)
- {
- DataTable dt = dt_Partick.Clone();
- for (int j = 0; j < data.Rows.Count; j++)
- {
- if (typeName[i].ToString() == data.Rows[j]["TypeId"].ToString())
- {
- DataRow row = dt.NewRow();
- row["TypeId"] = data.Rows[j]["TypeId"];
- row["TypeName"] = data.Rows[j]["TypeName"];
- row["TypeColor"] = data.Rows[j]["TypeColor"];
- row["ar"] = data.Rows[j]["Area"];
- dt.Rows.Add(row);
- }
- }
- DataRow dr = dt_Partick.NewRow();
- dr["TypeId"] = dt.Rows[0]["TypeId"].ToString();
- dr["TypeName"] = dt.Rows[0]["TypeName"].ToString();
- dr["TypeColor"] = dt.Rows[0]["TypeColor"].ToString();
- dr["con"] = dt.Rows.Count;
- dr["av"] = dt.Compute("min(ar)", "");
- dr["max"] = dt.Compute("Max(ar)", "");
- dr["ar"] = dt.Compute("SUM(ar)", "");
- dt_Partick.Rows.Add(dr);
- }
- for (int i = 0; i < dt_Partick.Rows.Count; i++)
- {
- for (int j = 0; j < table.Rows.Count; j++)
- {
- if (dt_Partick.Rows[i]["TypeId"].ToString() == table.Rows[j]["TypeId"].ToString())
- {
- dt_Partick.Rows[i]["GroupName"] = table.Rows[j]["GroupName"];
- break;
- }
- }
- }
- return dt_Partick;
- }
- private DataTable ConSolidateInvalid(DataTable dt)
- {
-
- DataTable dt_invalid = dt.Clone();
- DataTable dt_no_invalid = dt.Clone();
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- if (dt.Rows[i]["TypeName"].ToString()=="Invalid")
- {
- dt_invalid.Rows.Add(dt.Rows[i].ItemArray);
- }
- else
- {
- dt_no_invalid.Rows.Add(dt.Rows[i].ItemArray);
- }
- }
- return dt_no_invalid;
- }
- /// <summary>
- /// 获取颗粒成分数据
- /// </summary>
- private Chartdate GetPComponentData(string path)
- {
- DataOperation.DataAccess.ParticleData particledata = new DataOperation.DataAccess.ParticleData(path);
- //创建新的图形数据源
- Chartdate chart = new Chartdate();
- chart.Title = m_ReportApp.m_reportname;
- chart.YName = m_str_AxisY;
- //int idx = m_ReportApp.m_DataMgrFun.GetPropIndexByPropItemName(m_ReportApp.SourceGridData.ConditionItemList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
- //int sel = m_ReportApp.SourceGridData.ConditionItemList[idx].comboDownList.IndexOf(m_ReportApp.SourceGridData.ConditionItemList[idx].itemVal.ToString());
- //int sel = m_conditionChoose.m_SourceGridData.GetPropIndexByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
- int sel = m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListIndexByItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
- string filedAndParticl = "";
-
- DataTable dt = particledata.GetParticleListForParticlSize("area", filedAndParticl);
- //设置标签名称
- List<string> listName = new List<string>();
- //ListName
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- if (Convert.ToInt32(dt.Rows[i]["TypeId"]) < 100)
- {
- continue;
- }
- listName.Add(dt.Rows[i]["TypeName"].ToString());
- }
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- if (Convert.ToInt32(dt.Rows[i]["TypeId"]) > 100)
- {
- continue;
- }
- int index = FLID.IndexOf(Convert.ToInt32(dt.Rows[i]["TypeId"]));
- if (index == -1)
- {
- index = 7;
- }
- string name = NameList[index];
- if (listName.IndexOf(name) == -1)
- {
- listName.Add(name);
- }
- }
- chart.ListName = listName;
- //设置数据
- List<Item> listData = new List<Item>();
- //ListData
- for (int k = 0; k < dt.Rows.Count; k++)
- {
- string str = dt.Rows[k]["con"].ToString();
- string name = dt.Rows[k]["TypeName"].ToString();
- if (Convert.ToInt32(dt.Rows[k]["TypeId"]) < 100)
- {
- int index = FLID.IndexOf(Convert.ToInt32(dt.Rows[k]["TypeId"]));
- if (index == -1)
- {
- index = 7;
- }
- name = NameList[index];
- }
- Item item = new Item()
- {
- value = decimal.Round(decimal.Parse(str), 2).ToString(),
- name = name
- };
- listData.Add(item);
- }
- chart.ListData = listData;
- return chart;
- }
- /// <summary>
- /// 获取元素成分数据
- /// </summary>
- private Chartdate GetEComponentData(string path)
- {
- DataOperation.DataAccess.ParticleData particledata = new DataOperation.DataAccess.ParticleData(path);
- //创建新的图形数据源
- Chartdate chart = new Chartdate();
- chart.Title = m_ReportApp.m_reportname;
- chart.YName = m_str_AxisY;
- //int idx = m_ReportApp.m_DataMgrFun.GetPropIndexByPropItemName(m_ReportApp.SourceGridData.ConditionItemList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
- //int sel = m_ReportApp.SourceGridData.ConditionItemList[idx].comboDownList.IndexOf(m_ReportApp.SourceGridData.ConditionItemList[idx].itemVal.ToString());
- //int sel = m_conditionChoose.m_SourceGridData.GetPropIndexByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
- int sel = m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListIndexByItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
- string filedAndParticl = "";
- DataTable dt = particledata.GetElementForArea(filedAndParticl);
- //设置标签名称
- List<string> listName = new List<string>();
- //ListName
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- listName.Add(dt.Rows[i]["name"].ToString());
- }
- chart.ListName = listName;
- //设置数据
- List<Item> listData = new List<Item>();
- //ListData
- for (int k = 0; k < dt.Rows.Count; k++)
- {
- string str = dt.Rows[k]["earea"].ToString();
- try
- {
- Item item = new Item()
- {
- value = decimal.Round(decimal.Parse(str), 2).ToString(),
- name = dt.Rows[k]["name"].ToString()
- };
- listData.Add(item);
- }
- catch
- {
- Item item = new Item()
- {
- value = str,
- name = dt.Rows[k]["name"].ToString()
- };
- listData.Add(item);
- }
- }
- chart.ListData = listData;
- return chart;
- }
- /// <summary>
- /// 获取此尺寸分布图数据
- /// </summary>
- private Chartdate GetPSizeData(string path)
- {
- DataOperation.DataAccess.ParticleData particledata = new DataOperation.DataAccess.ParticleData(path);
- //创建新的图形数据源
- Chartdate chart = new Chartdate();
- chart.Title = m_ReportApp.m_reportname;
- chart.YName = m_str_AxisY;
- //设置标签名称
- List<string> listName = new List<string>();
- //获取粒级表
- string pathe = m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder + m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFile;
- DataSet ds = DataOperation.DataAccess.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");
- chart.ListName = listName;
- //int idx = m_ReportApp.m_DataMgrFun.GetPropIndexByPropItemName(m_ReportApp.SourceGridData.ConditionItemList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
- //int sel = m_ReportApp.SourceGridData.ConditionItemList[idx].comboDownList.IndexOf(m_ReportApp.SourceGridData.ConditionItemList[idx].itemVal.ToString());
- //int sel = m_conditionChoose.m_SourceGridData.GetPropIndexByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
- int sel = m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListIndexByItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
- string filedAndParticl = "";
- //idx = m_ReportApp.m_DataMgrFun.GetPropIndexByPropItemName(m_ReportApp.SourceGridData.ConditionItemList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.SIZE_CAL_METHOD_TYPE);
- //string con = m_ReportApp.SourceGridData.ConditionItemList[idx].itemVal.ToString();
- string con = m_conditionChoose.m_conditionData.GetPropItemDisplayValueByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.SIZE_CAL_METHOD_TYPE).ToString();
- string po = "";
- switch (con)
- {
- case "DMAX":
- po = "DMAX";
- break;
- case "DMIN":
- po = "DMIN";
- break;
- case "ECD":
- po = "Area";
- break;
- case "FERET":
- po = "DFERET";
- break;
- }
- DataTable dtp = particledata.GetParticleAll(filedAndParticl);
- //设置数据
- List<Item> listData = new List<Item>();
- //ListData
- 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));
- Item item = new Item()
- {
- value = datas.Count().ToString(),
- name = str
- };
- listData.Add(item);
- }
- chart.ListData = listData;
- return chart;
- }
- private Chartdate GetPSizeDataCombin(string path)
- {
- DataOperation.DataAccess.ParticleData particledata = new DataOperation.DataAccess.ParticleData(path);
- //创建新的图形数据源
- Chartdate chart = new Chartdate();
- chart.Title = m_ReportApp.m_reportname;
- chart.YName = m_str_AxisY;
- //设置标签名称
- List<string> listName = new List<string>();
- //获取粒级表
- string pathe = m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFileFolder + m_ReportApp.m_rstDataMgr.m_RptConfigFile.PartSizeFile;
- DataSet ds = DataOperation.DataAccess.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 idx = m_ReportApp.m_DataMgrFun.GetPropIndexByPropItemName(m_ReportApp.SourceGridData.ConditionItemList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
- //int sel = m_ReportApp.SourceGridData.ConditionItemList[idx].comboDownList.IndexOf(m_ReportApp.SourceGridData.ConditionItemList[idx].itemVal.ToString());
- //int sel = m_conditionChoose.m_SourceGridData.GetPropIndexByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
- int sel = m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListIndexByItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
- string filedAndParticl = "";
- //idx = m_ReportApp.m_DataMgrFun.GetPropIndexByPropItemName(m_ReportApp.SourceGridData.ConditionItemList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.SIZE_CAL_METHOD_TYPE);
- //string con = m_ReportApp.SourceGridData.ConditionItemList[idx].itemVal.ToString();
- string con = m_conditionChoose.m_conditionData.GetPropItemDisplayValueByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.SIZE_CAL_METHOD_TYPE).ToString();
- string po = "";
- switch (con)
- {
- case "DMAX":
- po = "DMAX";
- break;
- case "DMIN":
- po = "DMIN";
- break;
- case "ECD":
- po = "Area";
- break;
- case "FERET":
- po = "DFERET";
- break;
- }
- DataTable dtp = particledata.GetParticleAll(filedAndParticl);
- //计算分类整个表的数据
- DataTable dt = ClassificationIntegration(path, sel);
- List<string> listClassificationName = new List<string>();
- //ListName
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- listClassificationName.Add(dt.Rows[i]["e1"].ToString());
- }
- chart.ListName = listClassificationName;
- //设置数据
- List<Item> listData = new List<Item>();
- //ListData
- string strNameGroup = "";
- for (int j = 0; j < listClassificationName.Count; j++)
- {
- string strGroup = "";
- 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) + " and GroupName = '" + listClassificationName[j] + "'");
- strGroup += datas.Count();
- if (k != listName.Count - 1)
- {
- strGroup += ",";
- }
- }
- Item item = new Item()
- {
- value = strGroup,
- name = listClassificationName[j]
- };
- listData.Add(item);
- strNameGroup += listClassificationName[j];
- if (j != listClassificationName.Count - 1)
- {
- strNameGroup += ",";
- }
- }
- chart.Title = "[" + strNameGroup + "]";
- chart.ListData = listData;
- return chart;
- }
- private string getWhere(string max, string min, string col)
- {
- return col + ">=" + min + " and " + col + "<" + max;
- }
- #endregion
- #region echarts
- /// <summary>
- /// 通过m_list_chartstruct,组合json数据格式
- /// </summary>
- /// <returns></returns>
- private List<Chartdate> GetListJsonStrByChartStruct(int sel)
- {
- List<Chartdate> list = new List<Chartdate>();
- Chartdate chartdate = new Chartdate();
- switch (ComSel)
- {
- case "CommonlyUsedClassify":
- //chartdate = GetCommonlyUsedClassifyData(m_DataMgr.ResultFilesList[m_DataMgr.GetWorkingResult()].FilePath);
- chartdate = GetInclusionAreaRatioClassData(m_DataMgr.ResultFilesList[m_DataMgr.GetWorkingResultId()].FilePath, sel);
- break;
- case "PComponent":
- chartdate = GetPComponentData(m_DataMgr.ResultFilesList[m_DataMgr.GetWorkingResultId()].FilePath);
- break;
- case "EComponent":
- chartdate = GetEComponentData(m_DataMgr.ResultFilesList[m_DataMgr.GetWorkingResultId()].FilePath);
- break;
- case "PSize":
- chartdate = GetPSizeData(m_DataMgr.ResultFilesList[m_DataMgr.GetWorkingResultId()].FilePath);
- break;
- case "PSizeCombin":
- chartdate = GetPSizeDataCombin(m_DataMgr.ResultFilesList[m_DataMgr.GetWorkingResultId()].FilePath);
- break;
- case "InclusionareaRatio":
- chartdate = GetInclusionAreaRatioData(m_DataMgr.ResultFilesList[m_DataMgr.GetWorkingResultId()].FilePath, sel);
- break;
- case "InclusionareaClassRatio":
- chartdate=GetInclusionAreaRatioClassData(m_DataMgr.ResultFilesList[m_DataMgr.GetWorkingResultId()].FilePath, sel);
- break;
- }
- list.Add(chartdate);
- return list;
- }
- /// <summary>
- /// 通过m_list_chartstruct,组合json数据格式
- /// </summary>
- /// <returns></returns>
- private ChartdateMore GetListJsonStr()
- {
- //int idx = m_ReportApp.m_DataMgrFun.GetPropIndexByPropItemName(m_ReportApp.SourceGridData.ConditionItemList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
- //int sel = m_ReportApp.SourceGridData.ConditionItemList[idx].comboDownList.IndexOf(m_ReportApp.SourceGridData.ConditionItemList[idx].itemVal.ToString());
- //int sel = m_conditionChoose.m_SourceGridData.GetPropIndexByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE_TYPE);
- int sel = m_conditionChoose.m_conditionData.ProItemProIndex();
- string filedAndParticl = "";
- DataOperation.DataAccess.ParticleData particledata = null;
- DataTable dt = new DataTable();
- ChartdateMore chart = new ChartdateMore();
- chart.Title = m_ReportApp.m_reportname;
- chart.YName = m_str_AxisY;
- List<string> listName = new List<string>();
- List<string> soursName = new List<string>();
- List<List<Item>> listDataMore = new List<List<Item>>();
- //idx = m_ReportApp.m_DataMgrFun.GetPropIndexByPropItemName(m_ReportApp.SourceGridData.ConditionItemList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE);
- //string sou = m_ReportApp.SourceGridData.ConditionItemList[idx].itemVal.ToString();
- string sou = m_conditionChoose.m_conditionData.GetPropItemDisplayValueByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE).ToString();
- if (sou.Contains("+"))
- {
- for (int i = 0; i < sou.Split('+').Length; i++)
- {
- ResultFile resultFile = m_DataMgr.ResultFilesList.Find(s => s.anotherFileName == sou.Split('+')[i]);
- if (resultFile == null)
- {
- continue;
- }
- soursName.Add(resultFile.anotherFileName);
- particledata = new DataOperation.DataAccess.ParticleData(resultFile.FilePath);
- switch (ComSel)
- {
- case "InclusionareaRatio":
- dt = particledata.GetAreaByAllIncA("");
- //设置标签名称
-
- for (int a = 0; a < dt.Rows.Count; a++)
- {
- if (Convert.ToInt32(dt.Rows[a]["TypeId"]) < 100)
- {
- continue;
- }
- listName.Add(dt.Rows[a]["TypeName"].ToString());
- }
- //设置数据
- List<Item> listData3 = new List<Item>();
- for (int k = 0; k < dt.Rows.Count; k++)
- {
- string str = dt.Rows[k]["ar"].ToString();
- string name = dt.Rows[k]["TypeName"].ToString();
- if (Convert.ToInt32(dt.Rows[k]["TypeId"]) < 100)
- {
- continue;
- }
- Item item = new Item()
- {
- value = decimal.Round(decimal.Parse(dt.Rows[k]["ar"].ToString()), 2).ToString(),
- name = name
- };
- listData3.Add(item);
- }
- listDataMore.Add(listData3);
- break;
- case "CommonlyUsedClassify":
- //计算分类整个表的数据
- dt = ClassificationIntegration(resultFile.FilePath,sel);
- ////List<string> listName = new List<string>();
- ////ListName
- for (int a = 0; a < dt.Rows.Count; a++)
- {
- listName.Add(dt.Rows[a]["e1"].ToString());
- }
- //chart.ListName = listName;
- ////DataTable dt
- //设置数据
- List<Item> listData2 = new List<Item>();
- ////ListData
- for (int k = 0; k < dt.Rows.Count; k++)
- {
- string str = dt.Rows[k]["Cunt"].ToString();
- string name = dt.Rows[k]["e1"].ToString();
- Item item = new Item()
- {
- value = decimal.Round(decimal.Parse(str), 2).ToString(),
- name = name
- };
- listData2.Add(item);
- //listData2.Add(item);
- }
- listDataMore.Add(listData2);
- break;
- case "PComponent":
- //创建新的图形数据源
- dt = particledata.GetParticleListByIncA("area");
- //设置标签名称
- for (int j = 0; j < dt.Rows.Count; j++)
- {
- if (Convert.ToInt32(dt.Rows[j]["TypeId"]) < 100)
- {
- continue;
- }
- string name = dt.Rows[j]["TypeName"].ToString();
- if (!listName.Contains(name))
- {
- listName.Add(name);
- }
- }
- for (int j = 0; j < dt.Rows.Count; j++)
- {
- if (Convert.ToInt32(dt.Rows[j]["TypeId"]) > 100)
- {
- continue;
- }
- int index = FLID.IndexOf(Convert.ToInt32(dt.Rows[j]["TypeId"]));
- if (index == -1)
- {
- index = 7;
- }
- string name = NameList[index];
- if (!listName.Contains(name))
- {
- listName.Add(name);
- }
- }
- //设置数据
- List<Item> listData = new List<Item>();
- //ListData
- for (int k = 0; k < dt.Rows.Count; k++)
- {
- string str = dt.Rows[k]["con"].ToString();
- string name = dt.Rows[k]["TypeName"].ToString();
- if (Convert.ToInt32(dt.Rows[k]["TypeId"]) < 100)
- {
- if (Convert.ToInt32(dt.Rows[k]["TypeId"])==-1)
- {
- name = NameList[7];
- }
- else
- {
- int index = FLID.IndexOf(Convert.ToInt32(dt.Rows[k]["TypeId"]));
- name = NameList[index];
- }
-
- }
- Item item = new Item()
- {
- value = decimal.Round(decimal.Parse(str), 2).ToString(),
- name = name
- };
- listData.Add(item);
- }
- listDataMore.Add(listData);
- break;
- case "EComponent":
- //创建新的图形数据源
- dt = particledata.GetElementForArea(filedAndParticl);
- //ListName
- for (int j = 0; j < dt.Rows.Count; j++)
- {
- string name = dt.Rows[j]["name"].ToString();
- if (!listName.Contains(name))
- {
- listName.Add(name);
- }
- }
- //设置数据
- List<Item> listData1 = new List<Item>();
- //ListData
- for (int k = 0; k < dt.Rows.Count; k++)
- {
- string str = dt.Rows[k]["earea"].ToString();
- try
- {
- Item item = new Item()
- {
- value = decimal.Round(decimal.Parse(str), 2).ToString(),
- name = dt.Rows[k]["name"].ToString()
- };
- listData1.Add(item);
- }
- catch
- {
- Item item = new Item()
- {
- value = str,
- name = dt.Rows[k]["name"].ToString()
- };
- listData1.Add(item);
- }
- }
- listDataMore.Add(listData1);
- break;
- case "PSize":
- //获取粒级表
- string pathe = m_DataMgr.m_RptConfigFile.PartSizeFileFolder + m_DataMgr.m_RptConfigFile.PartSizeFile;
- DataSet ds = DataOperation.DataAccess.XMLoperate.GetXml(pathe);
- string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
- List<string> temp = new List<string>();
- for (int j = 0; j < sizestr.Split(',').Length - 1; j++)
- {
- if (sizestr.Split(',')[j].Length > 0)
- {
- double d1 = Convert.ToDouble(sizestr.Split(',')[j]);
- double d2 = Convert.ToDouble(sizestr.Split(',')[j + 1]);
- string name = d1.ToString() + "~" + d2.ToString();
- temp.Add(name);
- if (!listName.Contains(name))
- {
- listName.Add(name);
- }
- }
- }
- double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
- string name1 = d.ToString() + "~MAX";
- temp.Add(name1);
- if (!listName.Contains(name1))
- {
- listName.Add(name1);
- }
- //string con = m_ReportApp.SourceGridData.ConditionItemList[m_ReportApp.m_DataMgrFun.GetPropIndexByPropItemName(m_ReportApp.SourceGridData.ConditionItemList, OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.SIZE_CAL_METHOD_TYPE)].itemVal.ToString();
- string con = m_conditionChoose.m_conditionData.GetPropItemDisplayValueByPropItemName(OTS_REPORT_PROP_GRID_ITEMS.SIZE_CAL_METHOD_TYPE).ToString();
- string po = "";
- switch (con)
- {
- case "DMAX":
- po = "DMAX";
- break;
- case "DMIN":
- po = "DMIN";
- break;
- case "ECD":
- po = "Area";
- break;
- case "FERET":
- po = "DFERET";
- break;
- }
- DataTable dtp = particledata.GetParticleAll(filedAndParticl);
- //设置数据
- List<Item> listData4 = new List<Item>();
- //ListData
- for (int k = 0; k < temp.Count; k++)
- {
- string str = temp[k];
- string d1 = str.Split('~')[0];
- string d2 = str.Split('~')[1];
- if (d2 == "MAX")
- {
- d2 = "999";
- }
- DataRow[] datas = dtp.Select(getWhere(d2, d1, po));
- Item item = new Item()
- {
- value = datas.Count().ToString(),
- name = str
- };
- listData4.Add(item);
- }
- listDataMore.Add(listData4);
- break;
- }
- }
- }
- chart.ListName = listName;
- chart.SoursName = soursName;
- chart.ListData = listDataMore;
- return chart;
- }
- class Chartdate
- {
- public string Title { get; set; }
- public string YName { get; set; }
- public List<string> ListName { get; set; }
- public List<Item> ListData { get; set; }
- }
- class ChartdateMore
- {
- public string Title { get; set; }
- public string YName { get; set; }
- public List<string> ListName { get; set; }
- public List<string> SoursName { get; set; }
- public List<List<Item>> ListData { get; set; }
- }
- class Item
- {
- public string value { get; set; }
- public string name { get; set; }
- }
- //获取图片
- private void button1_Click(object sender, EventArgs e)
- {
-
- }
- /// <summary>
- /// 加载浏览器
- /// </summary>
- public void InitBrowser()
- {
-
- //加载网页
- if (m_ReportApp.browser == null || m_ReportApp.trans)
- {
- // 获取生成路径下网页文件的绝对路径
- string fileName = Path.Combine(Directory.GetCurrentDirectory(), url);
- //加载网页
- m_ReportApp.browser = new ChromiumWebBrowser(fileName);
-
- //禁止网页
- m_ReportApp.browser.MenuHandler = new MenuHandler();
- m_ReportApp.browser.Dock = DockStyle.Fill;
- m_ReportApp.js.MessageText = "";
- //添加网页到当前自定义控件
- this.Controls.Add(m_ReportApp.browser);
- //供页面调用以传递数据
- m_ReportApp.browser.RegisterJsObject("jsObj", m_ReportApp.js, false);
-
- //网页加载结束后调用事件
- m_ReportApp.browser.FrameLoadEnd += WebBrowser_FrameLoadEnd;
- }
- else
- {
- m_ReportApp.browser.ResetText();
- m_ReportApp.browser.Reload();
- m_ReportApp.browser.Refresh();
- //供页面调用以传递数据
- this.Controls.Add(m_ReportApp.browser);
- }
- if (m_ReportApp.timerKG)
- {
- timer1.Enabled = true;
- }
- }
- /// <summary>
- /// 页面加载结束后事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void WebBrowser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e)
- {
- if (e.Frame.IsMain)
- {
- //为页面图形提供数据参数
- string str = m_ReportApp.data;
- string strCombin = m_ReportApp.dataCombin;
- //执行网页脚本事件
- m_ReportApp.browser.ExecuteScriptAsync("showchart('" + str + "','" + strCombin + "','" + m_ReportApp.type + "')");
- }
- }
-
- //禁止网页操作,右键点击等
- class MenuHandler : CefSharp.IContextMenuHandler
- {
- void CefSharp.IContextMenuHandler.OnBeforeContextMenu(CefSharp.IWebBrowser browserControl, CefSharp.IBrowser browser, CefSharp.IFrame frame, CefSharp.IContextMenuParams parameters, CefSharp.IMenuModel model)
- {
- model.Clear();
- }
- bool CefSharp.IContextMenuHandler.OnContextMenuCommand(CefSharp.IWebBrowser browserControl, CefSharp.IBrowser browser, CefSharp.IFrame frame, CefSharp.IContextMenuParams parameters, CefSharp.CefMenuCommand commandId, CefSharp.CefEventFlags eventFlags)
- {
- //throw new NotImplementedException();
- return false;
- }
- void CefSharp.IContextMenuHandler.OnContextMenuDismissed(CefSharp.IWebBrowser browserControl, CefSharp.IBrowser browser, CefSharp.IFrame frame)
- {
- //throw new NotImplementedException();
- }
- bool CefSharp.IContextMenuHandler.RunContextMenu(CefSharp.IWebBrowser browserControl, CefSharp.IBrowser browser, CefSharp.IFrame frame, CefSharp.IContextMenuParams parameters, CefSharp.IMenuModel model, CefSharp.IRunContextMenuCallback callback)
- {
- return false;
- }
- }
- class JsEvent
- {
- public string MessageText { set; get; }
- public void ShowTest()
- {
- MessageBox.Show(MessageText);
- }
- }
- #endregion
- #region EChart导出图像委托调用部份
- public delegate void MyDelgate(string va);
- public event MyDelgate butclic;
- private void timer1_Tick(object sender, EventArgs e)
- {
- if (butclic == null)
- return;
- if (m_ReportApp.js == null)
- return;
- if (m_ReportApp.js.MessageText == null)
- return;
- if (m_ReportApp.js.MessageText != "")
- {
- butclic(m_ReportApp.js.MessageText);
- timer1.Enabled = false;
- m_ReportApp.timerKG = false;
- }
- }
- #endregion
- }
- }
|