Exemple #1
0
        public virtual IDrawObject Clone()
        {
            LineTool l = new LineTool(Type);

            l.Copy(this);
            return(l);
        }
Exemple #2
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; }
        }
Exemple #3
0
 public virtual void Copy(LineTool acopy)
 {
     base.Copy(acopy);
     m_p1     = acopy.m_p1;
     m_p2     = acopy.m_p2;
     Selected = acopy.Selected;
     Lenth    = acopy.Lenth;
 }
Exemple #4
0
 protected virtual void MouseMovePerpendicular(ICanvas canvas, UnitPoint point)
 {
     if (m_perSnap.Owner is LineTool)
     {
         LineTool src = m_perSnap.Owner as LineTool;
         m_p1 = HitUtil.NearestPointOnLine(src.P1, src.P2, point, true);
         m_p2 = point;
     }
 }
Exemple #5
0
 public NodePointLine(LineTool owner, ePoint id)
 {
     try
     {
         m_owner         = owner;
         m_clone         = m_owner.Clone() as LineTool;
         m_pointId       = id;
         m_originalPoint = GetPoint(m_pointId);
     }
     catch (Exception ex)
     { throw ex; }
 }
Exemple #6
0
 public void Finish()
 {
     try
     {
         m_endPoint = GetPoint(m_pointId);
         m_owner.P1 = m_clone.P1;
         m_owner.P2 = m_clone.P2;
         m_clone    = null;
     }
     catch (Exception ex)
     { throw ex; }
 }
Exemple #7
0
 protected void SetPoint(ePoint pointid, UnitPoint point, LineTool line)
 {
     try
     {
         if (pointid == ePoint.P1)
         {
             line.P1 = point;
         }
         if (pointid == ePoint.P2)
         {
             line.P2 = point;
         }
     }
     catch (Exception ex)
     { throw ex; }
 }
Exemple #8
0
 /// <summary>
 /// 得到当前图形元素的矩形区域
 /// </summary>
 public RectangleF GetBoundingRect(ICanvas canvas)
 {
     try
     {
         float thWidth = LineTool.ThresholdWidth(canvas, Width, ThresholdPixel);
         if (thWidth < Width)
         {
             thWidth = Width;
         }
         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(ScreenUtils.GetRect(location, Aqlocation, thWidth));
     }
     catch (Exception ex)
     { throw ex; }
 }
Exemple #9
0
 public virtual bool PointInObject(ICanvas canvas, UnitPoint point)
 {
     try
     {
         RectangleF boundingrect = GetBoundingRect(canvas);
         if (boundingrect.Contains(point.Point) == false)
         {
             return(false);
         }
         float thWidth = LineTool.ThresholdWidth(canvas, Width, ThresholdPixel);
         if (HitUtil.PointInPoint(m_center, point, thWidth))
         {
             return(true);
         }
         return(HitUtil.IsPointInCircle(m_center, m_radius, point, thWidth / 2));
     }
     catch (Exception ex)
     { throw ex; }
 }
Exemple #10
0
        /// <summary>
        /// 得到当前图形元素的矩形区域
        /// </summary>
        public RectangleF GetBoundingRect(ICanvas canvas)
        {
            try
            {
                //Font m_font = new System.Drawing.Font("Arial Black", FontSize, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                //SizeF size= canvas.GetStrValueSize(StrValue, m_font);
                //UnitPoint aqlocation = new UnitPoint(location.X + (float)canvas.ToUnit(size.Width), location.Y - (float)canvas.ToUnit(size.Height));
                //return ScreenUtils.GetRect(location, aqlocation, 0);


                float thWidth = LineTool.ThresholdWidth(canvas, Width, ThresholdPixel);
                if (thWidth < Width)
                {
                    thWidth = Width;
                }
                UnitPoint Aqlocation = new UnitPoint(location.X + canvas.ToUnit((float)10 * str_value.Length), location.Y - canvas.ToUnit(10F));
                return(ScreenUtils.GetRect(location, Aqlocation, thWidth));
            }
            catch (Exception ex)
            { throw ex; }
        }
