コード例 #1
0
        private void MouseDownSetBridge(MouseEventArgs e)
        {
            UnitPoint mousePoint = this.ToUnit(this.mouseDownPoint);

            if (this.bridgeStart.IsEmpty)
            {
                this.bridgeStart = mousePoint;
            }
            else
            {
                this.bridgeEnd = mousePoint;
                BridgingModel param = this.bridgeFunc?.Invoke();
                if (param != null)
                {
                    //1.获取图形区域与桥接直线交叉的图形
                    var  oldObjects = this.Model.DrawingLayer.Objects.FindAll(f => HitUtil.LineIntersectWithRect(this.bridgeStart, this.bridgeEnd, f.GetBoundingRectangle(BoundingRectangleType.All)));
                    bool isChanged  = false;
                    //2.计算直线与图形的交点
                    var newObjects = BridgeHelper.GetBridgeObjects(oldObjects, this.bridgeStart, this.bridgeEnd, param, out isChanged);
                    if (isChanged)
                    {
                        this.Model.DoBridge(newObjects, oldObjects, true);
                    }
                }
                this.CommandEscape();
            }
        }
コード例 #2
0
        public bool ObjectInRectangle(ICanvas canvas, RectangleF rect, bool anyPoint)
        {
            if (m_allPts == null || m_allPts.Count < 1)
            {
                return(false);
            }
            RectangleF boundingrect = GetBoundingRect(canvas);

            if (anyPoint)
            {
                for (int ii = 0; ii < m_allPts.Count - 1; ++ii)
                {
                    if (HitUtil.LineIntersectWithRect(m_allPts[ii], m_allPts[ii + 1], rect))
                    {
                        return(true);
                    }
                }
                return(false);
            }
            //make sure all points are in the rectangle
            foreach (var curPt in m_allPts)
            {
                if (!rect.Contains(curPt.Point))
                {
                    return(false);
                }
            }
            return(true);
        }
コード例 #3
0
ファイル: Line.cs プロジェクト: liyangTeam/WSXCut
        public bool ObjectInRectangle(RectangleF rectangle, bool anyPoint)
        {
            RectangleF boundingRectangleF = this.GetBoundingRectangle(BoundingRectangleType.All);

            if (anyPoint)
            {
                return(HitUtil.LineIntersectWithRect(this.P1, this.P2, rectangle));
            }
            return(rectangle.Contains(boundingRectangleF));
        }
コード例 #4
0
        public bool ObjectInRectangle(ICanvas canvas, RectangleF rect, bool anyPoint)
        {
            RectangleF boundingrect = GetBoundingRect(canvas);

            if (anyPoint)
            {
                return(HitUtil.LineIntersectWithRect(m_p1, m_p2, rect));
            }
            return(rect.Contains(boundingrect));
        }
コード例 #5
0
        public bool ObjectInRectangle(ICanvas canvas, RectangleF rect, bool anyPoint)
        {
            RectangleF boundingrect = GetBoundingRect(canvas);

            if (anyPoint)
            {
                return(HitUtil.LineIntersectWithRect(new UnitPoint(position.X - 0.2, position.Y + 0.2), new UnitPoint(position.X + 0.2, position.Y - 0.2), rect));
            }
            return(rect.Contains(boundingrect));
        }
コード例 #6
0
ファイル: LineCommon.cs プロジェクト: liyangTeam/WSXCut
        public override bool ObjectInRectangle(RectangleF rectangle, bool anyPoint)
        {
            if (anyPoint)//包含图形的任一点即可
            {
                return(HitUtil.LineIntersectWithRect(base.Points[0].Point, base.Points[1].Point, rectangle));
            }
            RectangleF rectangleF = this.GetBoundingRectangle(BoundingRectangleType.SelectRange);

            return(rectangle.Contains(rectangleF));
        }
コード例 #7
0
 /// <summary>
 /// 判断一个元素是否在一个举行区域内
 /// </summary>
 public bool ObjectInRectangle(ICanvas canvas, RectangleF rect, bool anyPoint)
 {
     try
     {
         RectangleF boundingrect = GetBoundingRect(canvas);
         if (anyPoint)
         {
             return(HitUtil.LineIntersectWithRect(Location, aqlocation, rect));
         }
         return(rect.Contains(boundingrect));
     }
     catch (Exception ex)
     { throw ex; }
 }
