當前位置: 首頁>>代碼示例>>C#>>正文


C# XGraphicsPath.AddLine方法代碼示例

本文整理匯總了C#中PdfSharp.Drawing.XGraphicsPath.AddLine方法的典型用法代碼示例。如果您正苦於以下問題:C# XGraphicsPath.AddLine方法的具體用法?C# XGraphicsPath.AddLine怎麽用?C# XGraphicsPath.AddLine使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PdfSharp.Drawing.XGraphicsPath的用法示例。


在下文中一共展示了XGraphicsPath.AddLine方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: RenderOpenPath

    void RenderOpenPath(XGraphics gfx)
    {
      gfx.TranslateTransform(15, 20);

      XPen pen = new XPen(XColors.Navy, Math.PI);
      pen.DashStyle = XDashStyle.Dash;

      XGraphicsPath path = new XGraphicsPath();
      path.AddLine(10, 120, 50, 60);
      path.AddArc(50, 20, 110, 80, 180, 180);
      path.AddLine(160, 60, 220, 100);
      gfx.DrawPath(pen, path);
    }
開發者ID:vronikp,項目名稱:EventRegistration,代碼行數:13,代碼來源:SimplePaths.cs

示例2: DrawPathOpen

    /// <summary>
    /// Strokes an open path.
    /// </summary>
    void DrawPathOpen(XGraphics gfx, int number)
    {
      BeginBox(gfx, number, "DrawPath (open)");

      XPen pen = new XPen(XColors.Navy, Math.PI);
      pen.DashStyle = XDashStyle.Dash;

      XGraphicsPath path = new XGraphicsPath();
      path.AddLine(10, 120, 50, 60);
      path.AddArc(50, 20, 110, 80, 180, 180);
      path.AddLine(160, 60, 220, 100);
      gfx.DrawPath(pen, path);

      EndBox(gfx);
    }
開發者ID:bossaia,項目名稱:alexandrialibrary,代碼行數:18,代碼來源:Paths.cs

示例3: RenderAlternatePath

    void RenderAlternatePath(XGraphics gfx)
    {
      gfx.TranslateTransform(15, 20);

      XPen pen = new XPen(XColors.Navy, 2.5);

      // Alternate fill mode
      XGraphicsPath path = new XGraphicsPath();
      path.FillMode = XFillMode.Alternate;
      path.AddLine(10, 130, 10, 40);
      path.AddBeziers(new XPoint[]{new XPoint(10, 40), new XPoint(30, 0), new XPoint(40, 20), new XPoint(60, 40), 
                                   new XPoint(80, 60), new XPoint(100, 60), new XPoint(120, 40)});
      path.AddLine(120, 40, 120, 130);
      path.CloseFigure();
      path.AddEllipse(40, 80, 50, 40);
      gfx.DrawPath(pen, XBrushes.DarkOrange, path);
    }
開發者ID:bossaia,項目名稱:alexandrialibrary,代碼行數:17,代碼來源:AlternateAndWinding.cs

示例4: RenderPage

    public override void RenderPage(XGraphics gfx)
    {
      base.RenderPage(gfx);

      XGraphicsPath path = new XGraphicsPath();

      path.AddLine(50, 150, 50, 100);
      path.AddArc(50, 50, 100, 100, -180, 180);
      path.AddLine(150, 70, 200, 70);
      path.AddLine(200, 70, 200, 150);
      path.CloseFigure();
      XPen pen = new XPen(XColors.Red, 50);

      path.Widen(pen, new XMatrix(), 3);
      path.FillMode = this.properties.General.FillMode;
      gfx.DrawPath(properties.Pen2.Pen, properties.Brush2.Brush, path);
    }
開發者ID:vronikp,項目名稱:EventRegistration,代碼行數:17,代碼來源:PathWiden.cs

示例5: RenderPage

    public override void RenderPage(XGraphics gfx)
    {
      base.RenderPage(gfx);

      XGraphicsPath path = new XGraphicsPath();

      path.AddLine(50, 150, 50, 100);
      path.AddArc(50, 50, 100, 100, -180, 180);
      path.AddLine(150, 70, 200, 70);
      path.AddLine(200, 70, 200, 150);
      path.CloseFigure();
      path.Flatten(XMatrix.Identity, 0.1);
      gfx.DrawPath(properties.Pen2.Pen, properties.Brush2.Brush, path);
    }
開發者ID:AnthonyNystrom,項目名稱:Pikling,代碼行數:14,代碼來源:PathFlatten.cs

示例6: Render

        internal void Render(XUnit x, XUnit y, XUnit width, XUnit height, RoundedCorner roundedCorner)
        {
            // If there is no rounded corner, we can use the usual Render method.
            if (roundedCorner == RoundedCorner.None)
            {
                Render(x, y, width, height);
                return;
            }

            if (_shading == null || _brush == null)
                return;

            XGraphicsPath path = new XGraphicsPath();

            switch (roundedCorner)
            {
                case RoundedCorner.TopLeft:
                    path.AddArc(new XRect(x, y, width * 2, height * 2), 180, 90); // Error in CORE: _corePath.AddArc().
                    path.AddLine(new XPoint(x + width, y), new XPoint(x + width, y + height));
                    break;
                case RoundedCorner.TopRight:
                    path.AddArc(new XRect(x - width, y, width * 2, height * 2), 270, 90); // Error in CORE: _corePath.AddArc().
                    path.AddLine(new XPoint(x + width, y + height), new XPoint(x, y + height));
                    break;
                case RoundedCorner.BottomRight:
                    path.AddArc(new XRect(x - width, y - height, width * 2, height * 2), 0, 90); // Error in CORE: _corePath.AddArc().
                    path.AddLine(new XPoint(x, y + height), new XPoint(x, y));
                    break;
                case RoundedCorner.BottomLeft:
                    path.AddArc(new XRect(x, y - height, width * 2, height * 2), 90, 90); // Error in CORE: _corePath.AddArc().
                    path.AddLine(new XPoint(x, y), new XPoint(x + width, y));
                    break;
            }

            path.CloseFigure();
            _gfx.DrawPath(_brush, path);
        }
開發者ID:Sl0vi,項目名稱:MigraDoc,代碼行數:37,代碼來源:ShadingRenderer.cs

示例7: RenderWindingPath

    void RenderWindingPath(XGraphics gfx)
    {
      gfx.TranslateTransform(15, 150);

      XPen pen = new XPen(XColors.Navy, 2.5);

      // Winding fill mode
      XGraphicsPath path = new XGraphicsPath();
      path = new XGraphicsPath();
      path.FillMode = XFillMode.Winding;
      path.AddLine(130, 130, 130, 40);
      path.AddBeziers(new XPoint[]{new XPoint(130, 40), new XPoint(150, 0), new XPoint(160, 20), new XPoint(180, 40), 
                                   new XPoint(200, 60), new XPoint(220, 60), new XPoint(240, 40)});
      path.AddLine(240, 40, 240, 130);
      path.CloseFigure();
      path.AddEllipse(160, 80, 50, 40);
      gfx.DrawPath(pen, XBrushes.DarkOrange, path);
    }
開發者ID:bossaia,項目名稱:alexandrialibrary,代碼行數:18,代碼來源:AlternateAndWinding.cs

示例8: DrawPathAlternateAndWinding

    /// <summary>
    /// Draws an alternating and a winding path.
    /// </summary>
    void DrawPathAlternateAndWinding(XGraphics gfx, int number)
    {
      BeginBox(gfx, number, "DrawPath (alternate / winding)");

      XPen pen = new XPen(XColors.Navy, 2.5);

      // Alternate fill mode
      XGraphicsPath path = new XGraphicsPath();
      path.FillMode = XFillMode.Alternate;
      path.AddLine(10, 130, 10, 40);
      path.AddBeziers(new XPoint[]{new XPoint(10, 40), new XPoint(30, 0), new XPoint(40, 20), new XPoint(60, 40), 
                                   new XPoint(80, 60), new XPoint(100, 60), new XPoint(120, 40)});
      path.AddLine(120, 40, 120, 130);
      path.CloseFigure();
      path.AddEllipse(40, 80, 50, 40);
      gfx.DrawPath(pen, XBrushes.DarkOrange, path);

      // Winding fill mode
      path = new XGraphicsPath();
      path.FillMode = XFillMode.Winding;
      path.AddLine(130, 130, 130, 40);
      path.AddBeziers(new XPoint[]{new XPoint(130, 40), new XPoint(150, 0), new XPoint(160, 20), new XPoint(180, 40), 
                                   new XPoint(200, 60), new XPoint(220, 60), new XPoint(240, 40)});
      path.AddLine(240, 40, 240, 130);
      path.CloseFigure();
      path.AddEllipse(160, 80, 50, 40);
      gfx.DrawPath(pen, XBrushes.DarkOrange, path);

      EndBox(gfx);
    }
開發者ID:bossaia,項目名稱:alexandrialibrary,代碼行數:33,代碼來源:Paths.cs

示例9: Draw

    /// <summary>
    /// Draws the marker given through rendererInfo at the specified position. Position specifies
    /// the center of the marker.
    /// </summary>
    internal static void Draw(XGraphics graphics, XPoint pos, MarkerRendererInfo rendererInfo)
    {
      if (rendererInfo.MarkerStyle == MarkerStyle.None)
        return;

      double size = rendererInfo.MarkerSize;
      double size2 = size / 2;
      double x0, y0, x1, y1;
      double g;

      XPen foreground = new XPen(rendererInfo.MarkerForegroundColor, 0.5);
      XBrush background = new XSolidBrush(rendererInfo.MarkerBackgroundColor);

      XGraphicsPath gp = new XGraphicsPath();
      switch (rendererInfo.MarkerStyle)
      {
        case MarkerStyle.Square:
          x0 = pos.X - size2;
          y0 = pos.Y - size2;
          x1 = pos.X + size2;
          y1 = pos.Y + size2;
          gp.AddLine(x0, y0, x1, y0);
          gp.AddLine(x1, y0, x1, y1);
          gp.AddLine(x1, y1, x0, y1);
          gp.AddLine(x0, y1, x0, y0);
          break;

        case MarkerStyle.Diamond:
          gp.AddLine(x1 = pos.X + size2, pos.Y, pos.X, y0 = pos.Y - size2);
          gp.AddLine(pos.X, y0, x0 = pos.X - size2, pos.Y);
          gp.AddLine(x0, pos.Y, pos.X, y1 = pos.Y + size2);
          gp.AddLine(pos.X, y1, x1, pos.Y);
          break;

        case MarkerStyle.Triangle:
          y0 = pos.Y + size / 2;
          y1 = pos.Y - size / 2;
          g = Math.Sqrt(size * size * 4 / 3) / 2;
          gp.AddLine(pos.X, y1, pos.X + g, y0);
          gp.AddLine(pos.X + g, y0, pos.X - g, y0);
          gp.AddLine(pos.X - g, y0, pos.X, y1);
          break;

        case MarkerStyle.Plus:
          g = size2 / 4;
          gp.AddLine(pos.X - size2, pos.Y + g, pos.X - g, pos.Y + g);
          gp.AddLine(pos.X - g, pos.Y + g, pos.X - g, pos.Y + size2);
          gp.AddLine(pos.X - g, pos.Y + size2, pos.X + g, pos.Y + size2);
          gp.AddLine(pos.X + g, pos.Y + size2, pos.X + g, pos.Y + g);
          gp.AddLine(pos.X + g, pos.Y + g, pos.X + size2, pos.Y + g);
          gp.AddLine(pos.X + size2, pos.Y + g, pos.X + size2, pos.Y - g);
          gp.AddLine(pos.X + size2, pos.Y - g, pos.X + g, pos.Y - g);
          gp.AddLine(pos.X + g, pos.Y - g, pos.X + g, pos.Y - size2);
          gp.AddLine(pos.X + g, pos.Y - size2, pos.X - g, pos.Y - size2);
          gp.AddLine(pos.X - g, pos.Y - size2, pos.X - g, pos.Y - g);
          gp.AddLine(pos.X - g, pos.Y - g, pos.X - size2, pos.Y - g);
          gp.AddLine(pos.X - size2, pos.Y - g, pos.X - size2, pos.Y + g);
          break;

        case MarkerStyle.Circle:
        case MarkerStyle.Dot:
          x0 = pos.X - size2;
          y0 = pos.Y - size2;
          gp.AddEllipse(x0, y0, size, size);
          break;

        case MarkerStyle.Dash:
          x0 = pos.X - size2;
          y0 = pos.Y - size2 / 3;
          x1 = pos.X + size2;
          y1 = pos.Y + size2 / 3;
          gp.AddLine(x0, y0, x1, y0);
          gp.AddLine(x1, y0, x1, y1);
          gp.AddLine(x1, y1, x0, y1);
          gp.AddLine(x0, y1, x0, y0);
          break;

        case MarkerStyle.X:
          g = size / 4;
          gp.AddLine(pos.X - size2 + g, pos.Y - size2, pos.X, pos.Y - g);
          gp.AddLine(pos.X, pos.Y - g, pos.X + size2 - g, pos.Y - size2);
          gp.AddLine(pos.X + size2 - g, pos.Y - size2, pos.X + size2, pos.Y - size2 + g);
          gp.AddLine(pos.X + size2, pos.Y - size2 + g, pos.X + g, pos.Y);
          gp.AddLine(pos.X + g, pos.Y, pos.X + size2, pos.Y + size2 - g);
          gp.AddLine(pos.X + size2, pos.Y + size2 - g, pos.X + size2 - g, pos.Y + size2);
          gp.AddLine(pos.X + size2 - g, pos.Y + size2, pos.X, pos.Y + g);
          gp.AddLine(pos.X, pos.Y + g, pos.X - size2 + g, pos.Y + size2);
          gp.AddLine(pos.X - size2 + g, pos.Y + size2, pos.X - size2, pos.Y + size2 - g);
          gp.AddLine(pos.X - size2, pos.Y + size2 - g, pos.X - g, pos.Y);
          gp.AddLine(pos.X - g, pos.Y, pos.X - size2, pos.Y - size2 + g);
          break;

        case MarkerStyle.Star:
          {
            XPoint[] points = new XPoint[10];

//.........這裏部分代碼省略.........
開發者ID:inexorabletash,項目名稱:PDFsharp,代碼行數:101,代碼來源:MarkerRenderer.cs

示例10: ToXGraphicsPath

        /// <summary>
        /// 
        /// </summary>
        /// <param name="pg"></param>
        /// <param name="dx"></param>
        /// <param name="dy"></param>
        /// <param name="scale"></param>
        /// <returns></returns>
        public static XGraphicsPath ToXGraphicsPath(this Core2D.XPathGeometry pg, double dx, double dy, Func<double, double> scale)
        {
            var gp = new XGraphicsPath();
            gp.FillMode = pg.FillRule == Core2D.XFillRule.EvenOdd ? XFillMode.Alternate : XFillMode.Winding;

            foreach (var pf in pg.Figures)
            {
                var startPoint = pf.StartPoint;

                foreach (var segment in pf.Segments)
                {
                    if (segment is Core2D.XArcSegment)
                    {
            #if CORE
                        //var arcSegment = segment as Core2D.XArcSegment;
                        // TODO: Convert WPF/SVG elliptical arc segment format to GDI+ bezier curves.
                        //startPoint = arcSegment.Point;
            #endif
            #if WPF
                        var arcSegment = segment as Core2D.XArcSegment;
                        var point1 = new XPoint(
                            scale(startPoint.X),
                            scale(startPoint.Y));
                        var point2 = new XPoint(
                            scale(arcSegment.Point.X),
                            scale(arcSegment.Point.Y));
                        var size = new XSize(
                            scale(arcSegment.Size.Width),
                            scale(arcSegment.Size.Height));
                        gp.AddArc(
                            point1,
                            point2,
                            size, arcSegment.RotationAngle, arcSegment.IsLargeArc,
                            arcSegment.SweepDirection == Core2D.XSweepDirection.Clockwise ? XSweepDirection.Clockwise : XSweepDirection.Counterclockwise);
                        startPoint = arcSegment.Point;
            #endif
                    }
                    else if (segment is Core2D.XBezierSegment)
                    {
                        var bezierSegment = segment as Core2D.XBezierSegment;
                        gp.AddBezier(
                            scale(startPoint.X),
                            scale(startPoint.Y),
                            scale(bezierSegment.Point1.X),
                            scale(bezierSegment.Point1.Y),
                            scale(bezierSegment.Point2.X),
                            scale(bezierSegment.Point2.Y),
                            scale(bezierSegment.Point3.X),
                            scale(bezierSegment.Point3.Y));
                        startPoint = bezierSegment.Point3;
                    }
                    else if (segment is Core2D.XLineSegment)
                    {
                        var lineSegment = segment as Core2D.XLineSegment;
                        gp.AddLine(
                            scale(startPoint.X),
                            scale(startPoint.Y),
                            scale(lineSegment.Point.X),
                            scale(lineSegment.Point.Y));
                        startPoint = lineSegment.Point;
                    }
                    else if (segment is Core2D.XPolyBezierSegment)
                    {
                        var polyBezierSegment = segment as Core2D.XPolyBezierSegment;
                        if (polyBezierSegment.Points.Count >= 3)
                        {
                            gp.AddBezier(
                                scale(startPoint.X),
                                scale(startPoint.Y),
                                scale(polyBezierSegment.Points[0].X),
                                scale(polyBezierSegment.Points[0].Y),
                                scale(polyBezierSegment.Points[1].X),
                                scale(polyBezierSegment.Points[1].Y),
                                scale(polyBezierSegment.Points[2].X),
                                scale(polyBezierSegment.Points[2].Y));
                        }

                        if (polyBezierSegment.Points.Count > 3
                            && polyBezierSegment.Points.Count % 3 == 0)
                        {
                            for (int i = 3; i < polyBezierSegment.Points.Count; i += 3)
                            {
                                gp.AddBezier(
                                    scale(polyBezierSegment.Points[i - 1].X),
                                    scale(polyBezierSegment.Points[i - 1].Y),
                                    scale(polyBezierSegment.Points[i].X),
                                    scale(polyBezierSegment.Points[i].Y),
                                    scale(polyBezierSegment.Points[i + 1].X),
                                    scale(polyBezierSegment.Points[i + 1].Y),
                                    scale(polyBezierSegment.Points[i + 2].X),
                                    scale(polyBezierSegment.Points[i + 2].Y));
                            }
//.........這裏部分代碼省略.........
開發者ID:monocraft,項目名稱:Core2D,代碼行數:101,代碼來源:XPathGeometryConverter.cs

示例11: AddLine

        public static void AddLine(XGraphicsPath path, LineSegment segment, Random random, bool straightEdges)
        {
            if (Settings.HandDrawn && !straightEdges)
              {
            var dx = segment.End.X - segment.Start.X;
            var dy = segment.End.Y - segment.Start.Y;
            var distance = (float) Math.Sqrt(dx*dx + dy*dy);
            var points = random.Next(Math.Max(3, (int) (distance/15)), Math.Max(6, (int) (distance/8)));
            var lines = points - 1;
            var last = segment.Start;
            for (var line = 0; line < lines; ++line)
            {
              Vector next;
              if (line == 0)
              {
            next = last;
              }
              else if (line == lines - 1)
              {
            next = segment.End;
              }
              else
              {
            var fraction = line/(float) (lines - 1);
            var x = segment.Start.X + (segment.End.X - segment.Start.X)*fraction;
            var y = segment.Start.Y + (segment.End.Y - segment.Start.Y)*fraction;

            x += random.Next(-1, 2);
            y += random.Next(-1, 2);
            next = new Vector(x, y);
              }

              path.AddLine(last.ToPointF(), next.ToPointF());
              last = next;
            }
              }
              else
              {
            path.AddLine(segment.Start.ToPointF(), segment.End.ToPointF());
              }
        }
開發者ID:taradinoc,項目名稱:trizbort,代碼行數:41,代碼來源:Drawing.cs

示例12: DrawChevron

 public static void DrawChevron(XGraphics graphics, PointF pos, float angle, float size, Brush fillBrush)
 {
     if (m_chevronPath == null)
       {
     var apex = new PointF(0.5f, 0);
     var leftCorner = new PointF(-0.5f, 0.5f);
     var rightCorner = new PointF(-0.5f, -0.5f);
     m_chevronPath = new XGraphicsPath();
     m_chevronPath.AddLine(apex, rightCorner);
     m_chevronPath.AddLine(rightCorner, leftCorner);
     m_chevronPath.AddLine(leftCorner, apex);
       }
       var state = graphics.Save();
       graphics.TranslateTransform(pos.X, pos.Y);
       graphics.RotateTransform(angle);
       graphics.ScaleTransform(size, size);
       graphics.DrawPath(fillBrush, m_chevronPath);
       graphics.Restore(state);
 }
開發者ID:taradinoc,項目名稱:trizbort,代碼行數:19,代碼來源:Drawing.cs

示例13: AddLine

        public static void AddLine(XGraphicsPath path, LineSegment segment, Random random)
        {
            if (Settings.HandDrawn)
            {
                float dx = segment.End.X - segment.Start.X;
                float dy = segment.End.Y - segment.Start.Y;
                float distance = (float)Math.Sqrt(dx * dx + dy * dy);
                int points = random.Next(Math.Max(3, (int)(distance / 15)), Math.Max(6, (int)(distance / 8)));
                int lines = points - 1;
                Vector last = segment.Start;
                for (int line = 0; line < lines; ++line)
                {
                    Vector next;
                    if (line == 0)
                    {
                        next = last;
                    }
                    else if (line == lines - 1)
                    {
                        next = segment.End;
                    }
                    else
                    {
                        float fraction = (float)line / (float)(lines - 1);
                        float x = segment.Start.X + (segment.End.X - segment.Start.X) * fraction;
                        float y = segment.Start.Y + (segment.End.Y - segment.Start.Y) * fraction;

                        x += random.Next(-1, 2);
                        y += random.Next(-1, 2);
                        next = new Vector(x, y);
                    }

                    path.AddLine(last.ToPointF(), next.ToPointF());
                    last = next;
                }
            }
            else
            {
                path.AddLine(segment.Start.ToPointF(), segment.End.ToPointF());
            }
        }
開發者ID:ChrisPC,項目名稱:trizbort,代碼行數:41,代碼來源:Drawing.cs


注:本文中的PdfSharp.Drawing.XGraphicsPath.AddLine方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。