有一个重要问题,在改变直线的宽度的时候,箭头的长短会随着改变而变得很难看,这点如何解决?

解决方案 »

  1.   

    提供一个vb.net的函数,自己翻译下吧Private Sub DrawArrow(ByVal S_Graphics As Graphics, ByVal pen1 As Pen, ByVal X0 As Single, ByVal Y0 As Single, ByVal X1 As Single, ByVal Y1 As Single, ByVal ArrowLen As Single)
            Dim Xa As Single, Ya As Single, Xb As Single, Yb As Single, D As Double
            D = System.Math.Sqrt((Y1 - Y0) * (Y1 - Y0) + (X1 - X0) * (X1 - X0))
            If D > 0.0000000001 Then
                Xa = X1 + ArrowLen * MZoom * ((X0 - X1) + (Y0 - Y1) / 4) / D
                Ya = Y1 + ArrowLen * MZoom * ((Y0 - Y1) - (X0 - X1) / 4) / D
                Xb = X1 + ArrowLen * MZoom * ((X0 - X1) - (Y0 - Y1) / 4) / D
                Yb = Y1 + ArrowLen * MZoom * ((Y0 - Y1) + (X0 - X1) / 4) / D
                S_Graphics.DrawLine(pen1, Xa, Ya, X1, Y1)
                S_Graphics.DrawLine(pen1, Xb, Yb, X1, Y1)
                'S_Graphics.DrawLine(New Pen(Color.Black, xk * Zoom), X0, Y0, X1, Y1) '如果仅画箭头,此句可删除
            End If
        End Sub
      

  2.   


    Graphics g = your graphics;
    g.SmoothingMode = SmoothingMode.HighQuality;
    using (Pen pen = new Pen(Color.Blue, thickness))//thickness
    {
        pen.EndCap = LineCap.Custom;
        pen.CustomEndCap = new AdjustableArrowCap(4f, 4f, false);
        g.DrawLine(pen, x1, y1, x2, y2);
    }Have a try.
      

  3.   

    MZoom貌似比例放缩因子吧?!
      

  4.   

    这个我试过了,你用的是自定义锚头,并不能达到调节角度的要求。另外用AdjustableArrowCap的话,大小还是会随着线的宽度而变化。