Browse Source

improve the DeleteSample function.

gsp 2 years ago
parent
commit
b051d60c85

+ 6 - 7
OTSIncAMeasureApp/0-OTSModel/Measure/3-MeasureFlow/CSmplMeasure.cs

@@ -836,7 +836,7 @@ namespace OTSModelSharp
 
                     m_pMsrThread.SendMessageToMeasureApp(MsgFieldEnd);
 
-                    COTSSample theSample = m_Sample;
+                   
                 }
                 while (bSaveThreadWorking)//wait untill all the field data has been saved.
                 {
@@ -1198,8 +1198,8 @@ namespace OTSModelSharp
 
 
                 // calculate field centers
-                List<System.Drawing.Point> listFieldCenter=new List<System.Drawing.Point>();
-                List<System.Drawing.Point> alllistFieldCenter = new List<System.Drawing.Point>();
+                List<System.Drawing.Point> listFieldCenter;
+                List<System.Drawing.Point> alllistFieldCenter ;
                 // listFieldCenter.clear();
                 if (!CalculateUnMeasuredFieldsCenters(out alllistFieldCenter,out listFieldCenter))
                 {// failed to calculate field centers
@@ -1303,8 +1303,7 @@ namespace OTSModelSharp
 
                     m_listHoleBSEImg.Add(pHoleBSEImg);
 
-                    //COTSMsrPrjResultData pProjMgrFile = m_pMsrThread.GetProjResultData();
-                    //pProjMgrFile.SetHoleBESImgList(m_listHoleBSEImg,true);
+                   
 
                     // prepare for the next
                     ++nNewFieldId;
@@ -1408,7 +1407,7 @@ namespace OTSModelSharp
         }
         public bool SaveFieldData(COTSFieldData fldData, string filedFileFoler)
         {
-            //loger.Warn("begin bitmap saving...");
+           
             string strFieldFileFolder = filedFileFoler;
 
             CBSEImageFileMgr pBSEImgFileMgr = new CBSEImageFileMgr();
@@ -1516,7 +1515,7 @@ namespace OTSModelSharp
         public void ParticleSpecialTreatment(ref COTSFieldData fld)
         {
             //we adopt such a strategy here:if some particles satisfy the predefined condition then we go through the second collecting with max EDS time,so that we got a more acurate result.
-            Dictionary<COTSParticleClr, int> mapPartXray = new Dictionary<COTSParticleClr, int>();   //std.map<COTSParticlePtr, int> mapPartXray = new std.map<COTSParticlePtr, int>();
+            Dictionary<COTSParticleClr, int> mapPartXray = new Dictionary<COTSParticleClr, int>();   
             double edsTime = 0; //to store the EDSTime returned from the engine.
             var bigparts = fld.GetListXrayParticles();
             var m_ClassifyEngine = new CClassifyEngine();

+ 24 - 3
OTSIncAMeasureApp/1-OTSMeasure/OTSMeasureDisplayResult.cs

@@ -158,7 +158,7 @@ namespace OTSMeasureApp
             m_MeasureApps.m_MessureStatuWindow.bBseData = ImageData;
             //获取灰度图数据
             double[] dGrayLevelData = new double[255];
-            dGrayLevelData = OTSImageData.GetStaticGaryData(ImageData, dGrayLevelData);
+            dGrayLevelData = GetStaticGaryData(ImageData, dGrayLevelData);
             m_MeasureApps.m_MessureStatuWindow.dGrayLevelData = dGrayLevelData;
             if (m_MeasureApps.m_MessureStatuWindow.panelXray.Visible)
             {
@@ -172,14 +172,35 @@ namespace OTSMeasureApp
             //显示BSE图
             m_MeasureApps.m_MessureStatuWindow.ShowImage(width, height, ImageData);
         }
+        public double[] GetStaticGaryData(byte[] Imagedata, double[] GrayLevelData)
+        {
+            try
+            {
+                //获得下标每一点的灰度值,并在数组里加一
+                for (int i = 0; i < Imagedata.Length; i++)
+                {
+                    byte graylevel = Imagedata[i];
+                    if (graylevel > 0 && graylevel < 255)
+                    {
+                        GrayLevelData[graylevel] += 1;
+                    }
+                }
+                return GrayLevelData;
+            }
+            catch (Exception ex)
+            {
+                log.Error(ex.ToString());
+                return null;
+            }
+        }
         #endregion
 
         #region 隐藏BSE图片
-   
+
         #endregion
 
         #region 初始窗口对象
-       
+
         int intFlag = 0;
         public void RunThreadLoadEvent()
         {

+ 2 - 485
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/OTSSamplespaceGraphicsPanelFun.cs

@@ -35,46 +35,7 @@ namespace OTSMeasureApp
      
 
         #region 鼠标方法操作
-        public static void MouseWheelFunction(List<CRectangleGDIObject> objList, CRectangleGDIObject m_RectangleGDIObjects, float globalZoomNum)
-        {
-            for (int i = 0; i < objList.Count; i++)
-            {
-                //多边形测量区域鼠标缩放
-                if (objList[i].CreateType == CreateRectangleType.Polygon)
-                {
-                    if (objList[i].DrawPolygonPointRegionF != null)
-                    {
-                        int polygonPointCount = objList[i].DrawPolygonPointRegionF.Count;
-                        if (polygonPointCount > 0)
-                        {
-                            for (int pointIndex = 0; pointIndex < polygonPointCount; pointIndex++)
-                            {
-                                PointF wheelPoint = new PointF();
-                                wheelPoint = objList[i].DrawPolygonPointRegionF[pointIndex];
-                                float X = wheelPoint.X * globalZoomNum;
-                                float Y = wheelPoint.Y * globalZoomNum;
-                                objList[i].PolygonPointRegionF[pointIndex] = new PointF(wheelPoint.X * globalZoomNum, wheelPoint.Y * globalZoomNum);
-                            }
-                        }
-                    }
-                }
-                else
-                {
-                    RectangleF rectF = new RectangleF();
-                    rectF = objList[i].RegionF;
-                    //根据样品孔中心点与样品台中心点的方向 设置宽度与高度\
-                    RectangleF returnRectF = OTSSamplespaceGraphicsPanelFun.MouseWheelFunctionF(m_RectangleGDIObjects, rectF, globalZoomNum);
-                    objList[i].Region = new Rectangle((int)returnRectF.X, (int)returnRectF.Y, (int)returnRectF.Width, (int)returnRectF.Height);
-                    objList[i].BSEImageWitdh = returnRectF.Width;
-                    objList[i].BSEImageHeight = returnRectF.Height;
-                    objList[i].BSEImageLocation = new PointF(returnRectF.X, returnRectF.Y);
-                    objList[i].SEMCenterPoint = returnRectF.Location;
-                    //重新绘制测量区域路径
-                    UpdateMeasureGraphicsPath(objList[i], objList[i].Region);
-
-                }
-            }
-        }
+       
         public static RectangleF MouseWheelFunctionF(CRectangleGDIObject RectangleGDIObject, RectangleF itemRect, float globalZoomNum)
         {
             //缩放比例
@@ -84,205 +45,13 @@ namespace OTSMeasureApp
             float Height = itemRect.Height * globalZoomNum;
             return new RectangleF(X, Y, Width, Height);
         }
-        public enum EnumMousePointPosition
-        {
-            MouseSizeNone = 0, //'无  
-            MouseSizeRight = 1, //'拉伸右边框  
-            MouseSizeLeft = 2, //'拉伸左边框  
-            MouseSizeBottom = 3, //'拉伸下边框  
-            MouseSizeTop = 4, //'拉伸上边框  
-            MouseSizeTopLeft = 5, //'拉伸左上角  
-            MouseSizeTopRight = 6, //'拉伸右上角  
-            MouseSizeBottomLeft = 7, //'拉伸左下角  
-            MouseSizeBottomRight = 8, //'拉伸右下角  
-            MouseDrag = 9   // '鼠标拖动  
-        }
+
         const int Band = 5;
        
-        public static EnumMousePointPosition MousePointPosition(Point point, Point e)
-        {
-            //MouseDrag 中心
-            if ((e.X == point.X) && (e.Y == point.Y))
-            {
-                return EnumMousePointPosition.MouseDrag;
-            }
-            //MouseSizeTopLeft 上左
-            if ((e.X < point.X) && (e.Y < point.Y))
-            {
-                return EnumMousePointPosition.MouseSizeTopLeft;
-            }
-            //MouseSizeTopRight 下右
-            if ((e.X > point.X) && (e.Y < point.Y))
-            {
-                return EnumMousePointPosition.MouseSizeTopRight;
-            }
-            //MouseSizeLeft 左侧
-            if ((e.X < point.X) && (e.Y == point.Y))
-            {
-                return EnumMousePointPosition.MouseSizeLeft;
-            }
-            //MouseSizeRight 右侧
-            if ((e.X > point.X) && (e.Y == point.Y))
-            {
-                return EnumMousePointPosition.MouseSizeRight;
-            }
-            //MouseSizeTop 上侧
-            if ((e.X == point.X) && (e.Y < point.Y))
-            {
-                return EnumMousePointPosition.MouseSizeTop;
-            }
-            //MouseSizeBottom 下侧
-            if ((e.X == point.X) && (e.Y > point.Y))
-            {
-                return EnumMousePointPosition.MouseSizeBottom;
-            }
-            //MouseSizeBottomRight 下左
-            if ((e.X < point.X) && (e.Y > point.Y))
-            {
-                return EnumMousePointPosition.MouseSizeBottomLeft;
-            }
-            //MouseSizeBottomRight 下右
-            if ((e.X > point.X) && (e.Y > point.Y))
-            {
-                return EnumMousePointPosition.MouseSizeBottomRight;
-            }
-            return EnumMousePointPosition.MouseSizeNone;
-        }
-        #endregion
-
       
-
-        #region 根据选择的测量区域 切换至最上层
-        public static List<CRectangleGDIObject> SelectMeasureIndexIsTop(List<CRectangleGDIObject> objList, string SampleName)
-        {
-            List<CRectangleGDIObject> objListTemp = objList;
-            CRectangleGDIObject itemTemp = null;
-            foreach (CRectangleGDIObject item in objList)
-            {
-                if (item.SampleName == SampleName)
-                {
-                    //临时记录所选测量区域
-                    itemTemp = item;
-                    //删除原信息
-                    objListTemp.Remove(item);
-                    //添加新信息
-                    objListTemp.Insert(objListTemp.Count, itemTemp);
-                    break;
-                }
-            }
-            return objListTemp;
-        }
-        #endregion
-
-        #region 根据选择的样品 切换至最上层
-        public static List<CRectangleGDIObject> SelectSampleIndexIsTop(List<CRectangleGDIObject> objList, string SampleName)
-        {
-            List<CRectangleGDIObject> objListTemp = objList;
-            CRectangleGDIObject itemTemp = null;
-            foreach (CRectangleGDIObject item in objList)
-            {
-                if (item.SampleName == SampleName)
-                {
-                    //临时记录所选样品
-                    itemTemp = item;
-                    //删除原信息
-                    objListTemp.Remove(item);
-                    //添加新信息
-                    objListTemp.Insert(objListTemp.Count, itemTemp);
-                    break;
-                }
-            }
-            return objListTemp;
-        }
-        #endregion
-
-        #region 获取拍摄BSE图 将byte数组转换为图片
-        public static Image GetBSEImage(byte[] ImageByte, int width, int height)
-        {
-            //图片
-            Bitmap bitmap = null;
-            //将byte数据转换为图片
-            bitmap = CImageHandler.ToGrayBitmap(ImageByte, width, height);
-            return bitmap;
-        }
         #endregion
 
      
-
-  
-   
-
- 
-
-       
-
-
-        #region 删除样品弹出提示
-        public static bool ShowDeleteDialog(string sampleName)
-        {
-            //国际化
-            OTSCommon.Language lan = new OTSCommon.Language();
-            Hashtable table = lan.GetNameTable("OTSIncAMeasureAppForm");
-
-            string str1 = table["message5"].ToString();
-            string str2 = table["message6"].ToString();
-
-            string sDeleteSampleName = str1;
-            sDeleteSampleName += sampleName;
-            sDeleteSampleName += "  信息 ?";
-            if (DialogResult.OK == MessageBox.Show(sDeleteSampleName, "Delete sample information prompt", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning))
-            {
-                return true;
-            }
-            else
-            {
-                return false;
-            }
-        }
-        #endregion
-
-        //#region 将点转换至工作区域
-        //public void PointToClient(Point rect)
-        //{
-        //    this.PointToClient(rect);
-        //}
-        //#endregion
-
-        #region 删除样品 同时删除帧图
-        public static bool DeleteSampleInfo(OTSIncAMeasureAppForm m_MeasureAppForm, string sampleSelectName)
-        {
-            try
-            {
-                //提交主窗体响应
-                bool deleteResult = false;
-                if (OTSSamplespaceGraphicsPanelFun.ShowDeleteDialog(sampleSelectName))
-                {
-                    //设置当前状态
-                    m_MeasureAppForm.m_MessageStates = (int)MessageState.StartMeasure;
-                    deleteResult = m_MeasureAppForm.DeleteSample(sampleSelectName);
-                    if (deleteResult)
-                    {
-                        //样品对象列表中无样品信息 则清除帧图对象列表信息
-                        bool result = m_MeasureAppForm.m_SamplepaceWindow.SampleIsEmptyClearSingleInfo();
-                        if(result)
-                        {
-                            m_MeasureAppForm.m_MeasureRetWindow.SetInit();
-                        }
-                    }
-                }
-                return true;
-            }
-            catch (Exception)
-            {
-                return false;
-            }
-        }
-        #endregion
-
-
-
-
-        
  
 
         #region 根据颜色枚举 获取颜色值
@@ -410,224 +179,6 @@ namespace OTSMeasureApp
         }
         #endregion
 
-   
-    
-
-    
-
-        #region 通过样品孔名称 获取在列表中的索引
-        /// <summary>
-        /// 通过样品孔名称 获取在列表中的索引
-        /// </summary>
-        /// <param name="oTSSampleStageData">样品台文件</param>
-        /// <param name="sampleHoleName">样品孔名称</param>
-        /// <returns></returns>
-        public static int GetSampleHoleIndex(StageDrawingData oTSSampleStageData,string sampleHoleName, ref OTSSampleHoleInfo sampleHoleInfo)
-        {
-            try
-            {
-                int sampleHoleIndex = -1;
-                if (oTSSampleStageData.sSHoleInfoList.Count > 0)
-                {
-                    for (int i = 0; i < oTSSampleStageData.sSHoleInfoList.Count; i++)
-                    {
-                        if (oTSSampleStageData.sSHoleInfoList[i].sSHoleName == sampleHoleName)
-                        {
-                            sampleHoleInfo = oTSSampleStageData.sSHoleInfoList[i];
-                            sampleHoleIndex = i;
-                            break;
-                        }
-                    }
-                }
-                return sampleHoleIndex;
-            }
-            catch (Exception)
-            {
-                return -1;
-            }
-        }
-        #endregion
-        
-        #region 添加帧图信息
-        /// <summary>
-        /// 添加帧图信息
-        /// </summary>
-        /// <param name="m_ALLSingleGDIObjects">帧图对象列表</param>
-        /// <param name="m_SingleGDIObjects">帧图对象列表</param>
-        /// <param name="sampleName">样品名称</param>
-        /// <returns></returns>
-        public static bool AddALLSingleInfo(List<CRectangleGDIObject> m_ALLSingleGDIObjects, List<CRectangleGDIObject> m_SingleGDIObjects, string sampleName)
-        {
-            bool result = false;
-            //判断ALLSingle对象列表中是否为空
-            if (m_ALLSingleGDIObjects != null)
-            {
-                bool IsExist = true;
-                if (m_ALLSingleGDIObjects.Count > 0)
-                {
-                    
-                    //判断是否包含样品名称
-                    foreach (var item in m_ALLSingleGDIObjects)
-                    {
-                        if (item.SampleName.Equals(sampleName))
-                        {
-                            IsExist = false;
-                            break;
-                        }
-                    }
-                }
-                if (IsExist)
-                {
-                    result = true;
-                    foreach (var item in m_SingleGDIObjects)
-                    {
-                        m_ALLSingleGDIObjects.Add(item);
-                    }
-                }
-                return result;
-            }
-            return result;
-        }
-        #endregion
-
-        #region 删除帧图信息
-        /// <summary>
-        /// 删除帧图信息
-        /// </summary>
-        /// <param name="m_ALLSingleGDIObjects">帧图对象列表</param>
-        /// <param name="sampleName">样品名称</param>
-        /// <returns></returns>
-        public static bool DeleteALLSingleInfo(List<CRectangleGDIObject> m_ALLSingleGDIObjects, string sampleName)
-        {
-            bool result = false;
-            int resultCount = 0;
-            //判断ALLSingle对象列表中是否为空
-            if (m_ALLSingleGDIObjects != null)
-            {
-                if (m_ALLSingleGDIObjects.Count > 0)
-                {
-                    for (int i = m_ALLSingleGDIObjects.Count - 1; i >= 0; i--)
-                    {
-                        if (m_ALLSingleGDIObjects[i].SampleName.Equals(sampleName))
-                        { 
-                            m_ALLSingleGDIObjects.RemoveAt(i);
-                            resultCount++;
-                        }
-                    }
-                }
-                else
-                {
-                    result = true;
-                }
-                if (resultCount > 0)
-                {
-                    result = true;
-                }
-            }
-            return result;
-        }
-        #endregion
-
-        #region 切换样品 填充帧图信息
-        public static void ChangeSampleFillSingleInfo(List<CRectangleGDIObject> m_ALLSingleGDIObjects, List<CRectangleGDIObject> m_SingleGDIObjects, string sampleName)
-        {
-            //判断帧图对象中是否存在当前工作样品帧图信息
-            bool IsExist = true;
-            //判断ALLSingle对象列表中是否为空
-            if (m_ALLSingleGDIObjects != null)
-            {
-                if (m_ALLSingleGDIObjects.Count > 0)
-                {
-                    foreach (var item in m_SingleGDIObjects)
-                    {
-                        if (item.SampleName.Equals(sampleName))
-                        {
-                            IsExist = false;
-                        }
-                    }
-                    if (IsExist)
-                    {
-                        //判断是否包含样品名称
-                        foreach (var item in m_ALLSingleGDIObjects)
-                        {
-                            if (item.SampleName.Equals(sampleName))
-                            {
-                                m_SingleGDIObjects.Add(item);
-                            }
-                        }
-                    }
-                }
-            }
-        }
-        #endregion
-
-        #region 修改已存在的帧图中样品名称
-        public static void EditWorkSampleName(List<CRectangleGDIObject> m_ALLSingleGDIObjects, string oldSampleName, string newSampleName)
-        {
-            int resultCount = 0;
-            //判断ALLSingle对象列表中是否为空
-            if (m_ALLSingleGDIObjects != null)
-            {
-                if (m_ALLSingleGDIObjects.Count > 0)
-                {
-                    for (int i = m_ALLSingleGDIObjects.Count - 1; i >= 0; i--)
-                    {
-                        if (m_ALLSingleGDIObjects[i].SampleName.Equals(oldSampleName))
-                        {
-                            m_ALLSingleGDIObjects[i].SampleName = newSampleName;
-                            resultCount++;
-                        }
-                    }
-                }
-            }
-        }
-        #endregion
-
-        #region 修改测量区域中GraphicsPath属性
-        public static void UpdateMeasureGraphicsPath(CRectangleGDIObject measureItem, Rectangle rectPara)
-        {
-            //重新绘制测量区域路径
-            GraphicsPath GPath = new GraphicsPath();
-            if (measureItem.CreateType == CreateRectangleType.Polygon)
-            {
-                GraphicsPath PolygonMeasurePath = new GraphicsPath();
-                PolygonMeasurePath.AddPolygon(measureItem.PolygonPointRegionF.ToArray());
-                GPath = PolygonMeasurePath;
-            }
-            else if(measureItem.CreateType == CreateRectangleType.CircleByThreePoints)
-            {
-                GPath.AddEllipse(rectPara);
-            }
-            else
-            {
-                if (measureItem.Shape == (int)CreateRectangleType.Circle)
-                {
-                    GPath.AddEllipse(rectPara);
-                }
-                else
-                {
-                    GPath.AddRectangle(rectPara);
-                }
-            }
-            measureItem.GPath = GPath;
-        }
-        #endregion
-
-        #region OnMouseWheel
-        public static void RestoreInitialPosition(List<CRectangleGDIObject> l_GDIObjects,float m_GlobalZoomNum)
-        {
-            for (int i = 0; i < l_GDIObjects.Count; i++)
-            {
-                RectangleF rectF = new RectangleF();
-                rectF = l_GDIObjects[i].DrawRegionF;
-                //根据样品孔中心点与样品台中心点的方向 设置宽度与高度\
-                l_GDIObjects[i].Region = new Rectangle((int)(rectF.X * m_GlobalZoomNum), (int)(rectF.Y * m_GlobalZoomNum), (int)(rectF.Width * m_GlobalZoomNum), (int)(rectF.Height * m_GlobalZoomNum));
-                PointF pointF = new PointF(rectF.X * m_GlobalZoomNum, rectF.Y * m_GlobalZoomNum);
-                SizeF sizeF = new SizeF((rectF.Width * m_GlobalZoomNum), (rectF.Height * m_GlobalZoomNum));
-                l_GDIObjects[i].RegionF = new RectangleF(pointF, sizeF);
-            }
-        }
-        #endregion
 
         #region 判断当前位置是否在不规则形状里面
         /// <summary>
@@ -707,39 +258,5 @@ namespace OTSMeasureApp
 
    
 
-
-        #region 获取 Rectangle 外框点集合
-        public static Point[] GetRectangleToPoint(RectangleF rectangleF)
-        {
-            int Left = (int)rectangleF.Left;
-            int Top = (int)rectangleF.Top;
-            int Right = (int)rectangleF.Right;
-            int Bottom = (int)rectangleF.Bottom;
-            List<Point> addPoint = new List<Point>();
-            for (int i = Left; i <= Right; i++)
-            {
-                addPoint.Add(new Point(Left + 1, Top));
-            }
-            for (int i = Top; i <= Bottom; i++)
-            {
-                addPoint.Add(new Point(Right,Top + 1));
-            }
-            for (int i = Right; i >= Left; i--)
-            {
-                addPoint.Add(new Point(Right - 1, Bottom));
-            }
-            for (int i = Bottom; i >= Top; i--)
-            {
-                addPoint.Add(new Point(Left,Bottom - 1));
-            }
-            return addPoint.ToArray();
-        }
-        #endregion
-
-       
-      
-
-       
-
     }
 }

+ 271 - 23
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/OTSSamplespaceWindow.cs

@@ -18,7 +18,19 @@ using OTSMeasureApp._4_OTSSamplespaceGraphicsPanel;
 
 namespace OTSMeasureApp
 {
-    
+    public enum EnumMousePointPosition
+    {
+        MouseSizeNone = 0, //'无  
+        MouseSizeRight = 1, //'拉伸右边框  
+        MouseSizeLeft = 2, //'拉伸左边框  
+        MouseSizeBottom = 3, //'拉伸下边框  
+        MouseSizeTop = 4, //'拉伸上边框  
+        MouseSizeTopLeft = 5, //'拉伸左上角  
+        MouseSizeTopRight = 6, //'拉伸右上角  
+        MouseSizeBottomLeft = 7, //'拉伸左下角  
+        MouseSizeBottomRight = 8, //'拉伸右下角  
+        MouseDrag = 9   // '鼠标拖动  
+    }
     public partial class OTSSamplespaceWindow : DockContent
     {
         #region 全局变量定义
@@ -799,13 +811,50 @@ namespace OTSMeasureApp
                 }
             }
             //修改测量区域集合 索引     (添加样品或者切换样品时,将当前工作样品显示在样品孔的最上)
-            m_MeasureGDIObjects = OTSSamplespaceGraphicsPanelFun.SelectMeasureIndexIsTop(m_MeasureGDIObjects, sampleName);
+            m_MeasureGDIObjects = SelectMeasureIndexIsTop(m_MeasureGDIObjects, sampleName);
             //修改样品集合 索引
-            m_SampleGDIObjects = OTSSamplespaceGraphicsPanelFun.SelectSampleIndexIsTop(m_SampleGDIObjects, sampleName);
+            m_SampleGDIObjects = SelectSampleIndexIsTop(m_SampleGDIObjects, sampleName);
 
         }
         #endregion
-
+        private  List<CRectangleGDIObject> SelectMeasureIndexIsTop(List<CRectangleGDIObject> objList, string SampleName)
+        {
+            List<CRectangleGDIObject> objListTemp = objList;
+            CRectangleGDIObject itemTemp = null;
+            foreach (CRectangleGDIObject item in objList)
+            {
+                if (item.SampleName == SampleName)
+                {
+                    //临时记录所选测量区域
+                    itemTemp = item;
+                    //删除原信息
+                    objListTemp.Remove(item);
+                    //添加新信息
+                    objListTemp.Insert(objListTemp.Count, itemTemp);
+                    break;
+                }
+            }
+            return objListTemp;
+        }
+        private  List<CRectangleGDIObject> SelectSampleIndexIsTop(List<CRectangleGDIObject> objList, string SampleName)
+        {
+            List<CRectangleGDIObject> objListTemp = objList;
+            CRectangleGDIObject itemTemp = null;
+            foreach (CRectangleGDIObject item in objList)
+            {
+                if (item.SampleName == SampleName)
+                {
+                    //临时记录所选样品
+                    itemTemp = item;
+                    //删除原信息
+                    objListTemp.Remove(item);
+                    //添加新信息
+                    objListTemp.Insert(objListTemp.Count, itemTemp);
+                    break;
+                }
+            }
+            return objListTemp;
+        }
 
         //响应委托事件的样品台数据
         public void InitStageDisplay(CStage SStage, CSEMStageData SEMStageData)
@@ -1767,12 +1816,12 @@ namespace OTSMeasureApp
                         //移动鼠标绘制测量区域
                         //以中心绘制测量区域方法
                      
-                        OTSSamplespaceGraphicsPanelFun.EnumMousePointPosition enumMouse = OTSSamplespaceGraphicsPanelFun.MousePointPosition(m_MouseDownPoint, m_MouseMovePoint);
+                        EnumMousePointPosition enumMouse = MousePointPosition(m_MouseDownPoint, m_MouseMovePoint);
                         Point LTPoint = new Point();
                         Size RBSize = new Size();
                         switch (enumMouse)
                         {
-                            case OTSSamplespaceGraphicsPanelFun.EnumMousePointPosition.MouseSizeTopLeft:
+                            case EnumMousePointPosition.MouseSizeTopLeft:
                                 if (m_DrawMeasureType == (int)CreateRectangleType.Circle)
                                 {
                                     LTPoint.X = m_MouseDownPoint.X - tmp;
@@ -1790,7 +1839,7 @@ namespace OTSMeasureApp
                                     rectangle = new Rectangle(LTPoint, RBSize);
                                 }
                                 break;
-                            case OTSSamplespaceGraphicsPanelFun.EnumMousePointPosition.MouseSizeTopRight:
+                            case EnumMousePointPosition.MouseSizeTopRight:
                                 if (m_DrawMeasureType == (int)CreateRectangleType.Circle)
                                 {
                                     LTPoint.X = m_MouseDownPoint.X;
@@ -1808,7 +1857,7 @@ namespace OTSMeasureApp
                                     rectangle = new Rectangle(LTPoint, RBSize);
                                 }
                                 break;
-                            case OTSSamplespaceGraphicsPanelFun.EnumMousePointPosition.MouseSizeBottomLeft:
+                            case EnumMousePointPosition.MouseSizeBottomLeft:
                                 if (m_DrawMeasureType == (int)CreateRectangleType.Circle)
                                 {
                                     LTPoint.X = m_MouseDownPoint.X - tmp;
@@ -1826,7 +1875,7 @@ namespace OTSMeasureApp
                                     rectangle = new Rectangle(LTPoint, RBSize);
                                 }
                                 break;
-                            case OTSSamplespaceGraphicsPanelFun.EnumMousePointPosition.MouseSizeBottomRight:
+                            case EnumMousePointPosition.MouseSizeBottomRight:
                                 if (m_DrawMeasureType == (int)CreateRectangleType.Circle)
                                 {
                                     LTPoint.X = m_MouseDownPoint.X;
@@ -2170,7 +2219,55 @@ namespace OTSMeasureApp
             Invalidate();
 
         }
-      
+        private  EnumMousePointPosition MousePointPosition(Point point, Point e)
+        {
+            //MouseDrag 中心
+            if ((e.X == point.X) && (e.Y == point.Y))
+            {
+                return EnumMousePointPosition.MouseDrag;
+            }
+            //MouseSizeTopLeft 上左
+            if ((e.X < point.X) && (e.Y < point.Y))
+            {
+                return EnumMousePointPosition.MouseSizeTopLeft;
+            }
+            //MouseSizeTopRight 下右
+            if ((e.X > point.X) && (e.Y < point.Y))
+            {
+                return EnumMousePointPosition.MouseSizeTopRight;
+            }
+            //MouseSizeLeft 左侧
+            if ((e.X < point.X) && (e.Y == point.Y))
+            {
+                return EnumMousePointPosition.MouseSizeLeft;
+            }
+            //MouseSizeRight 右侧
+            if ((e.X > point.X) && (e.Y == point.Y))
+            {
+                return EnumMousePointPosition.MouseSizeRight;
+            }
+            //MouseSizeTop 上侧
+            if ((e.X == point.X) && (e.Y < point.Y))
+            {
+                return EnumMousePointPosition.MouseSizeTop;
+            }
+            //MouseSizeBottom 下侧
+            if ((e.X == point.X) && (e.Y > point.Y))
+            {
+                return EnumMousePointPosition.MouseSizeBottom;
+            }
+            //MouseSizeBottomRight 下左
+            if ((e.X < point.X) && (e.Y > point.Y))
+            {
+                return EnumMousePointPosition.MouseSizeBottomLeft;
+            }
+            //MouseSizeBottomRight 下右
+            if ((e.X > point.X) && (e.Y > point.Y))
+            {
+                return EnumMousePointPosition.MouseSizeBottomRight;
+            }
+            return EnumMousePointPosition.MouseSizeNone;
+        }
         protected override void OnMouseUp(MouseEventArgs e)
         {
             //判断当前是否手绘
@@ -2267,7 +2364,7 @@ namespace OTSMeasureApp
                             //设置图形位置与大小
                             measureItem.Region = rectPara;
                             //重新绘制测量区域路径
-                            OTSSamplespaceGraphicsPanelFun.UpdateMeasureGraphicsPath(measureItem, rectPara);
+                            UpdateMeasureGraphicsPath(measureItem, rectPara);
                             //恢复光标
                             this.Cursor = System.Windows.Forms.Cursors.Default;
                               
@@ -2706,16 +2803,16 @@ namespace OTSMeasureApp
             {
                 
                     //恢复图像初始位置
-                    OTSSamplespaceGraphicsPanelFun.RestoreInitialPosition(m_MeasureFieldGDIObjects, m_GlobalZoomNum);
+                    RestoreInitialPosition(m_MeasureFieldGDIObjects, m_GlobalZoomNum);
 
-                    OTSSamplespaceGraphicsPanelFun.RestoreInitialPosition(m_ImageGDIObjects, m_GlobalZoomNum);
+                   RestoreInitialPosition(m_ImageGDIObjects, m_GlobalZoomNum);
                     //样品
-                    OTSSamplespaceGraphicsPanelFun.MouseWheelFunction(m_SampleGDIObjects,m_visualStage.GetEdgeGDIObj(), m_GlobalZoomNum);
+                    MouseWheelFunction(m_SampleGDIObjects,m_visualStage.GetEdgeGDIObj(), m_GlobalZoomNum);
                 //样品孔
-                OTSSamplespaceGraphicsPanelFun.MouseWheelFunction(m_visualStage.GetAllGDIObject(), m_visualStage.GetEdgeGDIObj(), m_GlobalZoomNum);
+                MouseWheelFunction(m_visualStage.GetAllGDIObject(), m_visualStage.GetEdgeGDIObj(), m_GlobalZoomNum);
 
                 //测量区域
-                OTSSamplespaceGraphicsPanelFun.MouseWheelFunction(m_MeasureGDIObjects,m_visualStage.GetEdgeGDIObj(), m_GlobalZoomNum);
+               MouseWheelFunction(m_MeasureGDIObjects,m_visualStage.GetEdgeGDIObj(), m_GlobalZoomNum);
                  
 
                     if (m_GlobalZoomNum == 1)
@@ -2746,7 +2843,59 @@ namespace OTSMeasureApp
               
             }
         }
+        private  void RestoreInitialPosition(List<CRectangleGDIObject> l_GDIObjects, float m_GlobalZoomNum)
+        {
+            for (int i = 0; i < l_GDIObjects.Count; i++)
+            {
+                RectangleF rectF = new RectangleF();
+                rectF = l_GDIObjects[i].DrawRegionF;
+                //根据样品孔中心点与样品台中心点的方向 设置宽度与高度\
+                l_GDIObjects[i].Region = new Rectangle((int)(rectF.X * m_GlobalZoomNum), (int)(rectF.Y * m_GlobalZoomNum), (int)(rectF.Width * m_GlobalZoomNum), (int)(rectF.Height * m_GlobalZoomNum));
+                PointF pointF = new PointF(rectF.X * m_GlobalZoomNum, rectF.Y * m_GlobalZoomNum);
+                SizeF sizeF = new SizeF((rectF.Width * m_GlobalZoomNum), (rectF.Height * m_GlobalZoomNum));
+                l_GDIObjects[i].RegionF = new RectangleF(pointF, sizeF);
+            }
+        }
+        private  void MouseWheelFunction(List<CRectangleGDIObject> objList, CRectangleGDIObject m_RectangleGDIObjects, float globalZoomNum)
+        {
+            for (int i = 0; i < objList.Count; i++)
+            {
+                //多边形测量区域鼠标缩放
+                if (objList[i].CreateType == CreateRectangleType.Polygon)
+                {
+                    if (objList[i].DrawPolygonPointRegionF != null)
+                    {
+                        int polygonPointCount = objList[i].DrawPolygonPointRegionF.Count;
+                        if (polygonPointCount > 0)
+                        {
+                            for (int pointIndex = 0; pointIndex < polygonPointCount; pointIndex++)
+                            {
+                                PointF wheelPoint = new PointF();
+                                wheelPoint = objList[i].DrawPolygonPointRegionF[pointIndex];
+                                float X = wheelPoint.X * globalZoomNum;
+                                float Y = wheelPoint.Y * globalZoomNum;
+                                objList[i].PolygonPointRegionF[pointIndex] = new PointF(wheelPoint.X * globalZoomNum, wheelPoint.Y * globalZoomNum);
+                            }
+                        }
+                    }
+                }
+                else
+                {
+                    RectangleF rectF = new RectangleF();
+                    rectF = objList[i].RegionF;
+                    //根据样品孔中心点与样品台中心点的方向 设置宽度与高度\
+                    RectangleF returnRectF = OTSSamplespaceGraphicsPanelFun.MouseWheelFunctionF(m_RectangleGDIObjects, rectF, globalZoomNum);
+                    objList[i].Region = new Rectangle((int)returnRectF.X, (int)returnRectF.Y, (int)returnRectF.Width, (int)returnRectF.Height);
+                    objList[i].BSEImageWitdh = returnRectF.Width;
+                    objList[i].BSEImageHeight = returnRectF.Height;
+                    objList[i].BSEImageLocation = new PointF(returnRectF.X, returnRectF.Y);
+                    objList[i].SEMCenterPoint = returnRectF.Location;
+                    //重新绘制测量区域路径
+                    UpdateMeasureGraphicsPath(objList[i], objList[i].Region);
 
+                }
+            }
+        }
         #endregion
 
         #region 鼠标方法操作
@@ -2825,10 +2974,37 @@ namespace OTSMeasureApp
                     item.DraggingPoint = e.Location;
 
                     //重新绘制测量区域路径
-                    OTSSamplespaceGraphicsPanelFun.UpdateMeasureGraphicsPath(item, item.Region);
+                   UpdateMeasureGraphicsPath(item, item.Region);
                 }
             }
         }
