Esempio n. 1
0
        public virtual void Draw(ICanvas canvas, RectangleF unitrect)
        {
            float sweep = SweepAngle;
            Pen   pen   = canvas.CreatePen(Color, Width);

            canvas.DrawArc(canvas, pen, m_center, m_radius, StartAngle, sweep);
            if (Selected)
            {
                canvas.DrawArc(canvas, DrawUtils.SelectedPen, m_center, m_radius, StartAngle, sweep);
                DrawUtils.DrawNode(canvas, m_center);
                DrawNodes(canvas);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 绘制矩形*
        /// </summary>
        /// <param name="canvas"></param>
        /// <param name="unitrect"></param>
        public virtual void Draw(ICanvas canvas, RectangleF unitrect)
        {
            //canvas.Invalidate();
            Color color = Color;
            Pen   pen   = canvas.CreatePen(color, Width);

            //pen.EndCap = System.Drawing.Drawing2D.LineCap.Round;
            //pen.StartCap = System.Drawing.Drawing2D.LineCap.Round;
            //canvas.DrawLine(canvas, pen, m_p1, m_p2);
            //UnitPoint p3 = new UnitPoint(m_p1.X, m_p2.Y);
            //UnitPoint p4 = new UnitPoint(m_p2.X, m_p1.Y);
            canvas.DrawRectangle(canvas, pen, m_p1, m_p2);
            if (Highlighted)                                                     //如果高亮
            {
                canvas.DrawRectangle(canvas, DrawUtils.SelectedPen, m_p1, m_p2); //画线
                //UnitPoint p3 = new UnitPoint(m_p1.X,m_p2.Y);
                //UnitPoint p4 = new UnitPoint(m_p2.X, m_p1.Y);
                //canvas.DrawLine(canvas, DrawUtils.SelectedPen, m_p1, p3);//画线
                //canvas.DrawLine(canvas, DrawUtils.SelectedPen, m_p1, p4);//画线
                //canvas.DrawLine(canvas, DrawUtils.SelectedPen, p3, m_p2);//画线
                //canvas.DrawLine(canvas, DrawUtils.SelectedPen, p4, m_p2);//画线
            }

            if (Selected)                                                        //如果被选中
            {
                canvas.DrawRectangle(canvas, DrawUtils.SelectedPen, m_p1, m_p2); //画线
                //UnitPoint p3 = new UnitPoint(m_p1.X, m_p2.Y);
                //UnitPoint p4 = new UnitPoint(m_p2.X, m_p1.Y);
                //canvas.DrawLine(canvas, DrawUtils.SelectedPen, m_p1, p3);//画线
                //canvas.DrawLine(canvas, DrawUtils.SelectedPen, m_p1, p4);//画线
                //canvas.DrawLine(canvas, DrawUtils.SelectedPen, p3, m_p2);//画线
                //canvas.DrawLine(canvas, DrawUtils.SelectedPen, p4, m_p2);//画线
                if (m_p1.IsEmpty == false)            //如果端点p1不存在
                {
                    DrawUtils.DrawNode(canvas, m_p1); //画点
                }
                if (m_p2.IsEmpty == false)            //如果端点p2不存在
                {
                    DrawUtils.DrawNode(canvas, m_p2); //画点
                }
                //MessageBox.Show("");
            }
            //if(Selected==false)
            //{
            //    canvas.DrawLine(canvas, pen, m_p1, p3);//画线
            //    canvas.DrawLine(canvas, pen, m_p1, p4);//画线
            //    canvas.DrawLine(canvas, pen, p3, m_p2);//画线
            //    canvas.DrawLine(canvas, pen, p4, m_p2);//画线
            //}
        }
Esempio n. 3
0
        void DrawCircle(ICanvas canvas, RectangleF unitrect)
        {
            Pen  pen    = canvas.CreatePen(Color, Width);
            bool inline = PointsInLine();

            //canvas.DrawArc(canvas, pen,new UnitPoint(0,0), 30, StartAngle, 180);
            if (inline == false)
            {
                canvas.DrawArc(canvas, pen, m_center, m_radius, StartAngle, 360);
            }
            else
            {
                canvas.DrawLine(canvas, pen, P1, P2);
                canvas.DrawLine(canvas, pen, P1, P3);
            }

            if (Selected)
            {
                if (inline == false)
                {
                    canvas.DrawArc(canvas, DrawUtils.SelectedPen, m_center, m_radius, StartAngle, 360);
                }
                else
                {
                    canvas.DrawLine(canvas, DrawUtils.SelectedPen, P1, P2);
                    canvas.DrawLine(canvas, DrawUtils.SelectedPen, P1, P3);
                }
                if (m_p1.IsEmpty == false)
                {
                    DrawUtils.DrawNode(canvas, P1);
                    //UnitPoint anglepoint = StartAngleNodePoint(canvas);
                    //if (!anglepoint.IsEmpty)
                    //    DrawUtils.DrawTriangleNode(canvas, anglepoint);
                    //anglepoint = EndAngleNodePoint(canvas);
                    //if (!anglepoint.IsEmpty)
                    //    DrawUtils.DrawTriangleNode(canvas, anglepoint);
                    //anglepoint = RadiusNodePoint(canvas);
                    //if (!anglepoint.IsEmpty)
                    //    DrawUtils.DrawTriangleNode(canvas, anglepoint);
                }
                if (m_p2.IsEmpty == false)
                {
                    DrawUtils.DrawNode(canvas, P2);
                }
                if (m_p3.IsEmpty == false)
                {
                    DrawUtils.DrawNode(canvas, P3);
                }
            }
        }
Esempio n. 4
0
        void DrawCircle(ICanvas canvas, RectangleF unitrect)
        {
            Pen  pen    = canvas.CreatePen(Color, Width);
            bool inline = PointsInLine();

            //canvas.DrawArc(canvas, pen,new UnitPoint(0,0), 30, StartAngle, 180);
            if (inline == false)
            {
                canvas.DrawArc(canvas, pen, m_center, m_radius, StartAngle, 360);
            }
            else
            {
                canvas.DrawLine(canvas, pen, P1, P2);
                canvas.DrawLine(canvas, pen, P1, P3);
            }

            if (Selected)
            {
                if (inline == false)
                {
                    canvas.DrawArc(canvas, DrawUtils.SelectedPen, m_center, m_radius, StartAngle, 360);
                }
                else
                {
                    canvas.DrawLine(canvas, DrawUtils.SelectedPen, P1, P2);
                    canvas.DrawLine(canvas, DrawUtils.SelectedPen, P1, P3);
                }
                if (m_p1.IsEmpty == false)
                {
                    DrawUtils.DrawNode(canvas, P1);
                }
                if (m_p2.IsEmpty == false)
                {
                    DrawUtils.DrawNode(canvas, P2);
                }
                if (m_p3.IsEmpty == false)
                {
                    DrawUtils.DrawNode(canvas, P3);
                }
                if (m_center.IsEmpty == false)
                {
                    DrawUtils.DrawNode(canvas, Center);
                }
                // DrawUtils.DrawNode(canvas, AnglePoint(0));
                //DrawUtils.DrawNode(canvas, AnglePoint(90));
                //DrawUtils.DrawNode(canvas, AnglePoint(180));
                //DrawUtils.DrawNode(canvas, AnglePoint(270));
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 在指定画板上绘制节点
        /// </summary>
        /// <param name="canvas"></param>
        protected virtual void DrawNodes(ICanvas canvas)
        {
            if (m_curPoint == eCurrentPoint.startAngle && m_lastPoint != UnitPoint.Empty)
            {
                canvas.DrawLine(canvas, DrawUtils.SelectedPen, m_center, m_lastPoint);
            }
            if (m_curPoint == eCurrentPoint.endAngle && m_lastPoint != UnitPoint.Empty)
            {
                canvas.DrawLine(canvas, DrawUtils.SelectedPen, m_center, m_lastPoint);
            }

            DrawUtils.DrawNode(canvas, StartAnglePoint);
            DrawUtils.DrawNode(canvas, EndAnglePoint);
            DrawUtils.DrawNode(canvas, RadiusPoint);
        }
Esempio n. 6
0
        /// <summary>
        /// 绘制图形
        /// </summary>
        /// <param name="canvas"></param>
        /// <param name="unitrect"></param>
        public virtual void Draw(ICanvas canvas, RectangleF unitrect)
        {
            if (m_curPoint.Equals(m_p1))
            {
                canvas.DrawLine(canvas, DrawUtils.SelectedPen, m_p1, m_p2); return;
            }
            if (m_curPoint.Equals(m_p2))
            {
                canvas.DrawLine(canvas, DrawUtils.SelectedPen, m_p1, m_p2); canvas.DrawLine(canvas, DrawUtils.SelectedPen, m_p2, m_p3); return;
            }
            if (m_curPoint.Equals(m_p3))
            {
                canvas.DrawLine(canvas, DrawUtils.SelectedPen, m_p1, m_p2); canvas.DrawLine(canvas, DrawUtils.SelectedPen, m_p2, m_p3); canvas.DrawLine(canvas, DrawUtils.SelectedPen, m_p3, m_p4); return;
            }
            //if (m_curPoint.Equals(m_p4)) { canvas.DrawLine(canvas, DrawUtils.SelectedPen, m_p1, m_p2); canvas.DrawLine(canvas, DrawUtils.SelectedPen, m_p2, m_p3); canvas.DrawLine(canvas, DrawUtils.SelectedPen, m_p3, m_p4); }
            Color color = Color;
            Pen   pen   = canvas.CreatePen(color, Width);

            canvas.DrawBezier(canvas, pen, m_p1, m_p2, m_p3, m_p4);
            if (Highlighted)                                                              //如果高亮
            {
                canvas.DrawBezier(canvas, DrawUtils.SelectedPen, m_p1, m_p2, m_p3, m_p4); //画线
                //canvas.DrawLine(canvas, DrawUtils.SelectedPen, m_p1, m_p2); canvas.DrawLine(canvas, DrawUtils.SelectedPen, m_p2, m_p3); canvas.DrawLine(canvas, DrawUtils.SelectedPen, m_p3, m_p4);
            }

            if (Selected)                                                                 //如果被选中,包括画图期间
            {
                canvas.DrawBezier(canvas, DrawUtils.SelectedPen, m_p1, m_p2, m_p3, m_p4); //画线
                //canvas.DrawLine(canvas, DrawUtils.SelectedPen, m_p1, m_p2); canvas.DrawLine(canvas, DrawUtils.SelectedPen, m_p2, m_p3); canvas.DrawLine(canvas, DrawUtils.SelectedPen, m_p3, m_p4);
                if (m_p1.IsEmpty == false)                                                //如果端点p1不存在
                {
                    DrawUtils.DrawNode(canvas, m_p1);                                     //画点
                }
                if (m_p2.IsEmpty == false)                                                //如果端点p2不存在
                {
                    DrawUtils.DrawNode(canvas, m_p2);                                     //画点
                }
                if (m_p3.IsEmpty == false)                                                //如果端点p3不存在
                {
                    DrawUtils.DrawNode(canvas, m_p3);                                     //画点
                }
                if (m_p4.IsEmpty == false)                                                //如果端点p4不存在
                {
                    DrawUtils.DrawNode(canvas, m_p4);                                     //画点
                }
                //MessageBox.Show("");
            }
        }
Esempio n. 7
0
        public void Draw(ICanvas canvas, RectangleF unitrect)
        {
            Color color = Color;
            Pen   pen   = canvas.CreatePen(color, Width);

            m_useEndArrow = true;

            if (m_useStartArrow)
            {
                pen.CustomStartCap = m_arrowCap;
            }
            else
            {
                pen.StartCap = System.Drawing.Drawing2D.LineCap.Round;
            }
            if (m_useEndArrow)
            {
                pen.CustomEndCap = m_arrowCap;
            }
            else
            {
                pen.EndCap = System.Drawing.Drawing2D.LineCap.Round;
            }
            canvas.DrawBezier(canvas, pen, m_p1, m_p1Ctrl, m_p2Ctrl, m_p2);

            if (Highlighted)
            {
                canvas.DrawBezier(canvas, DrawUtils.SelectedPen, m_p1, m_p1Ctrl, m_p2Ctrl, m_p2);
            }
            if (Selected)
            {
                canvas.DrawBezier(canvas, DrawUtils.SelectedPen, m_p1, m_p1Ctrl, m_p2Ctrl, m_p2);
                if (!m_p1.IsEmpty)
                {
                    DrawUtils.DrawNode(canvas, m_p1);
                }
                if (!m_p2.IsEmpty)
                {
                    DrawUtils.DrawNode(canvas, m_p2);
                }
            }
        }
Esempio n. 8
0
        public override void Draw(ICanvas canvas, RectangleF unitrect)
        {
            float halfWidth, halfHeight;

            GetHalfWidthAndHeight(out halfWidth, out halfHeight);
            UnitPoint ptLeftTop = new UnitPoint(Center.X - halfWidth, Center.Y + halfHeight);
            double    rwidth    = halfWidth * 2;
            double    rheight   = halfHeight * 2;
            Pen       pen       = canvas.CreatePen(Color, Width);

            canvas.FillEllipse(canvas, FillShapeBrush, ptLeftTop, (float)rwidth, (float)rheight);
            canvas.DrawEllipse(canvas, pen, ptLeftTop, (float)rwidth, (float)rheight);
            if (Selected)
            {
                canvas.DrawRectangle(canvas, DrawUtils.SelectedPen, ptLeftTop, (float)rwidth, (float)rheight);
                DrawUtils.DrawNode(canvas, m_center);
                DrawNodes(canvas);
            }
            if (Text != string.Empty)
            {
                canvas.DrawString(canvas, Text, Font, StrBrush, GetBoundingRect(canvas), StrFormat);
            }
        }
Esempio n. 9
0
 public virtual void Draw(ICanvas canvas, RectangleF unitrect)
 {
     try
     {
         Pen pen = null;
         if (Type == LineType.PointLine)
         {
             pen = new Pen(Color, Width);
         }
         else if (Type == LineType.Line)
         {
             pen = new Pen(Color, Width);
         }
         else
         {
             pen             = new Pen(Color, 1);
             pen.DashStyle   = DashStyle.Custom;
             pen.DashPattern = new float[] { 10f, 10f };
         }
         if (UseRoute)
         {
             pen.Color       = Color.DeepPink;
             pen.DashStyle   = DashStyle.Custom;
             pen.DashPattern = new float[] { 1f, 1f };
         }
         if (Type == LineType.PointLine)
         {
             GraphicsPath hPath     = new GraphicsPath();
             float        ScrtopY   = canvas.ToScreen(0);
             float        ScrtopX   = canvas.ToScreen(0);
             float        ScrRightX = canvas.ToScreen(0.03);
             float        ScrRightY = canvas.ToScreen(-0.08);
             float        ScrLeftX  = canvas.ToScreen(-0.03);
             float        ScrLeftY  = canvas.ToScreen(-0.08);
             hPath.AddLine(new PointF(ScrtopX, ScrLeftY), new PointF(ScrRightX, ScrRightY));
             hPath.AddLine(new PointF(ScrRightX, ScrRightY), new PointF(ScrtopX, ScrtopY));
             hPath.AddLine(new PointF(ScrtopX, ScrtopY), new PointF(ScrLeftX, ScrLeftY));
             hPath.CloseFigure();
             CustomLineCap HookCap = new CustomLineCap(hPath, null);
             pen.CustomEndCap = HookCap;
         }
         else
         {
             pen.EndCap = System.Drawing.Drawing2D.LineCap.Round;
         }
         pen.StartCap = System.Drawing.Drawing2D.LineCap.Round;
         canvas.DrawLine(canvas, pen, m_p1, m_p2);
         if (Highlighted)
         {
             canvas.DrawLine(canvas, DrawUtils.SelectedPen, m_p1, m_p2);
         }
         if (Selected)
         {
             canvas.DrawLine(canvas, DrawUtils.SelectedPen, m_p1, m_p2);
             if (m_p1.IsEmpty == false)
             {
                 DrawUtils.DrawNode(canvas, m_p1);
             }
             if (m_p2.IsEmpty == false)
             {
                 DrawUtils.DrawNode(canvas, m_p2);
             }
         }
     }
     catch (Exception ex)
     { throw ex; }
 }
Esempio n. 10
0
 protected void DrawNodes(ICanvas canvas)
 {
     DrawUtils.DrawNode(canvas, m_p1);
     DrawUtils.DrawNode(canvas, m_p3);
 }
Esempio n. 11
0
        private void DrawArc(ICanvas canvas, RectangleF unitrect)
        {
            try
            {
                Pen    pen    = new Pen(Color, Width);
                bool   inline = PointsInLine();
                double sweep  = GetSweep(StartAngle, EndAngle, Direction);

                if (inline == false)
                {
                    canvas.DrawArc(canvas, pen, m_center, m_radius, StartAngle, (float)sweep);
                }
                else
                {
                    canvas.DrawLine(canvas, pen, P1, P2);
                    canvas.DrawLine(canvas, pen, P1, P3);
                }

                if (Selected)
                {
                    if (inline == false)
                    {
                        canvas.DrawArc(canvas, DrawUtils.SelectedPen, m_center, m_radius, StartAngle, (float)sweep);
                    }
                    else
                    {
                        canvas.DrawLine(canvas, DrawUtils.SelectedPen, P1, P2);
                        canvas.DrawLine(canvas, DrawUtils.SelectedPen, P1, P3);
                    }
                    if (m_p1.IsEmpty == false)
                    {
                        DrawUtils.DrawNode(canvas, P1);
                        UnitPoint anglepoint = StartAngleNodePoint(canvas);
                        if (!anglepoint.IsEmpty)
                        {
                            DrawUtils.DrawTriangleNode(canvas, anglepoint);
                        }
                        anglepoint = EndAngleNodePoint(canvas);
                        if (!anglepoint.IsEmpty)
                        {
                            DrawUtils.DrawTriangleNode(canvas, anglepoint);
                        }
                        anglepoint = RadiusNodePoint(canvas);
                        if (!anglepoint.IsEmpty)
                        {
                            DrawUtils.DrawTriangleNode(canvas, anglepoint);
                        }
                    }
                    if (m_p2.IsEmpty == false)
                    {
                        DrawUtils.DrawNode(canvas, P2);
                    }
                    if (m_p3.IsEmpty == false)
                    {
                        DrawUtils.DrawNode(canvas, P3);
                    }
                }
            }
            catch (Exception ex)
            { throw ex; }
        }
Esempio n. 12
0
 public void Draw(ICanvas canvas, RectangleF unitrect)
 {
     try
     {
         Pen pen = new Pen(Color, Width);
         if (UseRoute)
         {
             pen.Color       = Color.DeepPink;
             pen.DashStyle   = DashStyle.Custom;
             pen.DashPattern = new float[] { 1f, 1f };
         }
         if (Type == BezierType.PointBezier)
         {
             GraphicsPath hPath     = new GraphicsPath();
             float        ScrtopY   = canvas.ToScreen(0);
             float        ScrtopX   = canvas.ToScreen(0);
             float        ScrRightX = canvas.ToScreen(0.03);
             float        ScrRightY = canvas.ToScreen(-0.08);
             float        ScrLeftX  = canvas.ToScreen(-0.03);
             float        ScrLeftY  = canvas.ToScreen(-0.08);
             if (float.IsNaN(ScrtopY) || float.IsInfinity(ScrtopY) ||
                 float.IsNaN(ScrtopX) || float.IsInfinity(ScrtopX) ||
                 float.IsNaN(ScrRightX) || float.IsInfinity(ScrRightX) ||
                 float.IsNaN(ScrRightY) || float.IsInfinity(ScrRightY) ||
                 float.IsNaN(ScrLeftX) || float.IsInfinity(ScrLeftX) ||
                 float.IsNaN(ScrLeftY) || float.IsInfinity(ScrLeftY))
             {
                 return;
             }
             hPath.AddLine(new PointF(ScrtopX, ScrLeftY), new PointF(ScrRightX, ScrRightY));
             hPath.AddLine(new PointF(ScrRightX, ScrRightY), new PointF(ScrtopX, ScrtopY));
             hPath.AddLine(new PointF(ScrtopX, ScrtopY), new PointF(ScrLeftX, ScrLeftY));
             hPath.CloseFigure();
             CustomLineCap HookCap;
             try
             {
                 HookCap = new CustomLineCap(hPath, null);
             }
             catch
             { return; }
             pen.CustomEndCap = HookCap;
         }
         else
         {
             pen.EndCap = System.Drawing.Drawing2D.LineCap.Round;
         }
         pen.StartCap = System.Drawing.Drawing2D.LineCap.Round;
         if (Highlighted)
         {
             Pen Choosepen = (Pen)DrawUtils.SelectedPen.Clone();
             canvas.DrawBizer(canvas, Choosepen, m_p1, m_p4, m_p3, m_p2);
         }
         else if (Selected)
         {
             Pen Choosepen = (Pen)DrawUtils.SelectedPen.Clone();
             canvas.DrawBizer(canvas, Choosepen, m_p1, m_p4, m_p3, m_p2);
             canvas.DrawLine(canvas, Choosepen, m_p1, m_p4);
             canvas.DrawLine(canvas, Choosepen, m_p2, m_p3);
             if (m_p2.IsEmpty == false)
             {
                 DrawUtils.DrawNode(canvas, m_p2);
             }
             if (m_p3.IsEmpty == false)
             {
                 DrawUtils.DrawNode(canvas, m_p3);
             }
             if (m_p1.IsEmpty == false)
             {
                 DrawUtils.DrawNode(canvas, m_p1);
             }
             if (m_p4.IsEmpty == false)
             {
                 DrawUtils.DrawNode(canvas, m_p4);
             }
         }
         else
         {
             canvas.DrawBizer(canvas, pen, m_p1, m_p4, m_p3, m_p2);
         }
     }
     catch (Exception ex)
     { throw ex; }
 }