コード例 #8
0
 /// <summary>
 /// 判断一个元素是否在一个举行区域内
 /// </summary>
 public bool ObjectInRectangle(ICanvas canvas, RectangleF rect, bool anyPoint)
 {
     try
     {
         RectangleF boundingrect = GetBoundingRect(canvas);
         if (anyPoint)
         {
             float     PriWidth   = canvas.ToScreen(this.radius);
             UnitPoint aqlocation = new UnitPoint(Location.X + canvas.ToUnit(PriWidth), Location.Y - canvas.ToUnit(PriWidth));
             return(HitUtil.LineIntersectWithRect(Location, aqlocation, rect));
         }
         return(rect.Contains(boundingrect));
     }
     catch (Exception ex)
     { throw ex; }
 }
コード例 #9
0
ファイル: StarCommon.cs プロジェクト: liyangTeam/WSXCut
        public override bool ObjectInRectangle(RectangleF rectangle, bool anyPoint)
        {
            RectangleF rectangleF = this.GetBoundingRectangle(BoundingRectangleType.SelectRange);

            if (anyPoint)//包含图形的任一点即可
            {
                for (int i = 0; i < this.Points.Count - 1; i++)
                {
                    if (HitUtil.LineIntersectWithRect(this.Points[i].Point, this.Points[i + 1].Point, rectangle))
                    {
                        return(true);
                    }
                }
            }
            return(rectangle.Contains(rectangleF));
        }
コード例 #10
0
 /// <summary>
 /// 判断当前图形元素是否在一个矩形区域内
 /// </summary>
 public bool ObjectInRectangle(ICanvas canvas, RectangleF rect, bool anyPoint)
 {
     try
     {
         RectangleF boundingrect = GetBoundingRect(canvas);
         if (anyPoint)
         {
             float     ProduceWidth = canvas.ToScreen(width / 96);
             float     ProduceHight = canvas.ToScreen(height / 96);
             UnitPoint Aqlocation   = new UnitPoint(location.X + canvas.ToUnit(ProduceWidth), location.Y - canvas.ToUnit(ProduceHight));
             return(HitUtil.LineIntersectWithRect(location, Aqlocation, rect));
         }
         return(rect.Contains(boundingrect));
     }
     catch (Exception ex)
     { throw ex; }
 }
コード例 #11
0
ファイル: Hexagon.cs プロジェクト: liyangTeam/WSXCut
        public bool ObjectInRectangle(RectangleF rectangle, bool anyPoint)
        {
            RectangleF rectangleF = this.GetBoundingRectangle(BoundingRectangleType.All);

            if (anyPoint)//包含图形的任一点即可
            {
                if (HitUtil.LineIntersectWithRect(this.hexagonPoints[this.SideCount - 1], this.hexagonPoints[0], rectangle))
                {
                    return(true);
                }
                for (int i = 0; i < this.hexagonPoints.Length - 1; i++)
                {
                    if (HitUtil.LineIntersectWithRect(this.hexagonPoints[i], this.hexagonPoints[i + 1], rectangle))
                    {
                        return(true);
                    }
                }
            }
            return(rectangle.Contains(rectangleF));
        }
コード例 #12
0
 /// <summary>
 /// 判断当前元素是否被选中
 /// </summary>
 public bool ObjectInRectangle(ICanvas canvas, RectangleF rect, bool anyPoint)
 {
     try
     {
         RectangleF boundingrect = GetBoundingRect(canvas);
         if (anyPoint)
         {
             UnitPoint Aqlocation = new UnitPoint(location.X + canvas.ToUnit((float)10 * str_value.Length), location.Y);
             if (HitUtil.LineIntersectWithRect(location, Aqlocation, rect))
             {
                 return(true);
             }
             Aqlocation = new UnitPoint(location.X, location.Y - canvas.ToUnit((float)10));
             return(HitUtil.LineIntersectWithRect(location, Aqlocation, rect));
         }
         return(rect.Contains(boundingrect));
     }
     catch (Exception ex)
     { throw ex; }
 }
コード例 #13
0
        public bool ObjectInRectangle(ICanvas canvas, RectangleF rect, bool anyPoint)
        {
            if (anyPoint)
            {
                const int     nSamplePts = 8;
                List <PointF> samplePts  = m_crv.SamplePoints(nSamplePts);
                Debug.Assert(samplePts.Count > 1);
                UnitPoint prePt = new UnitPoint();
                UnitPoint curPt = new UnitPoint();
                for (int ii = 1; ii < samplePts.Count; ++ii)
                {
                    prePt.SetPoint(samplePts[ii - 1]);
                    curPt.SetPoint(samplePts[ii]);
                    if (HitUtil.LineIntersectWithRect(prePt, curPt, rect))
                    {
                        return(true);
                    }
                }
                return(false);
            }
            RectangleF boundingrect = GetBoundingRect(canvas);

            return(rect.Contains(boundingrect));
        }