Exemple #11
0
 public virtual eDrawObjectMouseDownEnum OnMouseDown(ICanvas canvas, UnitPoint point, ISnapPoint snappoint)
 {
     try
     {
         Selected = false;
         if (snappoint is PerpendicularSnapPoint && snappoint.Owner is LineTool)
         {
             LineTool src = snappoint.Owner as LineTool;
             m_p2 = HitUtil.NearestPointOnLine(src.P1, src.P2, m_p1, true);
             return(eDrawObjectMouseDownEnum.DoneRepeat);
         }
         if (Control.ModifierKeys == Keys.Control)
         {
             point = HitUtil.OrthoPointD(m_p1, point, 45);
         }
         m_p2 = point;
         return(eDrawObjectMouseDownEnum.DoneRepeat);
     }
     catch (Exception ex)
     { throw ex; }
 }
Exemple #12
0
        public ISnapPoint SnapPoint(ICanvas canvas, UnitPoint point, List <IDrawObject> otherobjs, Type[] runningsnaptypes, Type usersnaptype)
        {
            try
            {
                if (Type == LineType.Line || Type == LineType.Dote)
                {
                    float thWidth = ThresholdWidth(canvas, Width);
                    if (runningsnaptypes != null)
                    {
                        foreach (Type snaptype in runningsnaptypes)
                        {
                            if (snaptype == typeof(VertextSnapPoint))
                            {
                                if (HitUtil.CircleHitPoint(m_p1, thWidth, point))
                                {
                                    return(new VertextSnapPoint(canvas, this, m_p1));
                                }
                                if (HitUtil.CircleHitPoint(m_p2, thWidth, point))
                                {
                                    return(new VertextSnapPoint(canvas, this, m_p2));
                                }
                            }
                            //if (snaptype == typeof(MidpointSnapPoint))
                            //{
                            //    UnitPoint p = MidPoint(canvas, m_p1, m_p2, point);
                            //    if (p != UnitPoint.Empty)
                            //        return new MidpointSnapPoint(canvas, this, p);
                            //}
                            if (snaptype == typeof(IntersectSnapPoint))
                            {
                                LineTool otherline = Utiles.FindObjectTypeInList(this, otherobjs, typeof(LineTool)) as LineTool;
                                if (otherline == null)
                                {
                                    continue;
                                }
                                UnitPoint p = HitUtil.LinesIntersectPoint(m_p1, m_p2, otherline.m_p1, otherline.m_p2);
                                if (p != UnitPoint.Empty)
                                {
                                    return(new IntersectSnapPoint(canvas, this, p));
                                }
                            }
                        }
                        return(null);
                    }

                    //if (usersnaptype == typeof(MidpointSnapPoint))
                    //    return new MidpointSnapPoint(canvas, this, HitUtil.LineMidpoint(m_p1, m_p2));
                    if (usersnaptype == typeof(IntersectSnapPoint))
                    {
                        LineTool otherline = Utiles.FindObjectTypeInList(this, otherobjs, typeof(LineTool)) as LineTool;
                        if (otherline == null)
                        {
                            return(null);
                        }
                        UnitPoint p = HitUtil.LinesIntersectPoint(m_p1, m_p2, otherline.m_p1, otherline.m_p2);
                        if (p != UnitPoint.Empty)
                        {
                            return(new IntersectSnapPoint(canvas, this, p));
                        }
                    }
                    if (usersnaptype == typeof(VertextSnapPoint))
                    {
                        double d1 = HitUtil.Distance(point, m_p1);
                        double d2 = HitUtil.Distance(point, m_p2);
                        if (d1 <= d2)
                        {
                            return(new VertextSnapPoint(canvas, this, m_p1));
                        }
                        return(new VertextSnapPoint(canvas, this, m_p2));
                    }
                    if (usersnaptype == typeof(NearestSnapPoint))
                    {
                        UnitPoint p = HitUtil.NearestPointOnLine(m_p1, m_p2, point);
                        if (p != UnitPoint.Empty)
                        {
                            return(new NearestSnapPoint(canvas, this, p));
                        }
                    }
                    if (usersnaptype == typeof(PerpendicularSnapPoint))
                    {
                        UnitPoint p = HitUtil.NearestPointOnLine(m_p1, m_p2, point);
                        if (p != UnitPoint.Empty)
                        {
                            return(new PerpendicularSnapPoint(canvas, this, p));
                        }
                    }
                }
                return(null);
            }
            catch (Exception ex)
            { throw ex; }
        }
Exemple #13
0
        public RectangleF GetBoundingRect(ICanvas canvas)
        {
            float thWidth = LineTool.ThresholdWidth(canvas, Width, ThresholdPixel);

            return(ScreenUtils.GetRect(new UnitPoint(position.X - 0.2, position.Y + 0.2), new UnitPoint(position.X + 0.2, position.Y - 0.2), thWidth));
        }