画线出现参数错误异常
画线的方法
/// <summary>
/// 画线方法,画出一条线
/// </summary>
/// <param name="g"></param>
public void Draw(Graphics g)
{
pen.StartCap = cap1;
pen.EndCap = cap2;
pen.Width = lineWidth;
pen.Color = LineColor;
pen.LineJoin = LineJoin.Round;
g.DrawLine(pen,StartPoint,EndPoint);------------------> 这抛出异常,异常代码如下
g.Dispose();
}
异常-->"参数无效。"
所有参数均有值
StartPoint = {X = 257 Y = 17}
EndPoint = {X = 257 Y = 18}
pen 参数有三个异常
CustomEndCap = “pen.CustomEndCap”引发了“System.ArgumentException”类型的异常
CustomStartCap = “pen.CustomEndCap”引发了“System.ArgumentException”类型的异常
DashPattern = “pen.DashPattern”引发了“System.OutOfMemoryException”类型的异常
这是线的构造方法
/// <summary>
/// 构造函数,用于初始化一条线的相关信息
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
public Lines(Point a, Point b)
{
startPoint = a;
endPoint = b;
x1 = startPoint.X;
y1 = startPoint.Y;
x2 = endPoint.X;
y2 = endPoint.Y;
lineWidth = 1;
lineColor = Color.Black;
pen = new Pen(lineColor, lineWidth);
pen.StartCap = cap1;
pen.EndCap = cap2;
}
在线等待。。。