소스 검색

save the hole preview image to the stage object not the sample object.When drawing the polygon measure area,press escape key can remove the last drawing point.

gsp 10 달 전
부모
커밋
e1fda483e6

+ 1 - 1
Bin/x64/Debug/Config/SysData/OTSProgMgrParam.pmf

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <XMLData RunMode="ProfessionalMode" SysType="IncA">
-  <Member RegName="GenParam" DefaultArea="100" DefaultSampleName="Sample" DefaultShape="0" MeasParamFileFolderName=".\Config\ProData\" MeasSwitch="true" PartSTDLibFolderName=".\Config\SysData\" PropertyDisplayMode="0" StdLibFileName="Cleanness_N" SteelTechnology="0" UseSysSTD="true" />
+  <Member RegName="GenParam" DefaultArea="100" DefaultSampleName="Sample" DefaultShape="0" MeasParamFileFolderName=".\Config\ProData\" MeasSwitch="true" PartSTDLibFolderName=".\Config\SysData\" PropertyDisplayMode="0" StdLibFileName="NoSTDDB" SteelTechnology="0" UseSysSTD="true" />
   <Member RegName="ImageProcParam" AutoBGRemoveType="0:MIDDLE" BGRemoveType="2:MATRIX" MatrixStep="50" OverlapParam="0" ParticleSelectionCondition="">
     <Member RegName="BGGray" end="255" start="80" />
     <Member RegName="IncArea" end="100" start="2" />

+ 28 - 24
OTSCPP/OTSClassifyEngine/InclutionEngine/OTSClassifyEng.cpp

@@ -528,7 +528,7 @@ namespace OTSClassifyEngine
 		}
 
 		// nitride classification
-		if (!NitrideClassify(a_listElChemsIncNoFe, a_dMolarSumNoFe, nIncId))
+		if (!NitrideClassify(steelTech,a_listElChemsIncNoFe, a_dMolarSumNoFe, nIncId))
 		{
 			// something wrong
 			LogErrorTrace(__FILE__, __LINE__, _T("COTSClassifyEng::ClassifyXray: failed to call NitrideClassify method."));
@@ -544,7 +544,7 @@ namespace OTSClassifyEngine
 		}
 
 		// oxide classification
