Profile Picture

Draw Line with Arrow head

Posted By Ashley Davy Last Year
Author
Message
Ashley Davy
Question Posted Last Year
View Quick Profile
Forum Newbie

Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)

Group: Forum Members
Last Active: Last Month
Posts: 33, Visits: 108
How do I programmatically draw a line with an Arrow head at the end?

Nevron Support
Posted Last Year
View Quick Profile
Supreme Being

Supreme Being (4,063 reputation)Supreme Being (4,063 reputation)Supreme Being (4,063 reputation)Supreme Being (4,063 reputation)Supreme Being (4,063 reputation)Supreme Being (4,063 reputation)Supreme Being (4,063 reputation)Supreme Being (4,063 reputation)Supreme Being (4,063 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 2,945, Visits: 3,303
The following function creates a line shape:

private NShape CreateLineShape(NPoint start, NPoint end, NStroke stroke)
{
  NShape shape = new NShape();
    
  shape.Init1DShape(EN1DShapeXForm.Vector);
  shape.Height = 0;

  NGeometry geom = new NGeometry();
  NMoveTo moveTo = geom.MoveTo(0.0d, 0.5d);
  moveTo.Relative = true;
  moveTo.ShowFill = false;
  geom.Stroke = stroke;
  geom.LineTo(1.0d, 0.5d).Relative = true;
  shape.Geometry = geom;

  shape.SetBeginPoint(start);
  shape.SetEndPoint(end);

  return shape;
}

If you would like the line to have the default appearance of connectors you need to add the "Connectors" user class to it:

// create a line with connector styling
    NShape line = CreateLineShape(new NPoint(10, 10), new NPoint(100, 200), new NStroke(1, NColor.Black));
    line.UserClass = "Connector";
    drawing.ActivePage.Items.Add(line);

alternatively, you can create a line with specific arrowheads like this:

// create a line with specific arrowheads
      NShape line = CreateLineShape(new NPoint(10, 10), new NPoint(100, 200), new NStroke(1, NColor.Black));
      line.Geometry.BeginArrowhead = new NArrowhead(ENArrowheadShape.Circle, 10, 10);
      line.Geometry.EndArrowhead = new NArrowhead(ENArrowheadShape.Triangle, 10, 10);
      drawing.ActivePage.Items.Add(line);



Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic