Esempio n. 1
0
        public RectangleF GetBoundingRect(ICanvas canvas)
        {
            try
            {
                float thWidth = LineTool.ThresholdWidth(canvas, Width, ThresholdPixel);
                if (thWidth < Width)
                {
                    thWidth = Width;
                }

                RectangleF rect = RectangleF.Empty;
                if (m_p2.IsEmpty || m_p3.IsEmpty)
                {
                    rect = ScreenUtils.GetRect(m_p1, m_lastPoint, thWidth);
                }

                if (rect.IsEmpty)
                {
                    float r = m_radius + thWidth / 2;
                    rect = HitUtil.CircleBoundingRect(m_center, r);
                    if (Selected)
                    {
                        float w = (float)canvas.ToUnit(20);
                        rect.Inflate(w, w);
                    }
                }
                if (m_lastPoint.IsEmpty == false)
                {
                    rect = RectangleF.Union(rect, new RectangleF(m_lastPoint.Point, new SizeF(0, 0)));
                }
                return(rect);
            }
            catch (Exception ex)
            { throw ex; }
        }
Esempio n. 2
0
        /// <summary>
        /// 获取包裹图形的矩形区域,用于清除画图轨迹
        /// </summary>
        /// <param name="canvas"></param>
        /// <returns></returns>
        public RectangleF GetBoundingRect(ICanvas canvas)
        {
            t.X = m_point.X > t.X?m_point.X:t.X;
            t.Y = m_point.Y > t.Y ? m_point.Y : t.Y;
            float r = Convert.ToSingle(Math.Sqrt((Math.Pow((m_curPoint.X - t.X), 2.0) + Math.Pow((m_curPoint.Y - t.Y), 2.0)) / 2.0));
            //Console.WriteLine(r+" ");
            RectangleF rect = HitUtil.CircleBoundingRect(new UnitPoint((m_curPoint.X + Math.Abs(t.X)) / 2.0, (m_curPoint.Y + Math.Abs(t.Y)) / 2.0), 2 * r);

            // if drawing either angle then include the mouse point in the ractangle - this is to redraw (erase) the line drawn
            // from center point to mouse point
            //Console.WriteLine(r+" "+t.X+" "+t.Y);
            return(rect);

            //float thWidth = ThresholdWidth(canvas, Width);
            //return ScreenUtils.GetRect(m_p1, m_p2, thWidth);
        }
Esempio n. 3
0
 public virtual bool ObjectInRectangle(ICanvas canvas, RectangleF rect, bool anyPoint)
 {
     try
     {
         float      r            = m_radius + Width / 2;
         RectangleF boundingrect = HitUtil.CircleBoundingRect(m_center, r);
         if (anyPoint)
         {
             UnitPoint lp1 = new UnitPoint(rect.Left, rect.Top);
             UnitPoint lp2 = new UnitPoint(rect.Left, rect.Bottom);
             if (HitUtil.CircleIntersectWithLine(m_center, m_radius, lp1, lp2))
             {
                 return(true);
             }
             lp1 = new UnitPoint(rect.Left, rect.Bottom);
             lp2 = new UnitPoint(rect.Right, rect.Bottom);
             if (HitUtil.CircleIntersectWithLine(m_center, m_radius, lp1, lp2))
             {
                 return(true);
             }
             lp1 = new UnitPoint(rect.Left, rect.Top);
             lp2 = new UnitPoint(rect.Right, rect.Top);
             if (HitUtil.CircleIntersectWithLine(m_center, m_radius, lp1, lp2))
             {
                 return(true);
             }
             lp1 = new UnitPoint(rect.Left, rect.Top);
             lp2 = new UnitPoint(rect.Right, rect.Top);
             if (HitUtil.CircleIntersectWithLine(m_center, m_radius, lp1, lp2))
             {
                 return(true);
             }
             lp1 = new UnitPoint(rect.Right, rect.Top);
             lp2 = new UnitPoint(rect.Right, rect.Bottom);
             if (HitUtil.CircleIntersectWithLine(m_center, m_radius, lp1, lp2))
             {
                 return(true);
             }
         }
         return(rect.Contains(boundingrect));
     }
     catch (Exception ex)
     { throw ex; }
 }
