日期:2014-05-18  浏览次数:20794 次

GDI 画图的问题,高手来帮忙(关于画三角形)
我的程序中画了很多的线,每一条线要加一个三角形的箭头,这个箭头要跟线的方向一致。分不够再加。
不知道大家明白我的意思没?

------解决方案--------------------
Pen pen = new Pen(Color.Blue);
pen.EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
e.Graphics.DrawLine(pen, 0, 20, 20, 20);


或者可以自定义线帽:
pen.CustomEndCap = new AdjustableArrowCap(3, 5, true);
pen.StartCap = LineCap.Custom;
------解决方案--------------------
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
Pen linepen = new Pen(Color.Blue, 1);
linepen.CustomEndCap = new System.Drawing.Drawing2D.AdjustableArrowCap((float)(linepen.Width * 3), (float)(linepen.Width * 4), true);
g.DrawLine(linepen, new Point(this.Top + 10, this.Left + 10), new Point(this.Top + 100, this.Left + 100));