trying to draw a dotted line with an end cap arrow like shown below:
image.png (227 Bytes)
here’s the code i am using:
License oLic = new License();
oLic.SetLicense(“Aspose.Total.lic”);
Bitmap oImage = new Bitmap(100, 100);
Graphics g = Graphics.FromImage(oImage);
SolidBrush oLineBrush = new SolidBrush(Color.Blue);
Pen myPen = new Pen(oLineBrush, 3f);
myPen.DashStyle = DashStyle.Dash;
GraphicsPath oPath = new GraphicsPath();
oPath.AddLine(new Point(50, 5), new Point(50, 75));
Pen oTempConnPen = (Pen)myPen.Clone();
AdjustableArrowCap oEndArrow = new AdjustableArrowCap(5, 5);
oTempConnPen.StartCap = LineCap.ArrowAnchor;
g.DrawPath(oTempConnPen, oPath);
g.Save();
oImage.Save(@"c:\temp\dw.png");
What aspose draws is the following:
image.png (10.2 KB)
@dileepawijay,
We reproduced the issue you mentioned. We will evaluate on how to draw a dotted line with an arrow at the end for your requirements.
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): DRAWINGNET-1253
You can obtain Paid Support services if you need support on a priority basis, along with the direct access to our Paid Support management team.
@dileepawijay,
For the time being, as a workaround you can try to draw a dashed line and an arrow separately. See the following sample code that you may try:
using Aspose.Drawing;
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
namespace ConsoleAppW
{
class Program
{
static void Main(string[] args)
{
License oLic = new License();
oLic.SetLicense("Aspose.Drawing.NET.lic");
Bitmap oImage = new Bitmap(200, 69);
Graphics g = Graphics.FromImage(oImage);
g.SmoothingMode = SmoothingMode.HighQuality;
g.Clear(Color.White);
PointF begin = new PointF(0, 38);
PointF end = new PointF(140, 38);
float penWidth = 4;
{
// Draw arrow:
Pen myPen = new Pen(Brushes.Black, penWidth);
AdjustableArrowCap arrowCap = new AdjustableArrowCap(6, 12);
myPen.CustomEndCap = arrowCap;
PointF arrowEnd = new PointF(end.X + arrowCap.Height * myPen.Width, end.Y);
GraphicsPath oPath = new GraphicsPath();
oPath.AddLine(end, arrowEnd);
g.DrawPath(myPen, oPath);
}
{
// Draw dashed line:
Pen myPen = new Pen(Brushes.Black, penWidth);
myPen.DashStyle = DashStyle.Dash;
GraphicsPath oPath = new GraphicsPath();
oPath.AddLine(begin, end);
g.DrawPath(myPen, oPath);
}
oImage.Save(@"dw.png");
}
}
}
dw.png (291 Bytes)
Hope, this helps a bit.
your solution works, but then I have figure out the direction of the arrow based on the line points. Since these components cost a lot of money I would expect Aspose to fix this bug and release soon.
@dileepawijay,
Sure, we will fix the issue in Aspose.Drawing API. Once we have an update on it, we will let you know.