+        private  void UpdateMeasureGraphicsPath(CRectangleGDIObject measureItem, Rectangle rectPara)
+        {
+            //重新绘制测量区域路径
+            GraphicsPath GPath = new GraphicsPath();
+            if (measureItem.CreateType == CreateRectangleType.Polygon)
+            {
+                GraphicsPath PolygonMeasurePath = new GraphicsPath();
+                PolygonMeasurePath.AddPolygon(measureItem.PolygonPointRegionF.ToArray());
+                GPath = PolygonMeasurePath;
+            }
+            else if (measureItem.CreateType == CreateRectangleType.CircleByThreePoints)
+            {
+                GPath.AddEllipse(rectPara);
+            }
+            else
+            {
+                if (measureItem.Shape == (int)CreateRectangleType.Circle)
+                {
+                    GPath.AddEllipse(rectPara);
+                }
+                else
+                {
+                    GPath.AddRectangle(rectPara);
+                }
+            }
+            measureItem.GPath = GPath;
+        }
         public void MouseMoveMeasureFucntion(CRectangleGDIObject item, MouseEventArgs e)
         {
             //判断移动的样品 是否在样品台尺寸范围内
@@ -2855,7 +3031,7 @@ namespace OTSMeasureApp
                 item.DraggingPoint = e.Location;
                 #endregion
                 //重新绘制测量区域路径
-                OTSSamplespaceGraphicsPanelFun.UpdateMeasureGraphicsPath(item, item.Region);
+                UpdateMeasureGraphicsPath(item, item.Region);
                 //帧图
                 MouseMoveSingleFucntion(m_MeasureFieldGDIObjects, e);
                 Invalidate();
@@ -2919,7 +3095,7 @@ namespace OTSMeasureApp
 
                     item.DraggingPoint = e.Location;
                     //重新绘制测量区域路径
-                    OTSSamplespaceGraphicsPanelFun.UpdateMeasureGraphicsPath(item, item.Region);
+                 UpdateMeasureGraphicsPath(item, item.Region);
                     //帧图
                     MouseMoveSingleFucntion(m_MeasureFieldGDIObjects, e);
                 }
