有关生成错误的代码,请参见图片。我尝试过重新订购的东西,它总是在第二次调用DrawArc
时发生。我只是复制粘贴线
g.DrawArc(SystemPens.ButtonFace, outerCircle[-1], 115, 220);
连续两次说明由于拼写错误或计算错误而未发生错误。
第一次运行正常,第二次运行错误。
调用ReLayout()
的代码:
public ButtonFan()
{
InitializeComponent();
for (int i = 0; i < buttonLabels.Count(); i++)
{
buttonLabels[i] = new System.Windows.Forms.Label();
this.buttonLabels[i].Name = "label"+i.ToString();
this.buttonLabels[i].Size = new System.Drawing.Size(50, 23);
this.buttonLabels[i].TabIndex = i;
this.buttonLabels[i].Text = "label"+i.ToString();
}
ReLayout();
}
答案 0 :(得分:1)
原来在FIRST
中生成了错误g.DrawArc(SystemPens.ButtonFace, outerCircle[-1], 115, 220);
语句。仍然不确定为什么它直到下一个才会抱怨,但我发现它的方式是添加一行:
Console.WriteLine("Finished first arc");
第一次抽签后。然后在Console.WriteLine
上弹出错误。
当然Console.WriteLine
没有错误,所以这意味着它必须从前一个语句翻转,该语句试图将矩形调整为负大小并在其中绘制一个弧。
将[-1]
更改为[150]
解决了问题。