|
@@ -147,6 +147,7 @@ namespace OTSIncAReportApp.OTSTemplateDesigner
|
|
|
DT_field_dt.Columns.Add(colpict2);
|
|
|
|
|
|
//表名Largest_frame表:(子表) 显示20条颗粒除外的部份颗粒信息
|
|
|
+ DataTable DT_field_dt_copy = new DataTable();
|
|
|
DataTable DT_Largest_frame = new DataTable();
|
|
|
DT_Largest_frame.TableName = "Largest_frame";
|
|
|
DT_Largest_frame.Columns.Add("pid");
|
|
@@ -338,36 +339,67 @@ namespace OTSIncAReportApp.OTSTemplateDesigner
|
|
|
DirectoryInfo theFolder = new DirectoryInfo(str_path_FIELD_FILES_MARK);
|
|
|
if (theFolder.Exists)
|
|
|
{
|
|
|
- for (int i = 0; i <= theFolder.GetFiles().Count(); i++)
|
|
|
+ //for (int i = 0; i <= theFolder.GetFiles().Count(); i++)
|
|
|
+ //{
|
|
|
+ // //判断i.bmp图片是否存在,如果不存在跳出当前循环
|
|
|
+ // if (!DetermineWhetherTheFileExists(theFolder, i))
|
|
|
+ // continue;
|
|
|
+ // //在数据表中有颗粒在该帧图中的话,则对该帧图标记图像进行读取存入数据库
|
|
|
+ // DataRow[] datarowlist = dt_ParticlesGridDevidePage.Select(" fieldid = " + i);
|
|
|
+
|
|
|
+ // if (datarowlist.Count() > 0)
|
|
|
+ // {
|
|
|
+ // Bitmap ls_bp_fieldmark = new Bitmap(theFolder.GetFiles()[i].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"] = i;
|
|
|
+
|
|
|
+ // ls_bp_fieldmark.Dispose();
|
|
|
+ // DT_field_dt.Rows.Add(dr);
|
|
|
+
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ foreach (FileInfo nextifile in theFolder.GetFiles())
|
|
|
{
|
|
|
- //判断i.bmp图片是否存在,如果不存在跳出当前循环
|
|
|
- if (!DetermineWhetherTheFileExists(theFolder, i))
|
|
|
- continue;
|
|
|
- //在数据表中有颗粒在该帧图中的话,则对该帧图标记图像进行读取存入数据库
|
|
|
- DataRow[] datarowlist = dt_ParticlesGridDevidePage.Select(" fieldid = " + i);
|
|
|
- if (datarowlist.Count() > 0)
|
|
|
+ if (nextifile.Name.Contains(".bmp") == true || nextifile.Name.Contains(".BMP") == true)
|
|
|
{
|
|
|
- Bitmap ls_bp_fieldmark = new Bitmap(theFolder.GetFiles()[i].FullName);
|
|
|
+ //确认对应的帧图名
|
|
|
+ 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"] = i;
|
|
|
+ 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);
|
|
|
+ ls_bp_fieldmark.Dispose();
|
|
|
+ DT_field_dt.Rows.Add(dr);
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+ DataView vw = DT_field_dt.DefaultView;
|
|
|
+ vw.Sort = "FieldId ASC";
|
|
|
+ DT_field_dt_copy = vw.ToTable();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
#endregion
|
|
|
|
|
|
#region 插入-前20颗粒外的颗粒
|
|
@@ -464,14 +496,150 @@ namespace OTSIncAReportApp.OTSTemplateDesigner
|
|
|
|
|
|
}
|
|
|
#endregion
|
|
|
+ FrameGraphParticleTable(dt_ParticlesGridDevidePage, str_resultPath, fielddata, DT_field_dt);
|
|
|
|
|
|
-
|
|
|
- m_list_dt.Add(DT_field_dt);
|
|
|
+ m_list_dt.Add(DT_field_dt_copy);
|
|
|
m_list_dt.Add(DT_Largest_frame);
|
|
|
m_list_dt.Add(DT_Largest20);
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
+ private bool JudgeWhetherItExists(int id, DataTable dt,string column)
|
|
|
+ {
|
|
|
+ for (int i=0;i<dt.Rows.Count;i++)
|
|
|
+ {
|
|
|
+ if (id == Convert.ToInt32(dt.Rows[i][column].ToString()))
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ ///
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dt_ParticlesGridDevidePage">数据源</param>
|
|
|
+ /// <param name="str_resultPath">地址</param>
|
|
|
+ /// <param name="fielddata"></param>
|
|
|
+ /// <param name="DT_field_dt">主表</param>
|
|
|
+ private void FrameGraphParticleTable(DataTable dt_ParticlesGridDevidePage,string str_resultPath, ParticleData fielddata,DataTable DT_field_dt)
|
|
|
+ {
|
|
|
+
|
|
|
+ //表名Largest_frame表:(子表) 显示20条颗粒除外的部份颗粒信息
|
|
|
+ DataTable FrameGraphSubTable = new DataTable();
|
|
|
+ FrameGraphSubTable.TableName = "FrameGraphSubTable";
|
|
|
+ FrameGraphSubTable.Columns.Add("pid");
|
|
|
+ FrameGraphSubTable.Columns.Add("Size");
|
|
|
+ FrameGraphSubTable.Columns.Add("Width");
|
|
|
+ FrameGraphSubTable.Columns.Add("Class");
|
|
|
+ FrameGraphSubTable.Columns.Add("ColName1");
|
|
|
+ FrameGraphSubTable.Columns.Add("ColName2");
|
|
|
+ FrameGraphSubTable.Columns.Add("ColName3");
|
|
|
+ FrameGraphSubTable.Columns.Add("ColName4");
|
|
|
+ FrameGraphSubTable.Columns.Add("ColName5");
|
|
|
+ FrameGraphSubTable.Columns.Add("ColName6");
|
|
|
+ FrameGraphSubTable.Columns.Add("ColVal1");
|
|
|
+ FrameGraphSubTable.Columns.Add("ColVal2");
|
|
|
+ FrameGraphSubTable.Columns.Add("ColVal3");
|
|
|
+ FrameGraphSubTable.Columns.Add("ColVal4");
|
|
|
+ FrameGraphSubTable.Columns.Add("ColVal5");
|
|
|
+ FrameGraphSubTable.Columns.Add("ColVal6");
|
|
|
+ DataColumn colpictid = new DataColumn("FieldId");
|
|
|
+ colpictid.DataType = typeof(int);
|
|
|
+ FrameGraphSubTable.Columns.Add(colpictid);
|
|
|
+ //图像列
|
|
|
+ DataColumn colpict = new DataColumn("p1");
|
|
|
+ colpict.DataType = System.Type.GetType("System.Byte[]");
|
|
|
+ FrameGraphSubTable.Columns.Add(colpict);
|
|
|
+
|
|
|
+ for (int i_row = 0; i_row < dt_ParticlesGridDevidePage.Rows.Count; i_row++)
|
|
|
+ {
|
|
|
+ if (dt_ParticlesGridDevidePage.Rows[i_row]["element"].ToString() == "")
|
|
|
+ continue;
|
|
|
+ //获取颗粒的fieldid,和particleid
|
|
|
+ string str_fieldid = dt_ParticlesGridDevidePage.Rows[i_row]["fieldid"].ToString();
|
|
|
+
|
|
|
+ //if (Convert.ToInt32(str_fieldid) < 20)
|
|
|
+ if (JudgeWhetherItExists(Convert.ToInt32(str_fieldid), DT_field_dt, "FieldId"))
|
|
|
+ {
|
|
|
+
|
|
|
+ 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 != "")
|
|
|
+ {
|
|
|
+
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ 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 = FrameGraphSubTable.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();
|
|
|
+
|
|
|
+ FrameGraphSubTable.Rows.Add(dr);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ m_list_dt.Add(FrameGraphSubTable);
|
|
|
+ }
|
|
|
|
|
|
private bool DetermineWhetherTheFileExists(DirectoryInfo theFolder ,int id)
|
|
|
{
|