@@ -2975,7 +3151,7 @@ namespace OTSMeasureApp
                     item.DraggingPoint = e.Location;
 
                     //重新绘制测量区域路径
-                    OTSSamplespaceGraphicsPanelFun.UpdateMeasureGraphicsPath(item, item.Region);
+                   UpdateMeasureGraphicsPath(item, item.Region);
                 }
             }
         }
@@ -3061,7 +3237,7 @@ namespace OTSMeasureApp
                 item.BSEImageHeight = item.Region.Height;
                 item.BSEImageLocation = item.Region.Location;
                 //重新绘制测量区域路径
-                OTSSamplespaceGraphicsPanelFun.UpdateMeasureGraphicsPath(item, item.Region);
+                UpdateMeasureGraphicsPath(item, item.Region);
             }
         }
         #endregion
@@ -3084,7 +3260,7 @@ namespace OTSMeasureApp
                     break;
                 case "DeleteStage":
                     //删除样品
-                    OTSSamplespaceGraphicsPanelFun.DeleteSampleInfo(m_MeasureAppForm, m_SampleSelectName);
+                   DeleteSampleInfo(m_SampleSelectName);
                     break;
                 case "DriveSEMToCenterLocation":
                     //驱动SEM到中心位置
@@ -3142,7 +3318,55 @@ namespace OTSMeasureApp
                     break;
             }
         }