-		if (!OxideClassify(a_listElChemsIncNoFe, a_dMolarSumNoFe, nIncId))
+		if (!OxideClassify(steelTech, a_listElChemsIncNoFe, a_dMolarSumNoFe, nIncId))
 		{
 			// something wrong
 			LogErrorTrace(__FILE__, __LINE__, _T("COTSClassifyEng::ClassifyXray: failed to call OxideClassify method."));
@@ -920,7 +920,7 @@ namespace OTSClassifyEngine
 
 		// check if the rest element chemistries map an oxide
 		int nIncId = (int)OTS_PARTICLE_TYPE::NOT_IDENTIFIED;
-		if (!GetSulfildeOxideComplexItemId(a_listElChemsIncNoFe, a_dMolarSumNoFe, strSulfideBaseName, nIncId))
+		if (!GetSulfildeOxideComplexItemId(steelTech,a_listElChemsIncNoFe, a_dMolarSumNoFe, strSulfideBaseName, nIncId))
 		{
 			a_nIncId = (int)OTS_PARTICLE_TYPE::NOT_IDENTIFIED;
 			return FALSE;
@@ -933,7 +933,7 @@ namespace OTSClassifyEngine
 		}
 		
 		nIncId = (int)OTS_PARTICLE_TYPE::NOT_IDENTIFIED;
-		if (!GetSulfildeNitrideComplexItemId(a_listElChemsIncNoFe, a_dMolarSumNoFe, strSulfideBaseName, nIncId))
+		if (!GetSulfildeNitrideComplexItemId(steelTech,a_listElChemsIncNoFe, a_dMolarSumNoFe, strSulfideBaseName, nIncId))
 		{
 			a_nIncId = (int)OTS_PARTICLE_TYPE::NOT_IDENTIFIED;
 			return FALSE;
@@ -972,7 +972,7 @@ namespace OTSClassifyEngine
 	}
 
 	// oxides classification
-	BOOL COTSClassifyEng::OxideClassify(
+	BOOL COTSClassifyEng::OxideClassify(STEEL_TECHNOLOGY steelTech,
 		CElementChemistriesList& a_listElChemsIncNoFe,
 		double a_dMolarSumNoFe,
 		int& a_nIncId)
@@ -1103,7 +1103,7 @@ namespace OTSClassifyEngine
 
 		// is it an Aluminate?
 		
-		else if (IsAnCa_Aluminate(listOxideSubElChems, dOxideSubElMolarSum, aluminateStr))
+		else if (IsAnCa_Aluminate(steelTech, listOxideSubElChems, dOxideSubElMolarSum, aluminateStr))
 		{
 			// Aluminate
 			strOxideName = aluminateStr;
@@ -1145,7 +1145,7 @@ namespace OTSClassifyEngine
 	}
 
 	// nitrides classification
-	BOOL COTSClassifyEng::NitrideClassify(
+	BOOL COTSClassifyEng::NitrideClassify(STEEL_TECHNOLOGY steelTech,
 		CElementChemistriesList& a_listElChemsIncNoFe,
 		double a_dMolarSumNoFe,
 		int& a_nIncId)
@@ -1286,7 +1286,7 @@ namespace OTSClassifyEngine
 
 		// check if the rest element chemistries map an oxide
 		int nIncId = (int)OTS_PARTICLE_TYPE::INVALID;
-		if (!OxideClassify( a_listElChemsIncNoFe, a_dMolarSumNoFe, nIncId))
+		if (!OxideClassify(steelTech, a_listElChemsIncNoFe, a_dMolarSumNoFe, nIncId))
 		{
 			// something wrong
 			LogErrorTrace(__FILE__, __LINE__, _T("COTSClassifyEng::NitrideClassify: failed to call OxideClassify method."));
@@ -1673,10 +1673,10 @@ namespace OTSClassifyEngine
 
 		
 	}
-	BOOL COTSClassifyEng::GetSulfildeOxideComplexItemId(CElementChemistriesList& a_listElChemsIncNoFe, double a_dMolarSumNoFe, CString strSulfideBaseName, int& a_nIncId)
+	BOOL COTSClassifyEng::GetSulfildeOxideComplexItemId(STEEL_TECHNOLOGY steelTech, CElementChemistriesList& a_listElChemsIncNoFe, double a_dMolarSumNoFe, CString strSulfideBaseName, int& a_nIncId)
 	{
 		int nIncId;
-		if (!OxideClassify(a_listElChemsIncNoFe, a_dMolarSumNoFe, nIncId))
+		if (!OxideClassify(steelTech,a_listElChemsIncNoFe, a_dMolarSumNoFe, nIncId))
 		{
 
 			a_nIncId = (int)OTS_PARTICLE_TYPE::NOT_IDENTIFIED;
@@ -1766,10 +1766,10 @@ namespace OTSClassifyEngine
 		return TRUE;
 	}
 
-	BOOL COTSClassifyEng::GetSulfildeNitrideComplexItemId(CElementChemistriesList& a_listElChemsIncNoFe, double a_dMolarSumNoFe, CString strSulfideBaseName, int& a_nIncId)
+	BOOL COTSClassifyEng::GetSulfildeNitrideComplexItemId(STEEL_TECHNOLOGY steelTech, CElementChemistriesList& a_listElChemsIncNoFe, double a_dMolarSumNoFe, CString strSulfideBaseName, int& a_nIncId)
 	{
 		int nIncId;
-		if (!NitrideClassify(a_listElChemsIncNoFe, a_dMolarSumNoFe, nIncId))
+		if (!NitrideClassify(steelTech,a_listElChemsIncNoFe, a_dMolarSumNoFe, nIncId))
 		{			
 			a_nIncId = (int)OTS_PARTICLE_TYPE::NOT_IDENTIFIED;
 			return FALSE;
@@ -2352,7 +2352,7 @@ namespace OTSClassifyEngine
 	}
 
 	// check if is a Aluminate
-	BOOL COTSClassifyEng::IsAnCa_Aluminate(CElementChemistriesList& a_listElChems, double a_dMolarSum,CString& strName)
+	BOOL COTSClassifyEng::IsAnCa_Aluminate(STEEL_TECHNOLOGY steelTech,CElementChemistriesList& a_listElChems, double a_dMolarSum,CString& strName)
 	{
 		// get key element of Aluminate 
 		CElementChemistryPtr pKeyElChem = GetNamedElementChemistry(a_listElChems, ALUMINATE_KEY_ELEMENT_NAME[0]);
@@ -2378,18 +2378,22 @@ namespace OTSClassifyEngine
 			double dFirstElMolar = pKeyElChem->GetMolarPercentage();//Al
 			double dSecondElMolar = pKeyElChem2->GetMolarPercentage();//Ca
 			double dRatio = dFirstElMolar/dSecondElMolar ;// Al/Ca
-			if (dRatio < 1.2 || dRatio > 1.0)//12CaO-7Al2O3  14/12
+			if (steelTech == STEEL_TECHNOLOGY::CaProcessMode)
 			{
-				// not a Spinel, return FALSE
-				strName = ALUMINATE12CaO_7Al2O3_STR;
-				return TRUE;
-			}
-			if (dRatio < 0.9 || dRatio > 0.6)//3CaO-Al2O3 2/3
-			{
-				// not a Spinel, return FALSE
-				strName = ALUMINATE3CaO_Al2O3_STR;
-				return TRUE;
-			}
+				if (dRatio < 1.2 || dRatio > 1.0)//12CaO-7Al2O3  14/12
+				{
+					// not a Spinel, return FALSE
+					strName = ALUMINATE12CaO_7Al2O3_STR;
+					return TRUE;
+				}
+				if (dRatio < 0.9 || dRatio > 0.6)//3CaO-Al2O3 2/3
+				{
+					// not a Spinel, return FALSE
+					strName = ALUMINATE3CaO_Al2O3_STR;
+					return TRUE;
+				}
+
+			}			
 			else
 			{
 				strName = Ca_ALUMINATE_STR;

+ 5 - 5
OTSCPP/OTSClassifyEngine/InclutionEngine/OTSClassifyEng.h

@@ -54,13 +54,13 @@ namespace OTSClassifyEngine
 								 int& a_nIncId);
 
 		// oxides classification
-		 BOOL OxideClassify(
+		 BOOL OxideClassify(STEEL_TECHNOLOGY steelTech,
 								   CElementChemistriesList& a_listElChemsIncNoFe,
 								   double a_dSumNoFe,
 								   int& a_nIncId);
 
 		// nitrides classification
-		 BOOL NitrideClassify(
+		 BOOL NitrideClassify(STEEL_TECHNOLOGY steelTech,
 									 CElementChemistriesList& a_listElChemsIncNoFe,
 									 double a_dMolarSumNoFe,
 									 int& a_nIncId);
@@ -108,7 +108,7 @@ namespace OTSClassifyEngine
 		 BOOL IsASilicate(CElementChemistriesList& a_listElChems, double a_dMolarSum);
 
 		// check if is a Aluminate
-		 BOOL IsAnCa_Aluminate(CElementChemistriesList& a_listElChems, double a_dMolarSum, CString& strName);
+		 BOOL IsAnCa_Aluminate(STEEL_TECHNOLOGY steelTech,CElementChemistriesList& a_listElChems, double a_dMolarSum, CString& strName);
 
 		// check if the element chemistries list matching the STD
 		 BOOL MatchingSTD(CElementChemistriesList& a_listElChems, CSTDItemPtr a_pSTDItem, double a_dMolarSum);
@@ -126,10 +126,10 @@ namespace OTSClassifyEngine
 		// get classify STD items
 		BOOL GetClassifySTDItem(CInclutionSTDDataPtr a_pPartSTDDataPtr, INC_CLASSIFY_TYPE a_nClassifyType, CSTDItemsList& a_listSTDItems);
 		BOOL GetClassifyTypeOfSTDItem(int a_nIncId, INC_CLASSIFY_TYPE& a_nClassifyType);
-		BOOL GetSulfildeOxideComplexItemId(CElementChemistriesList& a_listElChemsIncNoFe,
+		BOOL GetSulfildeOxideComplexItemId(STEEL_TECHNOLOGY steelTech, CElementChemistriesList& a_listElChemsIncNoFe,
 			double a_dMolarSumNoFe, CString strSulfideBaseName,
 			int& nIncId);
-		BOOL GetSulfildeNitrideComplexItemId(CElementChemistriesList& a_listElChemsIncNoFe,
+		BOOL GetSulfildeNitrideComplexItemId(STEEL_TECHNOLOGY steelTech, CElementChemistriesList& a_listElChemsIncNoFe,
 			double a_dMolarSumNoFe, CString strSulfideBaseName,
 			int& nIncId);
 		void FilterOnSteelTech(STEEL_TECHNOLOGY steelTech,

+ 37 - 28
OTSIncAMeasureApp/1-OTSMeasure/Measure/3-MeasureFlow/CSmplMeasure.cs

@@ -566,7 +566,8 @@ namespace OTSModelSharp
         }
         public void DoMeasureForOneSample()
         {
-            using (AutoResetSEMControl autoReset = new AutoResetSEMControl(this)) //when this method exit ,the SetSEMExternalOff and ResetScan will be called automatically.
+            //using (AutoResetSEMControl autoReset = new AutoResetSEMControl(this)) //when this method exit ,the SetSEMExternalOff and ResetScan will be called automatically.
+            try
             {
                 // let the main thread to know that this sample measurement starts
                 var pStatus = m_Sample.GetMsrStatus();
@@ -586,24 +587,24 @@ namespace OTSModelSharp
                 if (!SetSEMDataMrs(m_Sample))
                 {
                     log.Error("DoMeasure: fail to set SEM data.");
-                    pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.FAILED);                   
+                    pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.FAILED);
                     pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
 
                     return;
                 }
-      
+
                 // set the BSE scan param
                 if (!SetBSEParam())
                 {
                     log.Error("DoMeasure: fail to set BSE param.");
-                    pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.FAILED);                  
+                    pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.FAILED);
                     pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
 
                     return;
                 }
 
-             
-                                                            
+
+
                 var pSEMDataGnr = new CSEMDataGnr();
                 log.Info("Get Kv, Brightness and Contrast!");
                 GetSEMDataGnrFromHw(ref pSEMDataGnr);
@@ -612,21 +613,21 @@ namespace OTSModelSharp
                 m_pSampleRstFile.SetSEMGnr(pSEMDataGnr);
 
                 // record SEM data
-                COTSMsrPrjResultData pProjMgrFile = m_pMsrThread.GetProjResultData();          
+                COTSMsrPrjResultData pProjMgrFile = m_pMsrThread.GetProjResultData();
 
 
                 CSEMStageData pSEMStageData = pProjMgrFile.GetSEMStageData();
-               
+
 
                 m_pSampleRstFile.SetSEMStageData(pSEMStageData);
 
                 // record stage
                 CStage pStage = pProjMgrFile.GetStage();
-              
+
 
                 m_pSampleRstFile.SetSEMStage(pStage);
 
-              
+
                 //-----save the static measure result file data into xml file and the dynamic data of every field will be saved into sqlite database
                 log.Info("Create result file!");
                 if (!m_pSampleRstFile.CreateResultFiles())
@@ -640,10 +641,10 @@ namespace OTSModelSharp
                 //------
                 var FldDatas = m_Sample.GetFieldsData();
 
-               
+
                 for (int i = 0; i < FldDatas.Count; ++i)
                 {// check and break if stop button is clicked
-                   
+
                     var curFld = FldDatas[i];
                     if (curFld.GetIsMeasureComplete())
                     {
@@ -665,14 +666,14 @@ namespace OTSModelSharp
                         ST_MSTMsg MsgSmpStop = new ST_MSTMsg(m_Sample);
 
                         MsgSmpStop.InitSamplePausedMsg();
-                       
+
                         m_pMsrThread.SendMessageToMeasureGUI(MsgSmpStop);
                         while (IsPaused())
                         {
                             Thread.Sleep(300);
-                        
+
                         }
-                       
+
                     }
                     if (IsAborted())
                     {// measure stopped			
@@ -686,10 +687,10 @@ namespace OTSModelSharp
                         }
                         break;
                     }
-                   
+
                     // check if sample measurement completes
                     COTSImgScanPrm pScanParam = m_Sample.GetMsrParams().GetImageScanParam();
-                 
+
                     if (IsSampleOver(pScanParam))
                     {
                         pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.SUCCESSED);
@@ -701,16 +702,16 @@ namespace OTSModelSharp
                     System.Drawing.PointF poiFieldCentre = curFld.GetOTSPosition();
 
                     // update thread measure status class, let the main thread know that starts a new field
-                  
 
-                    ST_MSTMsg MsgFieldStart = new ST_MSTMsg(m_Sample,curFld);
+
+                    ST_MSTMsg MsgFieldStart = new ST_MSTMsg(m_Sample, curFld);
 
                     MsgFieldStart.InitFieldStartMsg();
 
                     m_pMsrThread.SendMessageToMeasureGUI(MsgFieldStart);
                     int fldNo = curFld.GetId();
                     log.Warn("Current field:" + fldNo.ToString());
-                    
+
 
 
                     // move SEM to the field center
@@ -727,7 +728,7 @@ namespace OTSModelSharp
                     CBSEImgClr pBSEImg = AcquireABSEImage();
 
                     // let the main thread to know that image process is completed
-                
+
                     if (pBSEImg == null)
                     {
                         log.Error("ImageProcess: can't get BSE image.");
@@ -738,11 +739,11 @@ namespace OTSModelSharp
 
 
                     //BSEData
-                    ST_MSTMsg MsgFieldBSE = new ST_MSTMsg(m_Sample,curFld);
+                    ST_MSTMsg MsgFieldBSE = new ST_MSTMsg(m_Sample, curFld);
                     MsgFieldBSE.InitFieldBSEImageMsg();
 
                     m_pMsrThread.SendMessageToMeasureGUI(MsgFieldBSE);
-                  
+
 
                     log.Info("Acquire BSE image success! Processing image...");
 
@@ -768,7 +769,7 @@ namespace OTSModelSharp
                         }
 
                     }
-                   
+
 
                     COTSXRayParam pXRayParam = m_Sample.GetMsrParams().GetXRayParam();
 
@@ -786,7 +787,7 @@ namespace OTSModelSharp
                         {
                             log.Error(e.Message);
                         }
-                      
+
 
 
                     }
@@ -801,12 +802,12 @@ namespace OTSModelSharp
                     {
                         ClassifyFieldParticles(curFld);
                     }
-                    catch(Exception e)
+                    catch (Exception e)
                     {
                         log.Error(e.Message);
-                    
+
                     }
-                   
+
 
                     MsgFieldBSE.InitFieldSTDColoredPartsDataMsg();
 
@@ -826,6 +827,14 @@ namespace OTSModelSharp
 
                 TheLastWorkOfSampleMeasure();
             }
+            catch (Exception e)
+            {
+                log.Error(e.Message);
+            }
+            finally 
+            {
+                SetSEMExteralOff();
+            }
     }
         public void TheLastWorkOfSampleMeasure()
         {

+ 2 - 2
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/CRingGDIObject.cs

@@ -9,7 +9,7 @@ using System.Windows.Forms;
 
 namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
 {
-    class CRingGDIObject: CRectangleGDIObject
+    class CRingGDIObject: CDisplayGDIObject
     {
         private float ringWidth=10;//the distance between outline circle and inside circle.
 
@@ -69,7 +69,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
         }
 
 
-        override public bool ifRectangleIntersect(CRectangleGDIObject otherUnZoomgdi)
+        override public bool ifRectangleIntersect(CDisplayGDIObject otherUnZoomgdi)
         {
             var path = GetInsideCirclePath();//the inside circle is the blank area that there's no field rect.
             var vertexPoints = otherUnZoomgdi.GetVertexPoints();

+ 14 - 14
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/CVisualSampleArea.cs

@@ -11,9 +11,9 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
     {
    
      
-          CRectangleGDIObject m_SampleGDIObject;//
-          CRectangleGDIObject m_MeasureGDIObject;//path
-        private List<CRectangleGDIObject> frameOfHoleGDIObjects;// record all the position of the sampleHole image
+          CDisplayGDIObject m_SampleGDIObject;//
+          CDisplayGDIObject m_MeasureGDIObject;//path
+        //private List<CRectangleGDIObject> frameOfHoleGDIObjects;// record all the position of the sampleHole image
    
 
         private List<Point> polygonPathPoints;
@@ -28,36 +28,36 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
       
         public CVisualSampleArea()
         {
-            m_SampleGDIObject =  new CRectangleGDIObject();
+            m_SampleGDIObject =  new CDisplayGDIObject();
 
 
             //测量区域
-            m_MeasureGDIObject =  new CRectangleGDIObject();
+            m_MeasureGDIObject =  new CDisplayGDIObject();
 
 
-           frameOfHoleGDIObjects = new List<CRectangleGDIObject>();
+           
         
 
 
         }
 
-        public CRectangleGDIObject GetSampleGDIObject()
+        public CDisplayGDIObject GetSampleGDIObject()
         {
             return m_SampleGDIObject;
         }
 
-        public void SetSampleGDIObject(CRectangleGDIObject value)
+        public void SetSampleGDIObject(CDisplayGDIObject value)
         {
             m_SampleGDIObject = value;
            
         }
 
-        public CRectangleGDIObject GetMeasureGDIObject()
+        public CDisplayGDIObject GetMeasureGDIObject()
         {
             return m_MeasureGDIObject;
         }
 
-        public void SetMeasureGDIObject(CRectangleGDIObject value)
+        public void SetMeasureGDIObject(CDisplayGDIObject value)
         {
             m_MeasureGDIObject = value;
            
@@ -74,7 +74,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
         }
 
         public List<Point> PolygonPathPoints { get => polygonPathPoints; set => polygonPathPoints = value; }
-        public List<CRectangleGDIObject> FrameOfHoleGDIObjects { get => frameOfHoleGDIObjects; set => frameOfHoleGDIObjects = value; }
+        //public List<CRectangleGDIObject> FrameOfHoleGDIObjects { get => frameOfHoleGDIObjects; set => frameOfHoleGDIObjects = value; }
 
 
         public bool IsWorkSample()
@@ -88,12 +88,12 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
             m_SampleGDIObject.IsWorkSample = value;
         }
 
-        public List<CRectangleGDIObject> GetMeasureFieldGDIObjects()
+        public List<CDisplayGDIObject> GetMeasureFieldGDIObjects()
         {
             return m_MeasureGDIObject.SubItems();
         }
 
-        public void SetMeasureFieldGDIObjects(List<CRectangleGDIObject> value)
+        public void SetMeasureFieldGDIObjects(List<CDisplayGDIObject> value)
         {
             m_MeasureGDIObject.ClearSubItems();
             foreach (var gdi in value)
@@ -104,7 +104,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
         }
 
 
-        public void AddFieldGDIObject(CRectangleGDIObject gdi)
+        public void AddFieldGDIObject(CDisplayGDIObject gdi)
         {
             gdi.SetZoomNumber(m_MeasureGDIObject.GetZoomNumber());
             gdi.SetDisplayRefPoint(m_MeasureGDIObject.GetDisplayRefPoint());

+ 0 - 1319
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/CreateRectangle.cs

@@ -1,1319 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Drawing;
-using System.Drawing.Drawing2D;
-using System.Windows.Forms;
-
-namespace OTSMeasureApp
-{
-    
-
-    public class CRectangleGDIObject /*: CRectangleGDIObject */// 同样的方式可以从ADraggableGDIObject生成其它图形的继承角类,比如矩形,三形等等。。
-    {
-        public CRectangleGDIObject()
-        {
-       
-            ID = System.Guid.NewGuid().ToString();
-            OTSX = -1;
-            OTSY = -1;
-        }
-        /// <summary>
-        /// 创建图形
-        /// </summary>
-        /// <param name="startx">X位置</param>
-        /// <param name="starty">Y位置</param>
-        /// <param name="width">宽度</param>
-        /// <param name="height">高度</param>
-        /// <param name="cType">图形类型:createType=0 圆角矩形 createType=1 圆形 createType=2 文字</param>
-        /// <param name="content">文字内容</param>
-        public CRectangleGDIObject(float startx, float starty, float width, float height, CreateRectangleType cType, string content, string name)
-        {
-            var rec = new RectangleF(startx, starty, width, height);
-            m_OrigineRegionF = rec;
-            SetInitRegionF(m_OrigineRegionF);
-            CreateType = cType;
-            strContent = content;
-            NameOrHoleName = name;
-            ID = System.Guid.NewGuid().ToString();
-            OTSX = -1;
-            OTSY = -1;
-        }
-
-        public CRectangleGDIObject(RectangleF rect, CreateRectangleType cType)
-        {
-       
-            m_OrigineRegionF = rect;
-            SetInitRegionF(m_OrigineRegionF);
-            CreateType = cType;
-            ID = System.Guid.NewGuid().ToString();
-            //startPoint = new PointF(rect.Left, rect.Top);
-            //EndPoint = new PointF(rect.Right, rect.Bottom);
-            OTSX = -1;
-            OTSY = -1;
-        }
-        public CRectangleGDIObject(RectangleF rect, CreateRectangleType cType, string name)
-        {
-     
-            m_OrigineRegionF = rect;
-            SetInitRegionF(m_OrigineRegionF);
-            CreateType = cType;
-            NameOrHoleName = name;
-            ID = System.Guid.NewGuid().ToString();
-            OTSX = -1;
-            OTSY = -1;
-        }
- 
-        public CRectangleGDIObject(RectangleF rect, CreateRectangleType cType, ShapeType shape, string name, Color selColor)
-        {
-          
-            m_OrigineRegionF = rect;
-            SetInitRegionF(m_OrigineRegionF);
-            CreateType = cType;
-            NameOrHoleName = name;
-            Shape = shape;
-            SelColor = selColor;
-            ID = System.Guid.NewGuid().ToString();
-            OTSX = -1;
-            OTSY = -1;
-        }
-        public CRectangleGDIObject(RectangleF rectMeasure,  CreateRectangleType cType, ShapeType shape, string name, string sampleName, Color selColor)
-        {
-      
-            m_OrigineRegionF = rectMeasure;
-            SetInitRegionF(m_OrigineRegionF);
-            CreateType = cType;
-            NameOrHoleName = name;
-            Shape = shape;
-            SelColor = selColor;
-          
-            SampleName = sampleName;
-            ID = System.Guid.NewGuid().ToString();
-            OTSX = -1;
-            OTSY = -1;
-        }
-        //绘制帧图
-        public CRectangleGDIObject(RectangleF rectSingle, CreateRectangleType cType, string name, string sampleName, Color selColor)
-        {
-          
-            m_OrigineRegionF = rectSingle;
-            SetInitRegionF(m_OrigineRegionF);
-            CreateType = cType;
-            NameOrHoleName = name;
-            Shape = 0;
-            SelColor = selColor;
-            SampleName = sampleName;
-            ID = System.Guid.NewGuid().ToString();
-            OTSX = -1;
-            OTSY = -1;
-        }
-        //绘制帧图
-        public CRectangleGDIObject(RectangleF rectField, int OTSx, int OTSy, CreateRectangleType cType, string name, string sampleName, Color selColor)
-        {
-         
-            m_OrigineRegionF = rectField;
-            SetInitRegionF(m_OrigineRegionF);
-            CreateType = cType;
-            NameOrHoleName = name;
-            Shape = 0;
-            SelColor = selColor;
-            SampleName = sampleName;
-            ID = System.Guid.NewGuid().ToString();
-            OTSX = OTSx;
-            OTSY = OTSy;
-        }
-
-        /// <summary>
-        /// 获取样品孔中BSE图像
-        /// </summary>
-        /// <param name="rect">位置大小</param>
-        /// <param name="sampleHoleName">所在样品孔名称</param>
-        /// <param name="bseImage">图像信息</param>
-        /// <param name="bseImageWitdh">图像宽度</param>
-        /// <param name="bseImageHeight">图像高度</param>
-        /// <param name="drawImageLocation">图像开始位置</param>
-        /// <param name="cType">绘制类型</param>
-        public CRectangleGDIObject(RectangleF rect, int OTSx, int OTSy, string sampleName, string sampleHoleName,  float bseImageWitdh, float bseImageHeight, CreateRectangleType cType)
-        {
-         
-            m_OrigineRegionF = rect;
-            SetInitRegionF(m_OrigineRegionF);
-            NameOrHoleName = sampleHoleName;
-            SampleName = sampleName;
-            //生成编号
-            ID = System.Guid.NewGuid().ToString();
-            //图像信息
-            //BSEImage = bseImage;
-            //图像宽度
-            BSEImageWitdh = bseImageWitdh;
-            //图像高度
-            BSEImageHeight = bseImageHeight;
-            //图像位置
-            BSEImageLocation = rect.Location;
-            OTSX = OTSx;
-            OTSY = OTSy;
-            //绘制类型
-            CreateType = cType;
-        }
-
-
-        public CRectangleGDIObject(RectangleF rect, Point ImgPoint, float m_Multiple, CreateRectangleType cType)
-        {
-
-            m_OrigineRegionF = rect;
-            SetInitRegionF(m_OrigineRegionF);
-            CreateType = cType;
-            ID = System.Guid.NewGuid().ToString();
-  
-            OTSX = -1;
-            OTSY = -1;
-        }
-        /// <summary>
-        /// 获取多边形点集合
-        /// </summary>
-        /// <param name="mPoint"></param>
-        /// <param name="cType"></param>
-        public CRectangleGDIObject(List<PointF> mPoint, CreateRectangleType cType, ShapeType shape, string name, string sampleName, Color selColor)
-        {
-            ID = System.Guid.NewGuid().ToString();
-
-            this.SetOriginalPolygonPointFList(mPoint);
-
-
-            NameOrHoleName = name;
-            SampleName = sampleName;
-            CreateType = cType;
-            Shape = shape;
-            SelColor = selColor;
-
-
-         
-
-
-        }
-        #region 变量重写
-        public virtual  void OnPaint(PaintEventArgs e) 
-        {
-            if (createType == CreateRectangleType.SampleBackGround_Rectangle)
-            {
-                //获取颜色
-                Color myColor = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.RoundRectangleColor);
-                
-                System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
-                GraphicsPath grPath = CreateRoundedRectanglePath(m_RegionF, 20);
-                e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
-                e.Graphics.FillPath(sampleBrush, grPath);
-                e.Graphics.DrawPath(Pens.Black, grPath);
-            }
-            //样品台-圆形
-            else if (createType == CreateRectangleType.SampleBackGround_Circle)
-            {
-                //获取颜色
-                Color myColor = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.SampleBackGroundColor);
-                
-                System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
-                e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;  //图片柔顺模式选择
-                e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
-                e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点
-                e.Graphics.FillEllipse(sampleBrush, m_RegionF);
-                e.Graphics.DrawEllipse(Pens.Black, m_RegionF);
-            }
-            //圆形
-            else if (createType == CreateRectangleType.Circle)
-            {
-                System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White);
-                e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;  //图片柔顺模式选择
-                e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
-                e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点
-                e.Graphics.FillEllipse(sampleBrush, m_RegionF);
-                e.Graphics.DrawEllipse(Pens.Black, m_RegionF);
-            }
-            //文字
-            else if (createType == CreateRectangleType.Text)
-            {
-                //设置文字对齐方式
-                StringFormat sf = new StringFormat();
-                sf.Alignment = StringAlignment.Center;
-                sf.LineAlignment = StringAlignment.Center;
-                //文字颜色
-                Color myColor = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.FontColor);
-                
-                System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
-                SolidBrush solidBrush = new SolidBrush(Color.FromArgb(50, Color.Black));
-                //字体大小 根据样品孔Rectangle大小
-                float fontSize = m_RegionF.Width / 2;
-                Font font = new Font("宋体", fontSize, FontStyle.Regular);
-                if (fontSize == 0)
-                {
-                    font = new Font("宋体", 5, FontStyle.Regular);
-                }
-                //消除锯齿
-                e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;  //图片柔顺模式选择
-                e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
-                e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点
-               
-                e.Graphics.DrawString(strContent, font, sampleBrush, m_RegionF, sf);
-            }
-            //矩形
-            else if (createType == CreateRectangleType.Rectangle)
-            {
-                Color myColor = System.Drawing.Color.White;
-                System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
-                e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;  //图片柔顺模式选择
-                e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
-                e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点
-                e.Graphics.FillRectangle(sampleBrush, m_RegionF);
-                var m_Region = new Rectangle();
-                m_Region.X = (int)m_RegionF.X;
-                m_Region.Y = (int)m_RegionF.Y;
-                m_Region.Width = (int)m_RegionF.Width;
-                m_Region.Height = (int)m_RegionF.Height;
-                e.Graphics.DrawRectangle(Pens.Black, m_Region);
-            }
-            //选择样品台
-            else if (createType == CreateRectangleType.SelectSample)
-            {
-                Color myColor = selColor;
-
-                System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
-                e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;  //图片柔顺模式选择
-                e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
-                e.Graphics.CompositingQuality = CompositingQuality.AssumeLinear;//再加一点
-                if (Shape == 0)
-                {
-
-                    e.Graphics.FillEllipse(sampleBrush, m_RegionF);
-                    e.Graphics.DrawEllipse(Pens.Black, m_RegionF);
-                }
-                else
-                {
-                    e.Graphics.FillRectangle(sampleBrush, m_RegionF);
-                    var m_Region = new Rectangle();
-                    m_Region.X = (int)m_RegionF.X;
-                    m_Region.Y = (int)m_RegionF.Y;
-                    m_Region.Width = (int)m_RegionF.Width;
-                    m_Region.Height = (int)m_RegionF.Height;
-                    e.Graphics.DrawRectangle(Pens.Black, m_Region);
-                }
-            }
-            //测试区域
-            else if (createType == CreateRectangleType.MeasureArea)
-            {
-                Color myColor = selColor;
-                System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
-                Pen p = new Pen(myColor, 1);
-                e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;  //图片柔顺模式选择
-                e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
-                e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点
-
-
-                if (Shape == 0)
-                {
-
-                    e.Graphics.DrawEllipse(p, m_RegionF);
-                }
-                else
-                {
-                    var m_Region = new Rectangle();
-                    m_Region.X = (int)m_RegionF.X;
-                    m_Region.Y = (int)m_RegionF.Y;
-                    m_Region.Width = (int)m_RegionF.Width;
-                    m_Region.Height = (int)m_RegionF.Height;
-
-                    e.Graphics.DrawRectangle(p, m_Region);
-
-                }
-            }
-            //绘制帧图 直线
-            else if (createType == CreateRectangleType.SingleLine)
-            {
-                //设置颜色
-                Color myColor = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.FieldColor);
-             
-                //设置画笔
-                System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
-                Pen pen = new Pen(sampleBrush, 0.0001f);
-                //未抗锯齿
-                e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;
-                e.Graphics.InterpolationMode = InterpolationMode.Default;
-                e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
-                //设置直线位置与尺寸
-                PointF startPointF = new PointF(startPoint.X, startPoint.Y);
-                PointF endPointF = new PointF(endPoint.X, endPoint.Y);
-                //度量单位
-                e.Graphics.PageUnit = GraphicsUnit.Display;
-                e.Graphics.DrawLine(pen, startPointF, endPointF);
-
-            }
-            //绘制标样
-            else if (createType == CreateRectangleType.SpecimenRectangle)
-            {
-                Color myColor = System.Drawing.Color.Black;
-                System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
-                Pen pen = new Pen(sampleBrush, 0.0001f);
-                e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
-                var m_Region = new Rectangle();
-                m_Region.X = (int)m_RegionF.X;
-                m_Region.Y = (int)m_RegionF.Y;
-                m_Region.Width = (int)m_RegionF.Width;
-                m_Region.Height = (int)m_RegionF.Height;
-                e.Graphics.DrawRectangle(pen, m_Region);
-                e.Graphics.FillRectangle(sampleBrush, m_Region);
-            }
-            //绘制标样
-            else if (createType == CreateRectangleType.SpecimenCircle)
-            {
-                Color myColor = System.Drawing.Color.Black;
-                System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
-                Pen pen = new Pen(sampleBrush, 0.0001f);
-                e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
-                e.Graphics.DrawEllipse(pen, m_RegionF);
-                e.Graphics.FillEllipse(sampleBrush, m_RegionF);
-            }
-            //绘制帧图
-            else if (createType == CreateRectangleType.FieldRectangle)
-            {
-                Color myColor = SelColor;
-                System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
-                Pen pen = new Pen(sampleBrush, 0.01f);
-                e.Graphics.SmoothingMode = SmoothingMode.Default;
-                //设置直线位置与尺寸
-                PointF startPointF = new PointF(m_RegionF.Left, m_RegionF.Top);
-                PointF endPointF = new PointF(m_RegionF.Right, m_RegionF.Bottom);
-
-                float fontSize = m_RegionF.Width / 4;
-                Font font;
-                if (fontSize == 0)
-                {
-                    font = new Font("宋体", 5, FontStyle.Regular);
-                }
-                else
-                {
-                    font = new Font("宋体", fontSize, FontStyle.Regular);
-                }
-               
-                StringFormat sf = new StringFormat();
-                sf.Alignment = StringAlignment.Center;
-                sf.LineAlignment = StringAlignment.Center;
-                e.Graphics.DrawString(m_sequenceNum.ToString(), font, sampleBrush, m_RegionF, sf);
-
-
-                //绘制帧图
-                e.Graphics.DrawRectangle(pen, startPointF.X, startPointF.Y, endPointF.X - startPointF.X, endPointF.Y - startPointF.Y);
-            }
-            //绘制颗粒
-            else if (createType == CreateRectangleType.ParticleLine)
-            {
-                Color myColor = LineColor;
-                System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
-                Pen pen = new Pen(sampleBrush, 0.01f);
-                e.Graphics.SmoothingMode = SmoothingMode.Default;
-                //设置直线位置与长度
-                PointF startPointF = LineStartPoint;
-                float length = LineLength;
-                PointF endPointF = new PointF(startPointF.X + length, startPointF.Y);
-                e.Graphics.DrawLine(pen, startPointF, endPointF);
-            }
-            //矩形
-            else if (createType == CreateRectangleType.ParticleAreaRectangle)
-            {
-                Color myColor = System.Drawing.Color.White;
-                System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
-                e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;  //图片柔顺模式选择
-                e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
-                e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点
-                var m_Region = new Rectangle();
-                m_Region.X = (int)m_RegionF.X;
-                m_Region.Y = (int)m_RegionF.Y;
-                m_Region.Width = (int)m_RegionF.Width;
-                m_Region.Height = (int)m_RegionF.Height;
-                e.Graphics.DrawRectangle(Pens.Black, m_Region);
-            }
-            //绘制样品孔BSE图像
-            else if (createType == CreateRectangleType.DrawFrameOfHoleBSEImage)
-            {
-                Color myColor = System.Drawing.Color.White;
-                System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
-                e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;  //图片柔顺模式选择
-                e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
-                e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点
-
-                //设置直线位置与尺寸
-                PointF startPointF = new PointF(m_RegionF.Left, m_RegionF.Top);
-                PointF endPointF = new PointF(m_RegionF.Right + 2, m_RegionF.Bottom + 2);
-                //绘制样品孔中图像信息
-                if (BSEImage != null)
-                {
-                    e.Graphics.DrawImage(BSEImage, startPointF.X, startPointF.Y, endPointF.X - startPointF.X, endPointF.Y - startPointF.Y);
-
-                }
-            }
-            else if (createType == CreateRectangleType.DrawSEMCenterPoint)
-            {
-                Color myColor = System.Drawing.Color.Red;
-                System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
-                e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;  //图片柔顺模式选择
-                e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
-                e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点
-                //X轴线
-                PointF startPointX = semCenterPoint;
-                startPointX.X = startPointX.X - 3;
-                PointF endPointX = semCenterPoint;
-                endPointX.X = endPointX.X + 3;
-                //Y轴线
-                PointF startPointY = semCenterPoint;
-                startPointY.Y = startPointY.Y - 3;
-                PointF endPointY = semCenterPoint;
-                endPointY.Y = endPointY.Y + 3;
-                //绘制XY轴交叉线+ 
-                Pen pen = new Pen(sampleBrush, 0.0001f);
-                e.Graphics.DrawLine(pen, startPointX, endPointX);
-                e.Graphics.DrawLine(pen, startPointY, endPointY);
-            }
-            //绘制BSE标记
-            else if (createType == CreateRectangleType.DrawBSEElementSignPoint)
-            {
-                System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Green);
-                e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;  //图片柔顺模式选择
-                e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
-                e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点
-                Pen pen = new Pen(sampleBrush, 2f);
-                int X = (int)m_OrigineRegionF.X;
-                int Y = (int)m_OrigineRegionF.Y;
-                e.Graphics.DrawLine(pen, new Point(X - 8, Y), new Point(X + 8, Y));
-                e.Graphics.DrawLine(pen, new Point(X, Y - 8), new Point(X, Y + 8));
-            }
-            //绘制多边形测量区域
-            else if (createType == CreateRectangleType.Polygon)
-            {
-                e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;  //图片柔顺模式选择
-                e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
-                e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点
-                Color myColor = selColor;
-                System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
-                Pen pen = new Pen(myColor, 1);
-                if (GetPolygonPointFList().Count > 0)
-                {
-                    List<PointF> PolygonPointF = new List<PointF>();
-                    foreach (var item in m_PolygonPoints)
-                    {
-                        PolygonPointF.Add(item);
-                    }
-                    if (PolygonDrawingEndPoint.X != 0 && PolygonDrawingEndPoint.Y != 0)
-                    {
-                        PolygonPointF.Add(PolygonDrawingEndPoint);
-                    }
-
-                    e.Graphics.DrawLines(pen, PolygonPointF.ToArray());
-                    
-
-                }
-            }//多边形测量区域完成标识
-            else if (createType == CreateRectangleType.DrawPolygonFinish)
-            {
-                Color myColor = selColor;
-                System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
-                e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;  //图片柔顺模式选择
-                e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
-                e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点
-                Pen pen = new Pen(myColor, 1);
-                var m_Region = new Rectangle();
-                m_Region.X = (int)m_RegionF.X;
-                m_Region.Y = (int)m_RegionF.Y;
-                m_Region.Width = (int)m_RegionF.Width;
-                m_Region.Height = (int)m_RegionF.Height;
-                e.Graphics.DrawRectangle(pen, m_Region);
-            }
-            //绘制多边形测量区域
-            else if (createType == CreateRectangleType.CircleByThreePoints)
-            {
-                Color myColor = selColor;
-                System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
-                Pen p = new Pen(myColor, 1);
-                e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;  //图片柔顺模式选择
-                e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
-                e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点
-
-                var m_Region = new Rectangle();
-                m_Region.X = (int)m_RegionF.X;
-                m_Region.Y = (int)m_RegionF.Y;
-                m_Region.Width = (int)m_RegionF.Width;
-                m_Region.Height = (int)m_RegionF.Height;
-                e.Graphics.DrawEllipse(p, m_Region);
-
-            }
-        }
-        public  Image BSEImage
-        {
-            get { return bseImage; }
-            set { bseImage = value; }
-        }
-        public  float BSEImageWitdh
-        {
-            get { return bseImageWidth; }
-            set { bseImageWidth = value; }
-        }
-        public  float BSEImageHeight
-        {
-            get { return bseImageHeight; }
-            set { bseImageHeight = value; }
-        }
-        public  PointF BSEImageLocation
-        {
-            get { return bseImageLocation; }
-            set { bseImageLocation = value; }
-        }
-        public  Color LineColor
-        {
-            get { return lineColor; }
-            set { lineColor = value; }
-        }
-        public  float LineLength
-        {
-            get { return lineLength; }
-            set { lineLength = value; }
-        }
-        public  PointF LineStartPoint
-        {
-            get { return lineStartPoint; }
-            set { lineStartPoint = value; }
-        }
-    
-        public  int OTSX
-        {
-            get { return otsX; }
-            set { otsX = value; }
-        }
-        public  int OTSY
-        {
-            get { return otsY; }
-            set { otsY = value; }
-        }
-        public  CreateRectangleType CreateType
-        {
-            get { return createType; }
-            set { createType = value; }
-        }
-        public  ShapeType Shape
-        {
-            get { return shape; }
-            set { shape = value; }
-        }
-        public  Color SelColor
-        {
-            get { return selColor; }
-            set { selColor = value; }
-        }
-        public  string NameOrHoleName//holename when they are not field rectangle gdi object.
-        {
-            get { return nameOrHoleName; }
-            set { nameOrHoleName = value; }
-        }
-        public  string ID
-        {
-            get { return id; }
-            set { id = value; }
-        }
-        public  string SampleName
-        {
-            get { return sampleName; }
-            set { sampleName = value; }
-        }
-        public  int SampleCount
-        {
-            get { return sampleCount; }
-            set { sampleCount = value; }
-        }
-        public string StrContent
-        {
-            get { return strContent; }
-            set { strContent = value; }
-        }
-        public  RectangleF GetZoomedRegion
-        {
-            
-            get {
-                var m_Region = new RectangleF();
-                m_Region.X = m_RegionF.X;
-                m_Region.Y = m_RegionF.Y;
-                m_Region.Width = m_RegionF.Width;
-                m_Region.Height = m_RegionF.Height;
-                   return m_Region;          
-                }
-           
-        }
-        public List<PointF> GetVertexPoints()
-        {
-            List<PointF> vertexPoint = new List<PointF>();
-            var region = this.GetZoomedRegionF();
-            vertexPoint.Add(region.Location);
-            vertexPoint.Add(new PointF(region.X, region.Y + region.Height));
-            vertexPoint.Add(new PointF(region.X + region.Width, region.Y));
-            vertexPoint.Add(new PointF(region.X + region.Width, region.Y + region.Height));
-            return vertexPoint;
-        }
-
-        public  RectangleF GetZoomedRegionF()
-        { 
-            return m_RegionF; 
-        }
-        public  void SetInitRegionF(RectangleF OrigineRegionF)//not zoomed regine value
-        {
-            
-
-            float x1, y1;
-            x1 = OrigineRegionF.X * m_zoomNum + m_refPoint.X;
-            y1 = OrigineRegionF.Y * m_zoomNum + m_refPoint.Y;
-
-            float w1, h1;
-            w1 = OrigineRegionF.Width * m_zoomNum;
-            h1 = OrigineRegionF.Height * m_zoomNum;
-
-
-
-            m_OrigineRegionF = OrigineRegionF;
-
-            m_RegionF = new RectangleF(x1, y1, w1, h1);
-
-
-
-        }
-        internal void SetZoomedRegionF(RectangleF scaleRectangleF)
-        {
-            float x1, y1;
-            x1 = (scaleRectangleF.X-m_refPoint.X) / m_zoomNum ;
-            y1 = (scaleRectangleF.Y-m_refPoint.Y) / m_zoomNum ;
-
-            float w1, h1;
-            w1 = scaleRectangleF.Width / m_zoomNum;
-            h1 = scaleRectangleF.Height / m_zoomNum;
-
-
-            m_OrigineRegionF =  new RectangleF(x1, y1, w1, h1);
-
-            m_RegionF = scaleRectangleF;
-
-        }
-        private  Rectangle GetMinRectangleOfPolygon(List<PointF> polygonPointList)
-        {
-            if (polygonPointList != null)
-            {
-                if (polygonPointList.Count > 0)
-                {
-                    int pCount = polygonPointList.Count;
-                    float minX = polygonPointList[0].X;
-                    float minY = polygonPointList[0].Y;
-                    float maxX = polygonPointList[0].X;
-                    float maxY = polygonPointList[0].Y;
-                    //获取最小X,Y 最大X,Y
-                    for (int i = 0; i < pCount; i++)
-                    {
-                        minX = Math.Min(minX, polygonPointList[i].X);
-                        minY = Math.Min(minY, polygonPointList[i].Y);
-                        maxX = Math.Max(maxX, polygonPointList[i].X);
-                        maxY = Math.Max(maxY, polygonPointList[i].Y);
-                    }
-
-                    //创建外接矩形
-                    Rectangle rect = new Rectangle();
-                    rect.Location = new Point((int)minX, (int)minY);
-                    rect.Size = new Size((int)maxX - (int)minX, (int)maxY - (int)minY);
-                    return rect;
-                }
-            }
-            return new Rectangle();
-        }
-
-        public RectangleF GetOrigionalDrawRegionF()
-        { return m_OrigineRegionF; }
-
-
-        public List<PointF> GetOriginalPolygonPointFList()
-        { return m_originalPolygonPoints; }
-        public void SetOriginalPolygonPointFList(List<PointF> value)
-        {
-            if (m_zoomNum != 1)
-            {
-                var ps = new List<PointF>();
-                foreach (var p in value)
-                {
-                    var p1 = new PointF();
-
-                    p1.X = p.X * m_zoomNum+m_refPoint.X;
-                    p1.Y = p.Y  *m_zoomNum+ m_refPoint.Y;
-                    ps.Add(p1);
-
-                }
-
-
-               
-                m_PolygonPoints = ps;
-                m_originalPolygonPoints = value;
-            }
-            else 
-            {
-                m_originalPolygonPoints = value;
-                m_PolygonPoints = value;
-            }
-           
-
-        }
-
-        public List<PointF> GetPolygonPointFList()
-        { return m_PolygonPoints; }
-        public void SetPolygonPointFList(List<PointF> value)
-        {
-            if (m_zoomNum != 1)
-            {
-                var ps = new List<PointF>();
-                foreach (var p in value)
-                {
-                    var p1 = new PointF();
-
-                    p1.X = (p.X - m_refPoint.X) / m_zoomNum;
-                    p1.Y = (p.Y - m_refPoint.Y) / m_zoomNum;
-                    ps.Add(p1);
-
-                }
-
-
-                m_originalPolygonPoints = ps;
-                m_PolygonPoints = value;
-            }
-            else
-            {
-                m_originalPolygonPoints = value;
-                m_PolygonPoints = value;
-            }
-
-
-            var region = GetMinRectangleOfPolygon(m_PolygonPoints);
-            SetZoomedRegionF(region);
-
-        }
-
-        public GraphicsPath GetGPath()
-        {
-
-            var measureItem = this;
-            //重新绘制测量区域路径
-            GraphicsPath GPath = new GraphicsPath();
-        
-            if (measureItem.CreateType == CreateRectangleType.Polygon)
-            {
-                GraphicsPath PolygonMeasurePath = new GraphicsPath();
-                PolygonMeasurePath.AddPolygon(measureItem.GetPolygonPointFList().ToArray());
-                GPath = PolygonMeasurePath;
-            }
-            else if (measureItem.CreateType == CreateRectangleType.CircleByThreePoints)
-            {
-                GPath.AddEllipse(GetZoomedRegionF());
-            }
-            else
-            {
-                if (measureItem.Shape == (int)CreateRectangleType.Circle)
-                {
-                    GPath.AddEllipse(GetZoomedRegionF());
-                }
-                else
-                {
-                    GPath.AddRectangle(GetZoomedRegionF());
-                }
-            }
-          
-            return GPath;
-
-        }
-
-        public  PointF PolygonDrawingEndPoint
-        {
-            get { return endPoint; }
-            set { endPoint = value; }
-        }
-  
-
-        public  Point GetZoomedCenterPoint()
-        {
-            Point pCenterPoint = new Point();
-            //获取在工作窗口中X,Y位置
-            pCenterPoint.X = (int)(this.GetZoomedRegion.X + this.GetZoomedRegion.Width / 2);
-            pCenterPoint.Y = (int)(this.GetZoomedRegion.Y + this.GetZoomedRegion.Height / 2);
-            return pCenterPoint;
-        }
-
-        public PointF GetCenterPoint()
-        {
-            PointF pCenterPoint = new PointF();
-            //获取在工作窗口中X,Y位置
-            pCenterPoint.X = (this.GetOrigionalDrawRegionF().X + this.GetOrigionalDrawRegionF().Width / 2);
-            pCenterPoint.Y = (this.GetOrigionalDrawRegionF().Y + this.GetOrigionalDrawRegionF().Height / 2);
-            return pCenterPoint;
-        }
-        #endregion
-
-
-       
-        public  bool IsDragging
-        {
-            get { return m_IsDragging; }
-            set { m_IsDragging = value; }
-        }
-        public bool IsAltering// changing the size by gui operating.
-        {
-            get { return m_IsAlter; }
-            set { m_IsAlter = value; }
-        }
-
-        public  bool IsWorkSample
-        {
-            get { return m_IsWorkSample; }
-            set { m_IsWorkSample = value; }
-        }
-        public  PointF DraggingPoint
-        {
-            get { return m_DraggingPoint; }
-            set {
-                
-                    m_DraggingPoint = value;
-                    if (subItems.Count != 0)
-                    {
-                        foreach (var item in subItems)
-                        {
-                            item.DraggingPoint = m_DraggingPoint;
-                        }
-                
-                    }
-                }
-        }
-
-        public int SequenceNum { get => m_sequenceNum; set => m_sequenceNum = value; }
-        public bool IsMoving { get => m_IsMoving; set => m_IsMoving = value; }
-
-        public PointF GetDisplayRefPoint()
-        { return m_refPoint; }
-
-        public void SetDisplayRefPoint(PointF value)
-        { 
-            m_refPoint = value;
-            SetInitRegionF(m_OrigineRegionF);
-            if (m_originalPolygonPoints.Count != 0)
-            {
-                this.SetPolygonPointFList(m_originalPolygonPoints);
-            }
-        }
-
-        public float GetZoomNumber()
-        { return m_zoomNum; }
-
-
-        public void SetZoomNumber(float value)
-        { 
-            m_zoomNum = value;
-            SetInitRegionF(m_OrigineRegionF);
-            if (m_originalPolygonPoints.Count != 0)
-            {
-                this.SetPolygonPointFList(m_originalPolygonPoints);
-            }
-        }
-
-
-
-
-
-        #region 画圆角矩形
-        internal static GraphicsPath CreateRoundedRectanglePath(RectangleF rect, int cornerRadius)
-        {
-            GraphicsPath roundedRect = new GraphicsPath();
-            roundedRect.AddArc(rect.X, rect.Y, cornerRadius * 2, cornerRadius * 2, 180, 90);
-            roundedRect.AddLine(rect.X + cornerRadius, rect.Y, rect.Right - cornerRadius * 2, rect.Y);
-            roundedRect.AddArc(rect.X + rect.Width - cornerRadius * 2, rect.Y, cornerRadius * 2, cornerRadius * 2, 270, 90);
-            roundedRect.AddLine(rect.Right, rect.Y + cornerRadius * 2, rect.Right, rect.Y + rect.Height - cornerRadius * 2);
-            roundedRect.AddArc(rect.X + rect.Width - cornerRadius * 2, rect.Y + rect.Height - cornerRadius * 2, cornerRadius * 2, cornerRadius * 2, 0, 90);
-            roundedRect.AddLine(rect.Right - cornerRadius * 2, rect.Bottom, rect.X + cornerRadius * 2, rect.Bottom);
-            roundedRect.AddArc(rect.X, rect.Bottom - cornerRadius * 2, cornerRadius * 2, cornerRadius * 2, 90, 90);
-            roundedRect.AddLine(rect.X, rect.Bottom - cornerRadius * 2, rect.X, rect.Y + cornerRadius * 2);
-            roundedRect.CloseFigure();
-            return roundedRect;
-        }
-
-        public  bool IfZoomContains(Point mousePoint)
-        {
-            if (mousePoint.X > m_RegionF.Left && mousePoint.X < m_RegionF.Left + m_RegionF.Width)
-            {
-                if (mousePoint.Y > m_RegionF.Top && mousePoint.Y < m_RegionF.Top + m_RegionF.Height)
-                {
-                    return true;
-                
-                }
-            
-            
-            }
-            return false;
-        }
-        public bool IfContains(PointF thePoint)
-        {
-            if (thePoint.X > m_OrigineRegionF.Left && thePoint.X < m_OrigineRegionF.Left + m_OrigineRegionF.Width)
-            {
-                if (thePoint.Y > m_OrigineRegionF.Top && thePoint.Y < m_OrigineRegionF.Top + m_OrigineRegionF.Height)
-                {
-                    return true;
-
-                }
-
-
-            }
-            return false;
-        }
-
-        public  List<CRectangleGDIObject> SubItems()
-        {
-            if (subItems == null) subItems = new List<CRectangleGDIObject>();
-            return subItems;
-        }
-        public void AddSubItems(CRectangleGDIObject item)
-        {
-            if (subItems == null) subItems = new List<CRectangleGDIObject>();
-            subItems.Add(item);
-        }
-        public void ClearSubItems()
-        {
-            subItems.Clear();
-        }
-
-        public  void Zoom(PointF mousePoint, float zoomNum)
-
-        {
-            float X1;
-            float curZoom = m_zoomNum;
-            float deltaZoom = zoomNum - curZoom;
-            float Y1;
-            if (zoomNum == 1)
-            {
-                m_zoomNum = 1;
-                m_RegionF = m_OrigineRegionF;
-                m_refPoint = new PointF(0, 0);
-                m_PolygonPoints = m_originalPolygonPoints;
-            }
-            else 
-            {
-              
-
-                X1 = (m_RegionF.X - mousePoint.X) / curZoom * deltaZoom + m_RegionF.X;
-                Y1 = (m_RegionF.Y - mousePoint.Y) / curZoom * deltaZoom + m_RegionF.Y;
-
-                m_refPoint.X = (m_refPoint.X - mousePoint.X) / curZoom * deltaZoom + m_refPoint.X;
-                m_refPoint.Y = (m_refPoint.Y - mousePoint.Y) / curZoom * deltaZoom + m_refPoint.Y;
-
-                float Width = GetOrigionalDrawRegionF().Width * zoomNum;
-                float Height = GetOrigionalDrawRegionF().Height * zoomNum;
-                m_RegionF = new RectangleF(X1, Y1, Width, Height);
-                m_zoomNum = zoomNum;
-
-
-            } 
-           
-           
-
-
-            BSEImageWitdh = m_RegionF.Width;
-            BSEImageHeight = m_RegionF.Height;
-            BSEImageLocation = m_RegionF.Location;
-          
-
-            var scalePs = new List<PointF>();
-            foreach (var p in m_PolygonPoints)
-            {
-                float x, y;
-                x = (p.X - mousePoint.X) / curZoom * deltaZoom + p.X;
-                y = (p.Y - mousePoint.Y) / curZoom * deltaZoom + p.Y;
-              
-                scalePs.Add(new PointF(x, y));
-
-
-            }
-            m_PolygonPoints = scalePs;
-
-        
-            if (this.subItems.Count != 0)
-            {
-                foreach (var g in subItems)
-                {
-                    g.Zoom(mousePoint,zoomNum);
-                }
-
-
-            }
-        }
-        
-
-        public  void Move(PointF location)
-        {
-            
-            PointF offset = new PointF(location.X - DraggingPoint.X, location.Y - DraggingPoint.Y);
-            float X1;
-            float Y1;
-
-            X1 = (m_RegionF.X + offset.X);
-            Y1 = (m_RegionF.Y + offset.Y);
-
-
-            m_RegionF = new RectangleF(X1, Y1, m_RegionF.Width, m_RegionF.Height);
-        
-
-            m_refPoint.X = m_refPoint.X + offset.X;
-            m_refPoint.Y = m_refPoint.Y + offset.Y;
-
-            BSEImageWitdh = m_RegionF.Width;
-            BSEImageHeight = m_RegionF.Height;
-            BSEImageLocation = m_RegionF.Location;
-            //SEMCenterPoint = m_RegionF.Location;
-            LineStartPoint = m_RegionF.Location;
-
-            m_DraggingPoint = new Point((int)location.X,(int)location.Y);
-
-            var scalePs = new List<PointF>();
-            foreach (var p in m_PolygonPoints)
-            {
-                float x, y;
-                x = (p.X + offset.X);
-                y = (p.Y + offset.Y);
-
-                scalePs.Add(new PointF(x, y));
-
-
-            }
-            m_PolygonPoints = scalePs;
-          
-            if (this.subItems.Count != 0)
-            {
-                foreach (var g in subItems)
-                {
-                    g.Move(location);
-                }
-            
-            
-            }
-        }
-        public void PositionAltering(PointF location,bool ifZoomCoord)
-        {
-
-            PointF offset = new PointF(location.X - DraggingPoint.X, location.Y - DraggingPoint.Y);
-
-            PointF realShift;
-            if (ifZoomCoord)
-            {
-                realShift = new PointF(offset.X / m_zoomNum, offset.Y / m_zoomNum);
-            }
-            else
-            {
-                realShift = new PointF(offset.X , offset.Y );
-            }
-           
-
-  
-            m_OrigineRegionF = new RectangleF(m_OrigineRegionF.X+realShift.X, m_OrigineRegionF.Y+realShift.Y, m_OrigineRegionF.Width, m_OrigineRegionF.Height);
-
-            SetInitRegionF(m_OrigineRegionF);
-
-            BSEImageWitdh = m_RegionF.Width;
-            BSEImageHeight = m_RegionF.Height;
-            BSEImageLocation = m_RegionF.Location;
-          
-            LineStartPoint = m_RegionF.Location;
-
-            
-
-            var scalePs = new List<PointF>();
-            var OriginalPs = new List<PointF>();
-            foreach (var p in m_PolygonPoints)
-            {
-                float x, y;
-                x = (p.X + offset.X);
-                y = (p.Y + offset.Y);
-                scalePs.Add(new PointF(x, y));
-             
-
-
-            }
-            m_PolygonPoints = scalePs;
-
-            foreach (var p in m_originalPolygonPoints)
-            {
-             
-                OriginalPs.Add(new PointF(p.X + realShift.X, p.Y + realShift.Y));
-
-            }
-            m_originalPolygonPoints = OriginalPs;
-
-            m_DraggingPoint = new Point((int)location.X, (int)location.Y);
-
-            if (this.subItems.Count != 0)
-            {
-                foreach (var g in subItems)
-                {
-                    g.PositionAltering(location,ifZoomCoord);
-                }
-
-
-            }
-        }
-
-        public  CRectangleGDIObject Duplicate(CreateRectangleType newType)
-        {
-            CRectangleGDIObject r = new CRectangleGDIObject();
-            r.NameOrHoleName = this.nameOrHoleName;
-            r.SampleName = this.SampleName;
-            r.m_OrigineRegionF = this.m_OrigineRegionF;
-        
-            r.IsWorkSample = this.IsWorkSample;          
-            r.m_RegionF = this.m_RegionF;
-       
-
-            r.m_refPoint = this.m_refPoint;
-            r.m_zoomNum = this.m_zoomNum;
-         
-            r.shape = this.shape;
-
-            r.createType = newType;
-            
-            return r;
-        }
-       virtual public bool ifRectangleIntersect(CRectangleGDIObject othergdi)
-        {
-            return true;
-        }
-
-        #endregion
-        //是否设置为选择样品
-        private bool m_IsAlter;
-        //是否存在帧图信息
-      
-        //是否设置为拖动
-        private bool m_IsDragging;
-
-        private bool m_IsMoving;
-        //是否为工作样品
-        private bool m_IsWorkSample;
-        private CreateRectangleType createType;
-        private ShapeType shape;
-        private string id;
-        protected string nameOrHoleName="";
-        public string sampleName="";
-        //样品孔中样品的数量
-        public int sampleCount = 0;
-        public string strContent;
-        private Color selColor;
-        private PointF m_DraggingPoint;
-
-        private int m_sequenceNum;
-     
-        protected RectangleF m_RegionF;
-        //绘制时与移动缩放时记录的位置与尺寸
-        protected RectangleF m_OrigineRegionF;
-        //private GraphicsPath g_Path=new GraphicsPath();
-        private PointF startPoint;
-        private PointF endPoint;
-    
-        //绘制颗粒图
-        private Color lineColor;
-        private float lineLength;
-        private PointF lineStartPoint;
-        private int otsX;
-        private int otsY;
-        //绘制样品孔BSE图像
-        private Image bseImage;
-        //绘制样品孔BSE图像宽度
-        private float bseImageWidth;
-        //绘制样品孔BSE图像高度
-        private float bseImageHeight;
-        //绘制样品孔BSE图像位置
-        private PointF bseImageLocation;
-        //绘制SEM中心位置
-        private PointF semCenterPoint;
-     
-   
-        private List<PointF> m_PolygonPoints=new List<PointF>();
-        //绘制时与移动缩放时记录的位置
-        private List<PointF> m_originalPolygonPoints = new List<PointF>();
-
-        private List<CRectangleGDIObject> subItems=new List<CRectangleGDIObject>();
-
-      
-        protected float m_zoomNum=1;
-
-        private PointF m_refPoint=new PointF(0,0);
-
-        
-    }
-
-  
-    public enum XYIndex
-    {
-        X = 0,
-        Y = 1
-    }
-   
-    public enum CreateRectangleType
-    {
-        //样品台-圆形
-        SampleBackGround_Circle = -1,
-        //圆形
-        Circle = 0,
-        //圆角矩形
-        SampleBackGround_Rectangle = 1,
-        //样品孔中的文字
-        Text = 2,
-        //矩形
-        Rectangle = 3,
-        //选择的样品
-        SelectSample = 4,
-        //测量区域
-        MeasureArea = 5,
-        //帧图-直线绘制方式
-        SingleLine = 6,
-        //表样-矩形
-        SpecimenRectangle = 7,
-        //表样-圆形
-        SpecimenCircle = 8,
-        //帧图-矩形绘制
-        FieldRectangle = 9,
-        //颗粒直线图
-        ParticleLine = 10,
-        //颗粒分布图 鼠标
-        ParticleAreaRectangle = 11,
-        //绘制拍摄样品孔BSE照片
-        DrawFrameOfHoleBSEImage = 12,
-        //绘制sem中心点+
-        DrawSEMCenterPoint=13,
-        //绘制BSE采集标记
-        DrawBSEElementSignPoint = 14,
-        //多边形
-        Polygon = 15,
-        //多边形完成标识
-        DrawPolygonFinish = 16,
-        //圆形三点法
-        CircleByThreePoints=17,
-
-        RingShape=18
-    }
-  
-
-  
-
-
-
-    public enum ColorType
-    {
-        FieldColor,//帧图fd8f8f
-        RoundRectangleColor,//c8c8c8圆角矩形
-        SampleBackGroundColor,//c0c0c0圆角矩形
-        FontColor,//90ee90文字颜色
-        SampleColor,//f4f4f4 样品未选择
-        SampleSelColor//505050 样品选择后
-    }
-    
-    public enum GrayLevel
-    {
-        Min=0,
-        Max=255
-    }
-}

+ 110 - 89
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/OTSSamplespaceWindow.cs

@@ -75,10 +75,10 @@ namespace OTSMeasureApp
 
 
         //手绘测量区域
-        public static CRectangleGDIObject m_DrawMeasureGDIObject = new CRectangleGDIObject();
+        public static CDisplayGDIObject m_DrawMeasureGDIObject = new CDisplayGDIObject();
 
         //多边形测量区域完成标识
-        public static CRectangleGDIObject m_DrawPolygonFinishGDIObject;
+        public static CDisplayGDIObject m_DrawPolygonFinishGDIObject;
 
         //主窗体对象
         OTSIncAMeasureAppForm m_MeasureAppForm;
@@ -321,7 +321,9 @@ namespace OTSMeasureApp
         {
             m_DrawMeasureType = CreateRectangleType.Polygon;
             m_IsDrawMeasure = true;
-            m_DrawMeasureGDIObject = null;
+            //m_DrawMeasureGDIObject = null;
+            m_DrawMeasureGDIObject = new CDisplayGDIObject(new List<PointF>(), CreateRectangleType.Polygon, (ShapeType)m_DrawMeasureType, "", "", Color.Red);
+
             this.Cursor = Cursors.Hand;
         }
 
@@ -460,7 +462,7 @@ namespace OTSMeasureApp
 
                             }
 
