using OTSDataType; using OTSMeasureApp._4_OTSSamplespaceGraphicsPanel.VisualGDIObjects; using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel { public class CVisualStage { //original data CSEMStageData m_SEMStageData; //interchange object StageDrawingData m_OTSSampleStageData; PointF StageLTPointToSEMLocation = new Point(0, 0); PointF StageRBPointToSEMLocation = new Point(0, 0); float m_VisualStageEdgeLength; float m_OTSCoordStageEdgeLength = 0; int m_totalCtrlWidth; int m_totalCtrlHeight; //记录绘制样品台时的中心位置 PointF m_RegionStartCenterPoint = new PointF(0, 0); //样品台存在的List集合 the rectangle on the edge of stage ,usually one. private List m_StageEdgeGDIObjects; //标样存在的List集合 usually it is a samll circle. private List m_SpecimenGDIObjects; private List m_SampleHoleGDIObjects;// the hole gdi of the stage //文字内容 private List m_ContentGDIObjects;//the text that will display in the hole. private List frameOfHoleGDIObjects;// record all the position of the sampleHole image public List FrameOfHoleGDIObjects { get => frameOfHoleGDIObjects; set => frameOfHoleGDIObjects = value; } public StageDrawingData GetOTSSampleStageData() { return m_OTSSampleStageData; } public void SetOTSSampleStageData(StageDrawingData value) { m_OTSSampleStageData = value; } public CVisualStage(StageDrawingData oTSSampleStageData) { //样品台 m_StageEdgeGDIObjects = new List(); //标样 m_SpecimenGDIObjects = new List(); //样品孔 m_SampleHoleGDIObjects = new List(); //样品孔文字内容 m_ContentGDIObjects = new List(); m_OTSSampleStageData = oTSSampleStageData; frameOfHoleGDIObjects = new List(); } public CVisualStage() { //样品台 m_StageEdgeGDIObjects = new List(); //标样 m_SpecimenGDIObjects = new List(); //样品孔 m_SampleHoleGDIObjects = new List(); //样品孔文字内容 m_ContentGDIObjects = new List(); m_OTSSampleStageData = new StageDrawingData(); frameOfHoleGDIObjects = new List(); } public void clear() { m_StageEdgeGDIObjects.Clear(); m_SpecimenGDIObjects.Clear(); m_SampleHoleGDIObjects.Clear(); m_ContentGDIObjects.Clear(); } public CDisplayGDIObject GetEdgeGDIObj() { return m_StageEdgeGDIObjects[0]; } public float GetZoomNum() { return m_StageEdgeGDIObjects[0].GetZoomNumber(); } public PointF GetDisplayRefPoint() { return m_StageEdgeGDIObjects[0].GetDisplayRefPoint(); } public CDisplayGDIObject GetHoleGDIBySampleName(string name) { foreach (var g in m_SampleHoleGDIObjects) { if (g.SampleName == name) { return g; } } return null; } public CDisplayGDIObject GetHoleGDIByHoleName(string name) { foreach (var g in m_SampleHoleGDIObjects) { if (g.HoleNo == name) { return g; } } return null; } public CDisplayGDIObject GetHoleGDIByMousePoint(Point mousePoint) { foreach (var g in m_SampleHoleGDIObjects) { if (g.IfZoomContains(mousePoint)) { return g; } } return null; } public void cleargdiobj() { m_StageEdgeGDIObjects.Clear(); m_SpecimenGDIObjects.Clear(); m_SampleHoleGDIObjects.Clear(); m_ContentGDIObjects.Clear(); } public void InitSampleStageData(CStage SStage, CSEMStageData SEMStageData, int ctrlWidth, int ctrlHeight) { //获取样品台信息 if (null == SStage) { return; } m_SEMStageData = SEMStageData; //获得样品台数据 GetOTSSampleStageData().sStageName = SStage.GetName(); GetOTSSampleStageData().bStageShape = (ShapeType)SStage.GetBoundary().GetShape(); GetOTSSampleStageData().StageDomain = SStage.GetBoundary().GetRectDomain(); GetOTSSampleStageData().bSampleShape = (ShapeType)SStage.GetSTD().GetShape(); GetOTSSampleStageData().SampleRect = SStage.GetSTD().GetRectDomain(); int iSHoleCount = SStage.GetHoleList().Count; //样品孔个数 if (GetOTSSampleStageData().sSHoleInfoList.Count > 0) { GetOTSSampleStageData().sSHoleInfoList.Clear(); } var holeLst = SStage.GetHoleList(); for (int i = 0; i < iSHoleCount; i++) { CHole d = holeLst[i]; SampleHolePara SHoleInfo = new SampleHolePara(); //获取样品口的名称,形状,坐标 SHoleInfo.sHoleName = d.GetName(); SHoleInfo.iShape = (ShapeType)d.GetShape(); RectangleF r = d.GetRectDomain(); SHoleInfo.SampleHoleRect = r; GetOTSSampleStageData().sSHoleInfoList.Add(SHoleInfo); } //获取SEMData 绘制样品 GetOTSSampleStageData().iScanFieldSize100 = SEMStageData.GetScanFieldSize100(); //放大倍数为100倍时的屏幕尺寸 GetOTSSampleStageData().iXAxisDir = (int)SEMStageData.GetXAxisDir(); GetOTSSampleStageData().iYAxisDir = (int)SEMStageData.GetYAxisDir(); GetOTSSampleStageData().iXAxisStartVal = SEMStageData.GetXAxis().GetStart(); GetOTSSampleStageData().iXAxisEndVal = SEMStageData.GetXAxis().GetEnd(); GetOTSSampleStageData().iYAxisStartVal = SEMStageData.GetYAxis().GetStart(); GetOTSSampleStageData().iYAxisEndVal = SEMStageData.GetYAxis().GetEnd(); PointF xDomain = new PointF(GetOTSSampleStageData().StageDomain.Left, GetOTSSampleStageData().StageDomain.Top); PointF yDomain = new PointF(GetOTSSampleStageData().StageDomain.Right, GetOTSSampleStageData().StageDomain.Bottom); //OTS宽度高度差值 float widthDomain = Math.Abs(yDomain.X - xDomain.X); //设置样品台宽度 m_OTSCoordStageEdgeLength = widthDomain;//the stage must be a square.So we can only memorize an edge length.this is millimeter usually. m_VisualStageEdgeLength = ctrlHeight > ctrlWidth ? ctrlWidth : ctrlHeight;//the stage must be a square.So we can memorize an edge length only. //记录添加帧图的尺寸 鼠标滚动时使用的原值 m_totalCtrlWidth = ctrlWidth; m_totalCtrlHeight = ctrlHeight; return; } public PointF GetCenterPointF() { var item = m_StageEdgeGDIObjects[0].GetZoomedRegionF(); //声明中心点变量 PointF pCenterPoint = new Point(); //获取在工作窗口中X,Y位置 pCenterPoint.X = item.X + item.Width / 2; pCenterPoint.Y = item.Y + item.Height / 2; return pCenterPoint; } public PointF GetCenterPoint() { return m_StageEdgeGDIObjects[0].GetCenterPoint(); //声明中心点变量 } public void DrawSampleStage() { StageDrawingData SData = GetOTSSampleStageData(); try { if (SData.StageDomain.X == 0 && SData.StageDomain.Y == 0) { return; } string stageName = SData.sStageName; //获取样品台 ShapeType StageShape = SData.bStageShape; PointF stageLeftTop = new PointF(SData.StageDomain.Left, SData.StageDomain.Top); PointF stageRightBottom = new PointF(SData.StageDomain.Right, SData.StageDomain.Bottom); m_SEMStageData.ConvertSEMToOTSCoord(stageLeftTop, ref StageLTPointToSEMLocation); m_SEMStageData.ConvertSEMToOTSCoord(stageRightBottom, ref StageRBPointToSEMLocation); RectangleF Bourary; Bourary = GetCtrlCoordRectF(stageLeftTop, stageRightBottom); CDisplayGDIObject CreateBourary; //0:圆角矩形 1:圆形 2:文字 3:矩形 if (SData.bStageShape == ShapeType.RECTANGLE) { CreateBourary = new CDisplayGDIObject(Bourary, GDIType.StageBoundary_RoundedRectangle); } else { CreateBourary = new CDisplayGDIObject(Bourary, GDIType.Circle); } m_StageEdgeGDIObjects.Add(CreateBourary); //绘制后的样品台中心位置 PointF m_Region = GetCenterPoint(); //获取绘制后的样品台中心位置 if (m_RegionStartCenterPoint.X != m_Region.X || m_RegionStartCenterPoint.Y != m_Region.Y) { m_RegionStartCenterPoint = m_Region; } //获取样品孔 System.Collections.Generic.List ChloeClrList = SData.sSHoleInfoList; if (ChloeClrList.Count > 0) { for (int i = 0; i < ChloeClrList.Count; i++) { //获取微米信息 var xHole = new PointF(ChloeClrList[i].SampleHoleRect.Left, ChloeClrList[i].SampleHoleRect.Top); var yHole = new PointF(ChloeClrList[i].SampleHoleRect.Right, ChloeClrList[i].SampleHoleRect.Bottom); //将微米转换为像素 float widthHole = Math.Abs(yHole.X - xHole.X); float heightHole = Math.Abs(yHole.Y - xHole.Y); var RecF = GetCtrlCoordRectF(xHole, yHole); //获取矩形 CDisplayGDIObject CreateHole = null; //0:圆角矩形 1:圆形 2:文字 3:矩形 if (ChloeClrList[i].iShape == ShapeType.RECTANGLE) { CreateHole = new CDisplayGDIObject(RecF, GDIType.Rectangle); } else { CreateHole = new CDisplayGDIObject(RecF, GDIType.Circle); } CreateHole.HoleNo = ChloeClrList[i].sHoleName; m_SampleHoleGDIObjects.Add(CreateHole); //添加文字 CDisplayGDIObject CreateContent = GetCtrlCoordGDI(xHole, yHole, GDIType.Rectangle, "", ""); //类型 文字:2 CreateContent.GDIType = GDIType.Text; CreateContent.SetInitRegionF(CreateContent.GetZoomedRegionF()); CreateContent.strContent = ChloeClrList[i].sHoleName; CreateContent.HoleNo = ChloeClrList[i].sHoleName; m_ContentGDIObjects.Add(CreateContent); } } //获取标样 ShapeType StageShapes = SData.bStageShape; stageLeftTop = new PointF(SData.SampleRect.Left, SData.SampleRect.Top); stageRightBottom = new PointF(SData.SampleRect.Right, SData.SampleRect.Bottom); //获取矩形 CDisplayGDIObject CreateSTD; GDIType gt = ConvertShapeTypeToGDIType(StageShapes); if (gt == GDIType.Circle) { CreateSTD = GetCtrlCoordGDI(stageLeftTop, stageRightBottom, GDIType.SpecimenCircle, "", ""); } else { CreateSTD = GetCtrlCoordGDI(stageLeftTop, stageRightBottom, GDIType.SpecimenRectangle, "", ""); } m_SpecimenGDIObjects.Add(CreateSTD); return; } catch (Exception ex) { NLog.LogManager.GetCurrentClassLogger().Error(ex.ToString()); } } public CDisplayGDIObject GetCtrlCoordGDI(PointF OTSLeftTop, PointF OTSRightBottom, GDIType type, string content, string name) { //将微米信息 转换为 像素 PointF xPoints = new Point(); PointF yPoints = new Point(); xPoints.X = (float)MicronConvertToPixel(OTSLeftTop.X); xPoints.Y = (float)MicronConvertToPixel(OTSLeftTop.Y); yPoints.X = (float)MicronConvertToPixel(OTSRightBottom.X); yPoints.Y = (float)MicronConvertToPixel(OTSRightBottom.Y); //计算位置 xPoints = (PointF)CalculateLocationF(xPoints); yPoints = CalculateLocationF(yPoints); //获取图形四个点 float realStartX = Math.Min(xPoints.X, yPoints.X); float realStartY = Math.Min(xPoints.Y, yPoints.Y); float realEndX = Math.Max(xPoints.X, yPoints.X); float realEndY = Math.Max(xPoints.Y, yPoints.Y); //创建矩形 并返回类型对象 return new CDisplayGDIObject(realStartX, realStartY, realEndX - Math.Abs(realStartX), realEndY - Math.Abs(realStartY), type, content, name); } public RectangleF GetCtrlCoordRectF(PointF OTSLeftTop, PointF OTSRightBottom) { try { //将微米信息 转换为 像素 PointF leftTop = new PointF(); PointF rightBottom = new PointF(); leftTop.X = (float)MicronConvertToPixel(OTSLeftTop.X); leftTop.Y = (float)MicronConvertToPixel(OTSLeftTop.Y); rightBottom.X = (float)MicronConvertToPixel(OTSRightBottom.X); rightBottom.Y = (float)MicronConvertToPixel(OTSRightBottom.Y); //计算位置 leftTop = CalculateLocationF(leftTop); rightBottom = CalculateLocationF(rightBottom); //获取图形四个点 float realStartX = Math.Min(leftTop.X, rightBottom.X); float realStartY = Math.Min(leftTop.Y, rightBottom.Y); float realEndX = Math.Max(leftTop.X, rightBottom.X); float realEndY = Math.Max(leftTop.Y, rightBottom.Y); //创建矩形 并返回类型对象 return new RectangleF(realStartX, realStartY, realEndX - Math.Abs(realStartX), realEndY - Math.Abs(realStartY)); } catch (Exception) { return new RectangleF(); } } private PointF CalculateLocationF(PointF point) { //获取窗体的高度与宽度 float ctrlWidth = m_totalCtrlWidth; float ctrlHeight = m_totalCtrlHeight; //获取屏幕中心点 PointF pointXY = new PointF(); PointF screenPoint = new PointF(ctrlWidth / 2, ctrlHeight / 2); pointXY.X = screenPoint.X + point.X; pointXY.Y = screenPoint.Y - point.Y;//using minus because the coordinate system defference of OTS system and control system. return pointXY; } public double MicronConvertToPixel(double PointVal) { var v = m_VisualStageEdgeLength; return PointVal / ((double)m_OTSCoordStageEdgeLength / v); } public PointF OTSCoordToCtrlCoord(PointF point) { var x = MicronConvertToPixel(point.X); var y = MicronConvertToPixel(point.Y); return CalculateLocationF(new PointF((float)x, (float)y)); } public PointF CtrlCoordToOTSCoord(PointF point) { var ctrlcenter = m_StageEdgeGDIObjects[0].GetCenterPoint(); var x = PixelConvertToMicron(point.X - ctrlcenter.X); var y = PixelConvertToMicron(-(point.Y - ctrlcenter.Y)); return new PointF(x, y); } public RectangleF GetOTSCoordRegionF(PointF ctrlLeftTop, PointF ctrlRightBottom) { try { var ctrlcenter = m_StageEdgeGDIObjects[0].GetCenterPoint(); //将微米信息 转换为 像素 PointF leftTop = new PointF(); PointF rightBottom = new PointF(); leftTop.X = (float)PixelConvertToMicron(ctrlLeftTop.X - ctrlcenter.X); leftTop.Y = (float)PixelConvertToMicron((ctrlLeftTop.Y - ctrlcenter.Y)); rightBottom.X = (float)PixelConvertToMicron(ctrlRightBottom.X - ctrlcenter.X); rightBottom.Y = (float)PixelConvertToMicron((ctrlRightBottom.Y - ctrlcenter.Y)); //获取OTS图形四个点 float realStartX = Math.Min(leftTop.X, rightBottom.X); float realStartY = Math.Min(leftTop.Y, rightBottom.Y); float realEndX = Math.Max(leftTop.X, rightBottom.X); float realEndY = Math.Max(leftTop.Y, rightBottom.Y); //创建矩形 并返回类型对象 return new RectangleF(realStartX, -realEndY, realEndX - realStartX, realEndY - realStartY); } catch (Exception) { return new RectangleF(); } } public float PixelConvertToMicron(float Pixel) { return (float)(Pixel * ((double)m_OTSCoordStageEdgeLength / m_VisualStageEdgeLength)); } internal void DecreaseSampleCount(string sampleName) { foreach (var hole in m_SampleHoleGDIObjects) { if (hole.SampleName == sampleName) { hole.SampleCount -= 1; } } } public CDisplayGDIObject GetSampleHoleGdiobjByName(string holeName) { foreach (var hole in m_SampleHoleGDIObjects) { if (hole.HoleNo == holeName) { return hole; } } return null; } public bool GetVisualSampleArea(SampleMeasurePara SMeasurePara, out CVisualSampleArea a_visualSample) { //设置样品选择状态为非工作样品 string SampleHoleName = SMeasurePara.sampleHoleName; var item = GetSampleHoleGdiobjByName(SampleHoleName); if (item != null) { //设置颜色 Color selColor = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.SampleSelColor); //累加样品数量 item.SampleCount += 1; item.IsWorkSample = true; CDisplayGDIObject sampleGDIObject = item.Duplicate(); sampleGDIObject.sampleName = SMeasurePara.sSampleName; sampleGDIObject.SelColor = selColor; //add the default measure area from config file. CMeasureArea newMeasureGDIObject; PointF xHole = new PointF(SMeasurePara.MeasureRect.Left, SMeasurePara.MeasureRect.Top); PointF yHole = new PointF(SMeasurePara.MeasureRect.Right, SMeasurePara.MeasureRect.Bottom); RectangleF SampleRectangleF = GetCtrlCoordRectF(xHole, yHole); GetMeasureGdiObject(sampleGDIObject, SMeasurePara.iShape, SampleRectangleF, out newMeasureGDIObject); var newsample = new CVisualSampleArea(); newsample.SetSampleGDIObject(sampleGDIObject); newsample.SetMeasureGDIObject(newMeasureGDIObject); a_visualSample = newsample; return true; } a_visualSample = null; return false; } #region 根据样品位置 获取测量区域位置 public SampleMeasurePara GetSampleMeasurePara(CMeasureArea MeasureItem) { var item = MeasureItem; SampleMeasurePara sampleMeasurePara = new SampleMeasurePara(); var region = this.GetOTSCoordRegionF(item.GetOrigionalDrawRegionF().Location, new PointF(item.GetOrigionalDrawRegionF().Right, item.GetOrigionalDrawRegionF().Bottom)); sampleMeasurePara.MeasureRect = region; //设置样品孔名称 sampleMeasurePara.sampleHoleName = item.HoleNo; //设置样品名称 sampleMeasurePara.sSampleName = item.SampleName; //设置测量区域形状 sampleMeasurePara.iShape = item.Myshape; sampleMeasurePara.DrawPolygonPointList = ConvertPolygonPointToOTSPoint(item.GetOriginalPolygonPointFList()); sampleMeasurePara.sSampleName = MeasureItem.SampleName; sampleMeasurePara.sampleHoleName = MeasureItem.HoleNo; return sampleMeasurePara; } public List ConvertPolygonPointToOTSPoint(List polygonPointList) { List OTSPoint = new List(); if (polygonPointList != null) { foreach (var item in polygonPointList) { OTSPoint.Add(CtrlCoordToOTSCoord(item)); } } return OTSPoint; } public List PointFConvertPoint(List Points) { List PointFs = new List(); if (Points != null) { foreach (var itemPoint in Points) { PointFs.Add(new Point((int)itemPoint.X, (int)itemPoint.Y)); } } return PointFs; } public PointF[] PointConvertPointF(Point[] Points) { PointF[] PointFs = new PointF[Points.Length]; if (Points != null) { for (int i = 0; i < Points.Length; i++) { PointFs[i] = Points[i]; } } return PointFs; } public List PointConvertPointF(List Points) { List PointFs = new List(); if (Points != null) { foreach (var itemPoint in Points) { PointFs.Add(itemPoint); } } return PointFs; } #endregion #region 添加测量 public bool GetMeasureGdiObject(CDisplayGDIObject sampleGDIObject, ShapeType newShape, RectangleF newRegion, out CMeasureArea outMeasureRect) { CMeasureArea r = new CMeasureArea(); r.HoleNo = sampleGDIObject.HoleNo; r.SampleName = sampleGDIObject.SampleName; r.SetInitRegionF(sampleGDIObject.GetOrigionalDrawRegionF()); r.IsWorkSample = sampleGDIObject.IsWorkSample; r.SetZoomedRegionF(sampleGDIObject.GetZoomedRegionF()); r.SetDisplayRefPoint(this.GetDisplayRefPoint()); r.SetZoomNumber(sampleGDIObject.GetZoomNumber()); r.SetInitRegionF(newRegion); r.Myshape = newShape; r.SelColor = Color.Red; outMeasureRect = r; return true; } public bool GetMeasureGdiObjectFromSampleGdi(CDisplayGDIObject sampleGDIObject, out CMeasureArea outMeasureRect) { CMeasureArea r = new CMeasureArea(); r.HoleNo = sampleGDIObject.HoleNo; r.SampleName = sampleGDIObject.SampleName; r.SetInitRegionF(sampleGDIObject.GetOrigionalDrawRegionF()); r.IsWorkSample = sampleGDIObject.IsWorkSample; r.SetZoomedRegionF(sampleGDIObject.GetZoomedRegionF()); r.SetDisplayRefPoint(this.GetDisplayRefPoint()); r.SetZoomNumber(sampleGDIObject.GetZoomNumber()); r.Myshape=ConvertGDITypeToShapeType(sampleGDIObject.GDIType); r.SelColor = Color.Red; outMeasureRect = r; return true; } public GDIType ConvertShapeTypeToGDIType(ShapeType shape) { GDIType t; switch (shape) { case ShapeType.CIRCLE: t = GDIType.Circle; break; case ShapeType.RECTANGLE: t = GDIType.Rectangle; break; default: t = GDIType.Rectangle; break; } return t; } public ShapeType ConvertGDITypeToShapeType(GDIType t) { ShapeType s; switch (t) { case GDIType.Circle: s = ShapeType.CIRCLE; break; case GDIType.Rectangle: s = ShapeType.RECTANGLE; break; default: s = ShapeType.RECTANGLE; break; } return s; } #endregion public bool CheckMeasureAreaIsBeyondStageArea(RectangleF RMeasureArea) { otsdataconst.DOMAIN_SHAPE iShape = (otsdataconst.DOMAIN_SHAPE)ConvertGDITypeToShapeType( m_StageEdgeGDIObjects[0].GDIType); RectangleF pStageArea = m_StageEdgeGDIObjects[0].GetZoomedRegion; Rectangle pMeasureArea = new Rectangle((int)RMeasureArea.Left, (int)RMeasureArea.Top, (int)RMeasureArea.Width, (int)RMeasureArea.Height); CDomain a_DomainMeasureArea = new CDomain((otsdataconst.DOMAIN_SHAPE)iShape, pMeasureArea); CDomain a_DomainStageArea = new CDomain((otsdataconst.DOMAIN_SHAPE)iShape, pStageArea); return a_DomainStageArea.DomainInDomain(a_DomainMeasureArea); } public void ShowSemCoordvAL(Point mPoint, OTSIncAMeasureAppForm m_MeasureAppForm) { //鼠标在样品台中移动获取坐标 Point mousePoint = GetMouseOTSLocation(mPoint); PointF SEMPoint = new Point(); m_SEMStageData.ConvertOTSToSEMCoord(mousePoint, ref SEMPoint); //将微米转换为毫米 float mousePointX = Convert.ToSingle((SEMPoint.X / 1000).ToString("F2")); float mousePointY = Convert.ToSingle((SEMPoint.Y / 1000).ToString("F2")); //将样品台坐标转换为Sem 坐标 //编辑显示内容 string STSemCoordinate = "X:" + mousePointX + "|Y:" + mousePointY + ""; //显示XY轴 m_MeasureAppForm.ShowSemCoordvAL(STSemCoordinate); } public Point GetMouseOTSLocation(Point mousePoint) { var offsetX = mousePoint.X - this.GetDisplayRefPoint().X; var offsetY = mousePoint.Y - this.GetDisplayRefPoint().Y; PointF ctrlPoint = new PointF(offsetX / this.GetZoomNum(), offsetY / this.GetZoomNum()); PointF otsPoint = this.CtrlCoordToOTSCoord(ctrlPoint); Point OTSMousePosition = new Point(Convert.ToInt32(Math.Round(otsPoint.X, 0)), Convert.ToInt32(Math.Round(otsPoint.Y, 0))); return OTSMousePosition; } public bool IfMouseInSampleHole(Point mousePoint, out CDisplayGDIObject gdiItem) { foreach (CDisplayGDIObject item in m_SampleHoleGDIObjects) { if (item.IfZoomContains(mousePoint)) { gdiItem = item; return true; ; } } gdiItem = null; return false; } public bool IfMouseInStage(Point mousePoint, out CDisplayGDIObject gdiobj) { foreach (CDisplayGDIObject item in m_StageEdgeGDIObjects) { if (item.IfZoomContains(mousePoint)) { gdiobj = item; return true; } } gdiobj = null; return false; } public bool IfMouseInStage(Point mousePoint) { foreach (CDisplayGDIObject item in m_StageEdgeGDIObjects) { if (item.IfZoomContains(mousePoint)) { return true; } } return false; } public void OnMouseMove(MouseEventArgs e) { foreach (CDisplayGDIObject item in m_ContentGDIObjects) { item.IsDragging = true; item.DraggingPoint = e.Location; } foreach (CDisplayGDIObject item in m_SampleHoleGDIObjects) { item.IsDragging = true; item.DraggingPoint = e.Location; } foreach (CDisplayGDIObject item in m_SpecimenGDIObjects) { item.IsDragging = true; item.DraggingPoint = e.Location; } } public List GetAllGDIObject() { var allobj = new List(); foreach (CDisplayGDIObject item in m_StageEdgeGDIObjects) { allobj.Add(item); } foreach (CDisplayGDIObject item in m_SampleHoleGDIObjects) { allobj.Add(item); } foreach (CDisplayGDIObject item in m_SpecimenGDIObjects) { allobj.Add(item); } foreach (CDisplayGDIObject item in m_ContentGDIObjects) { allobj.Add(item); } return allobj; } public PointF GetCenterPoint(RectangleF rect) { //声明 PointF centerPoint = new PointF(); //设置X,Y坐标 centerPoint.X = rect.X + rect.Width / 2; centerPoint.Y = rect.Y + rect.Height / 2; return centerPoint; } } }