| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673 | using OTSCLRINTERFACE;using OTSDataType;using OTSSysMgrTools;using System;using System.Collections;using System.Collections.Generic;using System.Drawing;using System.Drawing.Drawing2D;using System.Windows.Forms;namespace OTSMeasureApp{    public class OTSSamplespaceGraphicsPanelFun    {        #region 构造方法        public OTSSamplespaceGraphicsPanelFun()        {                    }        #endregion               #region 鼠标在样品台中移动获取坐标        /// <summary>        /// 鼠标在样品台中移动获取坐标        /// </summary>        public static Point GetMouseLocationInRectangleGDIObject(Point mousePoint, ARectangleGDIObject RectangleGDIObjects, StageDrawingData oTSSampleStageData, int IsWidth, int Width, int Height)        {            if (RectangleGDIObjects.Region.Contains(mousePoint))            {                Point rectLocation = RectangleGDIObjects.Region.Location;                //样品台尺寸                Size rectSize = RectangleGDIObjects.Region.Size;                //鼠标在工作区域中的位置                string x = mousePoint.X.ToString();                string Y = mousePoint.Y.ToString();                //样品台起始位置c                string rectLocationX = rectLocation.X.ToString();                string rectLocationY = rectLocation.Y.ToString();                //OTS中心点                string rectLocationCenterX = (rectLocation.X + rectSize.Width / 2).ToString();                string rectLocationCenterY = (rectLocation.Y + rectSize.Height / 2).ToString();                //OTS坐标中鼠标的位置                int OTSX = -((rectLocation.X + rectSize.Width / 2) - mousePoint.X);                int OTSY = -(mousePoint.Y - (rectLocation.Y + rectSize.Height / 2));                //OTS坐标中鼠标的尺寸位置                double OTSWidth = 0;                double OTSHeight = 0;                if (oTSSampleStageData != null)                {                    //获取样品台两个坐标点                    ValueType XDomain = new Point(oTSSampleStageData.StageDomain.Left, oTSSampleStageData.StageDomain.Top);                    ValueType YDomain = new Point(oTSSampleStageData.StageDomain.Right, oTSSampleStageData.StageDomain.Bottom);                    //转换类型                    Point xDomain = ((System.Drawing.Point)XDomain);                    Point yDomain = ((System.Drawing.Point)YDomain);                    //宽度                    int widthDomain = Math.Abs(((Point)yDomain).X - ((Point)xDomain).X);                    int heightDomain = Math.Abs(((Point)yDomain).Y - ((Point)xDomain).Y);                    //换算鼠标在OTS坐标中的位置                    OTSWidth = (OTSX * ((double)widthDomain / (IsWidth == 0 ? (double)Width : (double)Height)));                    OTSHeight = (OTSY * ((double)widthDomain / (IsWidth == 0 ? (double)Width : (double)Height)));                }                Point OTSMousePosition = new Point(Convert.ToInt32(OTSWidth), Convert.ToInt32(OTSHeight));                return OTSMousePosition;            }            return new Point(0, 0);        }        public static int PixelConvertToMicrons(int Pixel, int widthDomain, int length)        {            return Convert.ToInt32((Pixel * ((double)widthDomain / length)));        }        public static float PixelConvertToMicron(int Pixel, int widthDomain, int length)        {            return (float)(Pixel * ((double)widthDomain / length));        }        public static Point GetGDIObjects(Point mousePoint, ARectangleGDIObject RectangleGDIObjects, StageDrawingData oTSSampleStageData, int IsWidth, int Width, int Height)        {            Point rectLocation = RectangleGDIObjects.Region.Location;            //样品台尺寸            Size rectSize = RectangleGDIObjects.Region.Size;            //鼠标在工作区域中的位置            string x = mousePoint.X.ToString();            string Y = mousePoint.Y.ToString();            //样品台起始位置            string rectLocationX = rectLocation.X.ToString();            string rectLocationY = rectLocation.Y.ToString();            //OTS中心点            string rectLocationCenterX = (rectLocation.X + rectSize.Width / 2).ToString();            string rectLocationCenterY = (rectLocation.Y + rectSize.Height / 2).ToString();            //OTS坐标中鼠标的位置            int OTSX = -((rectLocation.X + rectSize.Width / 2) - mousePoint.X);            int OTSY = -(mousePoint.Y - (rectLocation.Y + rectSize.Height / 2));            //OTS坐标中鼠标的尺寸位置            int OTSWidth = 0;            int OTSHeight = 0;            if (oTSSampleStageData != null)            {                //获取样品台两个坐标点                ValueType XDomain = new Point(oTSSampleStageData.StageDomain.Left, oTSSampleStageData.StageDomain.Top);                ValueType YDomain = new Point(oTSSampleStageData.StageDomain.Right, oTSSampleStageData.StageDomain.Bottom);                //转换类型                Point xDomain = ((System.Drawing.Point)XDomain);                Point yDomain = ((System.Drawing.Point)YDomain);                //宽度                int widthDomain = Math.Abs(((Point)yDomain).X - ((Point)xDomain).X);                int heightDomain = Math.Abs(((Point)yDomain).Y - ((Point)xDomain).Y);                //换算鼠标在OTS坐标中的位置                if (OTSX != 0)                {                    OTSWidth = Convert.ToInt32((OTSX * ((double)widthDomain / (IsWidth == 0 ? (double)Width : (double)Height))));                    OTSHeight = Convert.ToInt32((OTSY * ((double)widthDomain / (IsWidth == 0 ? (double)Width : (double)Height))));                }            }            Point OTSPosition = new Point(0, 0);            //if (OTSWidth > 0 && OTSHeight > 0)            //{            OTSPosition = new Point(Convert.ToInt32(OTSWidth), Convert.ToInt32(OTSHeight));            //}            return OTSPosition;        }              #region 测量区域与样品中心相差的距离        /// <summary>        /// 测量区域与样品中心相差的距离        /// </summary>        /// <param name="MeasureRectangle"></param>        /// <param name="SampleRectangle"></param>        /// <returns></returns>        public static Point GetSampleCenterDifferCenterPoint(Rectangle MeasureRectangle, Rectangle SampleRectangle)        {            Point DifferCenterPoint = new Point();            //获取测量区域与样品相差中心点距离            DifferCenterPoint.X = (MeasureRectangle.X + MeasureRectangle.Width / 2) - (SampleRectangle.X + SampleRectangle.Width / 2);            DifferCenterPoint.Y = (MeasureRectangle.Y + MeasureRectangle.Height / 2) - (SampleRectangle.Y + SampleRectangle.Height / 2);            return DifferCenterPoint;        }        #endregion        #endregion        #region 处理方法总汇        #region 获取中心点        public static Point GetCenterPoint(ARectangleGDIObject item)        {            //声明中心点变量            Point pCenterPoint = new Point();            //获取在工作窗口中X,Y位置            pCenterPoint.X = (int)(item.Region.X + item.Region.Width / 2);            pCenterPoint.Y = (int)(item.Region.Y + item.Region.Height / 2);            return pCenterPoint;        }        public static Point GetCenterPoint(Rectangle item)        {            //声明中心点变量            Point pCenterPoint = new Point();            //获取在工作窗口中X,Y位置            pCenterPoint.X = item.X + item.Width / 2;            pCenterPoint.Y = item.Y + item.Height / 2;            return pCenterPoint;        }        public static PointF GetCenterPointF(RectangleF item)        {            //声明中心点变量            PointF pCenterPoint = new Point();            //获取在工作窗口中X,Y位置            pCenterPoint.X = item.X + item.Width / 2;            pCenterPoint.Y = item.Y + item.Height / 2;            return pCenterPoint;        }        #endregion        #region 鼠标移动位置        public static ARectangleGDIObject GetMouseMoveLocation(ARectangleGDIObject item, MouseEventArgs e)        {            item.Region = new Rectangle(                                       item.Region.Left + e.X - item.DraggingPoint.X,                                       item.Region.Top + e.Y - item.DraggingPoint.Y,                                       item.Region.Width,                                       item.Region.Height);            item.DraggingPoint = e.Location;            return item;        }        #endregion        #region 绘制帧图方法        public static void DrawSingleImage(List<ARectangleGDIObject> m_SingleGDIObjects)        {            foreach (var item in m_SingleGDIObjects)            {                m_SingleGDIObjects.Add(item);            }        }        #endregion        #region 获取工作区域中心点        public static Point GetWorkAreaCenterPoint(Rectangle rect)        {            //声明            Point centerPoint = new Point();            //设置X,Y坐标            centerPoint.X = rect.X + rect.Width / 2;            centerPoint.Y = rect.Y + rect.Height / 2;            return centerPoint;        }        #endregion        #endregion        #region 鼠标方法操作        public static void MouseWheelFunction(List<ARectangleGDIObject> objList, ARectangleGDIObject m_RectangleGDIObjects, float globalZoomNum)        {            for (int i = 0; i < objList.Count; i++)            {                //多边形测量区域鼠标缩放                if (objList[i].Shape == (int)CreateRectangleType.Polygon)                {                    if (objList[i].DrawPolygonPointRegionF != null)                    {                        int polygonPointCount = objList[i].DrawPolygonPointRegionF.Count;                        if (polygonPointCount > 0)                        {                            for (int pointIndex = 0; pointIndex < polygonPointCount; pointIndex++)                            {                                PointF wheelPoint = new PointF();                                wheelPoint = objList[i].DrawPolygonPointRegionF[pointIndex];                                float X = wheelPoint.X * globalZoomNum;                                float Y = wheelPoint.Y * globalZoomNum;                                objList[i].PolygonPointRegionF[pointIndex] = new PointF(wheelPoint.X * globalZoomNum, wheelPoint.Y * globalZoomNum);                            }                        }                    }                }                //else                //{                    RectangleF rectF = new RectangleF();                    rectF = objList[i].RegionF;                    //根据样品孔中心点与样品台中心点的方向 设置宽度与高度\                    RectangleF returnRectF = OTSSamplespaceGraphicsPanelFun.MouseWheelFunctionF(m_RectangleGDIObjects, rectF, globalZoomNum);                    objList[i].Region = new Rectangle((int)returnRectF.X, (int)returnRectF.Y, (int)returnRectF.Width, (int)returnRectF.Height);                    objList[i].BSEImageWitdh = returnRectF.Width;                    objList[i].BSEImageHeight = returnRectF.Height;                    objList[i].BSEImageLocation = new PointF(returnRectF.X, returnRectF.Y);                    objList[i].SEMCenterPoint = returnRectF.Location;                    //重新绘制测量区域路径                    UpdateMeasureGraphicsPath(objList[i], objList[i].Region);                //}            }        }        public static RectangleF MouseWheelFunctionF(ARectangleGDIObject RectangleGDIObject, RectangleF itemRect, float globalZoomNum)        {            //缩放比例            float X = itemRect.X * globalZoomNum;            float Y = itemRect.Y * globalZoomNum;            float Width = itemRect.Width * globalZoomNum;            float Height = itemRect.Height * globalZoomNum;            return new RectangleF(X, Y, Width, Height);        }        public enum EnumMousePointPosition        {            MouseSizeNone = 0, //'无              MouseSizeRight = 1, //'拉伸右边框              MouseSizeLeft = 2, //'拉伸左边框              MouseSizeBottom = 3, //'拉伸下边框              MouseSizeTop = 4, //'拉伸上边框              MouseSizeTopLeft = 5, //'拉伸左上角              MouseSizeTopRight = 6, //'拉伸右上角              MouseSizeBottomLeft = 7, //'拉伸左下角              MouseSizeBottomRight = 8, //'拉伸右下角              MouseDrag = 9   // '鼠标拖动          }        const int Band = 5;        public static EnumMousePointPosition MousePointPosition(Size size, Point e)        {            if ((e.X >= -1 * Band) | (e.X <= size.Width) | (e.Y >= -1 * Band) | (e.Y <= size.Height))            {                if (e.X < Band)                {                    if (e.Y < Band) { return EnumMousePointPosition.MouseSizeTopLeft; }                    else                    {                        if (e.Y > -1 * Band + size.Height)                        { return EnumMousePointPosition.MouseSizeBottomLeft; }                        else                        { return EnumMousePointPosition.MouseSizeLeft; }                    }                }                else                {                    if (e.X > -1 * Band + size.Width)                    {                        if (e.Y < Band)                        { return EnumMousePointPosition.MouseSizeTopRight; }                        else                        {                            if (e.Y > -1 * Band + size.Height)                            { return EnumMousePointPosition.MouseSizeBottomRight; }                            else                            { return EnumMousePointPosition.MouseSizeRight; }                        }                    }                    else                    {                        if (e.Y < Band)                        { return EnumMousePointPosition.MouseSizeTop; }                        else                        {                            if (e.Y > -1 * Band + size.Height)                            { return EnumMousePointPosition.MouseSizeBottom; }                            else                            { return EnumMousePointPosition.MouseDrag; }                        }                    }                }            }            else            { return EnumMousePointPosition.MouseSizeNone; }        }        public static EnumMousePointPosition MousePointPosition(Point point, Point e)        {            //MouseDrag 中心            if ((e.X == point.X) && (e.Y == point.Y))            {                return EnumMousePointPosition.MouseDrag;            }            //MouseSizeTopLeft 上左            if ((e.X < point.X) && (e.Y < point.Y))            {                return EnumMousePointPosition.MouseSizeTopLeft;            }            //MouseSizeTopRight 下右            if ((e.X > point.X) && (e.Y < point.Y))            {                return EnumMousePointPosition.MouseSizeTopRight;            }            //MouseSizeLeft 左侧            if ((e.X < point.X) && (e.Y == point.Y))            {                return EnumMousePointPosition.MouseSizeLeft;            }            //MouseSizeRight 右侧            if ((e.X > point.X) && (e.Y == point.Y))            {                return EnumMousePointPosition.MouseSizeRight;            }            //MouseSizeTop 上侧            if ((e.X == point.X) && (e.Y < point.Y))            {                return EnumMousePointPosition.MouseSizeTop;            }            //MouseSizeBottom 下侧            if ((e.X == point.X) && (e.Y > point.Y))            {                return EnumMousePointPosition.MouseSizeBottom;            }            //MouseSizeBottomRight 下左            if ((e.X < point.X) && (e.Y > point.Y))            {                return EnumMousePointPosition.MouseSizeBottomLeft;            }            //MouseSizeBottomRight 下右            if ((e.X > point.X) && (e.Y > point.Y))            {                return EnumMousePointPosition.MouseSizeBottomRight;            }            return EnumMousePointPosition.MouseSizeNone;        }        #endregion        #region 切换样品        /// <summary>        /// 切换样品        /// </summary>        /// <param name="objList">样品信息列表</param>        /// <param name="stageName">样品台名称</param>        public static List<ARectangleGDIObject> SelectSampleIndex(List<ARectangleGDIObject> objList, string sampleName)        {            ArrayList listIndex = new ArrayList();            ARectangleGDIObject objItemTemp = null;            objItemTemp = objList[0];            for (int i = 0; i < objList.Count; i++)            {                if (objList[0].Name == sampleName)                {                    listIndex.Add(i);                }            }            for (int x = 0; x < listIndex.Count; x++)            {                for (int y = 0; y < objList.Count; y++)                {                    //将第一个元素放入临时项中                    if (y == Convert.ToInt32(listIndex[0]))                    {                        objItemTemp = objList[0];                    }                    //如果循环至最后一个位置,则将第一个元素复制到最后一个元素位置中                    else if ((y) == Convert.ToInt32(listIndex[listIndex.Count - 1]))                    {                        objList[Convert.ToInt32(listIndex[0])] = objList[y];                        objList[y] = objItemTemp;                        objList[y].IsWorkSample = true;                    }                }            }            return objList;        }        #endregion        #region 根据选择的测量区域 切换至最上层        public static List<ARectangleGDIObject> SelectMeasureIndexIsTop(List<ARectangleGDIObject> objList, string SampleName)        {            List<ARectangleGDIObject> objListTemp = objList;            ARectangleGDIObject itemTemp = null;            foreach (ARectangleGDIObject item in objList)            {                if (item.SampleName == SampleName)                {                    //临时记录所选测量区域                    itemTemp = item;                    //删除原信息                    objListTemp.Remove(item);                    //添加新信息                    objListTemp.Insert(objListTemp.Count, itemTemp);                    break;                }            }            return objListTemp;        }        #endregion        #region 根据选择的样品 切换至最上层        public static List<ARectangleGDIObject> SelectSampleIndexIsTop(List<ARectangleGDIObject> objList, string SampleName)        {            List<ARectangleGDIObject> objListTemp = objList;            ARectangleGDIObject itemTemp = null;            foreach (ARectangleGDIObject item in objList)            {                if (item.SampleName == SampleName)                {                    //临时记录所选样品                    itemTemp = item;                    //删除原信息                    objListTemp.Remove(item);                    //添加新信息                    objListTemp.Insert(objListTemp.Count, itemTemp);                    break;                }            }            return objListTemp;        }        #endregion        #region 获取拍摄BSE图 将byte数组转换为图片        public static Image GetBSEImage(byte[] ImageByte, int width, int height)        {            //图片            Bitmap bitmap = null;            //将byte数据转换为图片            bitmap = Imagepro.ToGrayBitmap(ImageByte, width, height);            return bitmap;        }        #endregion        #region 根据对象点 与 相距的宽度 生成一个矩形        /// <summary>        /// 根据对象点 与 相距的宽度 生成一个矩形        /// </summary>        /// <param name="width"></param>        /// <param name="xPoint"></param>        /// <param name="yPoint"></param>        /// <param name="type">0:圆角矩形 1:圆形 2:文字 3:矩形</param>        /// <returns></returns>        public static CreateRectangle GetPixRect(int width, Point xPoint, Point yPoint, int type, string str, string Name, int IsWidth, int Width, int Height)        {            try            {                //将微米信息 转换为 像素                Point xPoints = new Point();                Point yPoints = new Point();                xPoints.X = (int)MillimetersToPixelsWidth(width, xPoint.X, IsWidth, Width, Height);                xPoints.Y = (int)MillimetersToPixelsWidth(width, xPoint.Y, IsWidth, Width, Height);                yPoints.X = (int)MillimetersToPixelsWidth(width, yPoint.X, IsWidth, Width, Height);                yPoints.Y = (int)MillimetersToPixelsWidth(width, yPoint.Y, IsWidth, Width, Height);                //计算位置                xPoints = CalculateLocation(xPoints, Width, Height);                yPoints = CalculateLocation(yPoints, Width, Height);                //获取图形四个点                int realStartX = Math.Min(xPoints.X, yPoints.X);                int realStartY = Math.Min(xPoints.Y, yPoints.Y);                int realEndX = Math.Max(xPoints.X, yPoints.X);                int realEndY = Math.Max(xPoints.Y, yPoints.Y);                //创建矩形 并返回类型对象                return new CreateRectangle(realStartX, realStartY, realEndX - Math.Abs(realStartX), realEndY - Math.Abs(realStartY), type, str, Name);            }            catch (Exception)            {                return new CreateRectangle(new Rectangle(), 0, "");            }        }        public static Rectangle GetPixRects(int width, Point xPoint, Point yPoint, string sampleName, string sampleHoleName, int IsWidth, int Width, int Height)        {            try            {                //将微米信息 转换为 像素                Point xPoints = new Point();                Point yPoints = new Point();                xPoints.X = (int)MillimetersToPixelsWidth(width, xPoint.X, IsWidth, Width, Height);                xPoints.Y = (int)MillimetersToPixelsWidth(width, xPoint.Y, IsWidth, Width, Height);                yPoints.X = (int)MillimetersToPixelsWidth(width, yPoint.X, IsWidth, Width, Height);                yPoints.Y = (int)MillimetersToPixelsWidth(width, yPoint.Y, IsWidth, Width, Height);                //计算位置                xPoints = CalculateLocation(xPoints, Width, Height);                //yPoints = CalculateLocation(yPoints, Width, Height);                //获取图形四个点                int realStartX = Math.Min(xPoints.X, yPoints.X);                int realStartY = Math.Min(xPoints.Y, yPoints.Y);                int realEndX = Math.Max(xPoints.X, yPoints.X);                int realEndY = Math.Max(xPoints.Y, yPoints.Y);                //float startX = realStartX < 0 ? 0 : realStartX;                //float startY = realStartY < 0 ? 0 : realStartY;                //float endX = realEndX - Math.Abs(realStartX);                //float endY = endX / 4*3;                //xPoint.X = startX;                //xPoint.Y = startY;                //yPoint.X = endX;                //yPoint.Y = endY;                //创建矩形 并返回类型对象                return new Rectangle(xPoints.X, xPoints.Y, yPoints.X, yPoints.Y);                //return new RectangleF(realStartX < 0 ? 0 : realStartX, realStartY < 0 ? 0 : realStartY, realEndX - Math.Abs(realStartX), realEndY - Math.Abs(realStartY));            }            catch (Exception)            {                return new Rectangle();            }        }        public static RectangleF GetPixRectF(int width, Point xPoint, Point yPoint, string sampleName, string sampleHoleName, int IsWidth, int Width, int Height)        {            try            {                //将微米信息 转换为 像素                PointF xPoints = new PointF();                PointF yPoints = new PointF();                xPoints.X = (float)MillimetersToPixelsWidth(width, xPoint.X, IsWidth, Width, Height);                xPoints.Y = (float)MillimetersToPixelsWidth(width, xPoint.Y, IsWidth, Width, Height);                yPoints.X = (float)MillimetersToPixelsWidth(width, yPoint.X, IsWidth, Width, Height);                yPoints.Y = (float)MillimetersToPixelsWidth(width, yPoint.Y, IsWidth, Width, Height);                //计算位置                xPoints = CalculateLocationF(xPoints, Width, Height);                yPoints = CalculateLocationF(yPoints, Width, Height);                //创建矩形 并返回类型对象                return new RectangleF(xPoints.X, xPoints.Y, Math.Abs(yPoints.X - xPoints.X), Math.Abs(yPoints.Y - xPoints.Y));            }            catch (Exception)            {                return new RectangleF();            }        }        public static CreateRectangle GetChangeSizePixRects(int width, Point xPoint, Point yPoint, int type, string sampleName, string sampleHoleName, int IsWidth, int Width, int Height)        {            try            {                //将微米信息 转换为 像素                Point xPoints = new Point();                Point yPoints = new Point();                xPoints.X = (int)MillimetersToPixelsWidth(width, xPoint.X, IsWidth, Width, Height);                xPoints.Y = (int)MillimetersToPixelsWidth(width, xPoint.Y, IsWidth, Width, Height);                yPoints.X = (int)MillimetersToPixelsWidth(width, yPoint.X, IsWidth, Width, Height);                yPoints.Y = (int)MillimetersToPixelsWidth(width, yPoint.Y, IsWidth, Width, Height);                //计算位置                //xPoints = CalculateLocation(xPoints, Width, Height);                //yPoints = CalculateLocation(yPoints, Width, Height);                //获取图形四个点                int realStartX = Math.Min(xPoints.X, yPoints.X);                int realStartY = Math.Min(xPoints.Y, yPoints.Y);                int realEndX = Math.Max(xPoints.X, yPoints.X);                int realEndY = Math.Max(xPoints.Y, yPoints.Y);                //创建矩形 并返回类型对象                return new CreateRectangle(realStartX < 0 ? 0 : realStartX, realStartY < 0 ? 0 : realStartY, realEndX - Math.Abs(realStartX), realEndY - Math.Abs(realStartY), type, "", "");            }            catch (Exception)            {                return new CreateRectangle(new Rectangle(), 0, "");            }        }        public static double MillimetersToPixelsWidth(int width, double PointVal, int IsWidth, int Width, int Height)        {            return PointVal / ((double)width / (IsWidth == 0 ? (double)Width : (double)Height));        }        public static Point CalculateLocation(Point point, int Width, int Height)        {            //获取窗体的高度与宽度            int screenWidth = Width;            int screenHeight = Height;            //获取屏幕中心点            Point pointXY = new Point();            Point screenPoint = new Point(screenWidth / 2, screenHeight / 2);            pointXY.X = screenPoint.X + point.X; //(IsWidth == 0 ? screenPoint.X : screenPoint.Y) + point.X;            pointXY.Y = screenPoint.Y - point.Y;            return pointXY;        }        public static PointF CalculateLocationF(PointF point, int Width, int Height)        {            //获取窗体的高度与宽度            int screenWidth = Width;            int screenHeight = Height;            //获取屏幕中心点            PointF pointXY = new PointF();            PointF screenPoint = new PointF(screenWidth / 2, screenHeight / 2);            pointXY.X = screenPoint.X + point.X; //(IsWidth == 0 ? screenPoint.X : screenPoint.Y) + point.X;            pointXY.Y = screenPoint.Y - point.Y;            return pointXY;        }        #endregion        #region 通过OTS坐标 获取工作区域图形尺寸        public static void GetWorkSpaceSize(Point pStartPoint, Point pEndPoint)        {            int widthDomain = 0;            int heightDomain = 0;            //宽度            widthDomain = Math.Abs(((Point)pStartPoint).X - ((Point)pEndPoint).X);            heightDomain = Math.Abs(((Point)pStartPoint).Y - ((Point)pEndPoint).Y);        }        #endregion        #region 判断是否相同        /// <summary>        /// 判断是否相同        /// </summary>        /// <param name="sampleMeasurePara"></param>        /// <param name="SampleMeasureParaResult"></param>        /// <returns></returns>        public static bool IsValidate(OTSIncAMeasureAppForm m_MeasureAppForm, SampleMeasurePara sampleMeasurePara, SampleMeasurePara SampleMeasureParaResult)        {            try            {                if (sampleMeasurePara.sSampleName != SampleMeasureParaResult.sSampleName)                {                    return false;                }                if (sampleMeasurePara.MeasureRect != SampleMeasureParaResult.MeasureRect)                {                    return false;                }                if (sampleMeasurePara.sHoleName != SampleMeasureParaResult.sHoleName)                {                    return false;                }                return true;            }            catch (Exception)            {                return false;            }        }        #endregion        #region 获取工作样品信息        /// <summary>        /// 获取工作样品信息        /// </summary>        /// <param name="sampleName"></param>        /// <returns></returns>        public static ARectangleGDIObject GetWorkSample(string sampleName)        {            foreach (ARectangleGDIObject itemSample in OTSSamplespaceWindow.m_SampleGDIObjects)            {                if (itemSample.SampleName == sampleName)                {                    return itemSample;                }            }            return null;        }        #endregion        #region 获取测量区域        /// <summary>        /// 获取测量区域        /// </summary>        /// <param name="m_MeasureAppForm"></param>        /// <param name="sampleName"></param>        /// <returns></returns>        public static SampleMeasurePara GetMeasureInfo(OTSIncAMeasureAppForm m_MeasureAppForm, string sampleName, ARectangleGDIObject item, ARectangleGDIObject m_RectangleGDIObjects, StageDrawingData oTSSampleStageData, int wDomain, int w)        {            SampleMeasurePara sampleMeasurePara = new SampleMeasurePara();            foreach (ARectangleGDIObject measureItem in OTSSamplespaceWindow.m_MeasureGDIObjects)            {                if (sampleName == measureItem.SampleName)                {                    //设置测量区域位置与尺寸                    float left = 0;                    float Top = 0;                    float Right = 0;                    float Bottom = 0;                    float Widths = 0;                    float Height = 0;                    //设置测量区域位置与尺寸                    left = OTSSamplespaceGraphicsPanelFun.PixelConvertToMicron((int)item.RegionF.X, wDomain, w);                    Top = OTSSamplespaceGraphicsPanelFun.PixelConvertToMicron((int)item.RegionF.Y, wDomain, w);                    Right = OTSSamplespaceGraphicsPanelFun.PixelConvertToMicron((int)item.RegionF.Right, wDomain, w);                    Bottom = OTSSamplespaceGraphicsPanelFun.PixelConvertToMicron((int)item.RegionF.Bottom, wDomain, w);                    Widths = OTSSamplespaceGraphicsPanelFun.PixelConvertToMicron((int)item.RegionF.Width, wDomain, w);                    Height = OTSSamplespaceGraphicsPanelFun.PixelConvertToMicron((int)item.RegionF.Height, wDomain, w);                    //保存原位置                    RectangleF polygonRectPara = measureItem.DrawRegionF;                    if (measureItem.CreateType == (int)CreateRectangleType.Polygon)                    {                        polygonRectPara = GetPolygonToMinRectangle(measureItem.DrawPolygonPointRegionF);                        //设置测量区域位置与尺寸                        left = OTSSamplespaceGraphicsPanelFun.PixelConvertToMicron((int)polygonRectPara.X, wDomain, w);                        Top = OTSSamplespaceGraphicsPanelFun.PixelConvertToMicron((int)polygonRectPara.Y, wDomain, w);                        Right = OTSSamplespaceGraphicsPanelFun.PixelConvertToMicron((int)polygonRectPara.Right, wDomain, w);                        Bottom = OTSSamplespaceGraphicsPanelFun.PixelConvertToMicron((int)polygonRectPara.Bottom, wDomain, w);                        Widths = OTSSamplespaceGraphicsPanelFun.PixelConvertToMicron((int)polygonRectPara.Width, wDomain, w);                        Height = OTSSamplespaceGraphicsPanelFun.PixelConvertToMicron((int)polygonRectPara.Height, wDomain, w);                    }                    //设置测量区域                    PointF startPoint = new PointF(left, Top);                    SizeF MeasureSize = new SizeF(Widths, Height);                    sampleMeasurePara.MeasureRect = new Rectangle(new Point((int)startPoint.X, (int)startPoint.Y), new Size((int)MeasureSize.Width, (int)MeasureSize.Height));                    //设置样品孔名称                    sampleMeasurePara.sHoleName = item.Name;                    //设置样品名称                    sampleMeasurePara.sSampleName = item.SampleName;                    //设置测量区域形状                    sampleMeasurePara.iShape = item.Shape;                    //设置多边形点集合                    sampleMeasurePara.PolygonPointRegion = PointFConvertPoint(GetPolygonPointToOTSPoint(item.PolygonPointRegionF, wDomain, w));                    sampleMeasurePara.PolygonPointRegionF = GetPolygonPointToOTSPoint(item.PolygonPointRegionF, wDomain, w);                    sampleMeasurePara.DrawPolygonPointRegionF = GetPolygonPointToOTSPoint(item.DrawPolygonPointRegionF, wDomain, w);                    break;                }            }            return sampleMeasurePara;        }        public static SampleHolePara GetSampleHoleInfo(OTSIncAMeasureAppForm m_MeasureAppForm, string sampleHoleName, ARectangleGDIObject item, ARectangleGDIObject m_RectangleGDIObjects, StageDrawingData oTSSampleStageData, int wDomain, int w)        {            SampleHolePara sampleHolePara = new SampleHolePara();            foreach (ARectangleGDIObject sampleHoleItem in OTSSamplespaceWindow.m_SampleHoleGDIObjects)            {                if (sampleHoleName == sampleHoleItem.Name)                {                    //保存原位置                    Rectangle rectPara = sampleHoleItem.Region;                    //设置测量区域                    sampleHolePara.SampleHoleRect = sampleHoleItem.Region;                    //设置测量区域位置与尺寸                    float left = OTSSamplespaceGraphicsPanelFun.PixelConvertToMicron((int)item.RegionF.X, wDomain, w);                    float Top = OTSSamplespaceGraphicsPanelFun.PixelConvertToMicron((int)item.RegionF.Y, wDomain, w);                    float Right = OTSSamplespaceGraphicsPanelFun.PixelConvertToMicron((int)item.RegionF.Right, wDomain, w);                    float Bottom = OTSSamplespaceGraphicsPanelFun.PixelConvertToMicron((int)item.RegionF.Bottom, wDomain, w);                    float Widths = OTSSamplespaceGraphicsPanelFun.PixelConvertToMicron((int)item.RegionF.Width, wDomain, w);                    float Height = OTSSamplespaceGraphicsPanelFun.PixelConvertToMicron((int)item.RegionF.Height, wDomain, w);                    //Size sizeRegion = new Size(PointRB);                    PointF startPoint = new PointF(left, Top);                    SizeF sampleHoleSize = new SizeF(Widths, Height);                    sampleHolePara.SampleHoleRect = new Rectangle(new Point((int)startPoint.X, (int)startPoint.Y), new Size((int)sampleHoleSize.Width, (int)sampleHoleSize.Height));                    //设置样品孔名称                    sampleHolePara.sHoleName = item.Name;                    //设置测量区域形状                    sampleHolePara.iShape = item.Shape;                    break;                }            }            return sampleHolePara;        }        #endregion        #region 获取工作样品的测量区域信息        /// <summary>        /// 获取工作样品的测量区域信息        /// </summary>        /// <returns></returns>        public static Rectangle GetWorkMeasure(OTSIncAMeasureAppForm m_MeasureAppForm, ARectangleGDIObject m_RectangleGDIObjects, StageDrawingData oTSSampleStageData, int wDomain, int w)        {            foreach (ARectangleGDIObject itemMeasure in OTSSamplespaceWindow.m_MeasureGDIObjects)            {                if (itemMeasure.IsWorkSample)                {                    Point startPoint = new Point(itemMeasure.Region.Left, itemMeasure.Region.Top);                    Point endPoint = new Point(itemMeasure.Region.Right, itemMeasure.Region.Bottom);                    SampleMeasurePara rectMaesure = GetMeasureInfo(m_MeasureAppForm, itemMeasure.SampleName, itemMeasure, m_RectangleGDIObjects, oTSSampleStageData, wDomain, w);                    return rectMaesure.MeasureRect;                }            }            return new Rectangle();        }        #endregion        #region 删除样品弹出提示        public static bool ShowDeleteDialog(string sampleName)        {            //国际化            OTSSysMgrTools.Language lan = new OTSSysMgrTools.Language();            Hashtable table = lan.GetNameTable("OTSIncAMeasureAppForm");            string str1 = table["message5"].ToString();            string str2 = table["message6"].ToString();            string sDeleteSampleName = str1;            sDeleteSampleName += sampleName;            sDeleteSampleName += "  信息 ?";            if (DialogResult.OK == MessageBox.Show(sDeleteSampleName, "Delete sample information prompt", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning))            {                return true;            }            else            {                return false;            }        }        #endregion        #region 将点转换至工作区域        public void PointToClient(Point rect)        {            this.PointToClient(rect);        }        #endregion        #region 删除样品 同时删除帧图        public static bool DeleteSampleInfo(OTSIncAMeasureAppForm m_MeasureAppForm, string sampleSelectName)        {            try            {                //提交主窗体响应                bool deleteResult = false;                if (OTSSamplespaceGraphicsPanelFun.ShowDeleteDialog(sampleSelectName))                {                    //设置当前状态                    m_MeasureAppForm.m_MessageStates = (int)MessageState.StartMeasure;                    deleteResult = m_MeasureAppForm.DeleteSample(sampleSelectName);                    if (deleteResult)                    {                        //样品对象列表中无样品信息 则清除帧图对象列表信息                        bool result = m_MeasureAppForm.m_SamplepaceWindow.SampleIsEmptyClearSingleInfo();                        if(result)                        {                            m_MeasureAppForm.m_MeasureRetWindow.SetInit();                        }                    }                }                return true;            }            catch (Exception)            {                return false;            }        }        #endregion        #region 计算两个点之间的距离 (图形与鼠标点击获取的点)        public static Point StartToEndPointDist(ARectangleGDIObject m_RectangleGDIObjects, Point regionStartPoint)        {            Point differentPoint = new Point();            //获取点击后的样品台位置            Point m_Region = OTSSamplespaceGraphicsPanelFun.GetCenterPoint(m_RectangleGDIObjects.Region);            //获取鼠标按下的位置            Point regionEndPoint = m_Region;            //获取鼠标按下与抬起 位置差值            differentPoint.X = regionEndPoint.X - regionStartPoint.X;            differentPoint.Y = regionEndPoint.Y - regionStartPoint.Y;            return differentPoint;        }        #endregion        #region 计算两个点之间的距离 (图形中心与屏幕中心相差的距离)        public static Point RegionCenterToScreenCenterDist(ARectangleGDIObject regionCneter, Point screenCneter)        {            Point differentPoint = new Point();            //获取图形中心位置            Rectangle rectangle = new Rectangle();            rectangle.X = (int)regionCneter.RegionF.X;            rectangle.Y = (int)regionCneter.RegionF.Y;            rectangle.Width = (int)regionCneter.RegionF.Width;            rectangle.Height = (int)regionCneter.RegionF.Height;            Point m_RegionCenter = OTSSamplespaceGraphicsPanelFun.GetCenterPoint(rectangle);            //获取图形中心与屏幕中心相差的距离            differentPoint.X = m_RegionCenter.X - screenCneter.X;            differentPoint.Y = m_RegionCenter.Y - screenCneter.Y;            return differentPoint;        }        #endregion                #region 清除List中所有信息        public static List<ARectangleGDIObject> ListClear(List<ARectangleGDIObject> ListObject)        {            if (ListObject != null)            {                if (ListObject.Count > 0)                {                    ListObject.Clear();                }            }            return ListObject;        }        #endregion        #region 根据颜色枚举 获取颜色值        public static string GetColorValue(ColorType ColorEnum)        {            string ColorStr = string.Empty;            switch (ColorEnum)            {                case ColorType.SingleColor:                    ColorStr = "#fd8f8f";//帧图fd8f8f                    break;                case ColorType.RoundRectangleColor:                    ColorStr = "#c8c8c8";//c8c8c8圆角矩形                    break;                case ColorType.FontColor:                    ColorStr = "#90ee90";//90ee90文字颜色                    break;                case ColorType.SampleColor:                    ColorStr = "#f4f4f4";//f4f4f4 样品未选择                    break;                case ColorType.SampleSelColor:                    ColorStr = "#505050";//505050 样品选择后                    break;            }            return ColorStr;        }        #endregion        #region 获取测量区域的位置        public static SampleMeasurePara GetSampleMeasureRect(ARectangleGDIObject MeasureItem, OTSIncAMeasureAppForm m_MeasureAppForm, StageDrawingData oTSSampleStageData, ARectangleGDIObject m_RectangleGDIObjects, int IsWidth, int Width, int Height, int wDomain)        {            int w = (IsWidth == 0 ? Width : Height);            int iShape = 0;            Rectangle Srect = new Rectangle();            SampleMeasurePara sampleMeasureParas = new SampleMeasurePara();            //获取当前工作的测量区域信息            bool returnResult = m_MeasureAppForm.m_ProjParam.GetWSampleMrsArea(ref iShape, ref Srect);            if (returnResult)            {                //获取测量区域的OTS位置与尺寸                sampleMeasureParas = OTSSamplespaceGraphicsPanelFun.GetMeasureInfo(m_MeasureAppForm, MeasureItem.SampleName, MeasureItem, m_RectangleGDIObjects, oTSSampleStageData, wDomain, w);                //获取工作区域位置与尺寸                Rectangle WorkAreaRect = new Rectangle(0, 0, Width, Height);                //获取工作区域 中心点                Point ScreenPointCenter = OTSSamplespaceGraphicsPanelFun.GetWorkAreaCenterPoint(WorkAreaRect);                //获取样品台 中心点                PointF RectanglePointCenter = OTSSamplespaceGraphicsPanelFun.GetCenterPointF(m_RectangleGDIObjects.RegionF);                //获取屏幕中心点                float WorkAreaCenterPointX = OTSSamplespaceGraphicsPanelFun.PixelConvertToMicron(ScreenPointCenter.X, wDomain, w);                float WorkAreaCenterPointY = OTSSamplespaceGraphicsPanelFun.PixelConvertToMicron(ScreenPointCenter.Y, wDomain, w);                //获取样品台中心点                float CenterX = OTSSamplespaceGraphicsPanelFun.PixelConvertToMicron((int)RectanglePointCenter.X, wDomain, w);                float CenterY = OTSSamplespaceGraphicsPanelFun.PixelConvertToMicron((int)RectanglePointCenter.Y, wDomain, w);                Rectangle sampleMeasureRect = new Rectangle();                //根据屏幕中心点获取移动后样品台中心点的偏移位置                //sampleMeasureRect.X = -(WorkAreaCenterPointX - sampleMeasureParas.MeasureRect.X);                //sampleMeasureRect.Y = WorkAreaCenterPointY - sampleMeasureParas.MeasureRect.Bottom;                //根据样品台中心点获取开始点位置                sampleMeasureRect.X = -((int)CenterX - sampleMeasureParas.MeasureRect.X);                sampleMeasureRect.Y = (int)CenterY - sampleMeasureParas.MeasureRect.Bottom;                sampleMeasureParas.MeasureRect.X = sampleMeasureRect.X;                sampleMeasureParas.MeasureRect.Y = sampleMeasureRect.Y;                for (int i = 0; i < sampleMeasureParas.DrawPolygonPointRegionF.Count; i++)                {                    int X = -((int)CenterX - (int)sampleMeasureParas.DrawPolygonPointRegionF[i].X);                    int Y = (int)CenterY - (int)sampleMeasureParas.DrawPolygonPointRegionF[i].Y;                    //sampleMeasureParas.PolygonPointRegion[i] = new Point(X, Y);                    sampleMeasureParas.DrawPolygonPointRegionF[i] = new Point(X, Y);                }            }            return sampleMeasureParas;        }        public static SampleHolePara GetSampleHoleRect(ARectangleGDIObject sampleHoleItem, OTSIncAMeasureAppForm m_MeasureAppForm, StageDrawingData oTSSampleStageData, ARectangleGDIObject m_RectangleGDIObjects, int IsWidth, int Width, int Height, int wDomain)        {            int w = (IsWidth == 0 ? Width : Height);            SampleHolePara sampleHoleParas = new SampleHolePara();            //获取样品孔的OTS位置与尺寸            sampleHoleParas = OTSSamplespaceGraphicsPanelFun.GetSampleHoleInfo(m_MeasureAppForm, sampleHoleItem.Name, sampleHoleItem, m_RectangleGDIObjects, oTSSampleStageData, wDomain, w);            //获取工作区域位置与尺寸            Rectangle WorkAreaRect = new Rectangle(0, 0, Width, Height);            //获取工作区域 中心点            Point ScreenPointCenter = OTSSamplespaceGraphicsPanelFun.GetWorkAreaCenterPoint(WorkAreaRect);            //获取样品台 中心点            PointF RectanglePointCenter = OTSSamplespaceGraphicsPanelFun.GetCenterPointF(m_RectangleGDIObjects.RegionF);            //获取屏幕中心点            float WorkAreaCenterPointX = OTSSamplespaceGraphicsPanelFun.PixelConvertToMicron(ScreenPointCenter.X, wDomain, w);            float WorkAreaCenterPointY = OTSSamplespaceGraphicsPanelFun.PixelConvertToMicron(ScreenPointCenter.Y, wDomain, w);            //获取样品台中心点            float CenterX = OTSSamplespaceGraphicsPanelFun.PixelConvertToMicron((int)RectanglePointCenter.X, wDomain, w);            float CenterY = OTSSamplespaceGraphicsPanelFun.PixelConvertToMicron((int)RectanglePointCenter.Y, wDomain, w);            Rectangle sampleHoleRect = new Rectangle();            //根据样品台中心点获取开始点位置            sampleHoleRect.X = -((int)CenterX - sampleHoleParas.SampleHoleRect.X);            sampleHoleRect.Y = (int)CenterY - sampleHoleParas.SampleHoleRect.Bottom;            sampleHoleParas.SampleHoleRect.X = sampleHoleRect.X;            sampleHoleParas.SampleHoleRect.Y = sampleHoleRect.Y;            return sampleHoleParas;        }        #endregion        #region //设置测量区域信息(位置与大小)        public static bool SetWorkSamplHoleAndMeasureArea(ARectangleGDIObject MeasureItem, OTSIncAMeasureAppForm m_MeasureAppForm, StageDrawingData oTSSampleStageData, ARectangleGDIObject m_RectangleGDIObjects, int IsWidth, int Width, int Height, int wDomain)        {            //获取工作样品中的测量区域            SampleMeasurePara sampleMeasurePara = new SampleMeasurePara();            //设置测量区域位置            //获取修改后的测量区域的位置与尺寸            sampleMeasurePara = GetSampleMeasureRect(MeasureItem, m_MeasureAppForm, oTSSampleStageData, m_RectangleGDIObjects, IsWidth, Width, Height, wDomain);            sampleMeasurePara.sHoleName = MeasureItem.Name;            sampleMeasurePara.sSampleName = MeasureItem.SampleName;            //设置测量区域信息(位置与大小)            SampleMeasurePara SampleMeasureParaResult = m_MeasureAppForm.SetWorkSamplHoleAndMeasureArea(sampleMeasurePara);            if (OTSSamplespaceGraphicsPanelFun.IsValidate(m_MeasureAppForm, sampleMeasurePara, SampleMeasureParaResult))            {                return true;            }            return false;        }        #endregion        #region 根据list中的帧图信息 获取中心位置        public static PointF GetSingleCenterLocation(List<ARectangleGDIObject> m_SingleGDIObjects)        {            float MinX = 0f;            float MinY = 0f;            float MaxX = 0f;            float MaxY = 0f;            float width = 0f;            float height = 0f;            //获取最小XY 与最大XY            MinX = m_SingleGDIObjects[0].RegionF.X;            MinY = m_SingleGDIObjects[0].RegionF.Y;            MaxX = m_SingleGDIObjects[0].RegionF.X;            MaxY = m_SingleGDIObjects[0].RegionF.Y;            width = m_SingleGDIObjects[0].RegionF.Width;            height = m_SingleGDIObjects[0].RegionF.Height;            for (int i = 0; i < m_SingleGDIObjects.Count; i++)            {                MinX = Math.Min(m_SingleGDIObjects[i].RegionF.X, MinX);                MinY = Math.Min(m_SingleGDIObjects[i].RegionF.Y, MinY);                MaxX = Math.Max(m_SingleGDIObjects[i].RegionF.X, MaxX);                MaxY = Math.Max(m_SingleGDIObjects[i].RegionF.Y, MaxY);            }            //获取帧图的外框矩形            RectangleF SingleRect = new RectangleF(MinX, MinY, MaxX- MinX+ width, MaxY- MinY+ height);            //计算外框矩形的中心点            float PointFX = SingleRect.X + SingleRect.Width / 2;            float PointFY = SingleRect.Y + SingleRect.Height / 2;            PointF SingleCenterPoint = new PointF(PointFX, PointFY);            return SingleCenterPoint;        }        public static PointF GetSingleDrawCenterLocation(List<ARectangleGDIObject> m_SingleGDIObjects)        {            float MinX = 0f;            float MinY = 0f;            float MaxX = 0f;            float MaxY = 0f;            float width = 0f;            float height = 0f;            //获取最小XY 与最大XY            MinX = m_SingleGDIObjects[0].DrawRegionF.X;            MinY = m_SingleGDIObjects[0].DrawRegionF.Y;            MaxX = m_SingleGDIObjects[0].DrawRegionF.X;            MaxY = m_SingleGDIObjects[0].DrawRegionF.Y;            width = m_SingleGDIObjects[0].DrawRegionF.Width;            height = m_SingleGDIObjects[0].DrawRegionF.Height;            for (int i = 0; i < m_SingleGDIObjects.Count; i++)            {                MinX = Math.Min(m_SingleGDIObjects[i].DrawRegionF.X, MinX);                MinY = Math.Min(m_SingleGDIObjects[i].DrawRegionF.Y, MinY);                MaxX = Math.Max(m_SingleGDIObjects[i].DrawRegionF.X, MaxX);                MaxY = Math.Max(m_SingleGDIObjects[i].DrawRegionF.Y, MaxY);            }            //获取帧图的外框矩形            RectangleF SingleRect = new RectangleF(MinX, MinY, MaxX - MinX + width, MaxY - MinY + height);            //计算外框矩形的中心点            float PointFX = SingleRect.X + SingleRect.Width / 2;            float PointFY = SingleRect.Y + SingleRect.Height / 2;            PointF SingleCenterPoint = new PointF(PointFX, PointFY);            return SingleCenterPoint;        }        #endregion        #region 将所有帧图移植测量区域位置        public static void SetSingleLocationToMeasureLocation(List<ARectangleGDIObject> m_ObjectListGDIObjects, ARectangleGDIObject m_ObjectGDIObjects)        {            //获取帧图中心与测量区域中心            PointF singleCenterPoinF= GetSingleCenterLocation(m_ObjectListGDIObjects);            PointF singleDrawCenterPoinF = GetSingleDrawCenterLocation(m_ObjectListGDIObjects);            //测量区域 已改变为倍数的尺寸 中心点            PointF measureCenterPoin = GetCenterPointF(m_ObjectGDIObjects.Region);            //测量区域 正常尺寸 中心点            PointF measureCenterPoinF = GetCenterPointF(m_ObjectGDIObjects.RegionF);            //计算相差的XY距离            float moveX = measureCenterPoin.X - singleCenterPoinF.X;            float moveY = measureCenterPoin.Y - singleCenterPoinF.Y;            float moveFX = measureCenterPoinF.X - singleDrawCenterPoinF.X;            float moveFY = measureCenterPoinF.Y - singleDrawCenterPoinF.Y;            //需要移动的位置            PointF movePoint = new PointF(moveX, moveY);            PointF movePointF = new PointF(moveFX, moveFY);            foreach (var ObjectItem in m_ObjectListGDIObjects)            {                //计算移动后的位置                float X = ObjectItem.RegionF.X + movePoint.X;                float Y = ObjectItem.RegionF.Y + movePoint.Y;                float Width = ObjectItem.RegionF.Width;                float Height = ObjectItem.RegionF.Height;                ObjectItem.Region = new Rectangle((int)X, (int)Y, (int)Width, (int)Height);                ObjectItem.RegionF = new RectangleF(X, Y, Width, Height);                ObjectItem.DrawRegionF = new RectangleF(ObjectItem.DrawRegionF.X + movePointF.X, ObjectItem.DrawRegionF.Y + movePointF.Y, ObjectItem.DrawRegionF.Width, ObjectItem.DrawRegionF.Height);            }        }        #endregion        /// <summary>        /// 获取XML中电镜的选项         /// </summary>            #region 测量区域中心移动至SEM当前位置               /// <summary>        /// 测量区域中心移动至SEM当前位置          /// </summary>        /// <param name="m_SamplespaceWindow">样品台窗体对象</param>        /// <param name="mouseLocation">当前鼠标的位置</param>        public static void NewLocationDrawMeasureInfo(OTSSamplespaceWindow m_SamplespaceWindow, List<ARectangleGDIObject> m_RectangleGDIObjects, StageDrawingData oTSSampleStageData, int IsWidth,  Point moveToSEMLocation, List<ARectangleGDIObject> UpdateLocationGDIObject,float m_GlobalZoomNum)        {            //样品台中心点位置            Point m_StageCenterPoint = OTSSamplespaceGraphicsPanelFun.GetCenterPoint(m_RectangleGDIObjects[0]);            //当前与中心点相差距离            int m_StageCenterDiffX = 0;            int m_StageCenterDiffY = 0;            int diffNewX = 0;            int diffNewY = 0;            Point m_UpdateCenterPoint = new Point();                        foreach (var item in UpdateLocationGDIObject)            {                if(item.IsWorkSample)                {                    m_UpdateCenterPoint = OTSSamplespaceGraphicsPanelFun.GetCenterPoint(item);                    m_StageCenterDiffX = (int)((m_StageCenterPoint.X - m_UpdateCenterPoint.X) * 1);                    m_StageCenterDiffY = (int)((m_StageCenterPoint.Y - m_UpdateCenterPoint.Y) * 1);                    diffNewX = (int)(moveToSEMLocation.X * m_GlobalZoomNum);                    diffNewY = (int)(moveToSEMLocation.Y * m_GlobalZoomNum);                    //根据鼠标_更改测量区域的位置                    item.Region = new Rectangle( new Point(item.Region.X+ m_StageCenterDiffX + diffNewX, item.Region.Y + m_StageCenterDiffY - diffNewY),new Size(item.Region.Width, item.Region.Height));                    item.RegionF = new RectangleF(new PointF(item.RegionF.X + (m_StageCenterDiffX + diffNewX)/m_GlobalZoomNum, item.RegionF.Y + (m_StageCenterDiffY  - diffNewY)/m_GlobalZoomNum), new SizeF(item.RegionF.Width, item.RegionF.Height));                    item.DrawRegionF = item.RegionF;                    //修改多边形的绘制点集合                    if (item.CreateType == (int)CreateRectangleType.Polygon)                    {                        for (int i = 0; i < item.PolygonPointRegion.Count; i++)                        {                            item.PolygonPointRegion[i] = new Point(item.PolygonPointRegion[i].X + m_StageCenterDiffX + diffNewX, item.PolygonPointRegion[i].Y + m_StageCenterDiffY - diffNewY);                            item.PolygonPointRegionF[i] = new PointF(item.PolygonPointRegionF[i].X + (m_StageCenterDiffX + diffNewX), item.PolygonPointRegionF[i].Y + (m_StageCenterDiffY - diffNewY));                            item.DrawPolygonPointRegionF[i] = new PointF(item.DrawPolygonPointRegionF[i].X + (m_StageCenterDiffX + diffNewX) / m_GlobalZoomNum, item.DrawPolygonPointRegionF[i].Y + (m_StageCenterDiffY - diffNewY) / m_GlobalZoomNum);                        }                    }                }            }        }        public static bool NewLocationDrawSingleInfo(OTSIncAMeasureAppForm m_MeasureAppForm, OTSSamplespaceWindow m_SamplespaceWindow, List<ARectangleGDIObject> m_RectangleGDIObjects, StageDrawingData oTSSampleStageData, int IsWidth, Point moveToSEMLocation, List<ARectangleGDIObject> UpdateLocationGDIObject, ARectangleGDIObject WorkMeasure, float m_GlobalZoomNum)        {            //样品台中心点位置            Point m_StageCenterPoint = OTSSamplespaceGraphicsPanelFun.GetCenterPoint(m_RectangleGDIObjects[0]);            //当前与中心点相差距离            int m_StageCenterDiffX = 0;            int m_StageCenterDiffY = 0;            Point m_WorkMeasureCenterPoint = new Point();            if (UpdateLocationGDIObject == null)            {                return false;            }                       int diffNewX = 0;            int diffNewY = 0;            bool IsOK = true;            diffNewX = moveToSEMLocation.X;            diffNewY = moveToSEMLocation.Y;                        if (IsOK)            {                foreach (var item in UpdateLocationGDIObject)                {                    m_WorkMeasureCenterPoint = OTSSamplespaceGraphicsPanelFun.GetCenterPoint(WorkMeasure);                    m_StageCenterDiffX = m_StageCenterPoint.X - m_WorkMeasureCenterPoint.X;//(int)((m_StageCenterPoint.X - m_WorkMeasureCenterPoint.X) * m_GlobalZoomNum);                    m_StageCenterDiffY = m_StageCenterPoint.Y - m_WorkMeasureCenterPoint.Y;// (int)((m_StageCenterPoint.Y - m_WorkMeasureCenterPoint.Y) * m_GlobalZoomNum);                    diffNewX = (int)(moveToSEMLocation.X * m_GlobalZoomNum);                    diffNewY = (int)(moveToSEMLocation.Y * m_GlobalZoomNum);                    //根据鼠标_更改测量区域的位置                    item.Region = new Rectangle(new Point(item.Region.X + m_StageCenterDiffX + diffNewX, item.Region.Y + m_StageCenterDiffY - diffNewY), new Size(item.Region.Width, item.Region.Height));                    item.RegionF = new RectangleF(new PointF(item.RegionF.X + (m_StageCenterDiffX + diffNewX) , item.RegionF.Y + (m_StageCenterDiffY - diffNewY)), new SizeF(item.RegionF.Width, item.RegionF.Height));                    item.DrawRegionF = new RectangleF(new PointF(item.DrawRegionF.X + (m_StageCenterDiffX + diffNewX) / m_GlobalZoomNum, item.DrawRegionF.Y + (m_StageCenterDiffY - diffNewY) / m_GlobalZoomNum), new SizeF(item.DrawRegionF.Width, item.DrawRegionF.Height));                }            }            return IsOK;        }        #endregion          #region 通过样品孔名称 获取在列表中的索引        /// <summary>        /// 通过样品孔名称 获取在列表中的索引        /// </summary>        /// <param name="oTSSampleStageData">样品台文件</param>        /// <param name="sampleHoleName">样品孔名称</param>        /// <returns></returns>        public static int GetSampleHoleIndex(StageDrawingData oTSSampleStageData,string sampleHoleName, ref OTSSampleHoleInfo sampleHoleInfo)        {            try            {                int sampleHoleIndex = -1;                if (oTSSampleStageData.sSHoleInfoList.Count > 0)                {                    for (int i = 0; i < oTSSampleStageData.sSHoleInfoList.Count; i++)                    {                        if (oTSSampleStageData.sSHoleInfoList[i].sSHoleName == sampleHoleName)                        {                            sampleHoleInfo = oTSSampleStageData.sSHoleInfoList[i];                            sampleHoleIndex = i;                            break;                        }                    }                }                return sampleHoleIndex;            }            catch (Exception)            {                return -1;            }        }        #endregion                #region 添加帧图信息        /// <summary>        /// 添加帧图信息        /// </summary>        /// <param name="m_ALLSingleGDIObjects">帧图对象列表</param>        /// <param name="m_SingleGDIObjects">帧图对象列表</param>        /// <param name="sampleName">样品名称</param>        /// <returns></returns>        public static bool AddALLSingleInfo(List<ARectangleGDIObject> m_ALLSingleGDIObjects, List<ARectangleGDIObject> m_SingleGDIObjects, string sampleName)        {            bool result = false;            //判断ALLSingle对象列表中是否为空            if (m_ALLSingleGDIObjects != null)            {                bool IsExist = true;                if (m_ALLSingleGDIObjects.Count > 0)                {                                        //判断是否包含样品名称                    foreach (var item in m_ALLSingleGDIObjects)                    {                        if (item.SampleName.Equals(sampleName))                        {                            IsExist = false;                            break;                        }                    }                }                if (IsExist)                {                    result = true;                    foreach (var item in m_SingleGDIObjects)                    {                        m_ALLSingleGDIObjects.Add(item);                    }                }                return result;            }            return result;        }        #endregion        #region 删除帧图信息        /// <summary>        /// 删除帧图信息        /// </summary>        /// <param name="m_ALLSingleGDIObjects">帧图对象列表</param>        /// <param name="sampleName">样品名称</param>        /// <returns></returns>        public static bool DeleteALLSingleInfo(List<ARectangleGDIObject> m_ALLSingleGDIObjects, string sampleName)        {            bool result = false;            int resultCount = 0;            //判断ALLSingle对象列表中是否为空            if (m_ALLSingleGDIObjects != null)            {                if (m_ALLSingleGDIObjects.Count > 0)                {                    for (int i = m_ALLSingleGDIObjects.Count - 1; i >= 0; i--)                    {                        if (m_ALLSingleGDIObjects[i].SampleName.Equals(sampleName))                        {                             m_ALLSingleGDIObjects.RemoveAt(i);                            resultCount++;                        }                    }                }                else                {                    result = true;                }                if (resultCount > 0)                {                    result = true;                }            }            return result;        }        #endregion        #region 切换样品 填充帧图信息        public static void ChangeSampleFillSingleInfo(List<ARectangleGDIObject> m_ALLSingleGDIObjects, List<ARectangleGDIObject> m_SingleGDIObjects, string sampleName)        {            //判断帧图对象中是否存在当前工作样品帧图信息            bool IsExist = true;            //判断ALLSingle对象列表中是否为空            if (m_ALLSingleGDIObjects != null)            {                if (m_ALLSingleGDIObjects.Count > 0)                {                    foreach (var item in m_SingleGDIObjects)                    {                        if (item.SampleName.Equals(sampleName))                        {                            IsExist = false;                        }                    }                    if (IsExist)                    {                        //判断是否包含样品名称                        foreach (var item in m_ALLSingleGDIObjects)                        {                            if (item.SampleName.Equals(sampleName))                            {                                m_SingleGDIObjects.Add(item);                            }                        }                    }                }            }        }        #endregion        #region 修改已存在的帧图中样品名称        public static void EditWorkSampleName(List<ARectangleGDIObject> m_ALLSingleGDIObjects, string oldSampleName, string newSampleName)        {            int resultCount = 0;            //判断ALLSingle对象列表中是否为空            if (m_ALLSingleGDIObjects != null)            {                if (m_ALLSingleGDIObjects.Count > 0)                {                    for (int i = m_ALLSingleGDIObjects.Count - 1; i >= 0; i--)                    {                        if (m_ALLSingleGDIObjects[i].SampleName.Equals(oldSampleName))                        {                            m_ALLSingleGDIObjects[i].SampleName = newSampleName;                            resultCount++;                        }                    }                }            }        }        #endregion        #region 修改测量区域中GraphicsPath属性        public static void UpdateMeasureGraphicsPath(ARectangleGDIObject measureItem, Rectangle rectPara)        {            //重新绘制测量区域路径            GraphicsPath GPath = new GraphicsPath();            if (measureItem.CreateType == (int)CreateRectangleType.Polygon)            {                GraphicsPath PolygonMeasurePath = new GraphicsPath();                PolygonMeasurePath.AddPolygon(measureItem.PolygonPointRegionF.ToArray());                GPath = PolygonMeasurePath;            }            else if(measureItem.CreateType == (int)CreateRectangleType.CircleByThreePoints)            {                GPath.AddEllipse(rectPara);            }            else            {                if (measureItem.Shape == (int)CreateRectangleType.Circle)                {                    GPath.AddEllipse(rectPara);                }                else                {                    GPath.AddRectangle(rectPara);                }            }            measureItem.GPath = GPath;        }        #endregion        #region OnMouseWheel        public static void RecoverInitialPosition(List<ARectangleGDIObject> l_GDIObjects,float m_GlobalZoomNum)        {            for (int i = 0; i < l_GDIObjects.Count; i++)            {                RectangleF rectF = new RectangleF();                rectF = l_GDIObjects[i].DrawRegionF;                //根据样品孔中心点与样品台中心点的方向 设置宽度与高度\                l_GDIObjects[i].Region = new Rectangle((int)(rectF.X * m_GlobalZoomNum), (int)(rectF.Y * m_GlobalZoomNum), (int)(rectF.Width * m_GlobalZoomNum), (int)(rectF.Height * m_GlobalZoomNum));                PointF pointF = new PointF(rectF.X * m_GlobalZoomNum, rectF.Y * m_GlobalZoomNum);                SizeF sizeF = new SizeF((rectF.Width * m_GlobalZoomNum), (rectF.Height * m_GlobalZoomNum));                l_GDIObjects[i].RegionF = new RectangleF(pointF, sizeF);            }        }        #endregion        #region 判断当前位置是否在不规则形状里面        /// <summary>        /// 判断当前位置是否在不规则形状里面        /// </summary>        /// <param name="PointList">不规则形状坐标集合</param>        /// <param name="currentMouseLocation">当前鼠标坐标</param>        /// <returns></returns>        public static bool PositionPnpoly(List<Point> polygonPointList, Point currentMouseLocation)        {            double testx = currentMouseLocation.X;            double testy = currentMouseLocation.Y;            int nvert = polygonPointList.Count;            List<double> vertx = new List<double>();            List<double> verty = new List<double>();            for (int pointIndex = 0; pointIndex < polygonPointList.Count; pointIndex++)            {                vertx.Add(polygonPointList[pointIndex].X);                verty.Add(polygonPointList[pointIndex].Y);            }            int i, j, c = 0;            for (i = 0, j = nvert - 1; i < nvert; j = i++)            {                if (((verty[i] > testy) != (verty[j] > testy)) && (testx < (vertx[j] - vertx[i]) * (testy - verty[i]) / (verty[j] - verty[i]) + vertx[i]))                {                    c = 1 + c; ;                }            }            if (c % 2 == 0)            {                return false;            }            else            {                return true;            }        }        #endregion        #region 获取多边形最小外接矩形        /// <summary>        /// 获取多边形最小外接矩形        /// </summary>        /// <param name="polygonPointList">不规则形状坐标集合</param>        /// <returns></returns>        public static Rectangle GetPolygonToMinRectangle(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();        }        #endregion        #region 将多边形屏幕坐标转换为OTS坐标        /// <summary>        /// 将多边形屏幕坐标转换为OTS坐标        /// </summary>        /// <param name="polygonPointList">不规则形状坐标集合</param>        /// <returns></returns>        public static List<PointF> GetPolygonPointToOTSPoint(List<PointF> polygonPointList, int widthDomain, int length)        {            List<PointF> OTSPoint = new List<PointF>();            float X = 0;            float Y = 0;            if (polygonPointList != null)            {                foreach (var item in polygonPointList)                {                    X = (float)(item.X * ((double)widthDomain / length));                    Y = (float)(item.Y * ((double)widthDomain / length));                    OTSPoint.Add(new PointF(X, Y));                }            }            return OTSPoint;        }        #endregion        #region List<Point> 转换为 List<PointF>        /// <summary>        /// List<Point> 转换为 List<PointF>        /// </summary>        /// <param name="Points"></param>        /// <returns></returns>        public static List<PointF> PointConvertPointF(List<Point> Points)        {            List<PointF> PointFs = new List<PointF>();            if (Points != null)            {                foreach (var itemPoint in Points)                {                    PointFs.Add(itemPoint);                }            }            return PointFs;        }        public static 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 static Point[] PointFConvertPoint(PointF[] PointFs)        {            Point[] Points = new Point[PointFs.Length];            if (Points != null)            {                for (int i = 0; i < Points.Length; i++)                {                    Points[i] = new Point((int)PointFs[i].X, (int)PointFs[i].Y);                }            }            return Points;        }        /// <summary>        /// List<PointF> 转换为 List<Point>        /// </summary>        /// <param name="Points"></param>        /// <returns></returns>        public static List<Point> PointFConvertPoint(List<PointF> Points)        {            List<Point> PointFs = new List<Point>();            if (Points != null)            {                foreach (var itemPoint in Points)                {                    PointFs.Add(new Point((int)itemPoint.X, (int)itemPoint.Y));                }            }            return PointFs;        }        #endregion        #region 获取 Rectangle 外框点集合        public static Point[] GetRectangleToPoint(RectangleF rectangleF)        {            int Left = (int)rectangleF.Left;            int Top = (int)rectangleF.Top;            int Right = (int)rectangleF.Right;            int Bottom = (int)rectangleF.Bottom;            List<Point> addPoint = new List<Point>();            for (int i = Left; i <= Right; i++)            {                addPoint.Add(new Point(Left + 1, Top));            }            for (int i = Top; i <= Bottom; i++)            {                addPoint.Add(new Point(Right,Top + 1));            }            for (int i = Right; i >= Left; i--)            {                addPoint.Add(new Point(Right - 1, Bottom));            }            for (int i = Bottom; i >= Top; i--)            {                addPoint.Add(new Point(Left,Bottom - 1));            }            return addPoint.ToArray();        }        #endregion        //检查测量区域是否超过样品台区域        //RMeasureArea: 样品台的当前测量区域;  RStageArea: 样品台区域;  RMeasureArea《RStageArea             public static bool CheckMeasureAreaIsBeyondStageArea(Rectangle RMeasureArea, Rectangle RStageArea, int iShape)        {            Rectangle pMeasureArea = RMeasureArea;            Rectangle pStageArea = RStageArea;                               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);        }        #region 重新绘制        /// <summary>        /// 重新绘制        /// </summary>        /// <param name="e"></param>        /// <param name="m_ObjectGDIObjects"></param>        public static void OnPaint(PaintEventArgs e, List<ARectangleGDIObject> m_ObjectGDIObjects)//处理重绘情况        {            foreach (ARectangleGDIObject item in m_ObjectGDIObjects)            {                if (item != null)                {                    item.OnPaint(e);                }            }        }        #endregion        #region 显示XY轴        /// <summary>        /// 显示XY轴        /// </summary>        public static void ShowSemCoordvAL(Point mPoint, OTSIncAMeasureAppForm m_MeasureAppForm, List<ARectangleGDIObject> m_RectangleGDIObjects, StageDrawingData m_OTSSampleStageData,int IsWidth)        {            foreach (ARectangleGDIObject item in m_RectangleGDIObjects)            {                if (item.Region.Contains(mPoint))                {                    //鼠标在样品台中移动获取坐标                    Point mousePoint = OTSSamplespaceGraphicsPanelFun.GetMouseLocationInRectangleGDIObject(mPoint, m_RectangleGDIObjects[0], m_OTSSampleStageData, IsWidth, m_RectangleGDIObjects[0].Region.Width, m_RectangleGDIObjects[0].Region.Height);                    PointF SEMPoint = m_MeasureAppForm.m_ProjParam.ChangeOTSToSemCoord(mousePoint);                    //将微米转换为毫米                    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);                }            }        }         #endregion    }}
 |