Esempio n. 4
0
        /// <summary>
        /// 获取包裹图形的矩形区域,用于清除画图轨迹
        /// </summary>
        /// <param name="canvas"></param>
        /// <returns></returns>
        public RectangleF GetBoundingRect(ICanvas canvas)
        {
            float r = Convert.ToSingle(Math.Sqrt((Math.Pow((m_p1.X - m_p2.X), 2.0) + Math.Pow((m_p1.Y - m_p2.Y), 2.0)) / 2));
            //Console.WriteLine(r+" ");
            RectangleF rect = HitUtil.CircleBoundingRect(new UnitPoint((m_p1.X + m_p2.X) / 2.0, (m_p1.Y + m_p2.Y) / 2.0), r);

            // if drawing either angle then include the mouse point in the ractangle - this is to redraw (erase) the line drawn
            // from center point to mouse point

            return(rect);
            //double x1 = m_p1.X > m_p2.X ? m_p1.X : m_p2.X;
            //double x2 = m_p1.X > m_p2.X ? m_p2.X : m_p1.X;
            //double y1 = m_p1.Y > m_p2.Y ? m_p1.Y : m_p2.Y;
            //double y2 = m_p1.Y > m_p2.Y ? m_p2.Y : m_p1.Y;
            ////throw new NotImplementedException();
            //Console.WriteLine("GetBoundingRect "+x2 +" "+y1);
            //return new RectangleF(Convert.ToSingle(x2), Convert.ToSingle(y1), Convert.ToSingle(x1 - x2), Convert.ToSingle(y1 - y2));
            //Console.WriteLine();
        }
Esempio n. 5
0
        public RectangleF GetBoundingRect(ICanvas canvas)
        {
            float thWidth = Line.ThresholdWidth(canvas, Width, ThresholdPixel);

            if (thWidth < Width)
            {
                thWidth = Width;
            }
            float      r    = m_radius + thWidth / 2;
            RectangleF rect = HitUtil.CircleBoundingRect(m_center, r);

            // if drawing either angle then include the mouse point in the ractangle - this is to redraw (erase) the line drawn
            // from center point to mouse point
            if (m_curPoint == eCurrentPoint.startAngle || m_curPoint == eCurrentPoint.endAngle)
            {
                rect = RectangleF.Union(rect, new RectangleF(m_lastPoint.Point, new SizeF(0, 0)));
            }
            return(rect);
        }
Esempio n. 6
0
        /// <summary>
        /// 获取用户图像选择周围的边界矩形的坐标
        /// </summary>
        /// <param name="canvas"></param>
        /// <returns></returns>
        public RectangleF GetBoundingRect(ICanvas canvas)
        {
            float thWidth = Line.ThresholdWidth(canvas, Width, ThresholdPixel);

            if (thWidth < Width)
            {
                thWidth = Width;
            }

            RectangleF rect = RectangleF.Empty;

            //如果其中一个点是空的,那么绘制一条直线,因此返回一条直线的边界。
            if (m_p2.IsEmpty || m_p3.IsEmpty)
            {
                rect = ScreenUtils.GetRect(m_p1, m_lastPoint, thWidth);
            }

            if (rect.IsEmpty)
            {
                float r = m_radius + thWidth / 2;
                rect = HitUtil.CircleBoundingRect(m_center, r);
                if (Selected)
                {
                    float w = (float)canvas.ToUnit(20);                     // include space for the 'extern' nodes
                    rect.Inflate(w, w);
                }
            }
            //如果绘制任一角度,则在矩形中包含鼠标点-这是重新绘制(擦除)绘制的线。
            //从中心点到鼠标点
            //if (m_curPoint == eCurrentPoint.startAngle || m_curPoint == eCurrentPoint.endAngle)
            if (m_lastPoint.IsEmpty == false)
            {
                rect = RectangleF.Union(rect, new RectangleF(m_lastPoint.Point, new SizeF(0, 0)));
            }
            return(rect);
        }
Esempio n. 7
0
        public RectangleF GetBoundingRect(ICanvas canvas)
        {
            float thWidth = Line.ThresholdWidth(canvas, Width, ThresholdPixel);

            if (thWidth < Width)
            {
                thWidth = Width;
            }

            RectangleF rect = RectangleF.Empty;

            // if one of the points is empty, then a straight line is drawn, so return bounding rect for a line
            if (m_p2.IsEmpty || m_p3.IsEmpty)
            {
                rect = ScreenUtils.GetRect(m_p1, m_lastPoint, thWidth);
            }

            if (rect.IsEmpty)
            {
                float r = m_radius + thWidth / 2;
                rect = HitUtil.CircleBoundingRect(m_center, r);
                if (Selected)
                {
                    float w = (float)canvas.ToUnit(20); // include space for the 'extern' nodes
                    rect.Inflate(w, w);
                }
            }
            // if drawing either angle then include the mouse point in the rectangle - this is to redraw (erase) the line drawn
            // from center point to mouse point
            //if (m_curPoint == eCurrentPoint.startAngle || m_curPoint == eCurrentPoint.endAngle)
            if (m_lastPoint.IsEmpty == false)
            {
                rect = RectangleF.Union(rect, new RectangleF(m_lastPoint.Point, new SizeF(0, 0)));
            }
            return(rect);
        }