| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 | using System;using System.Collections.Generic;using System.Drawing;using System.Drawing.Drawing2D;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;namespace OTSMeasureApp._4_OTSSamplespaceGraphicsPanel{    class CRingGDIObject: CRectangleGDIObject    {        private float ringWidth=10;//the distance between outline circle and inside circle.        public float GetRingWidth()        {            return ringWidth*m_zoomNum;        }        public void SetRingWidth(float value)        {            ringWidth = value;        }        public CRingGDIObject(RectangleF rect, CreateRectangleType cType,string holename,string name, Color selColor)        {            m_OrigineRegionF = rect;            SetInitRegionF(m_OrigineRegionF);            CreateType = cType;            sampleName = name;            nameOrHoleName = holename;            SelColor = selColor;            ID = System.Guid.NewGuid().ToString();                  }        public override void OnPaint(PaintEventArgs e)        {                     e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;  //图片柔顺模式选择            e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量            e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点                   e.Graphics.DrawEllipse(Pens.Red, m_RegionF);            RectangleF insideRegine = new RectangleF();            insideRegine.X = m_RegionF.X + GetRingWidth();            insideRegine.Y = m_RegionF.Y + GetRingWidth();            insideRegine.Width = m_RegionF.Width - GetRingWidth() * 2;            insideRegine.Height = m_RegionF.Height - GetRingWidth() * 2;                    e.Graphics.DrawEllipse(Pens.Red, insideRegine);                 }          private GraphicsPath GetInsideCirclePath()        {            RectangleF insideRegine = new RectangleF();            insideRegine.X = m_OrigineRegionF.X + ringWidth;            insideRegine.Y = m_OrigineRegionF.Y + ringWidth;            insideRegine.Width = m_OrigineRegionF.Width - ringWidth * 2;            insideRegine.Height = m_OrigineRegionF.Height - ringWidth * 2;            GraphicsPath GPath = new GraphicsPath();            GPath.AddEllipse(insideRegine);            return GPath;        }        override public bool ifRectangleIntersect(CRectangleGDIObject otherUnZoomgdi)        {            var path = GetInsideCirclePath();//the inside circle is the blank area that there's no field rect.            var vertexPoints = otherUnZoomgdi.GetVertexPoints();            foreach (var p in vertexPoints)            {                if (!path.IsVisible(p))                {                    return true;                }            }            return false;        }    }}
 |