+        private  bool DeleteSampleInfo( string sampleSelectName)
+        {
+            try
+            {
+                //提交主窗体响应
+                bool deleteResult = false;
+                if (ShowDeleteDialog(sampleSelectName))
+                {
+                    //设置当前状态
+                    m_MeasureAppForm.m_MessageStates = (int)MessageState.StartMeasure;
+                    deleteResult = m_MeasureAppForm.DeleteSample(sampleSelectName);
+                    if (deleteResult)
+                    {
+                        //样品对象列表中无样品信息 则清除帧图对象列表信息
+                        bool result = m_MeasureAppForm.m_SamplepaceWindow.SampleIsEmptyClearSingleInfo();
+                        if (result)
+                        {
+                            m_MeasureAppForm.m_MeasureRetWindow.SetInit();
+                        }
+                    }
+                }
+                return true;
+            }
+            catch (Exception)
+            {
+                return false;
+            }
+        }
+        private  bool ShowDeleteDialog(string sampleName)
+        {
+            //国际化
+            OTSCommon.Language lan = new OTSCommon.Language();
+            Hashtable table = lan.GetNameTable("OTSIncAMeasureAppForm");
+
+            string str1 = table["message5"].ToString();
+            string str2 = table["message6"].ToString();
 
+            string sDeleteSampleName = str1;
+            sDeleteSampleName += sampleName;
+            sDeleteSampleName += "  信息 ?";
+            if (DialogResult.OK == MessageBox.Show(sDeleteSampleName, "Delete sample information prompt", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning))
+            {
+                return true;
+            }
+            else
+            {
+                return false;
+            }
+        }
         public bool setSlopFocusParam(_5_OTSMeasureStatuImageFun.SlopFocus slopFocus)
         {
             if (slopFocus == null)
@@ -4408,6 +4632,30 @@ namespace OTSMeasureApp
         #endregion
 
         #region 获取样品孔图片
+        private  int GetSampleHoleIndex(StageDrawingData oTSSampleStageData, string sampleHoleName, ref OTSSampleHoleInfo sampleHoleInfo)
+        {
+            try
+            {
+                int sampleHoleIndex = -1;
+                if (oTSSampleStageData.sSHoleInfoList.Count > 0)
+                {
+                    for (int i = 0; i < oTSSampleStageData.sSHoleInfoList.Count; i++)
+                    {
+                        if (oTSSampleStageData.sSHoleInfoList[i].sSHoleName == sampleHoleName)
+                        {
+                            sampleHoleInfo = oTSSampleStageData.sSHoleInfoList[i];
+                            sampleHoleIndex = i;
+                            break;
+                        }
+                    }
+                }
+                return sampleHoleIndex;
+            }
+            catch (Exception)
+            {
+                return -1;
+            }
+        }
         public void GetBSEPictures()
         {
             //获取当前工作的测量区域信息
@@ -4422,7 +4670,7 @@ namespace OTSMeasureApp
 
                     //获取当前样品孔的索引 与 样品中对应的测量区域
                     OTSSampleHoleInfo sampleHoleInfo = null;
-                    int sampleHoleIndex = OTSSamplespaceGraphicsPanelFun.GetSampleHoleIndex(m_visualStage.GetOTSSampleStageData(), m_SampleHoleSelectName, ref sampleHoleInfo);
+                    int sampleHoleIndex =GetSampleHoleIndex(m_visualStage.GetOTSSampleStageData(), m_SampleHoleSelectName, ref sampleHoleInfo);
                     if (sampleHoleInfo != null)
                     {
                         

+ 8 - 24
OTSIncAMeasureApp/5-OTSMeasureStatuImageFun/OTSImageData.cs

@@ -70,31 +70,12 @@ namespace OTSMeasureApp
             }
             catch (Exception ex)
             {
-               log.Error("(OTSMeasureStatusWindow.GetGaryData)  " + ex.ToString());
+               log.Error( ex.ToString());
                 return null;
             }
         }
 
-        public static double[] GetStaticGaryData(byte[] Imagedata, double[] GrayLevelData)
-        {
-            try
-            {
-                //获得下标每一点的灰度值,并在数组里加一
-                for (int i = 0; i < Imagedata.Length; i++)
-                {
-                    byte graylevel = Imagedata[i];
-                    if (graylevel > 0 && graylevel < 255)
-                    {
-                        GrayLevelData[graylevel] += 1;
-                    }
-                }
-                return GrayLevelData;
-            }
-            catch (Exception)
-            {
-                return null;
-            }
-        }
+   
 
         /// <summary>
         /// 计算去背景BSE图灰度分布数据
@@ -119,7 +100,7 @@ namespace OTSMeasureApp
             }
             catch (Exception ex)
             {
-               log.Error("(OTSMeasureStatusWindow.GetGaryData)  " + ex.ToString());
+               log.Error(ex.ToString());
                 return null;
             }
         }
@@ -157,8 +138,9 @@ namespace OTSMeasureApp
                     return false;
                 }
             }
-            catch (Exception)
+            catch (Exception ex)
             {
+                log.Error(ex.ToString());
                 //记录日志
                 return false;
             }
@@ -180,6 +162,7 @@ namespace OTSMeasureApp
             }
             catch (Exception ex)
             {
+                log.Error(ex.ToString());
                 return false;
             }
         }
@@ -192,6 +175,7 @@ namespace OTSMeasureApp
             }
             catch (Exception ex)
             {
+                log.Error(ex.ToString());
                 return false;
             }
         }
@@ -277,7 +261,7 @@ namespace OTSMeasureApp
                 }
                 catch (Exception ex)
                 {
-                   log.Error("InsertDataToExcelTable错误日志: " + ex.ToString());
+                   log.Error(ex.ToString());
                 }
             }
             //关闭excel

+ 1 - 1
OTSIncAMeasureApp/About.cs

@@ -20,7 +20,7 @@ namespace OTSMeasureApp
         private void About_Load(object sender, EventArgs e)
         {
 
-            richTextBox1.Text = "Version : 2.4\n";
+            richTextBox1.Text = "Version : 2.5\n";
             richTextBox1.Text += "Opton Copyright © 2022";
             richTextBox1.Select(0, richTextBox1.Text.Length);
             //richTextBox1.SelectionColor = Color.DarkBlue;

+ 6 - 0
OTSIncAMeasureApp/OTSIncAMeasureAppForm.cs

@@ -684,6 +684,12 @@ namespace OTSMeasureApp
         //返回删除的工作样品名
         public bool DeleteSample(string sDeleteWSampleName = "")
         {
+            if (m_MsrThreadWrapper.m_MsrThread.mapSmplMsr.ContainsKey(sDeleteWSampleName))
+            {
+                m_MsrThreadWrapper.m_MsrThread.mapSmplMsr.Remove(sDeleteWSampleName);
+            }
+           
+
             if (!m_ProjParam.DeleteWorkSample(sDeleteWSampleName))
             {
                 log.Error("(OTSIncAMeasureAppForm.DeleteSample)  m_DataMgrFun.DeleteWorkSample(sDeleteWSampleName) Failed, sDeleteWSampleName = " + sDeleteWSampleName);

+ 1 - 1
OTSIncAReportApp/OTSIncAReportApp.csproj

@@ -753,6 +753,7 @@
     <EmbeddedResource Include="1-UI\OTSTemplateDesigner\OTSReport_TemplateDesignerRM.resx">
       <DependentUpon>OTSReport_TemplateDesignerRM.cs</DependentUpon>
     </EmbeddedResource>
+    <EmbeddedResource Include="Properties\licenses.licx" />
     <EmbeddedResource Include="ReportTemplate\GBReport.resx">
       <DependentUpon>GBReport.cs</DependentUpon>
     </EmbeddedResource>
@@ -1310,7 +1311,6 @@
     <EmbeddedResource Include="Help.resx">
       <DependentUpon>Help.cs</DependentUpon>
     </EmbeddedResource>
-    <EmbeddedResource Include="Properties\licenses.licx" />
     <EmbeddedResource Include="Properties\Resources.resx">
       <Generator>PublicResXFileCodeGenerator</Generator>
       <LastGenOutput>Resources.Designer.cs</LastGenOutput>