我想把直线改成末端是箭头状的,可是不知道怎么在输入redPen.EndCap=a后跳出来可以选择的那个列表里没有ArrowAnchor这个选项,
请大家指教!
顺便问下,要画带箭头的直线是改变pen的endcap属性吧?
Pen redPen = new Pen(Color.Red, 1);
redPen.EndCap=a
请大家指教!
顺便问下,要画带箭头的直线是改变pen的endcap属性吧?
Pen redPen = new Pen(Color.Red, 1);
redPen.EndCap=a
System.Drawing.Drawing2D.AdjustableArrowCap lineCap = new System.Drawing.Drawing2D.AdjustableArrowCap(9,9,false); Pen p =new Pen(Brushes.Black,1);
p.CustomEndCap= (System.Drawing.Drawing2D.CustomLineCap)lineCap;
protected void DrawCaps(PaintEventArgs e)
{
GraphicsPath hPath = new GraphicsPath(); // Create the outline for our custom end cap.
hPath.AddLine(new Point(0, 0), new Point(0, 5));
hPath.AddLine(new Point(0, 5), new Point(5, 1));
hPath.AddLine(new Point(5, 1), new Point(3, 1)); // Construct the hook-shaped end cap.
CustomLineCap HookCap = new CustomLineCap(null, hPath); // Set the start cap and end cap of the HookCap to be rounded.
HookCap.SetStrokeCaps(LineCap.Round, LineCap.Round); // Create a pen and set end custom start and end
// caps to the hook cap.
Pen customCapPen = new Pen(Color.Black, 5);
customCapPen.CustomStartCap = HookCap;
customCapPen.CustomEndCap = HookCap; // Create a second pen using the start and end caps from
// the hook cap.
Pen capPen = new Pen(Color.Red, 10);
LineCap startCap;
LineCap endCap;
HookCap.GetStrokeCaps(out startCap, out endCap);
capPen.StartCap = startCap;
capPen.EndCap = endCap; // Create a line to draw.
Point[] points = { new Point(100, 100), new Point(200, 50),
new Point(250, 300) }; // Draw the lines.
e.Graphics.DrawLines(capPen, points);
e.Graphics.DrawLines(customCapPen, points);}