123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- using OTSMeasureApp._4_OTSSamplespaceGraphicsPanel.VisualGDIObjects;
- 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 : CMeasureArea
- {
- 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, string holename, string name, Color selColor)
- {
- m_OrigineRegionF = rect;
- SetInitRegionF(m_OrigineRegionF);
- 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);
- if (subItems.Count != 0)
- {
- foreach (var item in subItems)
- {
- item.OnPaint(e);
- }
- }
- }
- 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;
- }
- private bool ifRectangleIntersect(CDisplayGDIObject otherUnZoomgdi)
- {
- var path = GetInsideCirclePath();//the inside circle is the blank area that there's no field rect.
- var vertexPoints = otherUnZoomgdi.GetOriginalRegionVertexPoints();
- foreach (var p in vertexPoints)
- {
- if (!path.IsVisible(p))
- {
- return true;
- }
- }
- return false;
- }
-
- override public void AddSubItems(CVisualFieldGDIObject item)
- {
- if (subItems == null) subItems = new List<CVisualFieldGDIObject>();
- if (ifRectangleIntersect(item))
- {
- var r = item;
- r.SequenceNum = subItems.Count ;
- subItems.Add(item);
- }
- }
- }
- }
|