Explorar o código

Merge branch 'Release2.4' of http://36.129.163.148:10080/gaoshipeng/OTS2_0 into zty

# Conflicts:
#	OTSIncAReportApp/1-UI/frmReMeasure.cs
#	OTSIncAReportApp/3-ServiceCenter/HardwareController.cs
zty %!s(int64=3) %!d(string=hai) anos
pai
achega
4e176c30c2

+ 1 - 1
OTSCPP/OTSImagePro/FieldMgr.cpp

@@ -378,7 +378,7 @@ namespace OTSIMGPROC {
 		sizeImage.cx = dScanFiledSizeX;
 		sizeImage.cy = dScanFiledSizeY;
 		// pixel size (micros)
-		double dPixelSize = (double)dScanFiledSizeX / (double)sizeImage.cx;
+		//double dPixelSize = (double)dScanFiledSizeX / (double)ImageSizeByPixel.cx;
 
 		// the measure domain rectangle 
 		CRect rectMeasureDomain = m_pMeasureArea->GetDomainRect();

+ 5 - 5
OTSIncAMeasureApp/1-OTSMeasure/OTSMeasureDisplayResult.cs

@@ -347,8 +347,8 @@ namespace OTSMeasureApp
                     //已完成帧图的绘制 根据位置-判断相差范围  四舍五入返回的数值有偏差
                     int minTempRange = minRange;
                     int maxTempRange = maxRange;
-                    int XOffice = 0;
-                    int YOffice = 0;
+                    int XOffset = 0;
+                    int YOffset = 0;
                     //以放大倍数 获取当前倍数扫描尺寸 与100倍扫描尺寸的比例
                     int ScanFieldSize = m_MeasureApp.m_ProjParam.GetResultData().GetWorkingSample().GetSEMDataMsr().GetScanFieldSize();
                     int ScanFieldSize100 = m_MeasureApp.m_ProjParam.GetResultData().GetWorkingSample().GetSEMDataMsr().GetScanFieldSize100();
@@ -360,9 +360,9 @@ namespace OTSMeasureApp
                     }
                     for (int i = OTSSamplespaceWindow.m_SingleGDIObjects.Count - 1; i >= 0; i--)
                     {
-                        XOffice = OTSSamplespaceWindow.m_SingleGDIObjects[i].OTSX - CurrentFIELDOTSPoint.X;
-                        YOffice = OTSSamplespaceWindow.m_SingleGDIObjects[i].OTSY - CurrentFIELDOTSPoint.Y;
-                        if ((minTempRange < XOffice) && (XOffice < maxTempRange) && (minTempRange < YOffice) && (YOffice < maxTempRange))
+                        XOffset= OTSSamplespaceWindow.m_SingleGDIObjects[i].OTSX - CurrentFIELDOTSPoint.X;
+                        YOffset = OTSSamplespaceWindow.m_SingleGDIObjects[i].OTSY - CurrentFIELDOTSPoint.Y;
+                        if ((minTempRange < XOffset) && (XOffset < maxTempRange) && (minTempRange < YOffset) && (YOffset < maxTempRange))
                         {
                             //修改完成状态
                             OTSSamplespaceWindow.m_SingleGDIObjects[i].SelColor = changeColor;

+ 1 - 7
OTSIncAMeasureApp/2-OTSMeasureParamManage/COTSMeasureParam.cs

@@ -665,13 +665,7 @@ namespace OTSMeasureApp
             SMPara.sHoleName = WSample.GetSampleHoleName(); //获取样品孔名称
             SMPara.MeasureRect = (Rectangle)WSample.GetMsrArea().GetRectDomain();  //样品测量区域
 
-            //改变测量区域后重新设置样品修改状态
-            //m_ResultData.SetModify(true);
-            //string pathName = m_ProjDataMgr.GetPathName();
-            //if (pathName != "" && pathName != "Untitled")
-            //{
-            //    m_ProjDataMgr.Save();
-            //}
+     
             return SMPara;
 
         }

+ 34 - 34
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/OTSSamplespaceGraphicsPanelFun.cs

@@ -625,7 +625,7 @@ namespace OTSMeasureApp
         /// <param name="m_MeasureAppForm"></param>
         /// <param name="sampleName"></param>
         /// <returns></returns>
-        public static SampleMeasurePara GetMeasureInfo(OTSIncAMeasureAppForm m_MeasureAppForm, string sampleName, ARectangleGDIObject item, ARectangleGDIObject m_RectangleGDIObjects, StageDrawingData oTSSampleStageData, int wDomain, int w)
+        public static SampleMeasurePara GetMeasureInfo( string sampleName, ARectangleGDIObject item,  int wDomain, int w)
         {
             SampleMeasurePara sampleMeasurePara = new SampleMeasurePara();
             foreach (ARectangleGDIObject measureItem in OTSSamplespaceWindow.m_MeasureGDIObjects)
@@ -679,7 +679,7 @@ namespace OTSMeasureApp
             return sampleMeasurePara;
         }
 
-        public static SampleHolePara GetSampleHoleInfo(OTSIncAMeasureAppForm m_MeasureAppForm, string sampleHoleName, ARectangleGDIObject item, ARectangleGDIObject m_RectangleGDIObjects, StageDrawingData oTSSampleStageData, int wDomain, int w)
+        public static SampleHolePara GetSampleHoleInfo(string sampleHoleName, ARectangleGDIObject item, int wDomain, int w)
         {
             SampleHolePara sampleHolePara = new SampleHolePara();
             foreach (ARectangleGDIObject sampleHoleItem in OTSSamplespaceWindow.m_SampleHoleGDIObjects)
@@ -717,20 +717,20 @@ namespace OTSMeasureApp
         /// 获取工作样品的测量区域信息
         /// </summary>
         /// <returns></returns>
-        public static Rectangle GetWorkMeasure(OTSIncAMeasureAppForm m_MeasureAppForm, ARectangleGDIObject m_RectangleGDIObjects, StageDrawingData oTSSampleStageData, int wDomain, int w)
-        {
-            foreach (ARectangleGDIObject itemMeasure in OTSSamplespaceWindow.m_MeasureGDIObjects)
-            {
-                if (itemMeasure.IsWorkSample)
-                {
-                    Point startPoint = new Point(itemMeasure.Region.Left, itemMeasure.Region.Top);
-                    Point endPoint = new Point(itemMeasure.Region.Right, itemMeasure.Region.Bottom);
-                    SampleMeasurePara rectMaesure = GetMeasureInfo(m_MeasureAppForm, itemMeasure.SampleName, itemMeasure, m_RectangleGDIObjects, oTSSampleStageData, wDomain, w);
-                    return rectMaesure.MeasureRect;
-                }
-            }
-            return new Rectangle();
-        }
+        //public static Rectangle GetWorkMeasure( int wDomain, int w)
+        //{
+        //    foreach (ARectangleGDIObject itemMeasure in OTSSamplespaceWindow.m_MeasureGDIObjects)
+        //    {
+        //        if (itemMeasure.IsWorkSample)
+        //        {
+        //            Point startPoint = new Point(itemMeasure.Region.Left, itemMeasure.Region.Top);
+        //            Point endPoint = new Point(itemMeasure.Region.Right, itemMeasure.Region.Bottom);
+        //            SampleMeasurePara rectMaesure = GetMeasureInfo(itemMeasure.SampleName, itemMeasure,  wDomain, w);
+        //            return rectMaesure.MeasureRect;
+        //        }
+        //    }
+        //    return new Rectangle();
+        //}
         #endregion
 
         #region 删除样品弹出提示
@@ -811,21 +811,21 @@ namespace OTSMeasureApp
         #endregion
 
         #region 计算两个点之间的距离 (图形中心与屏幕中心相差的距离)
-        public static Point RegionCenterToScreenCenterDist(ARectangleGDIObject regionCneter, Point screenCneter)
-        {
-            Point differentPoint = new Point();
-            //获取图形中心位置
-            Rectangle rectangle = new Rectangle();
-            rectangle.X = (int)regionCneter.RegionF.X;
-            rectangle.Y = (int)regionCneter.RegionF.Y;
-            rectangle.Width = (int)regionCneter.RegionF.Width;
-            rectangle.Height = (int)regionCneter.RegionF.Height;
-            Point m_RegionCenter = OTSSamplespaceGraphicsPanelFun.GetCenterPoint(rectangle);
-            //获取图形中心与屏幕中心相差的距离
-            differentPoint.X = m_RegionCenter.X - screenCneter.X;
-            differentPoint.Y = m_RegionCenter.Y - screenCneter.Y;
-            return differentPoint;
-        }
+        //public static Point RegionCenterToScreenCenterDist(ARectangleGDIObject regionCneter, Point screenCneter)
+        //{
+        //    Point differentPoint = new Point();
+        //    //获取图形中心位置
+        //    Rectangle rectangle = new Rectangle();
+        //    rectangle.X = (int)regionCneter.RegionF.X;
+        //    rectangle.Y = (int)regionCneter.RegionF.Y;
+        //    rectangle.Width = (int)regionCneter.RegionF.Width;
+        //    rectangle.Height = (int)regionCneter.RegionF.Height;
+        //    Point m_RegionCenter = OTSSamplespaceGraphicsPanelFun.GetCenterPoint(rectangle);
+        //    //获取图形中心与屏幕中心相差的距离
+        //    differentPoint.X = m_RegionCenter.X - screenCneter.X;
+        //    differentPoint.Y = m_RegionCenter.Y - screenCneter.Y;
+        //    return differentPoint;
+        //}
         #endregion
         
         #region 清除List中所有信息
@@ -880,7 +880,7 @@ namespace OTSMeasureApp
             if (returnResult)
             {
                 //获取测量区域的OTS位置与尺寸
-                sampleMeasureParas = OTSSamplespaceGraphicsPanelFun.GetMeasureInfo(m_MeasureAppForm, MeasureItem.SampleName, MeasureItem, m_RectangleGDIObjects, oTSSampleStageData, wDomain, w);
+                sampleMeasureParas = OTSSamplespaceGraphicsPanelFun.GetMeasureInfo( MeasureItem.SampleName, MeasureItem,   wDomain, w);
                 //获取工作区域位置与尺寸
                 Rectangle WorkAreaRect = new Rectangle(0, 0, Width, Height);
                 //获取工作区域 中心点
@@ -912,12 +912,12 @@ namespace OTSMeasureApp
             return sampleMeasureParas;
         }
 
-        public static SampleHolePara GetSampleHoleRect(ARectangleGDIObject sampleHoleItem, OTSIncAMeasureAppForm m_MeasureAppForm, StageDrawingData oTSSampleStageData, ARectangleGDIObject m_RectangleGDIObjects, int IsWidth, int Width, int Height, int wDomain)
+        public static SampleHolePara GetSampleHoleRect(ARectangleGDIObject sampleHoleItem, ARectangleGDIObject m_RectangleGDIObjects, int IsWidth, int Width, int Height, int wDomain)
         {
             int w = (IsWidth == 0 ? Width : Height);
             SampleHolePara sampleHoleParas = new SampleHolePara();
             //获取样品孔的OTS位置与尺寸
-            sampleHoleParas = OTSSamplespaceGraphicsPanelFun.GetSampleHoleInfo(m_MeasureAppForm, sampleHoleItem.Name, sampleHoleItem, m_RectangleGDIObjects, oTSSampleStageData, wDomain, w);
+            sampleHoleParas = OTSSamplespaceGraphicsPanelFun.GetSampleHoleInfo( sampleHoleItem.Name, sampleHoleItem, wDomain, w);
             //获取工作区域位置与尺寸
             Rectangle WorkAreaRect = new Rectangle(0, 0, Width, Height);
             //获取工作区域 中心点

+ 12 - 11
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/OTSSamplespaceWindow.cs

@@ -3174,6 +3174,7 @@ namespace OTSMeasureApp
                 case "SetSEMCenterLocation":
                     //将测量区域移到SEM当前位置
                     SetMeasureToSEMLocation();
+                    GetSingleInfo();
                     break;
                 case "ReadSEMData":
                     m_MeasureAppForm.m_MessageStates = (int)MessageState.StartMeasure;
@@ -3181,7 +3182,7 @@ namespace OTSMeasureApp
                     CMeasureThreadWrapper.DoRunType = (int)MSR_THREAD_RunSTATUS.RUNMEASURE;
                     GetSingleInfo();
                     // 根据已完成测量的帧图信息 绘制帧图已完成状态 
-                    GetSingleInfoForSampleNameAndOTSSamplespaceWindow();
+                    //GetSingleInfoForSampleNameAndOTSSamplespaceWindow();
                     break;
                 case "SetSemData":
                     double SemMag = 0;
@@ -3871,12 +3872,12 @@ namespace OTSMeasureApp
     
                 #region 获取当前工作的测量区域信息
                 //是否获取过帧图标识
-                bool IsSingle = false;
+                bool IsPolygon = false;
                 if (m_MeasureAppForm.m_MessageStates == (int)MessageState.StartMeasure)
                 {
                     //设置测量区域形状与位置
-                    IsSingle = SetWorkSampleMeasureArea();
-                    if (!IsSingle)
+                    IsPolygon = SetWorkSampleMeasureArea();
+                    if (!IsPolygon)
                     {
                         return;
                     }
@@ -3889,7 +3890,7 @@ namespace OTSMeasureApp
                     m_MeasureAppForm.UpdatePropertyVal();
                 }
                 //如果当前工作样品是多边形则设置回原测量区域参数
-                if (IsSingle)
+                if (IsPolygon)
                 {
                     foreach (var MeasureItem in m_MeasureGDIObjects)
                     {
@@ -3921,6 +3922,7 @@ namespace OTSMeasureApp
                     Point pt = new Point(m_RectFieldRects[i].X, m_RectFieldRects[i].Y);
                     pt.X = m_RectFieldRects[i].X - m_RectFieldRects[i].Width / 2;
                     pt.Y = m_RectFieldRects[i].Y + m_RectFieldRects[i].Height / 2;
+
                     //获取Rectang 两点信息
                     Point XSTD = new Point(m_RectFieldRects[i].Left, m_RectFieldRects[i].Top);
                     Point YSTD = new Point(m_RectFieldRects[i].Right, m_RectFieldRects[i].Bottom);
@@ -4110,8 +4112,7 @@ namespace OTSMeasureApp
                 List<double> SemLocation = new List<double>();
                 if (GetSemLocation(ref SemLocation))
                 {
-                    //SemLocation[0] = 60000;
-                    //SemLocation[1] = 60000;
+                   
                     Point OTSLocation = m_MeasureAppForm.m_ProjParam.ConverSEMToOTSPoint(new Point((int)Math.Round(SemLocation[(int)XYIndex.X], 0), (int)Math.Round(SemLocation[(int)XYIndex.Y], 0)));
                     //转换为工作区域位置坐标
                     int w = (int)OTSSamplespaceGraphicsPanelFun.MillimetersToPixelsWidth(m_WDomain, Convert.ToDouble(OTSLocation.X), IsWidth, m_DefaultW, m_DefaultH);
@@ -4611,7 +4612,7 @@ namespace OTSMeasureApp
                         {
                             if (sampleHoleItem.Name == sampleHoleInfo.sSHoleName)
                             {
-                                SampleHolePara sampleHolePara = OTSSamplespaceGraphicsPanelFun.GetSampleHoleRect(sampleHoleItem, m_MeasureAppForm, m_OTSSampleStageData, m_RectangleGDIObjects[0], IsWidth, Width, Height, m_WDomain);
+                                SampleHolePara sampleHolePara = OTSSamplespaceGraphicsPanelFun.GetSampleHoleRect(sampleHoleItem, m_RectangleGDIObjects[0], IsWidth, Width, Height, m_WDomain);
                                 iShape = (DOMAIN_SHAPE)sampleHolePara.iShape;
                                 Srect = sampleHolePara.SampleHoleRect;
                                 //设置测量区域形状
@@ -4771,7 +4772,7 @@ namespace OTSMeasureApp
         #region 设置工作样品测量区域
         public bool SetWorkSampleMeasureArea(int shape = 0)
         {
-            bool IsSingle = false;
+            bool isPolygon = false;
             //获取当前工作的测量区域信息
             CDomain cDomain = new CDomain();
             DOMAIN_SHAPE iShape = 0;
@@ -4785,7 +4786,7 @@ namespace OTSMeasureApp
                 {
                     if (OTSSamplespaceGraphicsPanelFun.SetWorkSamplHoleAndMeasureArea(MeasureItem, m_MeasureAppForm, m_OTSSampleStageData, m_RectangleGDIObjects[0], IsWidth, Width, Height, m_WDomain))
                     {
-                        IsSingle = true;
+                        isPolygon = true;
                         SampleMeasurePara sampleMeasure = GetSampleMeasureRect(MeasureItem);
                         if (sampleMeasure.PolygonPointRegion == null)
                         {
@@ -4820,7 +4821,7 @@ namespace OTSMeasureApp
                     break;
                 }
             }
-            return IsSingle;
+            return isPolygon;
         }
         #endregion
 

+ 76 - 7
OTSIncAReportApp/1-UI/Control_Graph/Controls/Control_DrawDistrbutionImageAndBSE.cs

@@ -1674,23 +1674,22 @@ namespace OTSIncAReportGraph.Controls
 
                 Point sem_point = (Point)in_obj;
 
-                //第一步,连接电镜
-                ReportFun.ConnectToSEM();
+              
 
-                Thread.Sleep(500);
+                //Thread.Sleep(500);
 
                 //第二步,移动到指定位置,先读取再设置
-                if (ReportFun.m_SEMConnectionState == true)
+                if (ReportFun.ConnectToIpcSvr())
                 {
 
                     ReportFun.MoveSemToPointXY(sem_point.X, sem_point.Y);
 
                 }
 
-                Thread.Sleep(1500);
+                //Thread.Sleep(1500);
 
                 //第三步,断开电镜连接
-                ReportFun.DisConnectSEM();
+                //ReportFun.DisConnectSEM();
 
                
 
@@ -2187,7 +2186,7 @@ namespace OTSIncAReportGraph.Controls
             if (dr== DialogResult.OK)
             {
                 
-               if (ReportFun.DeleteParticlesFromLibrary(m_mouseOver_dparticle.ParticleId, m_mouseOver_dparticle.FieldId))
+               if (DeleteParticlesFromLibrary(m_mouseOver_dparticle.ParticleId, m_mouseOver_dparticle.FieldId))
                 {
                     MessageBox.Show("Deleted successfully");
 
@@ -2209,6 +2208,76 @@ namespace OTSIncAReportGraph.Controls
             }
            
         }
+
+
+        private bool DeleteParticlesFromLibrary(int in_clr_tagid, int in_clr_fieldid)
+        {
+            bool DoesItExist = false;
+            for (int i = 1; i < 201; i++)
+            {
+                if (System.IO.Directory.Exists(resultFile.FilePath + "\\FIELD_FILES\\Backups" + i.ToString()))
+                {
+                    DoesItExist = true;
+                    break;
+                }
+            }
+            if (!DoesItExist)
+            {
+                //备份数据库
+                BackupDatabase();
+            }
+            DoesItExist = false;
+
+            //防止为空校验判断
+            if (resultFile.List_OTSField == null)
+                return false;
+            Particle particle = resultFile.List_OTSField.Find(x => x.FieldID == in_clr_fieldid).ParticleList.Find(x => x.ParticleId == in_clr_tagid);
+            if (new ParticleData(resultFile.FilePath).DeleteFromData(Convert.ToString(particle.FieldId), Convert.ToString(particle.XrayId)))
+            {
+
+                return true;
+            }
+            else
+
+            {
+                return false;
+            }
+        }
+        private bool BackupDatabase()
+        {
+            //创建备份数据库文件夹
+            string sourcePath = resultFile.FilePath + "\\FIELD_FILES\\Inclusion.db";//源文件路径
+            string sourceName = "Inclusion.db";//源文件名称
+            string folderPath = resultFile.FilePath + "\\FIELD_FILES\\Backups";//目标文件夹
+            string Fields = "";
+            for (int i = 1; i < 201; i++)
+            {
+                if (System.IO.Directory.Exists(folderPath + i.ToString()))
+                {
+                    Fields = folderPath + i.ToString();
+                    break;
+                }
+                else
+                {
+                    System.IO.Directory.CreateDirectory(folderPath + i.ToString());
+                    Fields = folderPath + i.ToString();
+                    break;
+                }
+            }
+            if (Fields == "")
+            {
+                return false;
+            }
+            //复制数据库文件
+            string targetPath = Path.Combine(Fields, sourceName);
+            FileInfo file = new FileInfo(sourcePath);
+            if (file.Exists)
+            {
+                file.CopyTo(targetPath, true);
+            }
+
+            return true;
+        }
         int GetsIntersectionOfTheIntercepts(Point P1,Point P2,int y)
         {
             int x = (y - P1.Y * P2.X + P1.X * P2.Y) / (P2.Y - P1.Y);

+ 3 - 7
OTSIncAReportApp/1-UI/Control_Graph/Controls/Control_DrawDistrbutionSortImage.cs

@@ -929,22 +929,18 @@ namespace OTSIncAReportGraph.Controls
                 Point sem_point = (Point)in_obj;
 
                 //第一步,连接电镜
-                m_ReportFun.ConnectToSEM();
+                
 
-                Thread.Sleep(500);
 
                 //第二步,移动到指定位置,先读取再设置
-                if (m_ReportFun.m_SEMConnectionState == true)
+                if (m_ReportFun.ConnectToIpcSvr())
                 {
                     m_ReportFun.MoveSemToPointXY(sem_point.X, sem_point.Y);
                 }
 
                 Thread.Sleep(1500);
 
-                //第三步,断开电镜连接
-                m_ReportFun.DisConnectSEM();
-
-                //Thread.Sleep(1000);
+             
 
                 m_mythread_state = false;
             }

+ 244 - 244
OTSIncAReportApp/3-ServiceCenter/OutPIC.cs → OTSIncAReportApp/1-UI/Control_Graph/Controls/OutPIC.cs

@@ -1,244 +1,244 @@
-using OTSCommon.Model;
-using OTSIncAReportGraph;
-using OTSIncAReportGraph.Controls;
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-
-namespace OTSIncAReportApp._3_ServiceCenter
-{
-    class OutPIC
-    {
-        
-        //包含particle的field的列表对象
-        public List<DisplayField> m_list_allDfield = null;
-        public ResultFile resultFile = null;
-        public SaveFileDialog sfd = null;
-        public int type = 0;
-        /// <summary>
-        /// 获取每行图片的位置配合opencv方法使用
-        /// </summary>
-        /// <returns></returns>
-        private List<DataTable> opencv_piclist()
-        {
-            List<DataTable> list_dt_picdata = new List<DataTable>();
-            DataTable picDatat = new DataTable();
-            picDatat.Columns.Add("X", typeof(double));
-            picDatat.Columns.Add("Y", typeof(double));
-            foreach (var f in m_list_allDfield)
-            {
-                DataRow dr = picDatat.NewRow();
-                dr["X"] = f.Rect.X;
-                dr["Y"] = f.Rect.Y;
-                picDatat.Rows.Add(dr);
-            }
-            int y_max = Convert.ToInt32(picDatat.Compute("Max(Y)", "true"));
-            int y_min = Convert.ToInt32(picDatat.Compute("Min(Y)", "true"));
-            DataTable total_dt_X = picDatat.Copy();
-            DataView dv_x = total_dt_X.DefaultView;
-            DataView dv_x_2 = dv_x.ToTable(true, "X").DefaultView;
-            dv_x_2.Sort = "X ASC";
-            total_dt_X = dv_x_2.ToTable();
-
-
-            DataTable total_dt_Y = picDatat.Copy();
-            DataView dv_Y = total_dt_Y.DefaultView;
-            DataView dv_Y_2 = dv_Y.ToTable(true, "Y").DefaultView;
-            dv_Y_2.Sort = "Y ASC";
-            total_dt_Y = dv_Y_2.ToTable();
-
-
-            for (int i = 0; i < total_dt_Y.Rows.Count; i++)
-            {
-                NLog.LogManager.GetCurrentClassLogger().Info("Splice line"+i+1.ToString()+"of"+ total_dt_Y.Rows.Count.ToString()+".....");
-                DataTable data = new DataTable();
-                data.Columns.Add("mat", typeof(Bitmap));
-                data.Columns.Add("X", typeof(double));
-                for (int a = 0; a < total_dt_X.Rows.Count; a++)
-                {
-                    DataRow dr2 = data.NewRow();
-                    Bitmap bitmap = new Bitmap((int)m_list_allDfield[0].Rect.Width, (int)m_list_allDfield[0].Rect.Height);
-                    Graphics g = Graphics.FromImage(bitmap);
-                    g.Clear(Color.White);
-                    g.Dispose();
-                    dr2["mat"] = bitmap;
-                    dr2["X"] = total_dt_X.Rows[a]["X"];
-                    data.Rows.Add(dr2);
-                }
-                foreach (var f in m_list_allDfield)
-                {
-                    if (total_dt_Y.Rows[i]["Y"].ToString() == f.Rect.Y.ToString())
-                    {
-                        for (int c = 0; c < data.Rows.Count; c++)
-                        {
-                            if (data.Rows[c]["X"].ToString() == f.Rect.X.ToString())
-                            {
-                                data.Rows[c]["mat"] = f.OriginalImage;
-                                data.Rows[c]["X"] = f.Rect.X;
-                            }
-                        }
-
-                    }
-                }
-
-
-                DataView dataView1 = data.DefaultView;
-                dataView1.Sort = "X ASC";
-                data = dataView1.ToTable();
-
-
-                list_dt_picdata.Add(data);
-            }
-
-            return list_dt_picdata;
-        }
-        public void opencv_outpic(/*int type*/)
-        {
-            List<DataTable> list_dt_picdata = new List<DataTable>();
-            if (type == (int)Outpic_enum.pic)
-            {
-                list_dt_picdata = opencv_piclist();
-            }
-            else
-                    if (type == (int)Outpic_enum.Render_pic)
-            {
-                list_dt_picdata = opencv_piclist_Render();
-            }
-
-            OpenCvSharp.Mat[] list_mats = new OpenCvSharp.Mat[list_dt_picdata.Count];
-            NLog.LogManager.GetCurrentClassLogger().Info("Organize and splice all pictures......");
-            for (int i = 0; i < list_dt_picdata.Count; i++)
-            {
-                OpenCvSharp.Mat[] mats = new OpenCvSharp.Mat[list_dt_picdata[i].Rows.Count];
-                for (int a = 0; a < list_dt_picdata[i].Rows.Count; a++)
-                {
-                    mats[a] = OpenCvSharp.Extensions.BitmapConverter.ToMat((Bitmap)list_dt_picdata[i].Rows[a]["mat"]);
-                }
-                OpenCvSharp.Mat pano = new OpenCvSharp.Mat();
-                OpenCvSharp.Cv2.HConcat(mats, pano);
-                list_mats[i] = pano;
-                
-            }
-            NLog.LogManager.GetCurrentClassLogger().Info("Picture splicing completed.");
-            NLog.LogManager.GetCurrentClassLogger().Info("Save to disk......");
-            OpenCvSharp.Mat save_pano = new OpenCvSharp.Mat();
-            OpenCvSharp.Cv2.VConcat(list_mats, save_pano);
-            OpenCvSharp.Cv2.ImWrite(sfd.FileName, save_pano);
-            NLog.LogManager.GetCurrentClassLogger().Info("Save complete.");
-        }
-       
-        private List<DataTable> opencv_piclist_Render()
-        {
-            List<DataTable> list_dt_picdata = new List<DataTable>();
-            DataTable picDatat = new DataTable();
-            List<Field> fieldlist = resultFile.List_OTSField;
-            picDatat.Columns.Add("X", typeof(double));
-            picDatat.Columns.Add("Y", typeof(double));
-            foreach (var f in m_list_allDfield)
-            {
-                DataRow dr = picDatat.NewRow();
-                dr["X"] = f.Rect.X;
-                dr["Y"] = f.Rect.Y;
-                picDatat.Rows.Add(dr);
-            }
-            int y_max = Convert.ToInt32(picDatat.Compute("Max(Y)", "true"));
-            int y_min = Convert.ToInt32(picDatat.Compute("Min(Y)", "true"));
-            DataTable total_dt_X = picDatat.Copy();
-            DataView dv_x = total_dt_X.DefaultView;
-            DataView dv_x_2 = dv_x.ToTable(true, "X").DefaultView;
-            dv_x_2.Sort = "X ASC";
-            total_dt_X = dv_x_2.ToTable();
-
-
-            DataTable total_dt_Y = picDatat.Copy();
-            DataView dv_Y = total_dt_Y.DefaultView;
-            DataView dv_Y_2 = dv_Y.ToTable(true, "Y").DefaultView;
-            dv_Y_2.Sort = "Y ASC";
-            total_dt_Y = dv_Y_2.ToTable();
-
-
-            for (int i = 0; i < total_dt_Y.Rows.Count; i++)
-            {
-                NLog.LogManager.GetCurrentClassLogger().Info("Splice line" + i + 1.ToString() + "of" + total_dt_Y.Rows.Count.ToString() + ".....");
-
-                DataTable data = new DataTable();
-                data.Columns.Add("mat", typeof(Bitmap));
-                data.Columns.Add("X", typeof(double));
-                for (int a = 0; a < total_dt_X.Rows.Count; a++)
-                {
-                    DataRow dr2 = data.NewRow();
-                    Bitmap bitmap = new Bitmap((int)m_list_allDfield[0].Rect.Width, (int)m_list_allDfield[0].Rect.Height);
-                    Graphics g = Graphics.FromImage(bitmap);
-                    g.Clear(Color.White);
-                    g.Dispose();
-                    dr2["mat"] = bitmap;
-                    dr2["X"] = total_dt_X.Rows[a]["X"];
-                    data.Rows.Add(dr2);
-                }
-                foreach (var f in m_list_allDfield)
-                {
-                    if (total_dt_Y.Rows[i]["Y"].ToString() == f.Rect.Y.ToString())
-                    {
-                        for (int c = 0; c < data.Rows.Count; c++)
-                        {
-                            if (data.Rows[c]["X"].ToString() == f.Rect.X.ToString())
-                            {
-                                Bitmap image = new Bitmap(f.OriginalImage.Width, f.OriginalImage.Height);
-                                Graphics g2 = Graphics.FromImage(image);
-                                g2.DrawImage(f.OriginalImage, 0, 0, f.OriginalImage.Width, f.OriginalImage.Height);
-                                Graphics graph_2 = Graphics.FromImage(image);
-
-                                for (int a = 0; a < fieldlist.Count; a++)
-                                {
-                                    if (fieldlist[a].FieldID.ToString() == f.FieldID.ToString())
-                                    {
-                                        //先获取该Field中的所有Particle
-                                        List<Particle> list_particle;
-                                        list_particle = fieldlist[a].ParticleList;
-                                        //再循环计算所有的Particle对象
-                                        foreach (Particle particle in list_particle)
-                                        {
-                                            //创建DParticle颗粒
-                                            DisplayParticle dp = new DisplayParticle(particle);
-                                            List<Segment> list_seg;
-                                            list_seg = particle.SegmentList;
-                                            //创建颗粒分布图对应的类对象
-                                            List<DisplaySegment> list_dsegment = new List<DisplaySegment>();
-                                            //再循环取出里面所有的segment
-                                            foreach (Segment seg in list_seg)
-                                            {
-                                                #region 创建DSegment对象,并将STD分析出的化合物颜色保存到DSegment对象中
-
-                                                Point on_p = new Point() { X = seg.Start, Y = seg.Height };
-                                                Point off_p = new Point() { X = seg.Start + seg.Length, Y = seg.Height };
-                                                Pen npen = new Pen(dp.Color);
-                                                graph_2.DrawLine(npen, on_p, off_p);
-
-                                                #endregion
-                                            }
-                                        }
-                                    }
-                                }
-                                data.Rows[c]["mat"] = image;
-                                data.Rows[c]["X"] = f.Rect.X;
-                            }
-                        }
-                    }
-
-                }
-
-                DataView dataView1 = data.DefaultView;
-                dataView1.Sort = "X ASC";
-                data = dataView1.ToTable();
-                list_dt_picdata.Add(data);
-            }
-
-            return list_dt_picdata;
-        }
-    }
-}
+using OTSCommon.Model;
+using OTSIncAReportGraph;
+using OTSIncAReportGraph.Controls;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace OTSIncAReportApp._3_ServiceCenter
+{
+    class OutPIC
+    {
+        
+        //包含particle的field的列表对象
+        public List<DisplayField> m_list_allDfield = null;
+        public ResultFile resultFile = null;
+        public SaveFileDialog sfd = null;
+        public int type = 0;
+        /// <summary>
+        /// 获取每行图片的位置配合opencv方法使用
+        /// </summary>
+        /// <returns></returns>
+        private List<DataTable> opencv_piclist()
+        {
+            List<DataTable> list_dt_picdata = new List<DataTable>();
+            DataTable picDatat = new DataTable();
+            picDatat.Columns.Add("X", typeof(double));
+            picDatat.Columns.Add("Y", typeof(double));
+            foreach (var f in m_list_allDfield)
+            {
+                DataRow dr = picDatat.NewRow();
+                dr["X"] = f.Rect.X;
+                dr["Y"] = f.Rect.Y;
+                picDatat.Rows.Add(dr);
+            }
+            int y_max = Convert.ToInt32(picDatat.Compute("Max(Y)", "true"));
+            int y_min = Convert.ToInt32(picDatat.Compute("Min(Y)", "true"));
+            DataTable total_dt_X = picDatat.Copy();
+            DataView dv_x = total_dt_X.DefaultView;
+            DataView dv_x_2 = dv_x.ToTable(true, "X").DefaultView;
+            dv_x_2.Sort = "X ASC";
+            total_dt_X = dv_x_2.ToTable();
+
+
+            DataTable total_dt_Y = picDatat.Copy();
+            DataView dv_Y = total_dt_Y.DefaultView;
+            DataView dv_Y_2 = dv_Y.ToTable(true, "Y").DefaultView;
+            dv_Y_2.Sort = "Y ASC";
+            total_dt_Y = dv_Y_2.ToTable();
+
+
+            for (int i = 0; i < total_dt_Y.Rows.Count; i++)
+            {
+                NLog.LogManager.GetCurrentClassLogger().Info("Splice line"+i+1.ToString()+"of"+ total_dt_Y.Rows.Count.ToString()+".....");
+                DataTable data = new DataTable();
+                data.Columns.Add("mat", typeof(Bitmap));
+                data.Columns.Add("X", typeof(double));
+                for (int a = 0; a < total_dt_X.Rows.Count; a++)
+                {
+                    DataRow dr2 = data.NewRow();
+                    Bitmap bitmap = new Bitmap((int)m_list_allDfield[0].Rect.Width, (int)m_list_allDfield[0].Rect.Height);
+                    Graphics g = Graphics.FromImage(bitmap);
+                    g.Clear(Color.White);
+                    g.Dispose();
+                    dr2["mat"] = bitmap;
+                    dr2["X"] = total_dt_X.Rows[a]["X"];
+                    data.Rows.Add(dr2);
+                }
+                foreach (var f in m_list_allDfield)
+                {
+                    if (total_dt_Y.Rows[i]["Y"].ToString() == f.Rect.Y.ToString())
+                    {
+                        for (int c = 0; c < data.Rows.Count; c++)
+                        {
+                            if (data.Rows[c]["X"].ToString() == f.Rect.X.ToString())
+                            {
+                                data.Rows[c]["mat"] = f.OriginalImage;
+                                data.Rows[c]["X"] = f.Rect.X;
+                            }
+                        }
+
+                    }
+                }
+
+
+                DataView dataView1 = data.DefaultView;
+                dataView1.Sort = "X ASC";
+                data = dataView1.ToTable();
+
+
+                list_dt_picdata.Add(data);
+            }
+
+            return list_dt_picdata;
+        }
+        public void opencv_outpic(/*int type*/)
+        {
+            List<DataTable> list_dt_picdata = new List<DataTable>();
+            if (type == (int)Outpic_enum.pic)
+            {
+                list_dt_picdata = opencv_piclist();
+            }
+            else
+                    if (type == (int)Outpic_enum.Render_pic)
+            {
+                list_dt_picdata = opencv_piclist_Render();
+            }
+
+            OpenCvSharp.Mat[] list_mats = new OpenCvSharp.Mat[list_dt_picdata.Count];
+            NLog.LogManager.GetCurrentClassLogger().Info("Organize and splice all pictures......");
+            for (int i = 0; i < list_dt_picdata.Count; i++)
+            {
+                OpenCvSharp.Mat[] mats = new OpenCvSharp.Mat[list_dt_picdata[i].Rows.Count];
+                for (int a = 0; a < list_dt_picdata[i].Rows.Count; a++)
+                {
+                    mats[a] = OpenCvSharp.Extensions.BitmapConverter.ToMat((Bitmap)list_dt_picdata[i].Rows[a]["mat"]);
+                }
+                OpenCvSharp.Mat pano = new OpenCvSharp.Mat();
+                OpenCvSharp.Cv2.HConcat(mats, pano);
+                list_mats[i] = pano;
+                
+            }
+            NLog.LogManager.GetCurrentClassLogger().Info("Picture splicing completed.");
+            NLog.LogManager.GetCurrentClassLogger().Info("Save to disk......");
+            OpenCvSharp.Mat save_pano = new OpenCvSharp.Mat();
+            OpenCvSharp.Cv2.VConcat(list_mats, save_pano);
+            OpenCvSharp.Cv2.ImWrite(sfd.FileName, save_pano);
+            NLog.LogManager.GetCurrentClassLogger().Info("Save complete.");
+        }
+       
+        private List<DataTable> opencv_piclist_Render()
+        {
+            List<DataTable> list_dt_picdata = new List<DataTable>();
+            DataTable picDatat = new DataTable();
+            List<Field> fieldlist = resultFile.List_OTSField;
+            picDatat.Columns.Add("X", typeof(double));
+            picDatat.Columns.Add("Y", typeof(double));
+            foreach (var f in m_list_allDfield)
+            {
+                DataRow dr = picDatat.NewRow();
+                dr["X"] = f.Rect.X;
+                dr["Y"] = f.Rect.Y;
+                picDatat.Rows.Add(dr);
+            }
+            int y_max = Convert.ToInt32(picDatat.Compute("Max(Y)", "true"));
+            int y_min = Convert.ToInt32(picDatat.Compute("Min(Y)", "true"));
+            DataTable total_dt_X = picDatat.Copy();
+            DataView dv_x = total_dt_X.DefaultView;
+            DataView dv_x_2 = dv_x.ToTable(true, "X").DefaultView;
+            dv_x_2.Sort = "X ASC";
+            total_dt_X = dv_x_2.ToTable();
+
+
+            DataTable total_dt_Y = picDatat.Copy();
+            DataView dv_Y = total_dt_Y.DefaultView;
+            DataView dv_Y_2 = dv_Y.ToTable(true, "Y").DefaultView;
+            dv_Y_2.Sort = "Y ASC";
+            total_dt_Y = dv_Y_2.ToTable();
+
+
+            for (int i = 0; i < total_dt_Y.Rows.Count; i++)
+            {
+                NLog.LogManager.GetCurrentClassLogger().Info("Splice line" + i + 1.ToString() + "of" + total_dt_Y.Rows.Count.ToString() + ".....");
+
+                DataTable data = new DataTable();
+                data.Columns.Add("mat", typeof(Bitmap));
+                data.Columns.Add("X", typeof(double));
+                for (int a = 0; a < total_dt_X.Rows.Count; a++)
+                {
+                    DataRow dr2 = data.NewRow();
+                    Bitmap bitmap = new Bitmap((int)m_list_allDfield[0].Rect.Width, (int)m_list_allDfield[0].Rect.Height);
+                    Graphics g = Graphics.FromImage(bitmap);
+                    g.Clear(Color.White);
+                    g.Dispose();
+                    dr2["mat"] = bitmap;
+                    dr2["X"] = total_dt_X.Rows[a]["X"];
+                    data.Rows.Add(dr2);
+                }
+                foreach (var f in m_list_allDfield)
+                {
+                    if (total_dt_Y.Rows[i]["Y"].ToString() == f.Rect.Y.ToString())
+                    {
+                        for (int c = 0; c < data.Rows.Count; c++)
+                        {
+                            if (data.Rows[c]["X"].ToString() == f.Rect.X.ToString())
+                            {
+                                Bitmap image = new Bitmap(f.OriginalImage.Width, f.OriginalImage.Height);
+                                Graphics g2 = Graphics.FromImage(image);
+                                g2.DrawImage(f.OriginalImage, 0, 0, f.OriginalImage.Width, f.OriginalImage.Height);
+                                Graphics graph_2 = Graphics.FromImage(image);
+
+                                for (int a = 0; a < fieldlist.Count; a++)
+                                {
+                                    if (fieldlist[a].FieldID.ToString() == f.FieldID.ToString())
+                                    {
+                                        //先获取该Field中的所有Particle
+                                        List<Particle> list_particle;
+                                        list_particle = fieldlist[a].ParticleList;
+                                        //再循环计算所有的Particle对象
+                                        foreach (Particle particle in list_particle)
+                                        {
+                                            //创建DParticle颗粒
+                                            DisplayParticle dp = new DisplayParticle(particle);
+                                            List<Segment> list_seg;
+                                            list_seg = particle.SegmentList;
+                                            //创建颗粒分布图对应的类对象
+                                            List<DisplaySegment> list_dsegment = new List<DisplaySegment>();
+                                            //再循环取出里面所有的segment
+                                            foreach (Segment seg in list_seg)
+                                            {
+                                                #region 创建DSegment对象,并将STD分析出的化合物颜色保存到DSegment对象中
+
+                                                Point on_p = new Point() { X = seg.Start, Y = seg.Height };
+                                                Point off_p = new Point() { X = seg.Start + seg.Length, Y = seg.Height };
+                                                Pen npen = new Pen(dp.Color);
+                                                graph_2.DrawLine(npen, on_p, off_p);
+
+                                                #endregion
+                                            }
+                                        }
+                                    }
+                                }
+                                data.Rows[c]["mat"] = image;
+                                data.Rows[c]["X"] = f.Rect.X;
+                            }
+                        }
+                    }
+
+                }
+
+                DataView dataView1 = data.DefaultView;
+                dataView1.Sort = "X ASC";
+                data = dataView1.ToTable();
+                list_dt_picdata.Add(data);
+            }
+
+            return list_dt_picdata;
+        }
+    }
+}

+ 9 - 93
OTSIncAReportApp/1-UI/Control_Graph/OTSIncAReportGraphFuncation/OTSImageDisHelp.cs

@@ -75,7 +75,7 @@ namespace OTSIncAReportGraph.OTSIncAReportGraphFuncation
         public  ServiceInterface.HardwareController m_cfun = null;
 
         //是否已经连接到了电镜
-        public bool m_SEMConnectionState = false;
+        //public bool m_SEMConnectionState = false;
 
         //连接到电镜的ID号
         public int m_SEM_ID = 0;
@@ -254,34 +254,17 @@ namespace OTSIncAReportGraph.OTSIncAReportGraphFuncation
         /// <summary>
         /// 连接电镜,分布图使用
         /// </summary>
-        public void ConnectToSEM()
+        public bool ConnectToIpcSvr()
         {
            
          
-            log.Trace("(Connection_ForDrawDistrbutionImageAndBSE)" + "Connect to SEM");
-            if (!m_SEMConnectionState)
-            {
-
+         
 
                 //和电镜建立通讯连接
-                m_SEMConnectionState = m_cfun.Connect();
-             
-                log.Trace("(Connection_ForDrawDistrbutionImageAndBSE)" + "Connect to SEM" + ":--" + m_SEMConnectionState + "---");
-
-        
-            }
-            else
-            {
-             
-                log.Trace("(Connection_ForDrawDistrbutionImageAndBSE)" + ":allready connected, state:" + m_SEMConnectionState);
-                //断开电镜连接
-            }
-        }
-        public void DisConnectSEM()
-        {
-            m_SEMConnectionState = false;
-            m_cfun.DisConnect();
+            return  m_cfun.Connect();
+         
         }
+       
 
 
             /// <summary>
@@ -299,7 +282,7 @@ namespace OTSIncAReportGraph.OTSIncAReportGraphFuncation
             double ls_PositionY = 0;
             double ls_PositionR = 0;
 
-            if (m_SEMConnectionState)
+            if (m_cfun.Connect())
             {
                 m_cfun.GetSemPositionXY(ref ls_PositionX, ref ls_PositionY, ref ls_PositionR);
             }
@@ -309,7 +292,7 @@ namespace OTSIncAReportGraph.OTSIncAReportGraphFuncation
                 return;
             }
 
-            if (m_SEMConnectionState)
+            if (m_cfun.Connect())
             {
                 m_cfun.MoveSEMToPoint(new Point((int)in_PositionX, (int)in_PositionY), ls_PositionR);
             }
@@ -362,74 +345,7 @@ namespace OTSIncAReportGraph.OTSIncAReportGraphFuncation
 
         }
 
-        public bool DeleteParticlesFromLibrary(int in_clr_tagid, int in_clr_fieldid)
-        {
-            bool DoesItExist = false;
-            for (int i=1;i<201;i++)
-            {
-                if (System.IO.Directory.Exists(resultFile.FilePath + "\\FIELD_FILES\\Backups"+i.ToString()))
-                {
-                    DoesItExist = true;
-                    break;
-                }
-            }
-            if (!DoesItExist)
-            {
-                //备份数据库
-                BackupDatabase();
-            }
-            DoesItExist = false;
-
-            //防止为空校验判断
-            if (resultFile.List_OTSField == null)
-                return false;
-            Particle particle = resultFile.List_OTSField.Find(x => x.FieldID == in_clr_fieldid).ParticleList.Find(x => x.ParticleId == in_clr_tagid);
-            if (new ParticleData(resultFile.FilePath).DeleteFromData(Convert.ToString(particle.FieldId), Convert.ToString(particle.XrayId)))
-            {
-                
-                return true;
-            }else
-
-            {
-                return false;
-            }
-        }
-
-        public bool BackupDatabase()
-        {
-            //创建备份数据库文件夹
-            string sourcePath = resultFile.FilePath + "\\FIELD_FILES\\Inclusion.db";//源文件路径
-            string sourceName = "Inclusion.db";//源文件名称
-            string folderPath = resultFile.FilePath + "\\FIELD_FILES\\Backups";//目标文件夹
-            string Fields = "";
-            for (int i = 1; i < 201; i++)
-            {
-                if (System.IO.Directory.Exists(folderPath + i.ToString()))
-                {
-                    Fields = folderPath + i.ToString();
-                    break;
-                }
-                else
-                {
-                    System.IO.Directory.CreateDirectory(folderPath + i.ToString());
-                    Fields = folderPath + i.ToString();
-                    break;
-                }
-            }
-            if (Fields == "")
-            {
-                return false;
-            }
-            //复制数据库文件
-            string targetPath = Path.Combine(Fields, sourceName);
-            FileInfo file = new FileInfo(sourcePath);
-            if (file.Exists)
-            {
-                file.CopyTo(targetPath, true);
-            }
-
-            return true;
-        }
+        
         /// <summary>
         /// 传入所有的物理field坐标点,和单个物理field的宽高,返回所有field的左上角位置,和整个field组成的rect大小
         /// </summary>

+ 0 - 11
OTSIncAReportApp/1-UI/Control_Grids/OTSIncAReportGridsFuncation/OTSReportGridsFun.cs

@@ -237,17 +237,6 @@ namespace OTSIncAReportGrids.OTSIncAReportGridsFuncation
             return isSuccess;
         }
 
-        /// <summary>
-        /// 断开电镜连接
-        /// </summary>
-        public void DisConnectSEM_ForParticlesGrid()
-        {
-            m_cfun.DisConnect();
-            //if (m_cfun.DisConnectSem() == true)
-
-            m_SEMConnectionState = false;
-        }
-
         #endregion
 
         #region 获取数据_测量结果概况

+ 71 - 2
OTSIncAReportApp/1-UI/Control_Grids/ParticlesGridDevidePage.cs

@@ -1071,7 +1071,7 @@ namespace OTSIncAReportGrids
                 Thread.Sleep(1500);
 
                 //第三步,断开电镜连接
-                m_OTSIncAReportGridsFun.DisConnectSEM_ForParticlesGrid();
+                //m_OTSIncAReportGridsFun.DisConnectSEM_ForParticlesGrid();
 
                 //Thread.Sleep(500);
 
@@ -1921,7 +1921,7 @@ namespace OTSIncAReportGrids
                     {
                         if (i_ls_fieldid == item.FieldId && i_ls_particleid == item.ParticleId)
                         {
-                            if (ReportFun.DeleteParticlesFromLibrary(item.ParticleId, item.FieldId))
+                            if (DeleteParticlesFromLibrary(item.ParticleId, item.FieldId))
                             {
                                 MessageBox.Show("Deleted successfully");
 
@@ -1946,6 +1946,75 @@ namespace OTSIncAReportGrids
                 }
             }
         }
+
+        private bool DeleteParticlesFromLibrary(int in_clr_tagid, int in_clr_fieldid)
+        {
+            bool DoesItExist = false;
+            for (int i = 1; i < 201; i++)
+            {
+                if (System.IO.Directory.Exists(resultFile.FilePath + "\\FIELD_FILES\\Backups" + i.ToString()))
+                {
+                    DoesItExist = true;
+                    break;
+                }
+            }
+            if (!DoesItExist)
+            {
+                //备份数据库
+                BackupDatabase();
+            }
+            DoesItExist = false;
+
+            //防止为空校验判断
+            if (resultFile.List_OTSField == null)
+                return false;
+            Particle particle = resultFile.List_OTSField.Find(x => x.FieldID == in_clr_fieldid).ParticleList.Find(x => x.ParticleId == in_clr_tagid);
+            if (new ParticleData(resultFile.FilePath).DeleteFromData(Convert.ToString(particle.FieldId), Convert.ToString(particle.XrayId)))
+            {
+
+                return true;
+            }
+            else
+
+            {
+                return false;
+            }
+        }
+        private bool BackupDatabase()
+        {
+            //创建备份数据库文件夹
+            string sourcePath = resultFile.FilePath + "\\FIELD_FILES\\Inclusion.db";//源文件路径
+            string sourceName = "Inclusion.db";//源文件名称
+            string folderPath = resultFile.FilePath + "\\FIELD_FILES\\Backups";//目标文件夹
+            string Fields = "";
+            for (int i = 1; i < 201; i++)
+            {
+                if (System.IO.Directory.Exists(folderPath + i.ToString()))
+                {
+                    Fields = folderPath + i.ToString();
+                    break;
+                }
+                else
+                {
+                    System.IO.Directory.CreateDirectory(folderPath + i.ToString());
+                    Fields = folderPath + i.ToString();
+                    break;
+                }
+            }
+            if (Fields == "")
+            {
+                return false;
+            }
+            //复制数据库文件
+            string targetPath = Path.Combine(Fields, sourceName);
+            FileInfo file = new FileInfo(sourcePath);
+            if (file.Exists)
+            {
+                file.CopyTo(targetPath, true);
+            }
+
+            return true;
+        }
         private void DisplayData()
         {
             if (cbB_PageSize.SelectedItem.ToString() == "All")

+ 0 - 3
OTSIncAReportApp/1-UI/frmReMeasure.cs

@@ -768,9 +768,6 @@ namespace OTSIncAReportApp
 
             Thread.Sleep(500);
 
-            //第三步,断开电镜连接
-            m_OTSIncAReportGridsFun.DisConnectSEM_ForParticlesGrid();
-
             SetProgressMessage(table["str17"].ToString(), richTextBox_process);
         }
 

+ 37 - 1
OTSIncAReportApp/1-UI/frmReportApp.cs

@@ -1180,7 +1180,7 @@ namespace OTSIncAReportApp
             resultFile = m_rstDataMgr.CurResultFile;
             ReportFun = new OTSImageDisHelp(resultFile);
 
-            if (ReportFun.BackupDatabase())
+            if (BackupDatabase())
             {
                 MessageBox.Show("Backup succeeded");
             }
@@ -1189,6 +1189,42 @@ namespace OTSIncAReportApp
                 MessageBox.Show("Backup failed");
             }
         }
+
+        private bool BackupDatabase()
+        {
+            //创建备份数据库文件夹
+            string sourcePath = resultFile.FilePath + "\\FIELD_FILES\\Inclusion.db";//源文件路径
+            string sourceName = "Inclusion.db";//源文件名称
+            string folderPath = resultFile.FilePath + "\\FIELD_FILES\\Backups";//目标文件夹
+            string Fields = "";
+            for (int i = 1; i < 201; i++)
+            {
+                if (System.IO.Directory.Exists(folderPath + i.ToString()))
+                {
+                    Fields = folderPath + i.ToString();
+                    break;
+                }
+                else
+                {
+                    System.IO.Directory.CreateDirectory(folderPath + i.ToString());
+                    Fields = folderPath + i.ToString();
+                    break;
+                }
+            }
+            if (Fields == "")
+            {
+                return false;
+            }
+            //复制数据库文件
+            string targetPath = Path.Combine(Fields, sourceName);
+            FileInfo file = new FileInfo(sourcePath);
+            if (file.Exists)
+            {
+                file.CopyTo(targetPath, true);
+            }
+
+            return true;
+        }
     }
 }
 

+ 1 - 1
OTSIncAReportApp/OTSIncAReportApp.csproj

@@ -578,7 +578,7 @@
       <DependentUpon>OutputNlog.cs</DependentUpon>
     </Compile>
     <Compile Include="3-ServiceCenter\HardwareController.cs" />
-    <Compile Include="3-ServiceCenter\OutPIC.cs" />
+    <Compile Include="1-UI\Control_Graph\Controls\OutPIC.cs" />
     <Compile Include="Help.cs">
       <SubType>Form</SubType>
     </Compile>