|  | @@ -1445,12 +1445,31 @@ namespace OTSIncAReportGrids
 | 
	
		
			
				|  |  |          /// <summary>
 | 
	
		
			
				|  |  |          /// 在帧图上标记颗粒的位置矩形,并保存到FIELD_FILES_MARK文件夹中
 | 
	
		
			
				|  |  |          /// </summary>
 | 
	
		
			
				|  |  | -        public void SaveMarkParticleRectangleOnFieldFile(DataTable dataTable)
 | 
	
		
			
				|  |  | +        public void SaveMarkParticleRectangleOnFieldFile(DataTable dataTable ,out List<string> vs , out DataTable dt_FIeld)
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  | +            List<string> maxlength = new List<string>();
 | 
	
		
			
				|  |  | +            for (int i=0;i< dataTable.Rows.Count;i++)
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                if (dataTable.Rows[i]["TypeName"].ToString()!= "Not Identified")
 | 
	
		
			
				|  |  | +                {
 | 
	
		
			
				|  |  | +                    if (maxlength.Count<10)
 | 
	
		
			
				|  |  | +                    {
 | 
	
		
			
				|  |  | +                        maxlength.Add(dataTable.Rows[i]["Fieldid"].ToString());
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    else
 | 
	
		
			
				|  |  | +                    {
 | 
	
		
			
				|  |  | +                        break;
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            List<string> max_list = maxlength.Distinct().ToList();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              string str_path_FIELD_FILES = result.FilePath + "\\FIELD_FILES\\";
 | 
	
		
			
				|  |  |              string str_path_FIELD_FILES_MARK = result.FilePath + "\\FIELD_FILES_MARK\\";
 | 
	
		
			
				|  |  |              int intQuantity = 0;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +            //List<string> vs = new List<string>();
 | 
	
		
			
				|  |  | +            dt_FIeld = new DataTable();
 | 
	
		
			
				|  |  | +            vs = new List<string>();
 | 
	
		
			
				|  |  |              ////判断是否已经有导出过的标记帧图文件夹,如果已经存在,则直接返回不输出,先不加
 | 
	
		
			
				|  |  |              DirectoryInfo theFolder_FieldMark = new DirectoryInfo(str_path_FIELD_FILES_MARK);
 | 
	
		
			
				|  |  |              if (!theFolder_FieldMark.Exists)
 | 
	
	
		
			
				|  | @@ -1474,74 +1493,105 @@ namespace OTSIncAReportGrids
 | 
	
		
			
				|  |  |              DirectoryInfo theFolder = new DirectoryInfo(str_path_FIELD_FILES);
 | 
	
		
			
				|  |  |              if (theFolder.Exists)
 | 
	
		
			
				|  |  |              {
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                //循环帧图,再循环各帧图中的颗粒,进行标记,保存
 | 
	
		
			
				|  |  | -                foreach (FileInfo nextifile in theFolder.GetFiles())
 | 
	
		
			
				|  |  | +                DataTable dt = new DataTable();
 | 
	
		
			
				|  |  | +                dt.Columns.Add("fieldid");
 | 
	
		
			
				|  |  | +                dt.Columns.Add("id");
 | 
	
		
			
				|  |  | +                dt.Columns.Add("fieldName");
 | 
	
		
			
				|  |  | +                dt.Columns.Add("cunt",typeof(int));
 | 
	
		
			
				|  |  | +                dt.Columns.Add("fieldFullName");
 | 
	
		
			
				|  |  | +                for (int i = 0; i < max_list.Count; i++)
 | 
	
		
			
				|  |  |                  {
 | 
	
		
			
				|  |  | -                    //找出所有的用户库文件,在这个目录中
 | 
	
		
			
				|  |  | -                    if (nextifile.Name.Contains(".bmp") == true || nextifile.Name.Contains(".BMP") == true)
 | 
	
		
			
				|  |  | +                    foreach (FileInfo nextifile in theFolder.GetFiles())
 | 
	
		
			
				|  |  |                      {
 | 
	
		
			
				|  |  | -                        //确认对应的帧图名
 | 
	
		
			
				|  |  | -                        string str_fieldid = Path.GetFileNameWithoutExtension(nextifile.Name);
 | 
	
		
			
				|  |  | -                        str_fieldid = str_fieldid.Substring(5, str_fieldid.Length - 5);//减去field字符长度
 | 
	
		
			
				|  |  | +                        if (nextifile.Name.Contains(".bmp") == true || nextifile.Name.Contains(".BMP") == true)
 | 
	
		
			
				|  |  | +                        {
 | 
	
		
			
				|  |  | +                            //确认对应的帧图名
 | 
	
		
			
				|  |  | +                            string str_fieldid = Path.GetFileNameWithoutExtension(nextifile.Name);
 | 
	
		
			
				|  |  | +                            str_fieldid = str_fieldid.Substring(5, str_fieldid.Length - 5);//减去field字符长度
 | 
	
		
			
				|  |  | +                            bool bl = false;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                        if (intQuantity > 10)
 | 
	
		
			
				|  |  | -                            continue;
 | 
	
		
			
				|  |  | +                            if (str_fieldid == max_list[i].ToString())
 | 
	
		
			
				|  |  | +                            {
 | 
	
		
			
				|  |  | +                                bl = true;
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                        if (dataTable.Select(" fieldid = " + str_fieldid).Count() > 0)
 | 
	
		
			
				|  |  | -                        {
 | 
	
		
			
				|  |  | -                            Image img = Image.FromFile(nextifile.FullName);
 | 
	
		
			
				|  |  | -                            Bitmap ls_fieldbp = new Bitmap(img.Width, img.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
 | 
	
		
			
				|  |  | -                            using (Graphics g = Graphics.FromImage(ls_fieldbp))
 | 
	
		
			
				|  |  | +                            if (bl)
 | 
	
		
			
				|  |  |                              {
 | 
	
		
			
				|  |  | -                                g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
 | 
	
		
			
				|  |  | -                                g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
 | 
	
		
			
				|  |  | -                                g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
 | 
	
		
			
				|  |  | -                                g.DrawImage(img, 0, 0);
 | 
	
		
			
				|  |  | +                                DataRow dr = dt.NewRow();
 | 
	
		
			
				|  |  | +                                dr["fieldid"] = " fieldid = " + str_fieldid;
 | 
	
		
			
				|  |  | +                                dr["cunt"] = dataTable.Select(" fieldid = " + str_fieldid).Count();
 | 
	
		
			
				|  |  | +                                dr["fieldName"] = nextifile.Name;
 | 
	
		
			
				|  |  | +                                dr["fieldFullName"] = nextifile.FullName;
 | 
	
		
			
				|  |  | +                                dr["id"] = str_fieldid;
 | 
	
		
			
				|  |  | +                                dt.Rows.Add(dr);
 | 
	
		
			
				|  |  |                              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                            img.Dispose();
 | 
	
		
			
				|  |  | -                            img = null;
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                //DataView dv = dt.DefaultView;
 | 
	
		
			
				|  |  | +                //dv.Sort = "cunt DESC";
 | 
	
		
			
				|  |  | +                dt_FIeld = dt.Copy();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                            //循环将颗粒,进行标记到bitmap图上
 | 
	
		
			
				|  |  | -                            DataRow[] drlist = dt_AllParticle.Select("  fieldid = " + str_fieldid);
 | 
	
		
			
				|  |  | -                            if (drlist.Count() > 0)
 | 
	
		
			
				|  |  | -                                intQuantity = intQuantity + 1;
 | 
	
		
			
				|  |  | -                            for (int i_row = 0; i_row < drlist.Count(); i_row++)
 | 
	
		
			
				|  |  | -                            {
 | 
	
		
			
				|  |  | -                                //string str_fieldid = drlist[i_row]["fieldid"].ToString();
 | 
	
		
			
				|  |  | -                                string str_particleid = drlist[i_row]["particleid"].ToString();
 | 
	
		
			
				|  |  | -                                string str_stdtypeid = drlist[i_row]["typeid"].ToString();
 | 
	
		
			
				|  |  | -                                string str_offset_rect_X = drlist[i_row]["RectLeft"].ToString();
 | 
	
		
			
				|  |  | -                                string str_offset_rect_Y = drlist[i_row]["RectTop"].ToString();
 | 
	
		
			
				|  |  | -                                string str_offset_rect_Width = drlist[i_row]["RectWidth"].ToString();
 | 
	
		
			
				|  |  | -                                string str_offset_rect_Height = drlist[i_row]["RectHeight"].ToString();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                                //确定需要标记颗粒的定位
 | 
	
		
			
				|  |  | -                                Rectangle offset_rect = new Rectangle(Convert.ToInt32(str_offset_rect_X), Convert.ToInt32(str_offset_rect_Y),
 | 
	
		
			
				|  |  | -                        Convert.ToInt32(str_offset_rect_Width), Convert.ToInt32(str_offset_rect_Height));
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                                //向帧图进行标记颗粒位置
 | 
	
		
			
				|  |  | -                                Graphics g = Graphics.FromImage(ls_fieldbp);
 | 
	
		
			
				|  |  | -                                g.DrawRectangle(new Pen(Color.Aquamarine), offset_rect);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                                //判断是否超出了图像外面,是的话,让文字在左侧显示,默认在右侧显示
 | 
	
		
			
				|  |  | -                                int ls_offsetx = offset_rect.X + offset_rect.Width;
 | 
	
		
			
				|  |  | -                                if (ls_offsetx > ls_fieldbp.Width - 10)
 | 
	
		
			
				|  |  | -                                {
 | 
	
		
			
				|  |  | -                                    ls_offsetx = offset_rect.X - 10;
 | 
	
		
			
				|  |  | -                                }
 | 
	
		
			
				|  |  | -                                g.DrawString(str_fieldid + "" + str_particleid.ToString(),
 | 
	
		
			
				|  |  | -                                    new Font("黑体", 8), new SolidBrush(Color.Aqua), new PointF(ls_offsetx, offset_rect.Y));
 | 
	
		
			
				|  |  | +                for (int i=0;i< dt_FIeld.Rows.Count; i++)
 | 
	
		
			
				|  |  | +                {
 | 
	
		
			
				|  |  | +                    if (dataTable.Select(dt_FIeld.Rows[i]["fieldid"].ToString()).Count() > 0)
 | 
	
		
			
				|  |  | +                    {
 | 
	
		
			
				|  |  | +                        vs.Add(dt_FIeld.Rows[i]["id"].ToString());
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                                //保存带有标记的帧图
 | 
	
		
			
				|  |  | -                                ls_fieldbp.Save(str_path_FIELD_FILES_MARK + str_fieldid.ToString() + ".bmp");
 | 
	
		
			
				|  |  | +                        Image img = Image.FromFile(dt_FIeld.Rows[i]["fieldFullName"].ToString());
 | 
	
		
			
				|  |  | +                        Bitmap ls_fieldbp = new Bitmap(img.Width, img.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
 | 
	
		
			
				|  |  | +                        using (Graphics g = Graphics.FromImage(ls_fieldbp))
 | 
	
		
			
				|  |  | +                        {
 | 
	
		
			
				|  |  | +                            g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
 | 
	
		
			
				|  |  | +                            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
 | 
	
		
			
				|  |  | +                            g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
 | 
	
		
			
				|  |  | +                            g.DrawImage(img, 0, 0);
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                                //ls_fieldbp.Dispose();
 | 
	
		
			
				|  |  | +                        img.Dispose();
 | 
	
		
			
				|  |  | +                        img = null;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                        //循环将颗粒,进行标记到bitmap图上
 | 
	
		
			
				|  |  | +                        DataRow[] drlist = dt_AllParticle.Select(dt_FIeld.Rows[i]["fieldid"].ToString());
 | 
	
		
			
				|  |  | +                        if (drlist.Count() > 0)
 | 
	
		
			
				|  |  | +                            intQuantity = intQuantity + 1;
 | 
	
		
			
				|  |  | +                        for (int i_row = 0; i_row < drlist.Count(); i_row++)
 | 
	
		
			
				|  |  | +                        {
 | 
	
		
			
				|  |  | +                            //string str_fieldid = drlist[i_row]["fieldid"].ToString();
 | 
	
		
			
				|  |  | +                            string str_particleid = drlist[i_row]["particleid"].ToString();
 | 
	
		
			
				|  |  | +                            string str_stdtypeid = drlist[i_row]["typeid"].ToString();
 | 
	
		
			
				|  |  | +                            string str_offset_rect_X = drlist[i_row]["RectLeft"].ToString();
 | 
	
		
			
				|  |  | +                            string str_offset_rect_Y = drlist[i_row]["RectTop"].ToString();
 | 
	
		
			
				|  |  | +                            string str_offset_rect_Width = drlist[i_row]["RectWidth"].ToString();
 | 
	
		
			
				|  |  | +                            string str_offset_rect_Height = drlist[i_row]["RectHeight"].ToString();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                            //确定需要标记颗粒的定位
 | 
	
		
			
				|  |  | +                            Rectangle offset_rect = new Rectangle(Convert.ToInt32(str_offset_rect_X), Convert.ToInt32(str_offset_rect_Y),
 | 
	
		
			
				|  |  | +                    Convert.ToInt32(str_offset_rect_Width), Convert.ToInt32(str_offset_rect_Height));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                            //向帧图进行标记颗粒位置
 | 
	
		
			
				|  |  | +                            Graphics g = Graphics.FromImage(ls_fieldbp);
 | 
	
		
			
				|  |  | +                            g.DrawRectangle(new Pen(Color.Aquamarine), offset_rect);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                            //判断是否超出了图像外面,是的话,让文字在左侧显示,默认在右侧显示
 | 
	
		
			
				|  |  | +                            int ls_offsetx = offset_rect.X + offset_rect.Width;
 | 
	
		
			
				|  |  | +                            if (ls_offsetx > ls_fieldbp.Width - 10)
 | 
	
		
			
				|  |  | +                            {
 | 
	
		
			
				|  |  | +                                ls_offsetx = offset_rect.X - 10;
 | 
	
		
			
				|  |  |                              }
 | 
	
		
			
				|  |  | +                           
 | 
	
		
			
				|  |  | +                            g.DrawString(dt_FIeld.Rows[i]["id"].ToString() + "" + str_particleid.ToString(),
 | 
	
		
			
				|  |  | +                                new Font("黑体", 8), new SolidBrush(Color.Aqua), new PointF(ls_offsetx, offset_rect.Y));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                            //保存带有标记的帧图
 | 
	
		
			
				|  |  | +                            ls_fieldbp.Save(str_path_FIELD_FILES_MARK + dt_FIeld.Rows[i]["id"].ToString() + ".bmp");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                            //ls_fieldbp.Dispose();
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              //
 | 
	
		
			
				|  |  |              GC.Collect();
 |