-                            CRectangleGDIObject polygonGdi = new CRectangleGDIObject(ps, CreateRectangleType.Polygon, (ShapeType)SMeasrueArea.iShape, SMeasrueArea.sampleHoleName, SMeasrueArea.sSampleName, Color.Red);
+                            CDisplayGDIObject polygonGdi = new CDisplayGDIObject(ps, CreateRectangleType.Polygon, (ShapeType)SMeasrueArea.iShape, SMeasrueArea.sampleHoleName, SMeasrueArea.sSampleName, Color.Red);
 
 
                             sam.SetMeasureGDIObject(polygonGdi);
@@ -471,11 +473,11 @@ namespace OTSMeasureApp
                         {
                             PointF xHole = new PointF(SMeasrueArea.MeasureRect.Left, SMeasrueArea.MeasureRect.Top);
                             PointF yHole = new PointF(SMeasrueArea.MeasureRect.Right, SMeasrueArea.MeasureRect.Bottom);
-                            CRectangleGDIObject gdi = m_visualStage.GetCtrlCoordRect(xHole, yHole, (CreateRectangleType)SMeasrueArea.iShape, "", "");
+                            CDisplayGDIObject gdi = m_visualStage.GetCtrlCoordRect(xHole, yHole, (CreateRectangleType)SMeasrueArea.iShape, "", "");
                             gdi.SampleName = SMeasrueArea.sSampleName;
                             gdi.NameOrHoleName = SMeasrueArea.sampleHoleName;
                             gdi.Shape = SMeasrueArea.iShape;
-                            CRectangleGDIObject measureGdi;
+                            CDisplayGDIObject measureGdi;
                             if (m_visualStage.GetMeasureGdiObjectFromSampleGdi(gdi, out measureGdi))
                             {
 
@@ -485,7 +487,7 @@ namespace OTSMeasureApp
                         }
 
 
-                        List<CRectangleGDIObject> visualfieldRects = new List<CRectangleGDIObject>();
+                        List<CDisplayGDIObject> visualfieldRects = new List<CDisplayGDIObject>();
 
                         foreach (var fld in FldDatas)
                         {
@@ -507,7 +509,7 @@ namespace OTSMeasureApp
                             string sampleHoleName = sam.GetSampleGDIObject().NameOrHoleName;
 
 
-                            CRectangleGDIObject createRect = new CRectangleGDIObject(visualRect, (int)fld.GetOTSPosition().X, (int)fld.GetOTSPosition().Y, CreateRectangleType.FieldRectangle, sampleHoleName, sampleName, ColorStr);
+                            CDisplayGDIObject createRect = new CDisplayGDIObject(visualRect, (int)fld.GetOTSPosition().X, (int)fld.GetOTSPosition().Y, CreateRectangleType.FieldRectangle, sampleHoleName, sampleName, ColorStr);
 
                             visualfieldRects.Add(createRect);
 
@@ -757,7 +759,7 @@ namespace OTSMeasureApp
         {
 
 
-            CRectangleGDIObject itemAdd;
+            CDisplayGDIObject itemAdd;
             //设置样品选择状态为非工作样品
             foreach (var Sample in m_visualSamples)
             {
@@ -776,7 +778,7 @@ namespace OTSMeasureApp
                 //设置颜色
                 var ColorStr = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.SampleSelColor);
                 Color selColor = ColorStr;
-                CRectangleGDIObject sample = new CRectangleGDIObject(itemAdd.GetOrigionalDrawRegionF(), CreateRectangleType.SelectSample, shape, itemAdd.NameOrHoleName, selColor);
+                CDisplayGDIObject sample = new CDisplayGDIObject(itemAdd.GetOrigionalDrawRegionF(), CreateRectangleType.SelectSample, shape, itemAdd.NameOrHoleName, selColor);
                 //累加样品数量
                 itemAdd.SampleCount += 1;
                 itemAdd.IsWorkSample = true;
@@ -1009,14 +1011,14 @@ namespace OTSMeasureApp
                     break;
             }
         }
-        private List<CRectangleGDIObject> GetAllVisualSampleGDIObject()
+        private List<CDisplayGDIObject> GetAllVisualSampleGDIObject()
         {
-            List<CRectangleGDIObject> allobj = new List<CRectangleGDIObject>();
+            List<CDisplayGDIObject> allobj = new List<CDisplayGDIObject>();
             foreach (var s in m_visualSamples)
             {
                 allobj.Add(s.GetSampleGDIObject());
                 allobj.Add(s.GetMeasureGDIObject());
-                allobj.AddRange(s.FrameOfHoleGDIObjects);
+                allobj.AddRange(m_visualStage.FrameOfHoleGDIObjects);
                 foreach (var f in s.GetMeasureFieldGDIObjects())
                 {
                     allobj.Add(f);
@@ -1031,9 +1033,9 @@ namespace OTSMeasureApp
 
 
         }
-        private List<CRectangleGDIObject> GetOnlyVisualSampleGDIObject()
+        private List<CDisplayGDIObject> GetOnlyVisualSampleGDIObject()
         {
-            List<CRectangleGDIObject> allobj = new List<CRectangleGDIObject>();
+            List<CDisplayGDIObject> allobj = new List<CDisplayGDIObject>();
             foreach (var s in m_visualSamples)
             {
                 allobj.Add(s.GetSampleGDIObject());
@@ -1045,9 +1047,9 @@ namespace OTSMeasureApp
 
 
         }
-        private List<CRectangleGDIObject> GetAllVisualFieldGdiObject()
+        private List<CDisplayGDIObject> GetAllVisualFieldGdiObject()
         {
-            List<CRectangleGDIObject> allobj = new List<CRectangleGDIObject>();
+            List<CDisplayGDIObject> allobj = new List<CDisplayGDIObject>();
             foreach (var s in m_visualSamples)
             {
                 allobj.Add(s.GetMeasureGDIObject());
@@ -1140,7 +1142,7 @@ namespace OTSMeasureApp
                 {
                     if (m_DrawMeasureGDIObject == null)
                     {
-                        m_DrawMeasureGDIObject = new CRectangleGDIObject(new List<PointF>(), CreateRectangleType.Polygon, (ShapeType)m_DrawMeasureType, sampleHoleName, sampleName, Color.Red);
+                        m_DrawMeasureGDIObject = new CDisplayGDIObject(new List<PointF>(), CreateRectangleType.Polygon, (ShapeType)m_DrawMeasureType, sampleHoleName, sampleName, Color.Red);
 
                     }
 
@@ -1154,7 +1156,7 @@ namespace OTSMeasureApp
                         {
                             Point startPoint = new Point((int)(polygonPoints[0].X), (int)(polygonPoints[0].Y));//the last point is the first point too.we get the first point as the last point.
                             polygonPoints.Add(startPoint);
-                            CRectangleGDIObject polygonGdi = new CRectangleGDIObject(polygonPoints, CreateRectangleType.Polygon, (ShapeType)m_DrawMeasureType, sampleHoleName, sampleName, Color.Red);
+                            CDisplayGDIObject polygonGdi = new CDisplayGDIObject(polygonPoints, CreateRectangleType.Polygon, (ShapeType)m_DrawMeasureType, sampleHoleName, sampleName, Color.Red);
 
 
                             polygonGdi.SetZoomNumber(m_visualStage.GetZoomNum());
@@ -1210,7 +1212,7 @@ namespace OTSMeasureApp
                 {
                     if (m_DrawMeasureGDIObject == null)
                     {
-                        m_DrawMeasureGDIObject = new CRectangleGDIObject(new List<PointF>(), CreateRectangleType.Polygon, (ShapeType)m_DrawMeasureType, sampleHoleName, sampleName, Color.Red);
+                        m_DrawMeasureGDIObject = new CDisplayGDIObject(new List<PointF>(), CreateRectangleType.Polygon, (ShapeType)m_DrawMeasureType, sampleHoleName, sampleName, Color.Red);
                     }
                     var m_PolygonPoint = m_DrawMeasureGDIObject.GetPolygonPointFList();
 
@@ -1238,7 +1240,7 @@ namespace OTSMeasureApp
                             return;
                         }
                         Color MeasureColor = Color.Red;
-                        CRectangleGDIObject CRectangleGDI = new CRectangleGDIObject(rectangleThree, CreateRectangleType.CircleByThreePoints, (ShapeType)m_DrawMeasureType, sampleHoleName, sampleName, MeasureColor);
+                        CDisplayGDIObject CRectangleGDI = new CDisplayGDIObject(rectangleThree, CreateRectangleType.CircleByThreePoints, (ShapeType)m_DrawMeasureType, sampleHoleName, sampleName, MeasureColor);
 
 
                         m_DrawMeasureGDIObject = CRectangleGDI;
@@ -1285,9 +1287,9 @@ namespace OTSMeasureApp
                     Size size = new Size(sizeWH, sizeWH);
                     Rectangle rectangle = new Rectangle(m_MouseDownPoint, size);
                     Color MeasureColor = Color.Red;
-                    CRectangleGDIObject newGDI;
+                    CDisplayGDIObject newGDI;
 
-                    newGDI = new CRectangleGDIObject(rectangle, CreateRectangleType.MeasureArea, (ShapeType)m_DrawMeasureType, sampleName, sampleName, MeasureColor);
+                    newGDI = new CDisplayGDIObject(rectangle, CreateRectangleType.MeasureArea, (ShapeType)m_DrawMeasureType, sampleName, sampleName, MeasureColor);
 
                     newGDI.SetZoomNumber(m_visualStage.GetZoomNum());
                     newGDI.SetDisplayRefPoint(m_visualStage.GetDisplayRefPoint());
@@ -1320,7 +1322,7 @@ namespace OTSMeasureApp
                     var workingSam = GetWorkingVisualSample();
                     if (workingSam != null)
                     {
-                        foreach (CRectangleGDIObject item in workingSam.GetMeasureFieldGDIObjects())
+                        foreach (CDisplayGDIObject item in workingSam.GetMeasureFieldGDIObjects())
                         {
                             if (item.IfZoomContains(e.Location))
                             {
@@ -1385,9 +1387,8 @@ namespace OTSMeasureApp
                             return;
                         }
                     }
-                    if (GetWorkingVisualSample() != null)
-                    {
-                        foreach (CRectangleGDIObject item in GetWorkingVisualSample().FrameOfHoleGDIObjects)
+                   
+                        foreach (CDisplayGDIObject item in m_visualStage.FrameOfHoleGDIObjects)
                         {
                             if (item.IfZoomContains(e.Location))
                             {
@@ -1401,7 +1402,7 @@ namespace OTSMeasureApp
                             }
                         }
 
-                    }
+                    
 
                     //只点击样品上(测量区域被移动到其他地方)
                     for (int i = m_visualSamples.Count - 1; i >= 0; i--)
@@ -1431,7 +1432,7 @@ namespace OTSMeasureApp
                     }
                     //点击样品孔
 
-                    CRectangleGDIObject gdiitem;
+                    CDisplayGDIObject gdiitem;
                     if (m_visualStage.IfMouseInSampleHole(e.Location, out gdiitem))
                     {
 
@@ -1555,7 +1556,7 @@ namespace OTSMeasureApp
                     }
 
                     //click on the sample area without ctrl key,just switch to that sample.
-                    if (!(Control.ModifierKeys == Keys.Control) && !runflag)
+                    if (!(Control.ModifierKeys == Keys.Control) && !runflag) 
                     {
                         for (int i = m_visualSamples.Count - 1; i >= 0; i--)
                         {
@@ -1588,7 +1589,7 @@ namespace OTSMeasureApp
 
                     }
 
-                    CRectangleGDIObject stageobj;
+                    CDisplayGDIObject stageobj;
                     if (m_visualStage.IfMouseInStage(e.Location, out stageobj) )
                     {
 
@@ -1649,7 +1650,7 @@ namespace OTSMeasureApp
                             {
                                 Point PolygonFinishPoint = new Point((int)(startPoint.X - m_MinMeasureWidthValue / 2), (int)(startPoint.Y - m_MinMeasureWidthValue / 2));
                                 Rectangle pRect = new Rectangle(PolygonFinishPoint, new Size(rectSize, rectSize));
-                                CRectangleGDIObject createPolygonFinish = new CRectangleGDIObject(pRect, CreateRectangleType.DrawPolygonFinish, "", "", Color.Green);
+                                CDisplayGDIObject createPolygonFinish = new CDisplayGDIObject(pRect, CreateRectangleType.DrawPolygonFinish, "", "", Color.Green);
                                 m_DrawPolygonFinishGDIObject = createPolygonFinish;
 
                             }
@@ -1948,7 +1949,7 @@ namespace OTSMeasureApp
                 if (GetWorkingVisualSample() != null)
                 {
                     //样品孔BSE图片
-                    MouseMoveFucntion(GetWorkingVisualSample().FrameOfHoleGDIObjects, e);
+                    MouseMoveFucntion(m_visualStage.FrameOfHoleGDIObjects, e);
 
                 }
 
@@ -2058,14 +2059,13 @@ namespace OTSMeasureApp
 
             if (IsShowSampleHoleImage)
             {
-                if (GetWorkingVisualSample() != null)
-                {
-                    if (GetWorkingVisualSample().FrameOfHoleGDIObjects.Count > 0)
+                
+                    if (m_visualStage.FrameOfHoleGDIObjects.Count > 0)
                     {
-                        OnPaint(e, GetWorkingVisualSample().FrameOfHoleGDIObjects);
+                        OnPaint(e, m_visualStage.FrameOfHoleGDIObjects);
                     }
 
-                }
+               
 
 
             }
@@ -2085,9 +2085,9 @@ namespace OTSMeasureApp
 
 
         }
-        public void OnPaint(PaintEventArgs e, List<CRectangleGDIObject> m_ObjectGDIObjects)//处理重绘情况
+        public void OnPaint(PaintEventArgs e, List<CDisplayGDIObject> m_ObjectGDIObjects)//处理重绘情况
         {
-            foreach (CRectangleGDIObject item in m_ObjectGDIObjects.ToArray())
+            foreach (CDisplayGDIObject item in m_ObjectGDIObjects.ToArray())
             {
                 if (item != null)
                 {
@@ -2182,7 +2182,7 @@ namespace OTSMeasureApp
             Invalidate();
         }
 
-        private void MouseWheelFunction(List<CRectangleGDIObject> objList, Point mousePoint, float ZoomNum)
+        private void MouseWheelFunction(List<CDisplayGDIObject> objList, Point mousePoint, float ZoomNum)
         {
 
             for (int i = 0; i < objList.Count; i++)
@@ -2194,18 +2194,18 @@ namespace OTSMeasureApp
         #endregion
 
         #region 鼠标方法操作
-        public void MouseDownFunction(List<CRectangleGDIObject> objList, MouseEventArgs e)
+        public void MouseDownFunction(List<CDisplayGDIObject> objList, MouseEventArgs e)
         {
 
-            foreach (CRectangleGDIObject item in objList)
+            foreach (CDisplayGDIObject item in objList)
             {
                 item.IsMoving = true;
                 item.DraggingPoint = e.Location;
             }
         }
-        public void MouseMoveFucntion(List<CRectangleGDIObject> objList, MouseEventArgs e)
+        public void MouseMoveFucntion(List<CDisplayGDIObject> objList, MouseEventArgs e)
         {
-            foreach (CRectangleGDIObject item in objList)
+            foreach (CDisplayGDIObject item in objList)
             {
                 if (item.IsMoving)
                 {
@@ -2217,9 +2217,9 @@ namespace OTSMeasureApp
         }
 
 
-        public void MouseUpFucntion(List<CRectangleGDIObject> objList, MouseEventArgs e)
+        public void MouseUpFucntion(List<CDisplayGDIObject> objList, MouseEventArgs e)
         {
-            foreach (CRectangleGDIObject item in objList)
+            foreach (CDisplayGDIObject item in objList)
             {
                 if (item.IsDragging)
                 {
@@ -2302,19 +2302,7 @@ namespace OTSMeasureApp
                 return base.ProcessDialogKey(keyData);
             }
         }
-        private void OTSSamplespaceWindow_KeyDown(object sender, KeyEventArgs e)
-        {
-            KeyDowns();
-        }
-        private void OTSSamplespaceWindow_KeyUp(object sender, KeyEventArgs e)
-        {
-            //键盘抬起时,将选择区域的标识 设置为未选择状态
-            this.Cursor = System.Windows.Forms.Cursors.Default;
-
-            this.Invalidate();
-
-        }
-        public void KeyDowns()
+        public void OTSSamplespaceWindow_KeyDown(object sender, KeyEventArgs e)
         {
             //鼠标相对于屏幕的坐标
             Point p1 = MousePosition;
@@ -2434,7 +2422,41 @@ namespace OTSMeasureApp
                     }
                 }
             }
+
+            if (e.KeyCode == Keys.Escape && m_IsDrawMeasure == true && m_DrawMeasureType == CreateRectangleType.Polygon)
+            {
+                var polygonPoints = m_DrawMeasureGDIObject.GetPolygonPointFList();
+
+                if (polygonPoints.Count > 0)
+                {
+                    polygonPoints.RemoveAt(polygonPoints.Count - 1);//remove the last one.
+                    m_DrawMeasureGDIObject.SetPolygonPointFList(polygonPoints);
+
+
+                }
+                else
+                {
+                    m_IsDrawMeasure = false;
+
+                }
+
+
+
+            }
+            else if(e.KeyCode == Keys.Escape && m_IsDrawMeasure == true)
+            {
+                m_IsDrawMeasure = false;
+            }
+        }
+        private void OTSSamplespaceWindow_KeyUp(object sender, KeyEventArgs e)
+        {
+            //键盘抬起时,将选择区域的标识 设置为未选择状态
+            this.Cursor = System.Windows.Forms.Cursors.Default;
+
+            this.Invalidate();
+
         }
+       
         public void KeyUps()
         {
 
@@ -2450,15 +2472,14 @@ namespace OTSMeasureApp
             try
             {
 
+                m_visualStage.FrameOfHoleGDIObjects.Clear();
+                
                 m_visualStage.cleargdiobj();
                 var sam = GetWorkingVisualSample();
 
                 if (sam != null)
                 {
-                    if (sam.FrameOfHoleGDIObjects != null)
-                    {
-                        sam.FrameOfHoleGDIObjects.Clear();
-                    }
+                   
 
                     if (m_DrawMeasureGDIObject != null)
                     {
@@ -2511,7 +2532,7 @@ namespace OTSMeasureApp
 
                         }
 
-                        CRectangleGDIObject polygongdi = new CRectangleGDIObject(ps, CreateRectangleType.Polygon, (ShapeType)SMeasrueArea.iShape, SMeasrueArea.sampleHoleName, SMeasrueArea.sSampleName, Color.Red);
+                        CDisplayGDIObject polygongdi = new CDisplayGDIObject(ps, CreateRectangleType.Polygon, (ShapeType)SMeasrueArea.iShape, SMeasrueArea.sampleHoleName, SMeasrueArea.sSampleName, Color.Red);
 
 
                         sam.SetMeasureGDIObject(polygongdi);
@@ -2522,11 +2543,11 @@ namespace OTSMeasureApp
                     {
                         PointF xHole = new PointF(SMeasrueArea.MeasureRect.Left, SMeasrueArea.MeasureRect.Top);
                         PointF yHole = new PointF(SMeasrueArea.MeasureRect.Right, SMeasrueArea.MeasureRect.Bottom);
-                        CRectangleGDIObject gdi = m_visualStage.GetCtrlCoordRect(xHole, yHole, (CreateRectangleType)SMeasrueArea.iShape, "", "");
+                        CDisplayGDIObject gdi = m_visualStage.GetCtrlCoordRect(xHole, yHole, (CreateRectangleType)SMeasrueArea.iShape, "", "");
                         gdi.SampleName = SMeasrueArea.sSampleName;
                         gdi.NameOrHoleName = SMeasrueArea.sampleHoleName;
                         gdi.Shape = SMeasrueArea.iShape;
-                        CRectangleGDIObject measureGdi;
+                        CDisplayGDIObject measureGdi;
                         if (m_visualStage.GetMeasureGdiObjectFromSampleGdi(gdi, out measureGdi))
                         {
 
@@ -2591,14 +2612,14 @@ namespace OTSMeasureApp
 
         }
         #region 获取Filed帧图
-        public List<CRectangleGDIObject> GetOTSFieldVisualRects(CVisualSampleArea sam, MSR_RUN_TYPE runType)
+        public List<CDisplayGDIObject> GetOTSFieldVisualRects(CVisualSampleArea sam, MSR_RUN_TYPE runType)
         {
             List<Point> listCenterPoint=new List<Point>();
             Size rectSize=new Size();
 
             var m_ResultData = m_MeasureAppForm.m_ProjParam.GetResultData();
             var sample = m_ResultData.GetSampleByName(sam.GetSampleName());
-            List<CRectangleGDIObject> visualfieldRects = new List<CRectangleGDIObject>();
+            List<CDisplayGDIObject> visualfieldRects = new List<CDisplayGDIObject>();
 
             if (runType == MSR_RUN_TYPE.RUNSampleHoleImage)
             {
@@ -2631,7 +2652,7 @@ namespace OTSMeasureApp
                     string sampleHoleName = sam.GetSampleGDIObject().NameOrHoleName;
 
 
-                    CRectangleGDIObject createRect = new CRectangleGDIObject(visualRect, otsPoint.X, otsPoint.Y, CreateRectangleType.FieldRectangle, sampleHoleName, sampleName, ColorStr);
+                    CDisplayGDIObject createRect = new CDisplayGDIObject(visualRect, otsPoint.X, otsPoint.Y, CreateRectangleType.FieldRectangle, sampleHoleName, sampleName, ColorStr);
 
                     visualfieldRects.Add(createRect);
                 }
@@ -2697,7 +2718,7 @@ namespace OTSMeasureApp
             try
             {
 
-                List<CRectangleGDIObject> visualfieldRects = null;
+                List<CDisplayGDIObject> visualfieldRects = null;
 
                 visualfieldRects = GetOTSFieldVisualRects(visualsam, runType);//get all the possible field rects through C++ code.
 
@@ -2706,15 +2727,15 @@ namespace OTSMeasureApp
                     //-------maybe take more than one visualsample hole image for one sample,
                     //if the previous visual area's fields don't finish,then the unfinished field's area may overlap with the current visualsample's area.
                     // then there positions will conflict. So we should remove the unfinished fields first.
-                    var completeHoleImgs = new List<CRectangleGDIObject>();
-                    foreach (var holeImgfld in visualsam.FrameOfHoleGDIObjects)
+                    var completeHoleImgs = new List<CDisplayGDIObject>();
+                    foreach (var holeImgfld in m_visualStage. FrameOfHoleGDIObjects)
                     {
                         if (holeImgfld.BSEImage != null)
                         {
                             completeHoleImgs.Add(holeImgfld);
                         }
                     }
-                    visualsam.FrameOfHoleGDIObjects = completeHoleImgs;
+                    m_visualStage.FrameOfHoleGDIObjects = completeHoleImgs;
                     //------
                     foreach (var r in visualfieldRects)
                     {
@@ -2730,15 +2751,15 @@ namespace OTSMeasureApp
 
                         //绘制图像
 
-                        CRectangleGDIObject createImageRect = new CRectangleGDIObject(ImgRegionF, r.OTSX, r.OTSY, r.SampleName, r.NameOrHoleName, ImgRegionWidth, ImgRegionHeight, CreateRectangleType.DrawFrameOfHoleBSEImage);
+                        CDisplayGDIObject createImageRect = new CDisplayGDIObject(ImgRegionF, r.OTSX, r.OTSY, r.SampleName, r.NameOrHoleName, ImgRegionWidth, ImgRegionHeight, CreateRectangleType.DrawFrameOfHoleBSEImage);
                         //添加至List集合中
                         createImageRect.SetInitRegionF(r.GetOrigionalDrawRegionF());
                         createImageRect.NameOrHoleName = r.NameOrHoleName;
                         createImageRect.SetZoomNumber(m_visualStage.GetZoomNum());
                         createImageRect.SetDisplayRefPoint(m_visualStage.GetDisplayRefPoint());
-                       
-                        
-                        visualsam.FrameOfHoleGDIObjects.Add(createImageRect);
+
+
+                        m_visualStage.FrameOfHoleGDIObjects.Add(createImageRect);
                     }
 
                 }
@@ -3030,8 +3051,8 @@ namespace OTSMeasureApp
         public void AddHoleBSEImageData(byte[] ImageData, int width, int height, Point fieldPos, int fieldId)
         {
 
-            CRectangleGDIObject itemWorkSample;
-            var sam = GetWorkingVisualSample();
+            CDisplayGDIObject itemWorkSample;
+            //var sam = GetWorkingVisualSample();
 
             itemWorkSample = GetWorkingVisualSample().GetSampleGDIObject();
             //获取样品孔BSE图像
@@ -3039,21 +3060,21 @@ namespace OTSMeasureApp
             int m_iWidth = width;
             int m_iHeigh = height;
 
-            if (sam.FrameOfHoleGDIObjects.Count > 0)
+            if (m_visualStage.FrameOfHoleGDIObjects.Count > 0)
             {
-                for (int i = 0; i < sam.FrameOfHoleGDIObjects.Count; i++)
+                for (int i = 0; i < m_visualStage.FrameOfHoleGDIObjects.Count; i++)
                 {
 
                     var ctrlPos = m_visualStage.OTSCoordToCtrlCoord(fieldPos);
-                    if (sam.FrameOfHoleGDIObjects[i].BSEImage == null)// prevent miss match when this sample area is overlaying on the other area(already took image in the field)
+                    if (m_visualStage.FrameOfHoleGDIObjects[i].BSEImage == null)// prevent miss match when this sample area is overlaying on the other area(already took image in the field)
                     {
-                        if (sam.FrameOfHoleGDIObjects[i].IfContains(ctrlPos))
+                        if (m_visualStage.FrameOfHoleGDIObjects[i].IfContains(ctrlPos))
                         //if (i == fieldId)
                         {
 
 
                             bseImage = CImageHandler.ToGrayBitmap(ImageData, m_iWidth, m_iHeigh);
-                            sam.FrameOfHoleGDIObjects[i].BSEImage = bseImage;
+                            m_visualStage.FrameOfHoleGDIObjects[i].BSEImage = bseImage;
 
 
                             break;
@@ -3074,7 +3095,7 @@ namespace OTSMeasureApp
         {
 
 
-            GetWorkingVisualSample().FrameOfHoleGDIObjects.Clear();
+            m_visualStage.FrameOfHoleGDIObjects.Clear();
             Invalidate();
 
         }
@@ -3084,7 +3105,7 @@ namespace OTSMeasureApp
        
 
         #region 复位工作样品区域
-        public CRectangleGDIObject ResetMeasure(CRectangleGDIObject SampleGDIObjects, CRectangleGDIObject MeasureGDIObjects)
+        public CDisplayGDIObject ResetMeasure(CDisplayGDIObject SampleGDIObjects, CDisplayGDIObject MeasureGDIObjects)
         {
 
 
@@ -3111,12 +3132,12 @@ namespace OTSMeasureApp
 
             //定义测量区域
             RectangleF SampleRectangleF = m_visualStage.GetCtrlCoordRectF(xHole, yHole);
-            CRectangleGDIObject m_MeasureGDIObject = m_visualStage.GetCtrlCoordRect(xHole, yHole, (CreateRectangleType)MeasureInfo.SMeasurePara.iShape, "", "");
+            CDisplayGDIObject m_MeasureGDIObject = m_visualStage.GetCtrlCoordRect(xHole, yHole, (CreateRectangleType)MeasureInfo.SMeasurePara.iShape, "", "");
             m_MeasureGDIObject.SetInitRegionF(SampleRectangleF);
 
             var sam = GetWorkingVisualSample();
             var mea = sam.GetMeasureGDIObject();
-            CRectangleGDIObject m_ResetMeasureGDIobjects = ResetMeasure(sam.GetSampleGDIObject(), m_MeasureGDIObject);
+            CDisplayGDIObject m_ResetMeasureGDIobjects = ResetMeasure(sam.GetSampleGDIObject(), m_MeasureGDIObject);
             mea.SetInitRegionF(m_ResetMeasureGDIobjects.GetOrigionalDrawRegionF());
             mea.Shape = m_ResetMeasureGDIobjects.Shape;
             Invalidate();

+ 1 - 1
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/SEMDATAFieldManage.cs

@@ -232,7 +232,7 @@ namespace OTSMeasureApp
         #endregion
 
         #region 驱动SEM到中心位置
-        public bool DriveSEMToLocation(Point mousePoint,CVisualStage stage, List<CRectangleGDIObject> m_MeasureFieldGDIObjects)
+        public bool DriveSEMToLocation(Point mousePoint,CVisualStage stage, List<CDisplayGDIObject> m_MeasureFieldGDIObjects)
         {
             try
             {

+ 53 - 47
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/VisualStage.cs

@@ -40,12 +40,15 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
   
 
         //样品台存在的List集合 the rectangle on the edge of  stage ,usually one.
-        private List<CRectangleGDIObject> m_StageEdgeGDIObjects;
+        private List<CDisplayGDIObject> m_StageEdgeGDIObjects;
         //标样存在的List集合 usually it is a samll circle.
-        private List<CRectangleGDIObject> m_SpecimenGDIObjects;
-        private List<CRectangleGDIObject> m_SampleHoleGDIObjects;// the hole gdi of the stage 
+        private List<CDisplayGDIObject> m_SpecimenGDIObjects;
+        private List<CDisplayGDIObject> m_SampleHoleGDIObjects;// the hole gdi of the stage 
         //文字内容
-        private List<CRectangleGDIObject> m_ContentGDIObjects;//the text that will display in the hole.
+        private List<CDisplayGDIObject> m_ContentGDIObjects;//the text that will display in the hole.
+
+        private List<CDisplayGDIObject> frameOfHoleGDIObjects;// record all the position of the sampleHole image
+        public List<CDisplayGDIObject> FrameOfHoleGDIObjects { get => frameOfHoleGDIObjects; set => frameOfHoleGDIObjects = value; }
 
         public StageDrawingData GetOTSSampleStageData()
         {
@@ -60,31 +63,34 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
         public CVisualStage(StageDrawingData oTSSampleStageData)
         {
             //样品台
-            m_StageEdgeGDIObjects = new List<CRectangleGDIObject>();
+            m_StageEdgeGDIObjects = new List<CDisplayGDIObject>();
             //标样
-            m_SpecimenGDIObjects = new List<CRectangleGDIObject>();
+            m_SpecimenGDIObjects = new List<CDisplayGDIObject>();
             //样品孔
-            m_SampleHoleGDIObjects = new List<CRectangleGDIObject>();
+            m_SampleHoleGDIObjects = new List<CDisplayGDIObject>();
             //样品孔文字内容
-            m_ContentGDIObjects = new List<CRectangleGDIObject>();
+            m_ContentGDIObjects = new List<CDisplayGDIObject>();
 
             m_OTSSampleStageData = new StageDrawingData();
 
+            frameOfHoleGDIObjects = new List<CDisplayGDIObject>();
+
             SetOTSSampleStageData(oTSSampleStageData ?? throw new ArgumentNullException(nameof(oTSSampleStageData)));
         }
 
         public CVisualStage()
         {
             //样品台
-            m_StageEdgeGDIObjects = new List<CRectangleGDIObject>();
+            m_StageEdgeGDIObjects = new List<CDisplayGDIObject>();
             //标样
-            m_SpecimenGDIObjects = new List<CRectangleGDIObject>();
+            m_SpecimenGDIObjects = new List<CDisplayGDIObject>();
             //样品孔
-            m_SampleHoleGDIObjects = new List<CRectangleGDIObject>();
+            m_SampleHoleGDIObjects = new List<CDisplayGDIObject>();
             //样品孔文字内容
-            m_ContentGDIObjects = new List<CRectangleGDIObject>();
+            m_ContentGDIObjects = new List<CDisplayGDIObject>();
 
             m_OTSSampleStageData = new StageDrawingData();
+            frameOfHoleGDIObjects = new List<CDisplayGDIObject>();
         }
         public void clear()
         {
@@ -95,14 +101,14 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
 
 
         }
-        public CRectangleGDIObject GetEdgeGDIObj()
+        public CDisplayGDIObject GetEdgeGDIObj()
         {
             return m_StageEdgeGDIObjects[0];
         }
         public float GetZoomNum() { return m_StageEdgeGDIObjects[0].GetZoomNumber(); }
         public PointF GetDisplayRefPoint() { return m_StageEdgeGDIObjects[0].GetDisplayRefPoint(); }
 
-        public CRectangleGDIObject GetHoleGDIBySampleName(string name)
+        public CDisplayGDIObject GetHoleGDIBySampleName(string name)
         {
             foreach (var g in m_SampleHoleGDIObjects)
             {
@@ -115,7 +121,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
             return null;
         
         }
-        public CRectangleGDIObject GetHoleGDIByHoleName(string name)
+        public CDisplayGDIObject GetHoleGDIByHoleName(string name)
         {
             foreach (var g in m_SampleHoleGDIObjects)
             {
@@ -128,7 +134,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
             return null;
 
         }
-        public CRectangleGDIObject GetHoleGDIByMousePoint(Point  mousePoint)
+        public CDisplayGDIObject GetHoleGDIByMousePoint(Point  mousePoint)
         {
             foreach (var g in m_SampleHoleGDIObjects)
             {
@@ -260,15 +266,15 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
              
                 Bourary = GetCtrlCoordRectF(stageLeftTop, stageRightBottom);
 
-                CRectangleGDIObject CreateBourary;
+                CDisplayGDIObject CreateBourary;
                 //0:圆角矩形 1:圆形 2:文字 3:矩形
                 if (SData.bStageShape == (ShapeType.RECTANGLE))
                 {
-                    CreateBourary =  new CRectangleGDIObject(Bourary, CreateRectangleType.SampleBackGround_Rectangle);
+                    CreateBourary =  new CDisplayGDIObject(Bourary, CreateRectangleType.SampleBackGround_Rectangle);
                 }
                 else
                 {
-                    CreateBourary =  new CRectangleGDIObject(Bourary, CreateRectangleType.Circle);
+                    CreateBourary =  new CDisplayGDIObject(Bourary, CreateRectangleType.Circle);
                 }
       
                 CreateBourary.Shape = StageShape;
@@ -296,16 +302,16 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
                         float  heightHole = Math.Abs(yHole.Y - xHole.Y);
                         var RecF = GetCtrlCoordRectF(xHole, yHole);
                         //获取矩形
-                        CRectangleGDIObject CreateHole = null;
+                        CDisplayGDIObject CreateHole = null;
                         //0:圆角矩形 1:圆形 2:文字 3:矩形
                         if (ChloeClrList[i].iShape == (ShapeType)CreateRectangleType.SampleBackGround_Rectangle)
                         {
-                            CreateHole =  new CRectangleGDIObject(RecF, CreateRectangleType.Rectangle);
+                            CreateHole =  new CDisplayGDIObject(RecF, CreateRectangleType.Rectangle);
 
                         }
                         else
                         {
-                            CreateHole =  new CRectangleGDIObject(RecF, CreateRectangleType.Circle);
+                            CreateHole =  new CDisplayGDIObject(RecF, CreateRectangleType.Circle);
                         }
                 
                
@@ -315,7 +321,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
                         //添加文字
 
 
-                        CRectangleGDIObject CreateContent = GetCtrlCoordRect(xHole, yHole, CreateRectangleType.Rectangle, "", "");
+                        CDisplayGDIObject CreateContent = GetCtrlCoordRect(xHole, yHole, CreateRectangleType.Rectangle, "", "");
                         //类型 文字:2
                         CreateContent.CreateType = CreateRectangleType.Text;
                         CreateContent.SetInitRegionF(CreateContent.GetZoomedRegionF());
@@ -330,7 +336,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
                 stageRightBottom = new PointF(SData.SampleRect.Right, SData.SampleRect.Bottom);
 
                 //获取矩形
-                CRectangleGDIObject CreateSTD;
+                CDisplayGDIObject CreateSTD;
                 if (StageShapes == (int)CreateRectangleType.Circle)
                 {
                     CreateSTD = GetCtrlCoordRect(stageLeftTop, stageRightBottom, CreateRectangleType.SpecimenCircle, "", "");
@@ -350,7 +356,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
                 NLog.LogManager.GetCurrentClassLogger().Error( ex.ToString() );
             }
         }
-        public CRectangleGDIObject GetCtrlCoordRect(PointF OTSLeftTop, PointF OTSRightBottom, CreateRectangleType type, string content, string name)
+        public CDisplayGDIObject GetCtrlCoordRect(PointF OTSLeftTop, PointF OTSRightBottom, CreateRectangleType type, string content, string name)
         {
             try
             {
@@ -372,11 +378,11 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
                 float realEndY = Math.Max(xPoints.Y, yPoints.Y);
 
                 //创建矩形 并返回类型对象
-                return  new CRectangleGDIObject(realStartX, realStartY, realEndX - Math.Abs(realStartX), realEndY - Math.Abs(realStartY), type, content, name);
+                return  new CDisplayGDIObject(realStartX, realStartY, realEndX - Math.Abs(realStartX), realEndY - Math.Abs(realStartY), type, content, name);
             }
             catch (Exception)
             {
-                return  new CRectangleGDIObject(new Rectangle(), 0, "");
+                return  new CDisplayGDIObject(new Rectangle(), 0, "");
             }
         }
         public RectangleF GetCtrlCoordRectF(PointF OTSLeftTop, PointF OTSRightBottom)
@@ -509,7 +515,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
                 }
             }
         }
-        public CRectangleGDIObject GetSampleHoleGdiobjByName(string holeName)
+        public CDisplayGDIObject GetSampleHoleGdiobjByName(string holeName)
         {
             foreach (var hole in m_SampleHoleGDIObjects)
             {
@@ -543,7 +549,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
 
             
 
-                CRectangleGDIObject sampleGDIObject = item.Duplicate(CreateRectangleType.SelectSample);
+                CDisplayGDIObject sampleGDIObject = item.Duplicate(CreateRectangleType.SelectSample);
 
                 sampleGDIObject.sampleName = SMeasurePara.sSampleName;
 
@@ -552,7 +558,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
 
                 //add the default measure area from config file.
 
-                CRectangleGDIObject newMeasureGDIObject;
+                CDisplayGDIObject newMeasureGDIObject;
                 PointF xHole = new PointF(SMeasurePara.MeasureRect.Left, SMeasurePara.MeasureRect.Top);
                 PointF yHole = new PointF(SMeasurePara.MeasureRect.Right, SMeasurePara.MeasureRect.Bottom);
 
@@ -585,7 +591,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
         }
         #region 根据样品位置 获取测量区域位置
 
-        public SampleMeasurePara GetSampleMeasurePara(CRectangleGDIObject MeasureItem)
+        public SampleMeasurePara GetSampleMeasurePara(CDisplayGDIObject MeasureItem)
         {
 
             var item = MeasureItem;
@@ -674,7 +680,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
         /// <param name="IsIsDragging">是否选择样品 0:未选择 1:选择</param>
         /// <param name="sampleName">样品名称</param>
         /// <returns>是否成功</returns>
-        public bool GetMeasureGdiObject( CRectangleGDIObject sampleGDIObject,ShapeType newShape, RectangleF newRegion, out CRectangleGDIObject outMeasureRect)
+        public bool GetMeasureGdiObject( CDisplayGDIObject sampleGDIObject,ShapeType newShape, RectangleF newRegion, out CDisplayGDIObject outMeasureRect)
         {
             
                 var MeasureRect = sampleGDIObject.Duplicate(CreateRectangleType.MeasureArea);
@@ -688,7 +694,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
                 return true;
             
         }
-        public bool GetMeasureGdiObjectFromSampleGdi(CRectangleGDIObject sampleGDIObject,  out CRectangleGDIObject outMeasureRect)
+        public bool GetMeasureGdiObjectFromSampleGdi(CDisplayGDIObject sampleGDIObject,  out CDisplayGDIObject outMeasureRect)
         {
 
             //添加测量区域
@@ -755,9 +761,9 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
 
         }
 
-        public bool IfMouseInSampleHole(Point mousePoint,out CRectangleGDIObject gdiItem)
+        public bool IfMouseInSampleHole(Point mousePoint,out CDisplayGDIObject gdiItem)
         {
-            foreach (CRectangleGDIObject item in m_SampleHoleGDIObjects)
+            foreach (CDisplayGDIObject item in m_SampleHoleGDIObjects)
             {
                 if (item.IfZoomContains(mousePoint))
                 {
@@ -769,9 +775,9 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
             return false;
 
         }
-        public bool IfMouseInStage(Point mousePoint,out CRectangleGDIObject gdiobj)
+        public bool IfMouseInStage(Point mousePoint,out CDisplayGDIObject gdiobj)
         {
-            foreach (CRectangleGDIObject item in m_StageEdgeGDIObjects)
+            foreach (CDisplayGDIObject item in m_StageEdgeGDIObjects)
             {
                 if (item.IfZoomContains(mousePoint))
                 {
@@ -785,7 +791,7 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
         }
         public bool IfMouseInStage(Point mousePoint )
         {
-            foreach (CRectangleGDIObject item in m_StageEdgeGDIObjects)
+            foreach (CDisplayGDIObject item in m_StageEdgeGDIObjects)
             {
                 if (item.IfZoomContains(mousePoint))
                 {
@@ -800,17 +806,17 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
 
         public void OnMouseMove( MouseEventArgs e)
         {
-            foreach (CRectangleGDIObject item in m_ContentGDIObjects)
+            foreach (CDisplayGDIObject item in m_ContentGDIObjects)
             {
                 item.IsDragging = true;
                 item.DraggingPoint = e.Location;
             }
-            foreach (CRectangleGDIObject item in m_SampleHoleGDIObjects)
+            foreach (CDisplayGDIObject item in m_SampleHoleGDIObjects)
             {
                 item.IsDragging = true;
                 item.DraggingPoint = e.Location;
             }
-            foreach (CRectangleGDIObject item in m_SpecimenGDIObjects)
+            foreach (CDisplayGDIObject item in m_SpecimenGDIObjects)
             {
                 item.IsDragging = true;
                 item.DraggingPoint = e.Location;
@@ -818,23 +824,23 @@ namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel
 
 
         }
-        public List<CRectangleGDIObject> GetAllGDIObject()
+        public List<CDisplayGDIObject> GetAllGDIObject()
         {
-            var allobj = new List<CRectangleGDIObject>();
-            foreach (CRectangleGDIObject item in m_StageEdgeGDIObjects)
+            var allobj = new List<CDisplayGDIObject>();
+            foreach (CDisplayGDIObject item in m_StageEdgeGDIObjects)
             {
                 allobj.Add(item);
             }
 
-            foreach (CRectangleGDIObject item in m_SampleHoleGDIObjects)
+            foreach (CDisplayGDIObject item in m_SampleHoleGDIObjects)
             {
                 allobj.Add(item);
             }
-            foreach (CRectangleGDIObject item in m_SpecimenGDIObjects)
+            foreach (CDisplayGDIObject item in m_SpecimenGDIObjects)
             {
                 allobj.Add(item);
             }
-            foreach (CRectangleGDIObject item in m_ContentGDIObjects)
+            foreach (CDisplayGDIObject item in m_ContentGDIObjects)
             {
                 allobj.Add(item);
             }

+ 1 - 1
OTSIncAMeasureApp/6-OTSDisplayTreeViewData/OTSSolutionWindow.cs

@@ -730,7 +730,7 @@ namespace OTSMeasureApp
                         e.Handled = true;
                         break;
                 }
-                m_MeasureAppForm.m_SamplepaceWindow.KeyDowns();
+                m_MeasureAppForm.m_SamplepaceWindow.OTSSamplespaceWindow_KeyDown(sender, e);
             }
             catch (Exception)
             {

+ 1 - 1
OTSIncAMeasureApp/OTSIncAMeasureApp.csproj

@@ -541,7 +541,7 @@
       <DependentUpon>ProgMgrInfoForm.cs</DependentUpon>
     </Compile>
     <Compile Include="9-OTSRibbon\OTSRibbonFun.cs" />
-    <Compile Include="4-OTSSamplespaceGraphicsPanel\CreateRectangle.cs" />
+    <Compile Include="4-OTSSamplespaceGraphicsPanel\CDisplayGDIObject.cs" />
     <Compile Include="6-OTSDisplayTreeViewData\OTSDisplayTreeBase.cs" />
     <Compile Include="OTSIncAMeasureAppForm.cs">
       <SubType>Form</SubType>

+ 3 - 5
OTSIncAReportApp/1-UI/Control_Graph/Controls/Control_DrawDistrbutionImageAndBSE.cs

@@ -340,6 +340,7 @@ namespace OTSIncAReportGraph.Controls
 
             ProgressBarUpdate(100, table["str2"].ToString());
             m_frm_userprogress.Visible = false;
+            FullGraphMatch();
         }
 
         private void DrawRuler()
@@ -714,11 +715,7 @@ namespace OTSIncAReportGraph.Controls
                         dp.SetPaintState(PaintState.NOPAINT);//the particles which are out of screen don't display.to speed up the display efficient.
 
                     }
-                    //else
-                    //{
-                    //    dp.SetPaintState(PaintState.PAINT);
-                    //    dp.Zoom(zoomDelta, refPoint);
-                    //}
+                   
                 }
             }
             if (m_list_allDfield != null)
@@ -766,6 +763,7 @@ namespace OTSIncAReportGraph.Controls
             if (m_zoom_record <= m_f_zoom_mix)
             {
                 MoveImageToPoint(new PointF(0, 0));
+                FullGraphMatch();
             }
         }